def on_OadrRegisterReport_send(self, venID): db_reports = MetadataReports.find({MetadataReports.owned(): True}) requestID = "0" reportRequestID = 0 reports = [{ "duration": db_r.duration, "eiReportID": db_r.eiReportID, "data_points": [{ "rID": dp.rID, "oadrMinPeriod": dp.oadrMinPeriod, "oadrMaxPeriod": dp.oadrMaxPeriod, "oadrOnChange": dp.oadrOnChange, "marketContext": dp.marketContext, "reportType": dp.reportType, "readingType": dp.readingType } for dp in DataPoint.find({DataPoint.report(): db_r._id})], "reportRequestID": "0", "reportSpecifierID": db_r.specifierID, "reportName": db_r.reportName, "createdDateTime": db_r.createdDateTime.strftime("%Y-%m-%dT%H:%M:%S") } for db_r in db_reports] return requestID, reportRequestID, reports
def register_report(self, r_request): reportSpecifierID = r_request.find(".//ei:reportSpecifierID", namespaces=NAMESPACES).text reportRequestID = r_request.find(".//ei:reportRequestID", namespaces=NAMESPACES).text granularity = r_request.find(".//xcal:granularity/xcal:duration", namespaces=NAMESPACES).text reportBackDuration = r_request.find( ".//ei:reportBackDuration/xcal:duration", namespaces=NAMESPACES).text relatedDataPoints = [] for dp in r_request.findall(".//ei:specifierPayload", namespaces=NAMESPACES): rID = dp.find(".//ei:rID", namespaces=NAMESPACES).text readingType = dp.find(".//ei:readingType", namespaces=NAMESPACES) db_dp = DataPoint.find_one({ DataPoint.rid(): rID, DataPoint.reading_type(): readingType }) relatedDataPoints.append(db_dp._id) report = MetadataReports.find_one({ MetadataReports.owned(): True, MetadataReports.specifier_id(): reportSpecifierID }) report_subscription = ReportsToSend(report._id, reportRequestID, granularity, reportBackDuration, relatedDataPoints) report_subscription.save()