Python: added Conditions to price specs
authorjani <jani@asema.com>
Sat, 3 Aug 2019 09:17:39 +0000 (12:17 +0300)
committerjani <jani@asema.com>
Sat, 3 Aug 2019 09:17:39 +0000 (12:17 +0300)
19 files changed:
Common/Java/SmartAPI/docs/for-maven-user.txt
Common/Python/SmartAPI/model/Condition.py
Common/Python/SmartAPI/model/DependentPriceSpecification.py
Common/Python/SmartAPI/model/DistanceDependentPriceSpecification.py
Common/Python/SmartAPI/model/DurationAtDistanceDependentPriceSpecification.py
Common/Python/SmartAPI/model/DurationAtZoneDependentPriceSpecification.py
Common/Python/SmartAPI/model/DurationDependentPriceSpecification.py
Common/Python/SmartAPI/model/ObjectOperationDependentPriceSpecification.py
Common/Python/SmartAPI/model/PriceSpecification.py
Common/Python/SmartAPI/model/PropertyDependentPriceSpecification.py
Common/Python/SmartAPI/model/TimeDependentPriceListSpecification.py
Common/Python/SmartAPI/model/TimeDependentPriceSpecification.py
Common/Python/SmartAPI/model/TravelDistanceDependentPriceSpecification.py
Common/Python/SmartAPI/model/TravelDistanceDurationDependentPriceSpecification.py
Common/Python/SmartAPI/model/ZoneDependentPriceSpecification.py
Common/Python/SmartAPI/model/ZoneTravelDependentPriceSpecification.py
Common/Python/SmartAPI/model/ZoneTravelDurationDependentPriceSpecification.py
Common/Python/SmartAPI/tests/TestSequences.py
Examples/Python/AdaptDataService/AdaptDataService.py

index 20a867f1ca85efd7825c6744e4c5fe8471a33b55..7cf31aded3736b29122d1a76161fe84a7f9a5ede 100644 (file)
@@ -29,6 +29,5 @@ This is how to specify in your pom.xml file the dependency on version 0.0.1 of t
        </dependency>
 
 --------------------------------------------------------
-To put them together
 
-docs/sample-pom-for-seas-user.xml gives an example about how the pom.xml file for a simple Maven project called SeasMvnTest looks like. The SeasMvnTest project is a simplest Java application which uses SeasObjects as dependency.
+
index 6c88d06d21c8b2e3fc069c63c2e2db267f9b760d..562aa3f664ebeefbd80612fffdaad41a57ccdb34 100644 (file)
@@ -3,7 +3,6 @@ from SmartAPI.common.RESOURCE import RESOURCE
 from SmartAPI.common.Tools import Tools
 
 #from SmartAPI.model.Controllability import Controllability
-#from SmartAPI.model.Availability import Availability
 
 from SmartAPI.model.Obj import Obj
 from SmartAPI.rdf.Resource import Resource
@@ -17,18 +16,48 @@ class Condition(Obj):
        def __init__(self, uri = None):
                Obj.__init__(self, uri)         
                self.setType(RESOURCE.CONDITION)
+               self.init_property(PROPERTY.TEMPORALCONTEXT, 'temporalContext', self.hasTemporalContext, self.getTemporalContext)
                self.init_property(PROPERTY.REGEX, 'regexes', self.hasRegex, self.getRegexes, True)
                self.init_property(PROPERTY.OR, 'ors', self.hasOr, self.getOrs, True)
                self.init_property(PROPERTY.AND, 'ands', self.hasAnd, self.getAnds, True)
                self.init_property(PROPERTY.XOR, 'xors', self.hasXor, self.getXors, True)
+               self.init_property(PROPERTY.ACTION, 'actions', self.hasAction, self.getActions, True)
+               self.init_property(PROPERTY.EQUAL, 'equals', self.hasEqual, self.getEquals, True)
+               self.init_property(PROPERTY.NONEQUAL, 'nonEquals', self.hasNonEqual, self.getNonEquals, True)
+               self.init_property(PROPERTY.LESSER, 'lessers', self.hasLesser, self.getLessers, True)
+               self.init_property(PROPERTY.LESSEROREQUAL, 'lesserOrEquals', self.hasLesserOrEqual, self.getLesserOrEquals, True)
+               self.init_property(PROPERTY.GREATER, 'greaters', self.hasGreater, self.getGreaters, True)
+               self.init_property(PROPERTY.GREATEROREQUAL, 'greaterOrEquals', self.hasGreaterOrEqual, self.getGreaterOrEquals, True)
        
        def _parseStatement(self, statement, custom_classes = None):
+               from SmartAPI.model.TemporalContext import TemporalContext
+               
                self.parse_property(statement, PROPERTY.REGEX, self.addRegex, Variant, custom_classes = custom_classes)
                self.parse_property(statement, PROPERTY.OR, self.addOr, Variant, custom_classes = custom_classes)
                self.parse_property(statement, PROPERTY.AND, self.addAnd, Variant, custom_classes = custom_classes)
                self.parse_property(statement, PROPERTY.XOR, self.addXor, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.TEMPORALCONTEXT, self.setTemporalContext, TemporalContext, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.ACTION, self.addAction, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.EQUAL, self.addEqual, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.NONEQUAL, self.addNonEqual, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.LESSER, self.addLesser, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.LESSEROREQUAL, self.addLesserOrEqual, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.GREATER, self.addGreater, Variant, custom_classes = custom_classes)
+               self.parse_property(statement, PROPERTY.GREATEROREQUAL, self.addGreaterOrEqual, Variant, custom_classes = custom_classes)
+               
                super(Condition, self)._parseStatement(statement, custom_classes = custom_classes)
 
+       def hasAction(self):
+               return len(self.actions) > 0
+
+       def getActions(self):
+               return self.actions
+
+       def addAction(self, a):
+               if not isinstance(a, Variant):
+                       a = Variant(a)
+               self.actions.append(a)
+               
        def hasOr(self):
                return len(self.ors) > 0
 
@@ -36,7 +65,7 @@ class Condition(Obj):
                return self.ors
 
        def addOr(self, o):
-               if isinstance(o, Obj):
+               if not isinstance(o, Variant):
                        o = Variant(o)
                self.ors.append(o)
                
@@ -47,7 +76,7 @@ class Condition(Obj):
                return self.xors
 
        def addXor(self, o):
-               if isinstance(o, Obj):
+               if not isinstance(o, Variant):
                        o = Variant(o)
                self.xors.append(o)
 
@@ -58,7 +87,7 @@ class Condition(Obj):
                return self.ands
 
        def addAnd(self, a):
-               if isinstance(a, Obj):
+               if not isinstance(a, Variant):
                        a = Variant(a)
                self.ands.append(a)
 
@@ -72,3 +101,79 @@ class Condition(Obj):
                if not isinstance(regex, Variant):
                        regex = Variant(regex)
                self.regexes.append(regex)
+               
+       def hasEqual(self):
+               return len(self.equals) > 0
+
+       def getEquals(self):
+               return self.equals
+
+       def addEqual(self, e):
+               if not isinstance(e, Variant):
+                       e = Variant(e)
+               self.equals.append(e)
+       
+       def hasNonEqual(self):
+               return len(self.nonEquals) > 0
+
+       def getNonEquals(self):
+               return self.nonEquals
+
+       def addNonEqual(self, e):
+               if not isinstance(e, Variant):
+                       e = Variant(e)
+               self.nonEquals.append(e)
+
+       def hasLesser(self):
+               return len(self.lessers) > 0
+
+       def getLessers(self):
+               return self.lessers
+
+       def addLesser(self, l):
+               if not isinstance(l, Variant):
+                       l = Variant(l)
+               self.lessers.append(l)
+               
+       def hasLesserOrEqual(self):
+               return len(self.lesserOrEquals) > 0
+
+       def getLesserOrEquals(self):
+               return self.lesserOrEquals
+
+       def addLesserOrEqual(self, l):
+               if not isinstance(l, Variant):
+                       l = Variant(l)
+               self.lesserOrEquals.append(l)
+               
+       def hasGreater(self):
+               return len(self.greaters) > 0
+
+       def getGreaters(self):
+               return self.greaters
+
+       def addGreater(self, g):
+               if not isinstance(g, Variant):
+                       g = Variant(g)
+               self.greaters.append(g)
+               
+       def hasGreaterOrEqual(self):
+               return len(self.greaterOrEquals) > 0
+
+       def getGreaterOrEquals(self):
+               return self.greaterOrEquals
+
+       def addGreaterOrEqual(self, g):
+               if not isinstance(g, Variant):
+                       g = Variant(g)
+               self.greaterOrEquals.append(g)
+               
+       def hasTemporalContext(self):
+               return self.temporalContext is not None
+
+       def getTemporalContext(self):
+               return self.temporalContext
+
+       def setTemporalContext(self, t):
+               self.temporalContext = t
+       
index 88f93f83a501ca0e3f965b49aebbd772eb76e54f..379364d09844536d144f40b3cd9da9957f3dd4fb 100644 (file)
@@ -6,9 +6,8 @@ from SmartAPI.model.Condition import Condition
 
 class DependentPriceSpecification(PriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(DependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
-
                self.init_property(PROPERTY.LIST, 'conditions', self.hasCondition, self.getConditions, islist = True)
        
        def hasCondition(self):
index 57749bf3d3e244d74d2a1b753066d3710f44750a..21eaa7f80919b380276dffb4fb89a7854689d9c8 100644 (file)
@@ -6,7 +6,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class DistanceDependentPriceSpecification(TravelDistanceDependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(DistanceDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.DISTANCEDEPENDENTPRICESPECIFICATION)
                self.init_property(PROPERTY.LOCATION, 'coordinates', self.hasCoordinates, self.getCoordinates)
index 28de5e190781701a8d187fba5226498d389c6735..4ba2b925277d9511b386991122d2cf0c73871ae4 100644 (file)
@@ -6,7 +6,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class DurationAtDistanceDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(DurationAtDistanceDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION)
                self.init_property(PROPERTY.LOCATION, 'coordinates', self.hasCoordinates, self.getCoordinates)
index 8702559352f5c8137d9c306cfa12777bf06ab45b..5d48b7e9771cbff73204f2aa83b45de773eca29c 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class DurationAtZoneDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(DurationAtZoneDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION)
                
index 5d2a99795aa17b0b9ff42d926fdf4fd97a6da5ea..fd57950beaaf8fd2926434d4468074bbfb75d9fa 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class DurationDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(DurationDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.DURATIONDEPENDENTPRICESPECIFICATION)
                
index b745bb26a7d20811f71fb1633064585fb581e8bd..bee3780398d8c08ce260b52ca73efe11fe6bac33 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class ObjectOperationDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(ObjectOperationDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.OBJECTOPERATIONDEPENDENTPRICESPECIFICATION)
                
index 2989618fe0a2d2b5e77a5ea074016e61af1e4bd9..2b9c7847424cd5377ddce685afdb77b28abaaa64 100644 (file)
@@ -174,7 +174,7 @@ class PriceSpecification(GrObj):
         self.parse_property(statement, PROPERTY.VATPERCENTAGE, self.setVatPercentage, Variant, custom_classes = custom_classes)
         self.parse_property(statement, PROPERTY.QUANTITYKIND, self.setQuantity, Variant, custom_classes = custom_classes)
         self.parse_property(statement, PROPERTY.UNIT, self.setUnit, Variant, custom_classes = custom_classes)
-        self.parse_property(statement, PROPERTY.SECONDARYQUANTITYKIND, self.setSecondQuantity, Variantv, custom_classes = custom_classes)
+        self.parse_property(statement, PROPERTY.SECONDARYQUANTITYKIND, self.setSecondQuantity, Variant, custom_classes = custom_classes)
         self.parse_property(statement, PROPERTY.SECONDARYUNIT, self.setSecondUnit, Variant, custom_classes = custom_classes)
         
         super(PriceSpecification, self)._parseStatement(statement, custom_classes = custom_classes)
index 40b1b3e213de488c164182f1c7ec5714f7946d57..11a72a77fdf8b607ae553e730654c704cc66edba 100644 (file)
@@ -8,7 +8,7 @@ from rdflib import URIRef, XSD
 
 class PropertyDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(PropertyDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.PROPERTYDEPENDENTPRICESPECIFICATION)
                
index cdac502ee5049e13e436479edaf6c485704da410..ecf366440ed0691f22c836f09fe5ef4d9fac503a 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class TimeDependentPriceListSpecification(TimeDependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(TimeDependentPriceListSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.TIMEDEPENDENTPRICELISTSPECIFICATION)
                
index bc092633bd546aa7f1388260afea5b8d97d65513..c22091f2606d3ded54f1d3dd277f015954cc6e32 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class TimeDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(TimeDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.TIMEDEPENDENTPRICESPECIFICATION)
                
index d793bd592eb95dfd38d39f95a7e51751bc3e09bb..2196ab359f7892d052f7ae5abdb49c939c59564c 100644 (file)
@@ -7,7 +7,7 @@ from SmartAPI.common.PROPERTY import PROPERTY
 
 class TravelDistanceDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(TravelDistanceDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.TRAVELDISTANCEDEPENDENTPRICESPECIFICATION)
                
index 68325ae3700693c1957bdf97c4197657c3b70015..97d240b8e9c020b31735a0bd66531c882a0b0cd4 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class TravelDistanceDurationDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(TravelDistanceDurationDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.TRAVELDISTANCEDURATIONDEPENDENTPRICESPECIFICATION)
                
index af385e200296de8a6f90f8d2fed062857c5e27da..352b1c44e2967505e38f703eb05cec24bcd2e2fb 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class ZoneDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(ZoneDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.ZONEDEPENDENTPRICESPECIFICATION)
                
index 16d1c68a2c1aa24b959f2f984c22574e3be9f593..636c08de9f270b56c7447c0b01403cb009e4932b 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class ZoneTravelDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(ZoneTravelDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.ZONETRAVELDEPENDENTPRICESPECIFICATION)
                
index b1f7e5a1aa82bd0b9b027066a7ebf5a0ccdd260a..08f743a579ee45d4e0d0d47b09bb5bd6eeedbd3f 100644 (file)
@@ -4,7 +4,7 @@ from SmartAPI.common.RESOURCE import RESOURCE
 
 class ZoneTravelDurationDependentPriceSpecification(DependentPriceSpecification):
 
-       def __init__(uri = None, value = None, unit = None, validFrom = None, validThrough = None):
+       def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
                super(ZoneTravelDurationDependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
                self.setType(RESOURCE.ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION)
                
index 42edc477d5a1cb793963017230c93d1ed00128aa..1fd733d5af4869ea3b1ddc554281229362b03c21 100755 (executable)
@@ -43,7 +43,9 @@ from SmartAPI.model.Route import Route
 from SmartAPI.model.Coordinates import Coordinates
 from SmartAPI.model.Request import Request
 from SmartAPI.model.UnitPriceSpecification import UnitPriceSpecification
+from SmartAPI.model.PropertyDependentPriceSpecification import PropertyDependentPriceSpecification
 from SmartAPI.model.SomeItems import SomeItems
+from SmartAPI.model.Condition import Condition
 from SmartAPI.model.Offering import Offering
 from SmartAPI.model.Transaction import Transaction
 from SmartAPI.model.Entity import Entity
@@ -2105,8 +2107,46 @@ def velocityTest():
     print end - start
     """
     
+    
+def conditionalPriceSpecificationTest():
+    offering = Offering()
+    priceSpec = PropertyDependentPriceSpecification()
+    
+    c1 = Condition()
+    c1.addGreater(0)
+    c1.addAction(10)
+    priceSpec.addCondition(c1)
+    
+    c2 = Condition()
+    c2.addGreater(10)
+    c2.addAction(20)
+    priceSpec.addCondition(c2)
+    
+    c3 = Condition()
+    c3.addGreater(30)
+    c3.addAction(40)
+    priceSpec.addCondition(c3)
+    
+    c4 = Condition()
+    c4.addGreater(40)
+    c4.addAction(55)
+    priceSpec.addCondition(c4)
+    
+    offering.addPriceSpecification(priceSpec)
+    
+    stringData = Tools().toString(offering, SERIALIZATION.TURTLE)
+    
+    # print serialized data
+    print "Serialized data:"
+    print stringData
+
+    print "Parsing back the serialized data..."
+    parsed = Tools().fromStringAsObj(stringData, SERIALIZATION.TURTLE)
+    print Tools().toString(offering, SERIALIZATION.TURTLE)
+    
+    
 def main():
-    objectCopyTest()
+    #objectCopyTest()
     #serializeRequestTest()
     #longSerializeParseTest()
     #propertySerializeParseTest()
@@ -2124,7 +2164,6 @@ def main():
     #registrationTest()
     #registrySearchTest()
     #capacityTest()
-    #unitPriceSpecificationTest()
     #offeringTest()
     #TransactionSerialzeTest()
     #requestResponseTest3()
@@ -2144,6 +2183,8 @@ def main():
     #smallTests()
     #conceptValidationTest()
     #velocityTest()
+    #unitPriceSpecificationTest()
+    conditionalPriceSpecificationTest()
     
 if __name__=='__main__':
     main()
index 9ad9cb5b99db2f57b564deace4f58c895836ef75..54493772ac7a7d97f0bbd584705a0354e4c28a33 100755 (executable)
@@ -14,9 +14,12 @@ from SmartAPI.factory.ResponseFactory import ResponseFactory
 
 from SmartAPI.model.Activity import Activity
 from SmartAPI.model.Authorization import Authorization
+from SmartAPI.model.Condition import Condition
 from SmartAPI.model.Entity import Entity
 from SmartAPI.model.InterfaceAddress import InterfaceAddress
+from SmartAPI.model.Offering import Offering
 from SmartAPI.model.Organization import Organization
+from SmartAPI.model.PropertyDependentPriceSpecification import PropertyDependentPriceSpecification
 from SmartAPI.model.Service import Service
 from SmartAPI.model.TimeSeries import TimeSeries
 from SmartAPI.model.ValueObject import ValueObject
@@ -85,8 +88,32 @@ class SampleRegistration(object):
                        power.setMinimum(0.0)
                        power.setName("Power reading")
                        power.setDescription("This is the power reading of the unit.");
-                               
-
+                       
+                       offering = Offering()
+                       priceSpec = PropertyDependentPriceSpecification()
+                       
+                       c1 = Condition()
+                       c1.addGreater(0)
+                       c1.addAction(10)
+                       priceSpec.addCondition(c1)
+                       
+                       c2 = Condition()
+                       c2.addGreater(10)
+                       c2.addAction(20)
+                       priceSpec.addCondition(c2)
+                       
+                       c3 = Condition()
+                       c3.addGreater(30)
+                       c3.addAction(40)
+                       priceSpec.addCondition(c3)
+                       
+                       c4 = Condition()
+                       c4.addGreater(40)
+                       c4.addAction(55)
+                       priceSpec.addCondition(c4)
+                       
+                       offering.addPriceSpecification(priceSpec)
+                       dataSource.addOffering(offering)
                        dataSource.addValueObject(power)
 
                        agent.addEntity(sampleService)