Пример #1
0
    def make_graph(self):
        OwlClass.make_graph(self)

        PROV = Namespace('http://www.w3.org/ns/prov#')
        XSD = Namespace('http://www.w3.org/2001/XMLSchema#')
        LSUTECH = Namespace("http://www.lsutech.com#")

        self.g.remove((URIRef(self.uri), RDF.type, OWL.Class))
        self.g.add((URIRef(self.uri), RDF.type, PROV.Entity))
        if self.wasAttributedTo:
            self.g = self.g + self.wasAttributedTo.get_graph()
            self.g.add((URIRef(self.uri), PROV.wasAttributedTo,
                        URIRef(self.wasAttributedTo.uri)))
        if self.value:
            if type(self.value) is datetime.datetime:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.dateTime)))
            elif type(self.value) is int:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.integer)))
            elif type(self.value) is float:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.float)))
            else:  # string
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.string)))
        if self.scanTime:
            self.g.add((URIRef(self.uri), PROV.scanTime,
                        Literal(self.scanTime.strftime("%Y-%m-%dT%H:%M:%S"),
                                datatype=XSD.dateTime)))
        if self.blockchainuri:
            self.g.add((URIRef(self.uri), LSUTECH.blockchainuri,
                        URIRef(self.blockchainuri)))
Пример #2
0
    def make_graph(self):
        """
        Specialises RdfClass.make_graph()

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

        PROV = Namespace('http://www.w3.org/ns/prov#')
        self.g.bind('prov', PROV)

        self.g.remove((
            URIRef(self.uri),
            RDF.type,
            OWL.Class))
        self.g.add((
            URIRef(self.uri),
            RDF.type,
            PROV.Agent))

        if self.actedOnBehalfOf:
            self.g = self.g + self.actedOnBehalfOf.get_graph()
            self.g.add((URIRef(self.uri),
                        PROV.actedOnBehalfOf,
                        URIRef(self.actedOnBehalfOf.uri)))
Пример #3
0
    def make_graph(self):
        """
        Specialises RdfClass.make_graph()

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

        PROV = Namespace('http://www.w3.org/ns/prov#')
        XSD = Namespace('http://www.w3.org/2001/XMLSchema#')

        self.g.remove((URIRef(self.uri), RDF.type, OWL.Class))
        self.g.add((URIRef(self.uri), RDF.type, PROV.Entity))

        if self.wasAttributedTo:
            self.g = self.g + self.wasAttributedTo.get_graph()
            self.g.add((URIRef(self.uri), PROV.wasAttributedTo,
                        URIRef(self.wasAttributedTo.uri)))

        if self.value:
            if type(self.value) is datetime.datetime:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.dateTime)))
            elif type(self.value) is int:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.integer)))
            elif type(self.value) is float:
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.float)))
            else:  # string
                self.g.add((URIRef(self.uri), PROV.value,
                            Literal(self.value, datatype=XSD.string)))
Пример #4
0
    def __init__(self,
                 label,
                 startedAtTime,
                 endedAtTime,
                 wasAssociatedWith=None,
                 uri=None,
                 comment=None,
                 used_entities=None,
                 generated_entities=None,
                 wasInformedBy=None):

        OwlClass.__init__(self, label, uri, comment)

        self.__set_startedAtTime(startedAtTime)
        self.__set_endedAtTime(endedAtTime)

        if wasAssociatedWith:
            self.__set_wasAssociatedWith(wasAssociatedWith)
        else:
            self.wasAssociatedWith = None

        if used_entities:
            self.__set_used_entities(used_entities)
        else:
            self.used_entities = None

        if generated_entities:
            self.__set_generated_entities(generated_entities)
        else:
            self.generated_entities = None

        if wasInformedBy:
            self.__set_wasInformedBy(wasInformedBy)
        else:
            self.wasInformedBy = None
Пример #5
0
    def __init__(self, label, uri=None, comment=None, actedOnBehalfOf=None):

        OwlClass.__init__(self, label, uri, comment)

        if actedOnBehalfOf:
            self.set_actedOnBehalfOf(actedOnBehalfOf)
        else:
            self.actedOnBehalfOf = None
Пример #6
0
    def make_graph(self):
        """
        Specialises RdfClass.make_graph()

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

        XSD = Namespace('http://www.w3.org/2001/XMLSchema#')
        PROV = Namespace('http://www.w3.org/ns/prov#')
        self.g.bind('prov', PROV)

        self.g.remove((URIRef(self.uri), RDF.type, OWL.Class))
        self.g.add((URIRef(self.uri), RDF.type, PROV.Activity))

        if self.wasAssociatedWith:
            self.g = self.g + self.wasAssociatedWith.get_graph()
            self.g.add((URIRef(self.uri), PROV.wasAssociatedWith,
                        URIRef(self.wasAssociatedWith.uri)))

        if self.startedAtTime:
            self.g.add(
                (URIRef(self.uri), PROV.startedAtTime,
                 Literal(self.startedAtTime.strftime("%Y-%m-%dT%H:%M:%S::%f"),
                         datatype=XSD.dateTime)))

        if self.endedAtTime:
            self.g.add((URIRef(self.uri), PROV.endedAtTime,
                        Literal(self.endedAtTime.strftime("%Y-%m-%dT%H:%M:%S"),
                                datatype=XSD.dateTime)))

        if self.used_entities:
            for used_entity in self.used_entities:
                # add the Entity to the graph
                self.g = self.g + used_entity.get_graph()
                # associate the Entity with the Activity
                self.g.add(
                    (URIRef(self.uri), PROV.used, URIRef(used_entity.uri)))

        if self.generated_entities:
            for generated_entity in self.generated_entities:
                # add the Entity to the graph
                self.g = self.g + generated_entity.get_graph()
                # associate the Entity with the Activity
                self.g.add((URIRef(self.uri), PROV.generated,
                            URIRef(generated_entity.uri)))

        if self.wasInformedBy:
            self.g = self.g + self.wasInformedBy.get_graph()
            self.g.add((URIRef(self.uri), PROV.wasInformedBy,
                        URIRef(self.wasInformedBy.uri)))
Пример #7
0
    def __init__(self,
                 label,
                 wasReportedBy,
                 nativeId,
                 reportActivity,
                 generatedAtTime,
                 comment=None):

        OwlClass.__init__(self, label, comment)

        self.uri = 'http://placeholder.org#' + str(uuid.uuid4())
        self.__set_wasReportedBy(wasReportedBy)
        self.__set_nativeId(nativeId)
        self.__set_reportActivity(reportActivity)
        self.__set_generatedAtTime(generatedAtTime)
Пример #8
0
    def __init__(self,
                 label,
                 uri=None,
                 comment=None,
                 wasAttributedTo=None,
                 value=None):

        OwlClass.__init__(self, label, uri, comment)

        if wasAttributedTo:
            self.__set_wasAttributedTo(wasAttributedTo)
        else:
            self.wasAttributedTo = None

        if value:
            self.__set_value(value)
        else:
            self.value = None
Пример #9
0
    def __init__(self,
                 label,
                 uri=None,
                 blockchainuri=None,
                 comment=None,
                 wasAttributedTo=None,
                 value=None,
                 scanTime=None):
        OwlClass.__init__(self, label, uri, blockchainuri, comment)
        if wasAttributedTo:
            self.__set_wasAttributedTo(wasAttributedTo)
        else:
            self.wasAttributedTo = None

        if value:
            self.__set_value(value)
        else:
            self.value = None
        self.scanTime = scanTime if scanTime else datetime.strptime(
            "2071-01-01T00:00:00", "%Y-%m-%dT%H:%M:%S")
Пример #10
0
    def __init__(self,
                 label,
                 wasReportedBy,
                 nativeId,
                 reportActivity,
                 generatedAtTime,
                 comment=None):

        OwlClass.__init__(self, label, comment)

        self.uri = 'http://www.lsutech.com#' + str(
            HashValue(
                "%(label)s#%(cmt)s#%(blcu)s#%(rnds)s" % {
                    "blcu": self.blockchainuri if self.blockchainuri else "",
                    "label": self.label,
                    "cmt": self.comment,
                    "rnds": str(uuid4())
                }))
        self.__set_wasReportedBy(wasReportedBy)
        self.__set_nativeId(nativeId)
        self.__set_reportActivity(reportActivity)
        self.__set_generatedAtTime(generatedAtTime)
Пример #11
0
    def make_graph(self):
        """
        Specialises RdfClass.make_graph()

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

        XSD = Namespace('http://www.w3.org/2001/XMLSchema#')
        PROV = Namespace('http://www.w3.org/ns/prov#')
        self.g.bind('prov', PROV)
        PROMS = Namespace('http://promsns.org/def/proms#')
        self.g.bind('proms', PROMS)

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

        self.g = self.g + self.wasReportedBy.get_graph()

        self.g.add((URIRef(self.uri), PROMS.wasReportedBy,
                    URIRef(self.wasReportedBy.uri)))

        self.g.add((URIRef(self.uri), PROMS.nativeId,
                    Literal(self.nativeId, datatype=XSD.string)))

        self.g = self.g + self.reportActivity.get_graph()

        self.g.add((URIRef(self.uri), PROMS.startingActivity,
                    URIRef(self.reportActivity.uri)))

        self.g.add((URIRef(self.uri), PROMS.endingActivity,
                    URIRef(self.reportActivity.uri)))

        self.g.add((URIRef(self.uri), PROV.generatedAtTime,
                    Literal(self.generatedAtTime.isoformat(),
                            datatype=XSD.dateTime)))