Ejemplo n.º 1
0
 def ofInputType(self, type):
     if self.entity.hasCapability():
         a = self.entity.getCapabilities()[0]
         i = Input()
         i.setType(type)
         a.addInput(i)
     else:
         a = Activity()
         i = Input()
         i.setType(type)
         a.addInput(i)
         self.entity.addCapability(a)
Ejemplo n.º 2
0
    def addCapability(self, capability):
        '''
		@param capability: either Activity object, or URI string 
		'''
        from SmartAPI.model.Activity import Activity

        if isinstance(capability, Activity):
            self.capabilities.append(capability)
        elif isinstance(capability, str):
            activity = Activity(capability)
            activity.clearTypes()
            self.capabilities.append(activity)
Ejemplo n.º 3
0
	def create(cls, generatedBy):
		request = Request()
		if (generatedBy is None or  generatedBy == ""):
			raise InsufficientDataException("Invalid smartapi:generatedBy URI.")

		g = Activity(generatedBy)
		g.clearTypes()
		request.setGeneratedBy(g)
		
		request.setGeneratedAt(datetime.datetime.now())

		return request;
Ejemplo n.º 4
0
 def ofOutputType(self, type):
     if self.entity.hasCapability():
         a = self.entity.getCapabilities()[0]
         o = Output()
         o.setType(type)
         a.addOutput(o)
     else:
         a = Activity()
         o = Output()
         o.setType(type)
         a.addOutput(o)
         self.entity.addCapability(a)
Ejemplo n.º 5
0
    def create(self, generatedBy):
        notification = Notification()
        if (generatedBy is None
                or (generatedBy is not None and generatedBy == "")):
            raise InsufficientDataException("Invalid seas:generatedBy URI.")

        g = Activity(generatedBy)
        g.clearTypes()
        notification.setGeneratedBy(g)

        # timestamp of when this message is being generated (now)
        notification.setGeneratedAt(datetime.datetime.now())

        return notification
Ejemplo n.º 6
0
    def create(self, generatedBy):
        resp = Response()
        if (generatedBy is None
                or (generatedBy is not None and generatedBy == "")):
            raise InsufficientDataException("Invalid seas:generatedBy URI.")

        g = Activity(generatedBy)
        g.clearTypes()
        resp.setGeneratedBy(g)

        # timestamp of when this message is being generated (now)
        resp.setGeneratedAt(datetime.datetime.now())

        resp.addType(RESOURCE.RESPONSE)

        return resp
Ejemplo n.º 7
0
    def create(self, generatedBy):
        evaluation = Evaluation()
        if (generatedBy is None
                or (generatedBy is not None and generatedBy == "")):
            raise InsufficientDataException(
                "Invalid command generator id (seas:generatedBy) URI.")

        g = Activity(generatedBy)
        g.clearTypes()
        evaluation.setGeneratedBy(g)

        # timestamp of when this message is being generated (now)
        evaluation.setGeneratedAt(datetime.datetime.now())

        evaluation.addType(RESOURCE.COMMAND)

        return evaluation
Ejemplo n.º 8
0
    def setGeneratedBy(self, generatedBy):
        from SmartAPI.model.Activity import Activity

        if isinstance(generatedBy, Activity):
            self.generatedBy = generatedBy
        elif isinstance(generatedBy, str):
            generator = Activity(generatedBy)
            self.generatedBy = generator
Ejemplo n.º 9
0
    def parseStatement(self, statement):

        # get predicate
        predicate = str(statement.getPredicate())

        # generatedby
        if predicate == PROPERTY.GENERATEDBY:
            try:
                self.setGeneratedBy(Activity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:generatedBy value as resource."
                traceback.print_exc()
            return

        # generatedat
        if predicate == PROPERTY.GENERATEDAT:
            try:
                self.setGeneratedAt(statement.getObject().toPython())
            except:
                print "Unable to interpret seas:generatedAt value as date literal."
                traceback.print_exc()
            return

        # generationMethod
        if predicate == PROPERTY.GENERATIONMETHOD:
            try:
                self.addGenerationMethod(Obj().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:generationMethod value as resource."
                traceback.print_exc()
            return

        # dataSource
        if predicate == PROPERTY.DATASOURCE:
            try:
                self.addDataSource(Obj().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:dataSource value as resource."
                traceback.print_exc()
            return

        # property
        if predicate == PROPERTY.SMARTAPI_PROPERTY:
            try:
                self.addProperty(statement.getResource().toString())
            except:
                print "Unable to interpret seas:property value as resource."
                traceback.print_exc()
            return

        # pass on to Obj
        super(Provenance, self).parseStatement(statement)
Ejemplo n.º 10
0
	def createRegistrationRequest(self, generatedBy):
		req = Request()
		if (generatedBy is None or (generatedBy is not None and generatedBy == "")):
			raise InsufficientDataException("Invalid registrant (smartapi:generatedBy) URI.");
		
		req.setGeneratedBy(Activity(generatedBy))
		
		# timestamp of when this message is being generated (now)
		req.setGeneratedAt(datetime.datetime.now())

		req.addType(RESOURCE.REQUEST)
		
		return reqd
Ejemplo n.º 11
0
    def createTransaction(cls, transactionIdentifierUri, generatedBy):
        '''
		return a newly generated Transaction Object 
		'''
        from SmartAPI.model.Transaction import Transaction
        from SmartAPI.model.Activity import Activity
        from SmartAPI.smartapiexceptions.InsufficientDataException import InsufficientDataException

        transaction = Transaction(transactionIdentifierUri)
        if generatedBy is None:
            raise InsufficientDataException

        transaction.setGeneratedBy(Activity(generatedBy))
        transaction.getGeneratedBy().clearTypes()

        # timestamp of when this message is being generated (now)
        transaction.setGeneratedAt(datetime.datetime.now())

        return transaction
Ejemplo n.º 12
0
    def parseStatement(self, statement):
        from SmartAPI.model.Address import Address
        from SmartAPI.model.Coordinates import Coordinates
        from SmartAPI.model.Zone import Zone
        from SmartAPI.model.Controllability import Controllability
        from SmartAPI.model.Availability import Availability
        from SmartAPI.model.Activity import Activity
        from SmartAPI.model.Evaluation import Evaluation
        from SmartAPI.model.InterfaceAddress import InterfaceAddress
        from SmartAPI.model.ValueObject import ValueObject

        # get predicate
        predicate = str(statement.getPredicate())

        # zone
        if predicate == PROPERTY.ZONE:
            try:
                self.setZone(Zone().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:zone value as resource."
                print sys.exc_info()[1]
                traceback.print_exc()
            return

        # coordinates
        if predicate == PROPERTY.LOCATION:
            try:
                self.setCoordinates(Coordinates().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret geo:location value as resource."
                print sys.exc_info()[1]
                traceback.print_exc()
            return

            # coordinates
        if predicate == PROPERTY.HASADDRESS:
            try:
                self.setAddress(Address().parse(statement.getResource()))
            except:
                print "Unable to interpret vcard:hasAddress value as resource."
                print sys.exc_info()[1]
                traceback.print_exc()
            return

        if predicate == PROPERTY.ISMANAGEDBY:
            try:
                self.setManagedBy(Entity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:isManagedBy value as resource."
                print sys.exc_info()[1]
                traceback.print_exc()
            return

        # controllability
        if predicate == PROPERTY.HASEVALUATION:
            try:
                self.addControllability(Controllability().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:hasEvaluation value as resource."
                traceback.print_exc()
            return

        # availability
        if predicate == PROPERTY.HASAVAILABILITY:
            try:
                self.addAvailability(Availability().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:hasAvailability value as resource."
                traceback.print_exc()
            return

        # data availability
        if predicate == PROPERTY.HASDATAAVAILABILITY:
            try:
                self.addDataAvailability(Availability().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:hasDataAvailability value as resource."
                traceback.print_exc()
            return

        # hascapability
        if predicate == PROPERTY.HASCAPABILITY:
            try:
                self.addCapability(Activity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:hasCapability value as resource."
                traceback.print_exc()
            return

        # hascapability
        if predicate == PROPERTY.MANAGES:
            try:
                self.addManagedEntity(Entity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:hasCapability value as resource."
                traceback.print_exc()
            return

        # capacity
        if predicate == PROPERTY.CAPACITY:
            try:
                self.addCapacity(Evaluation().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:capacity value as resource."
                traceback.print_exc()
            return

        # interfaceaddress
        if predicate == PROPERTY.INTERFACE:
            try:
                self.addInterface(InterfaceAddress().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:interface value as resource."
                traceback.print_exc()
            return

        # creators
        if predicate == PROPERTY.CREATOR:
            try:
                self.addCreator(Entity().parse(statement.getResource()))
            except:
                print "Unable to interpret dc:creator value as resource."
                traceback.print_exc()
            return

        # owner
        if predicate == PROPERTY.OWNER:
            try:
                self.addOwner(Entity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:owner value as resource."
                traceback.print_exc()
            return

            # website
        if predicate == PROPERTY.HASURL:
            try:
                self.addWebsite(statement.getString())
            except:
                print "Unable to interpret vcard:hasURL value as string literal."
                traceback.print_exc()
            return

        # logo
        if predicate == PROPERTY.HASLOGO:
            try:
                self.addLogo(statement.getString())
            except:
                print "Unable to interpret vcard:hasLogo value as string literal."
                traceback.print_exc()
            return

        # photo
        if predicate == PROPERTY.HASPHOTO:
            try:
                self.addPhoto(statement.getString())
            except:
                print "Unable to interpret vcard:hasPhoto value as string literal."
                traceback.print_exc()
            return

        # sound
        if predicate == PROPERTY.HASSOUND:
            try:
                self.addSound(statement.getString())
            except:
                print "Unable to interpret vcard:hasSound value as string literal."
                traceback.print_exc()
            return

        # valueobject
        if predicate == PROPERTY.VALUEOBJECT:
            try:
                self.addValueObject(ValueObject().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:valueObject value as resource."
                traceback.print_exc()
            return

        # pass on to Object
        super(Entity, self).parseStatement(statement)
Ejemplo n.º 13
0
    def fetchFromTransactionServer(cls, senderId, notary, *args):
        '''
        @param senderId: URI string
        @param notary: URI string
        @param args: a variable number of Transaction Objects  
        
        @return a dictionary, key is SeasIdentifierUri of each transaction, value is Transaction Object
        '''
        try:
            client = HttpClient()
            # create an empty MIME multipart message
            sentHttpMessage = HttpMessage()
            # main request
            req = RequestFactory().create(senderId)
            req.setMethod(RESOURCE.READ)
            cls.messageIdCounter = cls.messageIdCounter + 1
            req.setMessageId(cls.messageIdCounter)
            a = Activity()
            req.addActivity(a)
            i = Input()
            a.addInput(i)
            system = SystemOfInterest()
            system.setSameAs(notary)
            i.setSystemOfInterest(system)

            param = Parameter()
            param.setKey("transactions")
            param.setName("Transaction id list")
            param.setDescription(
                "List of ids of transactions that are sent to be fetched the database."
            )

            for transaction in args:
                param.addValue(transaction.getIdentifierUri())
            i.addParameter(param)

            # save Request object to multipart message, Main part
            mainRequestString = Tools.toString(req)
            sentHttpMessage.addMainpart(mainRequestString)

            mainRequestHash = SmartAPICrypto().createEncodedMessageDigest(
                mainRequestString)
            requestSignature = SmartAPICrypto().sign(
                CryptoKeyWallet.getPrivateKey(), mainRequestHash)

            #create transaction for the main request
            if cls.transactionIdentifierUriPrefix == '':
                transactionIdentifierUri = senderId + uuid.uuid4().get_hex()
            else:
                transactionIdentifierUri = transactionIdentifierUri + uuid.uuid4(
                ).get_hex()
            requestTransaction = Factory.createTransaction(
                transactionIdentifierUri, senderId)
            requestTransaction.setSigner(senderId)
            requestTransactionMessage = Message()
            requestTransactionMessage.setMessageId(req.getMessageId())
            requestTransactionMessage.setHashCode(mainRequestHash)
            requestTransactionMessage.setSignature(requestSignature)
            requestTransaction.setMessage(requestTransactionMessage)

            # add requestTransaction to multipart message, non-Main part
            requestTransactionString = Tools.toString(requestTransaction)
            sentHttpMessage.add(transactionIdentifierUri,
                                requestTransactionString)

            # add transactions that are sent to multipart message, non-Main part
            for trans in args:
                sentHttpMessage.add(trans.getIdentifierUri(),
                                    Tools.toString(trans))

            # send out this multipart message
            payload = removeFrontHeader(sentHttpMessage.asString())
            resp, contentType = client.sendPost(
                notary, payload, sentHttpMessage.getContentType())

            receivedHttpMessagestr = addFrontHeader(resp, contentType)
            receivedHttpMessage = parseMIMEmessage(receivedHttpMessagestr)

            map = {}
            if isinstance(receivedHttpMessage, HttpMessageSingle):
                non_main_parts_dict = {}
            else:
                non_main_parts_dict = receivedHttpMessage.getNonMainPartsAsDict(
                )
            counter = 0
            for part in non_main_parts_dict.values():
                counter = counter + 1
                # recover the part from string to Seas Obj
                model = Tools().fromString(part, SERIALIZATION.TURTLE)
                rootRes = Tools().getTopNode(model)[0]
                seasCls = Tools().getResourceClass(rootRes)
                recoveredObj = seasCls.parse(rootRes)

                if isinstance(
                        recoveredObj, Transaction
                ):  # We want to save the Transaction that hold the requested data
                    map[recoveredObj.getIdentifierUri()] = recoveredObj

            return map

        except:
            traceback.print_exc()
Ejemplo n.º 14
0
    def _createStandardActivity(cls, identifier, interfaceAddress, methodUri,
                                temporalContext, timeSeries, valueObjects):
        '''
		@type identifier, methodUri: string; 
		@type valueObjects: a list of ValueObjects.
		others are object 
		'''
        from SmartAPI.model.Activity import Activity
        from SmartAPI.model.Entity import Entity

        if identifier is not None:
            a = Activity(identifier)
        else:
            a = Activity()
        a.setMethod(methodUri)
        e = Entity()
        if valueObjects is not None:
            for vo in valueObjects:
                e.addValueObject(vo)

        a.addEntity(e)
        if interfaceAddress is not None:
            a.addInterface(interfaceAddress)
        if temporalContext is not None:
            a.setTemporalContext(temporalContext)
        if timeSeries is not None:
            a.addTimeSerie(timeSeries)

        return a
Ejemplo n.º 15
0
    def createRequest(cls, key, method, senderIdentity, entity,
                      temporalContext, timeSeries, *valueObjects):
        from SmartAPI.factory.RequestFactory import RequestFactory
        from SmartAPI.model.Request import Request
        from SmartAPI.model.Activity import Activity
        from SmartAPI.model.Entity import Entity
        from SmartAPI.model.ValueObject import ValueObject

        if (senderIdentity is None) or (senderIdentity == ""):
            senderIdentity = cls.defaultIdentity
        r = RequestFactory().create(senderIdentity)

        if entity is None:
            raise NonePointerException(
                "Cannot create read request for null Entity.")

        # TODO should actually search for possible activity identifier uri in object.valueobject.capabilities
        a = Activity()
        r.addActivity(a)
        if key is not None:
            a.encrypt(key)

        a.setMethod(method)

        # 		if entity.hasIdentifierUri():
        # 			e = Entity(entity.getIdentifierUri())
        # 		else:
        # 			e = Entity()
        e = entity
        e.setValueObjects([])

        if temporalContext is not None:
            a.setTemporalContext(temporalContext)

        if timeSeries is not None:
            a.addTimeSerie(timeSeries)

        a.addEntity(e)

        if (valueObjects is None
                or len(valueObjects) == 0) and method == RESOURCE.WRITE:
            valueObjects = entity.getValueObjects()

        if valueObjects is not None:
            for v in valueObjects:
                #  				vo = ValueObject(quantity = v.getQuantity(), unit = v.getUnit(), dataType = v.getDataType(), description = v.getDescription())
                #  				if v.hasIdentifierUri():
                #  					vo.setIdentifierUri(v.getIdentifierUri())
                #  				if method == RESOURCE.WRITE:
                #  					vo.setValue(v.getValue())
                # 				e.addValueObject(vo)
                e.addValueObject(v)

        return r
Ejemplo n.º 16
0
 def getGeneratedBy(self):
     if not self.hasGeneratedBy():
         from SmartAPI.model.Activity import Activity
         self.generatedBy = Activity()
     return self.generatedBy
Ejemplo n.º 17
0
    def parseStatement(self, statement):
        '''
        It takes in statement as input, add property to existing model Class object.
        Return None
        '''
        from SmartAPI.model.Parameter import Parameter
        from SmartAPI.model.Provenance import Provenance
        from SmartAPI.model.Activity import Activity
        from SmartAPI.model.Offering import Offering

        # get predicate and object
        predicate = str(statement.getPredicate())
        objectNode = statement.getObject()

        # type
        if predicate == PROPERTY.RDF_TYPE:
            self.addType(URIRef(statement.getResource().toString()))
            return

        # sameas
        if predicate == PROPERTY.SAMEAS:
            self.setSameAs(statement.getResource().toString())
            return

        # generatedby
        if predicate == PROPERTY.GENERATEDBY:
            self.setGeneratedBy(Activity.parse(statement.getResource()))
            return

        # generatedat
        if predicate == PROPERTY.GENERATEDAT:
            self.setGeneratedAt(statement.getObject().toPython())
            return

        # provenance
        if predicate == PROPERTY.PROVENANCE:
            self.addProvenance(Provenance.parse(statement.getResource()))
            return

        # offerings
        if predicate == PROPERTY.OFFERS:
            self.addOffering(Offering.parse(statement.getResource()))
            return

        # target
        if predicate == PROPERTY.TARGET:
            self.addTarget(statement.getString())
            return

        # label
        if predicate == PROPERTY.RDFS_LABEL:
            self.setName(statement.getString())
            return

        # comment
        if predicate == PROPERTY.COMMENT:
            self.setDescription(statement.getString())
            return

        # sessionKey
        if predicate == PROPERTY.SESSIONKEY:
            self.setSessionKey(statement.getString())
            return

        # signature
        if predicate == PROPERTY.SIGNATURE:
            self.setSignature(statement.getString())
            return

        # hashcode
        if predicate == PROPERTY.HASHCODE:
            self.setHashCode(statement.getString())
            return

        # encryptionKeyType
        if predicate == PROPERTY.ENCRYPTIONKEYTYPE:
            self.setEncryptionKeyType(statement.getResource().toString())
            return

        # notary
        if predicate == PROPERTY.NOTARY:
            self.setNotary(statement.getResource().toString())
            return

        # parameters
        if predicate == PROPERTY.PARAMETER:
            p = Parameter().parse(statement.getResource())
            self.add(p.getKey(), p.getValues())
            return

        # if literal object
        if isinstance(objectNode, Literal):
            self.add(URIRef(predicate), objectNode.toPython())
            #print 'DEBUG: ', objectNode.datatype, '...', objectNode
            #           if ((objectNode.datatype is not None) and objectNode.datatype == XSD.duration):
            #               self.add(URIRef(predicate), statement.getString())
            #           else:
            #               self.add(URIRef(predicate), objectNode.toPython())
            return

#       if isinstance(objectNode, URIRef):
#           print "parse URI resource ", objectNode
#           self.add(URIRef(predicate), objectNode)
#           return

# if resource
        if isinstance(objectNode, URIRef):
            resource = statement.getResource()

            # first check if resource has a type implemented built-in
            # and parse using that
            klass = Tools().getResourceClass(resource, default=Obj)

            if klass is not None:
                self.add(URIRef(predicate), klass.parse(resource))
            else:
                # None found, resort to Obj (the base class)
                self.add(URIRef(predicate), Obj.parse(resource))

            return

        # Nothing else matches, use BNode as blank default entry
        if isinstance(objectNode, BNode):
            try:
                klass = Tools().getResourceClass(statement.getResource(),
                                                 default=None)
            except:
                klass = None
            if klass is not None:
                self.add(URIRef(predicate),
                         klass.parse(statement.getResource()))
            else:
                self.add(URIRef(predicate), objectNode.toPython())
            return
Ejemplo n.º 18
0
    def storeToTransactionServer(cls, senderId, notary, *args):
        '''
        @param senderId: URI string
        @param notary: URI string
        @param args: a variable number of Transaction Objects  
        @return a boolean value
        '''
        try:
            client = HttpClient()
            # create an empty MIME multipart message
            sentHttpMessage = HttpMessage()

            # construct Request object
            req = RequestFactory().create(senderId)
            req.setMethod(RESOURCE.WRITE)
            cls.messageIdCounter = cls.messageIdCounter + 1
            req.setMessageId(cls.messageIdCounter)
            a = Activity()
            req.addActivity(a)
            i = Input()
            a.addInput(i)
            system = SystemOfInterest()
            system.setSameAs(notary)
            i.setSystemOfInterest(system)

            param = Parameter()
            param.setKey("transactions")
            param.setName("Transaction id list")
            param.setDescription(
                "List of ids of transactions that are sent for storing into the database."
            )

            for transaction in args:
                param.addValue(transaction.getIdentifierUri())
            i.addParameter(param)

            # save Request object to multipart message, Main part
            mainRequestString = Tools.toString(req)
            sentHttpMessage.addMainpart(mainRequestString)

            mainRequestHash = SmartAPICrypto().createEncodedMessageDigest(
                mainRequestString)
            requestSignature = SmartAPICrypto().sign(
                CryptoKeyWallet.getPrivateKey(), mainRequestHash)

            # create transaction for the main request
            if cls.transactionIdentifierUriPrefix == '':
                transactionIdentifierUri = senderId + uuid.uuid4().get_hex()
            else:
                transactionIdentifierUri = cls.transactionIdentifierUriPrefix + uuid.uuid4(
                ).get_hex()
            requestTransaction = Factory.createTransaction(
                transactionIdentifierUri, senderId)
            requestTransaction.setSigner(senderId)
            requestTransactionMessage = Message()
            requestTransactionMessage.setMessageId(req.getMessageId())
            requestTransactionMessage.setHashCode(mainRequestHash)
            requestTransactionMessage.setSignature(requestSignature)
            requestTransaction.setMessage(requestTransactionMessage)

            # save requestTransaction to multipart message, non-Main part
            requestTransactionString = Tools.toString(requestTransaction)
            sentHttpMessage.add(transactionIdentifierUri,
                                requestTransactionString)

            # save transactions that are sent to multipart message, non-Main part
            for trans in args:
                sentHttpMessage.add(trans.getIdentifierUri(),
                                    Tools.toString(trans))

            # send out this multipart message
            payload = removeFrontHeader(sentHttpMessage.asString())
            #print '*** sent ****'
            #print payload
            #print '*************'
            resp, contentType = client.sendPost(
                notary, payload, sentHttpMessage.getContentType())
            #print "----response -----"
            #print resp
            return True

        except:
            traceback.print_exc()
            return False
Ejemplo n.º 19
0
    def parseStatement(self, statement):
        from SmartAPI.rdf.Variant import Variant
        from SmartAPI.model.Activity import Activity
        from SmartAPI.model.Device import Device
        from SmartAPI.model.Entity import Entity
        from SmartAPI.model.Input import Input
        from SmartAPI.model.Output import Output
        from SmartAPI.model.Parameter import Parameter
        from SmartAPI.model.SystemOfInterest import SystemOfInterest
        from SmartAPI.model.TemporalContext import TemporalContext
        from SmartAPI.model.InterfaceAddress import InterfaceAddress
        from SmartAPI.model.TimeSeries import TimeSeries
        from SmartAPI.common.Tools import Tools

        if statement is None:
            raise NonePointerException("Unable to parse None to Evaluation.")
            return

        # get predicate
        predicate = str(statement.getPredicate())

        # category
        if predicate == PROPERTY.CATEGORY:
            try:
                self.addCategory(str(statement.getResource().toString()))
            except:
                print "Unable to interpret seas:category value as resource."
                traceback.print_exc()
            return

        # systemofinterest
        if predicate == PROPERTY.SYSTEMOFINTEREST:
            try:
                self.setSystemOfInterest(SystemOfInterest().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:systemOhInterest value as resource."
                traceback.print_exc()
            return

        # interfaceaddress
        if predicate == PROPERTY.INTERFACE:
            try:
                self.addInterface(InterfaceAddress().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:interface value as resource."
                traceback.print_exc()
            return

        # timeserie
        if predicate == PROPERTY.TIMESERIES:
            try:
                self.addTimeSerie(TimeSeries().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:timeSeries value as resource."
                traceback.print_exc()
            return

        # value
        if predicate == PROPERTY.RDF_VALUE:
            self.setValue(Variant().parse(statement))
            return

        # valueobject
        if predicate == PROPERTY.VALUEOBJECT:
            try:
                self.addValueObject(ValueObject().parse(
                    statement.getResource()))
            except:
                print "Unable to interpret seas:valueObject value as resource."
                traceback.print_exc()
            return

        # input data
        if predicate == PROPERTY.HASINPUT:
            try:
                self.addInput(Input().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:hasInput value as resource."
                traceback.print_exc()
            return

        # input reference
        if predicate == PROPERTY.HASREFINPUT:
            try:
                input = Input().parse(statement.getResource())
                input.setInputType(Input.TYPE_REFERENCE)
                self.addInput(input)
            except:
                print "Unable to interpret seas:hasRefInput value as resource."
                traceback.print_exc()
            return

        # output
        if predicate == PROPERTY.HASOUTPUT:
            try:
                self.addOutput(Output().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:hasOutput value as resource."
                traceback.print_exc()
            return

        # activities
        if predicate == PROPERTY.ACTIVITY:
            try:
                self.addActivity(Activity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:activity value as resource."
                print statement
                print "------------------------"
                traceback.print_exc()
                raise
            return
        """"
        if predicate == PROPERTY.PARAMETER:
            try:
                self.addParameter(Parameter().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:parameter value as resource."
                traceback.print_exc()
            return
        """

        # entity
        if predicate == PROPERTY.ENTITY:
            try:
                self.addEntity(Entity().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:entity value (of type seas:Entity) as resource."
                traceback.print_exc()
            return

#       # entity
#       if predicate == PROPERTY.ENTITY:
#           types = None
#           try:
#               types = Tools().getResourceTypes(statement.getResource())
#           except:
#               print "Unable to interpret seas:entity value as resource."
#               traceback.print_exc()
#
#           # service
#           if types is not None and RESOURCE.SERVICE in types:
#               try:
#                   self.addEntity(Service().parse(statement.getResource()))
#               except:
#                   print "Unable to interpret seas:entity value (of type seas:Service) as resource."
#                   traceback.print_exc()
#               return
#
#           # device
#           if types is not None and RESOURCE.DEVICE in types:
#               try:
#                   self.addEntity(Device().parse(statement.getResource()))
#               except:
#                   print "Unable to interpret seas:entity value (of type seas:Device) as resource."
#                   traceback.print_exc()
#               return
#
#
#           # serviceprovider
#
#           # weatherserviceprovider
#
#           # could not match with any entity subtype
#           try:
#               self.addEntity(Entity().parse(statement.getResource()))
#           except:
#               print "Unable to interpret seas:entity value (of type seas:Entity) as resource."
#               traceback.print_exc()
#           return

# generatedat
        if predicate == PROPERTY.LIST:
            try:
                list_python, listType = statement.getResource().toList(
                    Evaluation)
                self.setList(list_python, listType)
            except:
                print "Unable to interpret seas:list value as list."
                traceback.print_exc()
            return

        # generatedat
        if predicate == PROPERTY.MAP:
            try:
                self.setMap(Map().parse(statement.getResource()))
            except:
                print "Unable to interpret seas:map value as resource."
                traceback.print_exc()
            return

        # pass on to Obj
        super(Evaluation, self).parseStatement(statement)