Python, Java, C++: more modifications to fit struture to arch doc
authorjani <jani@asema.com>
Fri, 4 Jan 2019 14:47:54 +0000 (16:47 +0200)
committerjani <jani@asema.com>
Fri, 4 Jan 2019 14:47:54 +0000 (16:47 +0200)
14 files changed:
Common/C++/SmartAPI/smartapi/factory/RequestFactory.cpp
Common/C++/SmartAPI/smartapi/model/Activity.cpp
Common/C++/SmartAPI/smartapi/model/Activity.h
Common/C++/SmartAPI/smartapi/model/Evaluation.cpp
Common/C++/SmartAPI/tests/TestSequences.cpp
Common/Java/SmartAPI/src/smartapi/agents/TradingAgent.java
Common/Java/SmartAPI/src/smartapi/model/Activity.java
Common/Java/SmartAPI/src/smartapi/model/Evaluation.java
Common/Java/SmartAPI/src/smartapi/model/Restriction.java
Common/Java/SmartAPI/src/smartapi/tests/TestEvaluation.java
Common/Java/SmartAPI/src/smartapi/tests/testOrientdb.java
Common/Python/SmartAPI/model/Activity.py
Common/Python/SmartAPI/model/Evaluation.py
Common/Python/SmartAPI/model/Restriction.py [new file with mode: 0644]

index 308ede7f5549f16e90d2756771f9816883001ab3..53239e9254532eb22262e71bc969b8d8d5e2f5bb 100644 (file)
@@ -209,7 +209,7 @@ Request* RequestFactory::create(EVP_PKEY* key, QString method, QString senderIde
                }
                //a->setTraverseTo(traverseTo);
        }
-       if (timeSeries) a->addTimeSeries(timeSeries);
+       if (timeSeries) a->addTimeSerie(timeSeries);
        if (key) a->encrypt(key);
        if (tcx) a->setTemporalContext(tcx);
        a->addEntity(e);
index 9896a137c88606685ee14dc80eeb208b59c6f9b9..26c20de0a0368a2e3d2c982e1c55e10fd550be02 100755 (executable)
@@ -7,7 +7,6 @@
 Activity::Activity(QString uri) : Evaluation(uri)
 {
        setType(RESOURCE__ACTIVITY);
-       INIT_PROPERTY(mTemporalContext)
        INIT_PROPERTY(mAuthorization)
        INIT_PROPERTY(mTraverseUntil);
        INIT_PROPERTYLIST(mInputs,PROPERTY__HASINPUT);
@@ -16,13 +15,11 @@ Activity::Activity(QString uri) : Evaluation(uri)
        INIT_PROPERTYLIST(mDataAvailabilities,PROPERTY__HASDATAAVAILABILITY);
        INIT_PROPERTYLIST(mInterfaces,PROPERTY__INTERFACE);
        INIT_PROPERTYLIST(mEntities,PROPERTY__ENTITY);
-       INIT_PROPERTYLIST(mTimeSeries,PROPERTY__TIMESERIES);
        INIT_PROPERTYLIST(mTraverseTo,PROPERTY__TRAVERSETO);
 }
 
 Activity::Activity(Activity* a) : Evaluation(a)
 {
-       SET_PROPERTY_REFERENCE(PROPERTY__TEMPORALCONTEXT, mTemporalContext, TemporalContext)
        SET_PROPERTY_REFERENCE(PROPERTY__AUTHORIZATION, mAuthorization, Authorization)
        SET_PROPERTY_REFERENCE(PROPERTY__TRAVERSEUNTIL, mTraverseUntil, Variant)
        SET_PROPERTYLIST_REFERENCE(PROPERTY__HASINPUT, mInputs, Input)
@@ -31,7 +28,6 @@ Activity::Activity(Activity* a) : Evaluation(a)
        SET_PROPERTYLIST_REFERENCE(PROPERTY__HASDATAAVAILABILITY, mDataAvailabilities, Availability)
        SET_PROPERTYLIST_REFERENCE(PROPERTY__INTERFACE, mInterfaces, InterfaceAddress)
        SET_PROPERTYLIST_REFERENCE(PROPERTY__ENTITY, mEntities, Entity)
-       SET_PROPERTYLIST_REFERENCE(PROPERTY__TIMESERIES, mTimeSeries, TimeSeries)
        SET_PROPERTYLIST_REFERENCE(PROPERTY__TRAVERSETO, mTraverseTo, Variant)
        setType(RESOURCE__ACTIVITY);
 }
@@ -57,7 +53,6 @@ Resource* Activity::serialize(Model* model)
 void Activity::parse(Statement* statement)
 {
        INIT_PARSE(statement)
-       PARSE_PROPERTY(PROPERTY__TEMPORALCONTEXT, setTemporalContext, TemporalContext)
        PARSE_PROPERTY(PROPERTY__HASINPUT, addInput, Input)
        PARSE_PROPERTY(PROPERTY__HASOUTPUT, addOutput, Output)
        PARSE_PROPERTY(PROPERTY__HASAVAILABILITY, addAvailability, Availability)
@@ -65,7 +60,6 @@ void Activity::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__INTERFACE, addInterface, InterfaceAddress)
        PARSE_PROPERTY(PROPERTY__ENTITY, addEntity, Entity)
        PARSE_PROPERTY(PROPERTY__AUTHORIZATION, setAuthorization, Authorization)
-       PARSE_PROPERTY(PROPERTY__TIMESERIES, addTimeSeries, TimeSeries)
        PARSE_PROPERTY(PROPERTY__TRAVERSEUNTIL, setTraverseUntil, Variant)
        PARSE_PROPERTY(PROPERTY__TRAVERSETO, addTraverseTo, Variant)
        FINISH_PARSE(Obj)
index b99c19b122dc2676d4cab729544c13e03379071b..8d9fbaef21b14652b167d933dd574edabc3a0e8d 100644 (file)
@@ -46,11 +46,6 @@ public:
        Output* firstOutput();
        Output* newOutput();
        
-       bool hasTimeSeries()                                                                            { return mTimeSeries.length() > 0; }
-       PropertyList<TimeSeries*> getTimeSeries()                                       { return mTimeSeries; }
-       void setTimeSeries(TimeSeries* ts)                                                      { mTimeSeries.clear(); addTimeSeries(ts); }
-       void addTimeSeries(TimeSeries* ts)                                                      { mTimeSeries.append(ts); }
-
        bool hasAvailability()                                                                          { return !mAvailabilities.isEmpty(); }
        PropertyList<Availability*> getAvailabilities()                         { return mAvailabilities; }
        void addAvailability(Availability* availability)                        { mAvailabilities.append(availability); }
@@ -77,13 +72,6 @@ public:
        Authorization* getAuthorization()                                                       { return mAuthorization; }
        void setAuthorization(Authorization* auth)                                      { add(PROPERTY__AUTHORIZATION, auth); mAuthorization = auth; }
 
-       bool hasTemporalContext()                                                                       { return (mTemporalContext != NULL); }
-       TemporalContext* getTemporalContext()                                           { return mTemporalContext; }
-       void setTemporalContext(TemporalContext* temporalContext)       { add(PROPERTY__TEMPORALCONTEXT, temporalContext); mTemporalContext = temporalContext; }
-       void setTemporalContext(QDateTime start)                                        { setTemporalContext(new TemporalContext(start)); }
-       void setTemporalContext(QDateTime start, QDateTime end)         { setTemporalContext(new TemporalContext(start, end)); }
-       void setTemporalContext(QDateTime start, QDateTime end, QString during) { setTemporalContext(new TemporalContext(start, end, during)); }
-
        bool hasTraverseUntil()                                                                         { return (mTraverseUntil != NULL); }
        int getTraverseUntil()                                                                          { PROPERTYVAL(mTraverseUntil, asInt, -1); }
        void setTraverseUntil(Variant* depth)                                           { mTraverseUntil = depth; }
@@ -97,7 +85,6 @@ public:
        void addTraverseTo(int depth)                                                           { addTraverseTo(new Variant(depth)); }
 
 private:
-       TemporalContext* mTemporalContext;
        Authorization* mAuthorization;
        PropertyList<Input*> mInputs;
        PropertyList<Output*> mOutputs;
@@ -105,7 +92,6 @@ private:
        PropertyList<Availability*> mDataAvailabilities;
        PropertyList<InterfaceAddress*> mInterfaces;
        PropertyList<Entity*> mEntities;
-       PropertyList<TimeSeries*> mTimeSeries;
        Variant* mTraverseUntil;
        PropertyList<Variant*> mTraverseTo;
        //QSet<int> mTraverseTo;
index e6e112921ddddec005787cd5d89e1a01c427db81..253d85f0b22bda838c2eba8653616cd07e5bb4c3 100755 (executable)
@@ -31,9 +31,10 @@ Evaluation::Evaluation(Evaluation* o) : ValueObject(o)
 {
        QListIterator<QUrl> e(o->getCategories());
        while (e.hasNext()) addCategory(e.next());
+
+       SET_PROPERTYLIST_REFERENCE(PROPERTY__TIMESERIES, mTimeSeries, TimeSeries)
        SET_PROPERTY_REFERENCE(PROPERTY__METHOD, mMethod, Variant)
        SET_PROPERTY_REFERENCE(PROPERTY__SYSTEMOFINTEREST, mSystemOfInterest, SystemOfInterest)
-       SET_PROPERTY_REFERENCE(PROPERTY__TEMPORALCONTEXT, mTemporalContext, TemporalContext)
        setType(RESOURCE__EVALUATION);
 }
 
index 571cf498db3366039458f5565f8fc4898e22765c..355bb2e56e1bf9ba8c98d8d922a7625addc48de9 100644 (file)
@@ -826,7 +826,7 @@ bool timeseriesResponseTest()
                testList.append(v);
        }
        ts->setList(testList);
-       a->setTimeSeries(ts);
+       a->setTimeSerie(ts);
        r->addActivity(a);
 
        QString serialized = Tools::toString(r, SERIALIZATION__TURTLE);
index 913b6a6b8e81c81515949a25d0cc38e2ed2966dc..6a2cef476aa30a422d5fb73da45ef2d9a4a9375a 100644 (file)
@@ -584,52 +584,6 @@ public class TradingAgent {
                        return false;
                }
        }
-
-       public static ValueObject getAccountTransactionsSum(String accountId, Date from, Date to, String myIdentifier, PrivateKey privKey)
-       {
-               try {
-                       Request req = Factory.createRequest(myIdentifier);
-                       Activity activity = req.newActivity(ACTIVITIES.ACCOUNT_TRANSACTION_SUM);
-                       activity.setMethod(RESOURCE.READ);
-                       Input input = activity.newInput();
-                       if ( accountId != null ) {
-                               input.add(PROPERTY.ACCOUNT, new Account(accountId));
-                       }
-                       TemporalContext tcx = new TemporalContext();
-                       input.add(PROPERTY.TEMPORALCONTEXT, tcx);
-                       if ( from != null ) {
-                               tcx.setStart(from);
-                       }
-                       if ( to != null ) {
-                               tcx.setEnd(to);
-                       }
-                       Response resp = TradingAgent.sendRequest(req, serverUri, privKey);
-                       if (resp != null ) {
-                               if (!resp.hasErrors()) {
-                                       for (Activity a : resp.getActivities()) {
-                                               if (a.hasErrors()) {
-                                                       Tools.printErrors(a);
-                                                       return null;
-                                               }
-                                               if ( a.hasOutput() && a.getFirstOutput().hasValueObject() ) {
-                                                       return a.getFirstOutput().getValueObjects().get(0);
-                                               }
-                                       }
-                                       if (debug) System.out.println("TradingAgent getAccountTransactionsSum method received a response without a contract.");
-                                       return null;
-                               } else {
-                                       Tools.printErrors(resp);
-                                       return null;
-                               }
-                       } else {
-                               if (debug) System.out.println("TradingAgent getAccountTransactionsSum method received a null response.");
-                               return null;
-                       }
-               } catch ( Exception e ) {
-                       e.printStackTrace();
-                       return null;
-               }
-       }
        
        /**
         * Add AccountUser as a client for the given account.
index 956b0c353cf627bbd5d93358745d93030224dbda..356a38bafffd29b0d36eeb0b0c078e0a3c1614b1 100644 (file)
@@ -12,7 +12,7 @@ import smartapi.common.PROPERTY;
 import smartapi.common.RESOURCE;
 import smartapi.rdf.Variant;
 
-public class Activity extends Obj {
+public class Activity extends Evaluation {
        
        public Activity()
        {
@@ -33,12 +33,6 @@ public class Activity extends Obj {
                return resource;
        }
        
-       // method accessors
-       public boolean hasMethod() { return has(PROPERTY.METHOD); }     
-       public String getMethod() { return getFirstAs(Obj.class, PROPERTY.METHOD).getIdentifierUri(); }
-       public void setMethod(String method) { set(PROPERTY.METHOD, new Obj(method != null ? NS.toAbsoluteUri(method) : method)); }
-       public void setMethod(Obj method) { set(PROPERTY.METHOD, method); }
-
        // input accessors
        public boolean hasInput() { return has(PROPERTY.HASINPUT); }
        public List<Input> getInputs() { return getAs(Input.class, PROPERTY.HASINPUT); }
@@ -105,7 +99,6 @@ public class Activity extends Obj {
        public List<Availability> getDataAvailabilities() { return getAs(Availability.class, PROPERTY.HASDATAAVAILABILITY); }
        public void addDataAvailability(Availability availability) { add(PROPERTY.HASDATAAVAILABILITY, availability); }
 
-
        // interface accessors
        public List<InterfaceAddress> getInterfaces() { return getAs(InterfaceAddress.class, PROPERTY.INTERFACE); }
        public void setInterface(InterfaceAddress interfaceAddress) { set(PROPERTY.INTERFACE, interfaceAddress); }
@@ -150,21 +143,6 @@ public class Activity extends Obj {
                return entity;
        }
 
-       // temporalcontext accessors
-       public boolean hasTemporalContext() { return has(PROPERTY.TEMPORALCONTEXT); }
-       public TemporalContext getTemporalContext() { return getFirstAs(TemporalContext.class, PROPERTY.TEMPORALCONTEXT); }
-       public void setTemporalContext(TemporalContext temporalContext) { set(PROPERTY.TEMPORALCONTEXT, temporalContext); }
-       public void setTemporalContext(Date start, Date end) { set(PROPERTY.TEMPORALCONTEXT, new TemporalContext(start, end)); }
-       public void setTemporalContext(Date start, Date end, String during) { set(PROPERTY.TEMPORALCONTEXT, new TemporalContext(start, end, during)); }
-       public void setTemporalContext(Date start) { set(PROPERTY.TEMPORALCONTEXT, new TemporalContext(start)); }
-       public void setTemporalContext(Time start, Time end) { set(PROPERTY.TEMPORALCONTEXT, new TemporalContext(start, end)); }
-       public void setTemporalContext(Time start, Time end, String during) { set(PROPERTY.TEMPORALCONTEXT, new TemporalContext(start, end, during)); }
-
-       // timeseries accessors
-       public boolean hasTimeSerie() { return has(PROPERTY.TIMESERIES); }
-       public List<TimeSeries> getTimeSeries() { return getAs(TimeSeries.class, PROPERTY.TIMESERIES); }
-       public void addTimeSerie(TimeSeries timeSerie) { add(PROPERTY.TIMESERIES, timeSerie); }
-       
        // traverseUntil accessors
        public boolean hasTraverseUntil() { return has(PROPERTY.TRAVERSEUNTIL); }
        public int getTraverseUntil() { return getFirstAsVariant(PROPERTY.TRAVERSEUNTIL).asInt(); }
index 407218003c8306cf79f96debfc9d1a1926772954..5e47b37e52a555e63b90092b4bda167c0ffc23bb 100644 (file)
@@ -86,6 +86,12 @@ public class Evaluation extends ValueObject implements Nudeable {
                }
        }
 
+       // method accessors
+       public boolean hasMethod() { return has(PROPERTY.METHOD); }     
+       public String getMethod() { return getFirstAs(Obj.class, PROPERTY.METHOD).getIdentifierUri(); }
+       public void setMethod(String method) { set(PROPERTY.METHOD, new Obj(method != null ? NS.toAbsoluteUri(method) : method)); }
+       public void setMethod(Obj method) { set(PROPERTY.METHOD, method); }
+       
        // category accessors
        public boolean hasCategory() { return has(PROPERTY.CATEGORY); } 
        public java.util.List<Obj> getCategories() { return getAs(Obj.class, PROPERTY.CATEGORY); }
@@ -93,13 +99,6 @@ public class Evaluation extends ValueObject implements Nudeable {
        public void addCategory(String category) { add(PROPERTY.CATEGORY, new Obj(category != null ? NS.toAbsoluteUri(category) : category)); }
        public void setCategory(Obj category) { set(PROPERTY.CATEGORY, category); }
        public void addCategory(Obj category) { add(PROPERTY.CATEGORY, category); }
-       public void setMethod(Obj method) { set(PROPERTY.CATEGORY, method); }
-
-       // valueObject accessors
-       public boolean hasValueObject() { return has(PROPERTY.VALUEOBJECT); }
-       public java.util.List<ValueObject> getValueObjects() { return getAs(ValueObject.class, PROPERTY.VALUEOBJECT); }
-       public void setValueObject(ValueObject valueObject) { set(PROPERTY.VALUEOBJECT, valueObject); }
-       public void addValueObject(ValueObject valueObjects) { add(PROPERTY.VALUEOBJECT, valueObjects); }
 
        // timeSeries accessors
        public boolean hasTimeSerie() { return has(PROPERTY.TIMESERIES); }
index 7954806b5281b4aa53922cff0460879f0fc7b413..d76a8a82febf765a26b5b3f7707c9ee7657e1776 100644 (file)
@@ -9,7 +9,7 @@ import smartapi.rdf.LinkedList;
 import smartapi.rdf.List;
 import smartapi.rdf.Variant;
 
-public class Restriction extends Obj {
+public class Restriction extends Evaluation {
        
        public Restriction()
        {
index 2e5340bf5426f7608e0b102e816996f3b8fe4f92..b5d6c24c967bdff28ae465f2d6f4a407bad9aa40 100644 (file)
@@ -13,7 +13,7 @@ public class TestEvaluation {
 
        protected static Evaluation init()
        {               
-               Evaluation evaluation = new Evaluation();               
+               Evaluation evaluation = new Evaluation();
                return init(evaluation);
        }
 
@@ -34,7 +34,6 @@ public class TestEvaluation {
                evaluation.setInstant(VALUE.DATE);
                evaluation.setMinimum(new Variant(VALUE.DOUBLE));
                evaluation.setMaximum(new Variant(VALUE.INT));
-               evaluation.addValueObject(TestValueObject.init());
                
                return evaluation;
        }
index 10abcc12a329ee84b4f089757bb648daeba89a9d..bf09cdcea53d25b28ddfdaee7a3da67331527c60 100644 (file)
@@ -80,8 +80,7 @@ public class testOrientdb {
               Activity a = Factory.createStandardReadActivity();
               Input in = new Input();
               a.addInput(in);
-              in.addValueObject(new ValueObject(RESOURCE.TEMPERATURE, RESOURCE.DEGREECELSIUS, 0));
-
+              
               Service s = new Service("http://shepherd6.com/Cid");
               s.addManagedEntity("http://sheep6.com/Cid");
 
index cdc2a4f81882cb5d19f4063e01594d11648414dc..79eeea85d71f95eaf852f200167ba3a864d3ac8d 100644 (file)
@@ -28,17 +28,13 @@ class Activity(Evaluation):
                self.init_property(PROPERTY.HASDATAAVAILABILITY, 'dataAvailabilities', self.hasDataAvailability, self.getDataAvailabilities, True)
                self.init_property(PROPERTY.INTERFACE, 'interfaces', self.hasInterface, self.getInterfaces, True)
                self.init_property(PROPERTY.ENTITY, 'entities', self.hasEntity, self.getEntities, True)
-               self.init_property(PROPERTY.TEMPORALCONTEXT, 'temporalContext', self.hasTemporalContext, self.getTemporalContext)
-               self.init_property(PROPERTY.TIMESERIES, 'timeSeries', self.hasTimeSeries, self.getTimeSeries, True)
-
+               
        def _parseStatement(self, statement):
                from SmartAPI.model.Availability import Availability
                from SmartAPI.model.Input import Input
                from SmartAPI.model.Output import Output
                from SmartAPI.model.InterfaceAddress import InterfaceAddress
                from SmartAPI.model.Entity import Entity
-               from SmartAPI.model.TimeSeries import TimeSeries
-               from SmartAPI.model.TemporalContext import TemporalContext
                
                self.parse_property(statement, PROPERTY.HASINPUT, self.addInput, Input)
                self.parse_property(statement, PROPERTY.HASREFINPUT, self.addRefInput, Input)
@@ -48,9 +44,7 @@ class Activity(Evaluation):
                self.parse_property(statement, PROPERTY.HASDATAAVAILABILITY, self.addDataAvailability, Availability)
                self.parse_property(statement, PROPERTY.INTERFACE, self.addInterface, InterfaceAddress) 
                self.parse_property(statement, PROPERTY.ENTITY, self.addEntity, Entity)
-               self.parse_property(statement, PROPERTY.TEMPORALCONTEXT, self.setTemporalContext, TemporalContext)
-               self.parse_property(statement, PROPERTY.TIMESERIES, self.addTimeSerie, TimeSeries)
-
+               
                super(Activity, self)._parseStatement(statement)
 
        def hasInput(self):
@@ -187,25 +181,4 @@ class Activity(Evaluation):
                        return self.outputs[0]
                except:
                        return None
-       
-       def hasTemporalContext(self):
-               return self.temporalContext is not None
-
-       def getTemporalContext(self):
-               return self.temporalContext
-
-       def setTemporalContext(self, temporalContext):
-               if isinstance(temporalContext, TemporalContext):
-                       self.temporalContext = temporalContext
-               else:
-                       print 'Error: parameter need to be TemporalContext object!'
-               
-       def hasTimeSeries(self):
-               return len(self.timeSeries) > 0
-       
-       def getTimeSeries(self):
-               return self.timeSeries
-               
-       def addTimeSerie(self, timeSerie):
-               self.timeSeries.append(timeSerie)
-               
\ No newline at end of file
+       
\ No newline at end of file
index f92b565a7d90881ceb5cbb5d63b633c42d43ed78..6770a01a89c28b001d5d67ea6134f6095a5514c2 100644 (file)
@@ -25,8 +25,6 @@ class Evaluation(ValueObject):
                self.init_property(PROPERTY.SYSTEMOFINTEREST, 'systemOfInterest', self.hasSystemOfInterest, self.getSystemOfInterest)
                self.init_property(PROPERTY.CATEGORY, 'categories', self.hasCategory, self.getCategories, islist = True)
                self.init_property(PROPERTY.TIMESERIES, 'timeSeries', self.hasTimeSeries, self.getTimeSeries, islist = True)
-               self.init_property(PROPERTY.VALUEOBJECT, 'valueObjects', self.hasValueObject, self.getValueObjects, islist = True)
-               self.init_property(PROPERTY.ACTIVITY, 'activities', self.hasActivity, self.getActivities, islist = True)
                self.init_property(PROPERTY.METHOD, 'method', self.hasMethod, self.getMethod)
                
        @classmethod
@@ -42,17 +40,13 @@ class Evaluation(ValueObject):
        def _parseStatement(self, statement):
                from SmartAPI.rdf.Variant import Variant
                from SmartAPI.model.Obj import Obj
-               from SmartAPI.model.Activity import Activity
                from SmartAPI.model.SystemOfInterest import SystemOfInterest
-               from SmartAPI.model.TemporalContext import TemporalContext
                from SmartAPI.model.TimeSeries import TimeSeries
                from SmartAPI.common.Tools import Tools
                
                self.parse_property(statement, PROPERTY.SYSTEMOFINTEREST, self.setSystemOfInterest, SystemOfInterest)
                self.parse_property(statement, PROPERTY.CATEGORY, self.addCategory, Variant)
                self.parse_property(statement, PROPERTY.TIMESERIES, self.addTimeSerie, TimeSeries)
-               self.parse_property(statement, PROPERTY.VALUEOBJECT, self.addValueObject, ValueObject)
-               self.parse_property(statement, PROPERTY.ACTIVITY, self.addActivity, Activity)
                self.parse_property(statement, PROPERTY.METHOD, self.setMethod, Variant)
                super(Evaluation, self)._parseStatement(statement)
 
@@ -79,18 +73,6 @@ class Evaluation(ValueObject):
        def getCategories(self):
                return self.categories
 
-       def hasValueObject(self):
-               return len(self.valueObjects) > 0
-       
-       def setValueObject(self, valueObject):
-               self.valueObjects = [valueObject]
-
-       def addValueObject(self, valueObject):
-               self.valueObjects.append(valueObject)
-
-       def getValueObjects(self):
-               return self.valueObjects
-
        def hasTimeSeries(self):
                return len(self.timeSeries) > 0
        
@@ -137,33 +119,4 @@ class Evaluation(ValueObject):
                        methodUri = Variant(methodUri)
                
                self.method = methodUri
-               
-       def hasActivity(self):
-               return len(self.activities) > 0
-       
-       def getActivities(self):
-               return self.activities
-
-       def setActivity(self, activity):
-               self.activities = [activity]
-
-       def addActivity(self, activity):
-               self.activities.append(activity)
-       
-       def newActivity(self, identifier=None):
-               from SmartAPI.model.Activity import Activity
-
-               if identifier:
-                       activity = Activity(identifier)
-                       self.addActivity(activity)
-                       return activity
-               else:
-                       activity = Activity()
-                       self.addActivity(activity)
-                       return activity
        
-       def firstActivity(self):
-               try:
-                       return self.activities[0]
-               except:
-                       return None
diff --git a/Common/Python/SmartAPI/model/Restriction.py b/Common/Python/SmartAPI/model/Restriction.py
new file mode 100644 (file)
index 0000000..b038bdd
--- /dev/null
@@ -0,0 +1,106 @@
+from SmartAPI.common.RESOURCE import RESOURCE
+from SmartAPI.common.PROPERTY import PROPERTY
+
+from SmartAPI.rdf.Resource import Resource
+from SmartAPI.model.Evaluation import Evaluation
+from SmartAPI.smartapiexceptions.NonePointerException import NonePointerException
+
+import traceback
+
+class Restriction(Evaluation):
+       
+       def __init__(self, uri = None):
+               Evaluation.__init__(self, uri)
+               self.setType(RESOURCE.RESTRICTION)
+
+               self.init_property(PROPERTY.CARDINALITY, 'cardinality', self.hasCardinality, self.getCardinality)
+               self.init_property(PROPERTY.MINCARDINALITY, 'minCardinality', self.hasMinCardinality, self.getMinCardinality)
+               self.init_property(PROPERTY.MAXCARDINALITY, 'maxCardinality', self.hasMaxCardinality, self.getMaxCardinality)
+               self.init_property(PROPERTY.OPTIONAL, 'optional', self.hasOptional, self.getOptional)
+               self.init_property(PROPERTY.ONDATARANGE, 'dataRange', self.hasDataRange, self.getDataRange)
+               self.init_property(PROPERTY.ONPROPERTIES, 'onProperties', self.hasOnProperty, self.getOnProperties, True)
+               
+       
+       @classmethod
+       def fromString(cls, data, serialization):
+               from SmartAPI.common.Tools import Tools
+               try:
+                       return cls.parse(Tools().getResourceByType(RESOURCE.RESTRICTION, Tools().fromString(data, serialization)))
+               except:
+                       print "Unable to parse Restriction from the given string."
+                       traceback.print_exc() 
+                       return None
+       
+       def _parseStatement(self, statement):
+               from SmartAPI.rdf.Variant import Variant
+               from SmartAPI.model.Obj import Obj
+               from SmartAPI.model.Activity import Activity
+               from SmartAPI.model.SystemOfInterest import SystemOfInterest
+               from SmartAPI.model.TemporalContext import TemporalContext
+               from SmartAPI.model.TimeSeries import TimeSeries
+               from SmartAPI.common.Tools import Tools
+               
+               self.parse_property(statement, PROPERTY.CARDINALITY, self.setCardinality, Variant)
+               self.parse_property(statement, PROPERTY.MINCARDINALITY, self.setMinCardinality, Variant)
+               self.parse_property(statement, PROPERTY.MAXCARDINALITY, self.setMaxCardinality, Variant)
+               self.parse_property(statement, PROPERTY.OPTIONAL, self.setOptional, Variant)
+               self.parse_property(statement, PROPERTY.ONDATARANGE, self.setDataRange, Obj)
+               self.parse_property(statement, PROPERTY.ONPROPERTIES, self.addOnProperty, Obj)
+               super(Evaluation, self)._parseStatement(statement)
+               
+               
+       def hasCardinality(self):
+               return self.cardinality is not None
+       
+       def getCardinality(self):
+               return self.cardinality
+               
+       def setCardinality(self, cardinality):
+               self.cardinality = cardinality
+               
+       def hasMinCardinality(self):
+               return self.minCardinality is not None
+       
+       def getMinCardinality(self):
+               return self.minCardinality
+       
+       def setMinCardinality(self, minCardinality):
+               self.minCardinality = minCardinality
+
+       def hasMaxCardinality(self):
+               return self.mxCardinality is not None
+       
+       def getMaxCardinality(self):
+               return self.maxCardinality
+       
+       def setMaxCardinality(self, maxCardinality):
+               self.maxCardinality = maxCardinality
+
+       def hasOptional(self):
+               return self.optional is not None
+       
+       def getOptional(self):
+               return self.optional
+       
+       def setOptional(self, optional):
+               self.optional = optional
+
+       def hasDataRange(self):
+               return self.dataRange is not None
+       
+       def getDataRange(self):
+               return self.dataRange
+       
+       def setDataRange(self, dataRange):
+               self.dataRange = dataRange
+
+       def hasOnProperty(self):
+               return len(self.onProperties) > 0
+       
+       def getOnProperties(self):
+               return self.onProperties
+       
+       def addOnProperty(self, onProperty):
+               self.onProperties.append(onProperty)
+
+