def __init__(self,
                 label,
                 wasReportedBy,
                 nativeId,
                 reportActivity,
                 generatedAtTime,
                 comment=None):

        PromsReport.__init__(self, label, wasReportedBy, nativeId,
                             reportActivity, generatedAtTime, comment)
    def __init__(self,
                 label,
                 wasReportedBy,
                 nativeId,
                 startingActivity,
                 endingActivity,
                 all_activities,
                 generatedAtTime,
                 comment=None):

        PromsReport.__init__(self, label, wasReportedBy, nativeId,
                             startingActivity, generatedAtTime, comment)

        self.__set_endingActivity(startingActivity, endingActivity)
        self.__set_all_activities(all_activities)
    def make_graph(self):
        """
        Specialises PromsReport.make_graph()

        :return: an rdflib Graph object
        """
        PromsReport.make_graph(self)

        PROMS = Namespace('http://promsns.org/def/proms#')
        self.g.bind('proms', PROMS)

        # The only thing we need to do here is to redefine the Report class as BasicReport.
        # There are no additional properties
        self.g.remove((URIRef(self.uri), RDF.type, PROMS.Report))
        self.g.add((URIRef(self.uri), RDF.type, PROMS.BasicReport))
    def make_graph(self):
        """
        Specialises PromsReport.make_graph()

        :return: an rdflib Graph object
        """
        PromsReport.make_graph(self)

        PROMS = Namespace('http://promsns.org/def/proms#')
        self.g.bind('proms', PROMS)

        self.g.remove((URIRef(self.uri), RDF.type, PROMS.Report))
        self.g.add((URIRef(self.uri), RDF.type, PROMS.InternalReport))

        for activity in self.all_activities:
            # add the Activity to the graph
            self.g = self.g + activity.get_graph()

        # remove the triple that points the endingActivity to the startingActivity in the Report class
        self.g.remove((None, PROMS.endingActivity, None))
        # re-add the endingActivity triple pointing to the new Activity
        self.g.add((URIRef(self.uri), PROMS.endingActivity,
                    URIRef(self.endingActivity.uri)))
Example #5
0
                                               '%Y-%m-%dT%H:%M:%S'),
                 uri=None,
                 wasAssociatedWith=ag1,
                 used_entities=[e1, e2, e3],
                 generated_entities=[g1])
#print a1.serialize_graph(format="turtle")

# some ID from the OC system for reference, perhaps a job number
native_id = 'abc-123'
r1 = PromsReport(
    'Test Report',
    #ReportType.External,
    #label=
    rs1,
    nativeId=native_id,
    reportActivity=a,  # same as endingActivity for External Report
    #a,  # same as startingActivity for External Report
    #'Test External Report from OC'
    #startedAtTime=datetime.strptime('2018-01-01T12:00:00', '%Y-%m-%dT%H:%M:%S'),
    generatedAtTime=datetime.strptime('2018-01-01T14:00:00',
                                      '%Y-%m-%dT%H:%M:%S'),
)
with open('report.ttl', 'w') as f:
    f.write(str(r1.serialize_graph(), encoding="utf-8"))
f = open("report.ttl", "r")
r2 = f.read()
f.close()

# try:
#     report_sender = ReportSender()
#     url = 'http://localhost:5000/function/lodge-report'
Example #6
0
# PROV Activity - the OC processing event seen as a black box
a = ProvActivity('Ocean Colour processing workflow',
                 datetime.strptime('2015-01-01T12:00:00', '%Y-%m-%dT%H:%M:%S'),
                 datetime.strptime('2015-01-01T14:00:00', '%Y-%m-%dT%H:%M:%S'),
                 uri=None,
                 wasAssociatedWith=ag1,
                 used_entities=[e1, e2, e3],
                 generated_entities=[g1])
#print a1.serialize_graph(format="turtle")

# some ID from the OC system for reference, perhaps a job number
native_id = 'abc-123'
r1 = PromsReport(
    'Test Report',
    ReportType.External,
    rs1,
    native_id,
    a,  # same as endingActivity for External Report
    a,  # same as startingActivity for External Report
    'Test External Report from OC')
with open('oc_report.ttl', 'w') as f:
    f.write(r1.serialize_graph())

try:
    report_sender = ReportSender()
    r = report_sender.post('http://18.188.14.133/proms/id/report/', r1)
    import pprint
    pprint.pprint(r.text)
except Exception as e:
    print(str(e))