Java: clean up the test sequences
authorjani <jani@asema.com>
Tue, 9 Jul 2019 21:46:10 +0000 (00:46 +0300)
committerjani <jani@asema.com>
Tue, 9 Jul 2019 21:46:10 +0000 (00:46 +0300)
12 files changed:
Common/C#/SmartAPI/model/GrObj.cs
Common/Java/SmartAPI/src/smartapi/common/DATATYPE.java
Common/Java/SmartAPI/src/smartapi/common/PROPERTY.java
Common/Java/SmartAPI/src/smartapi/common/RESOURCE.java
Common/Java/SmartAPI/src/smartapi/model/GrObj.java
Common/Java/SmartAPI/src/smartapi/tests/TestConverter.java
Common/Java/SmartAPI/src/smartapi/tests/TestSequence.java
Common/Java/SmartAPI/src/smartapi/tests/TestSomeItems.java
Common/Python/SmartAPI/model/GrObj.py
Ontology/src/1.0/DataOntology-1.0.ttl
Ontology/src/1.0/NetworkingOntology-1.0.ttl
Ontology/src/1.0/TradingOntology-1.0.ttl

index 9b4ee0ff6848005f5614c37c529f3afea249f35d..cf542a4c6fcfea295cfca28578a10bb63391bb1f 100644 (file)
@@ -12,7 +12,7 @@ namespace SmartAPI.Model
 
         private void init()
         {
-            this.initProperty<Variant>(PROPERTY.NAME, this.hasGrName, this.getGrNameVar);
+            this.initProperty<Variant>(PROPERTY.GR_NAME, this.hasGrName, this.getGrNameVar);
             this.initProperty<Variant>(PROPERTY.GR_DESCRIPTION, this.hasGrDescription, this.getGrDescriptionVar);
         }
 
@@ -34,7 +34,7 @@ namespace SmartAPI.Model
 
         public override void parse(Statement statement)
         {
-            if (this.parseProperty<Variant>(statement, PROPERTY.NAME, this.setGrName)) return;
+            if (this.parseProperty<Variant>(statement, PROPERTY.GR_NAME, this.setGrName)) return;
             if (this.parseProperty<Variant>(statement, PROPERTY.GR_DESCRIPTION, this.setGrDescription)) return;
 
             base.parse(statement);
index cbf7df6c0bb42741e5cb199a80d27a77025c409f..f4463ca8d459dcbe42331dc714586f457ef09d91 100644 (file)
@@ -1,6 +1,6 @@
 // This file is automatically created by HeaderFileGenerator.
 // Do not edit manually.
-// Generation time 2019/07/10 00:12:47
+// Generation time 2019/07/10 00:45:04
 
 package smartapi.common;
 
index 24f84316a337743456c597bb58d9edd15c4c077e..2d2bd8932e6b0603c0a126b450d116eaa2027657 100644 (file)
@@ -1,6 +1,6 @@
 // This file is automatically created by HeaderFileGenerator.
 // Do not edit manually.
-// Generation time Wed Jul 10 00:12:48 EEST 2019
+// Generation time Wed Jul 10 00:45:05 EEST 2019
 
 package smartapi.common;
 
index 958ca66b7b1bcc7c76204a2a0703feb6354dd480..db2f81048e3df1a6a78c84a966eeae8704fb2ef8 100644 (file)
@@ -1,6 +1,6 @@
 // This file is automatically created by HeaderFileGenerator.
 // Do not edit manually.
-// Generation time 2019/07/10 00:12:47
+// Generation time 2019/07/10 00:45:04
 
 package smartapi.common;
 
@@ -1280,6 +1280,7 @@ public final class RESOURCE {
        public static final String POWER = "http://data.nasa.gov/qudt/owl/quantity#Power";
        public static final String POWERAREA = "http://data.nasa.gov/qudt/owl/quantity#PowerArea";
        public static final String POWERAREAPERSOLIDANGLE = "http://data.nasa.gov/qudt/owl/quantity#PowerAreaPerSolidAngle";
+       public static final String POWERED = "http://smart-api.io/ontology/1.0/smartapi#Powered";
        public static final String POWERPERAREA = "http://data.nasa.gov/qudt/owl/quantity#PowerPerArea";
        public static final String POWERPERAREAANGLE = "http://data.nasa.gov/qudt/owl/quantity#PowerPerAreaAngle";
        public static final String POWERPERAREAQUARTICTEMPERATURE = "http://data.nasa.gov/qudt/owl/quantity#PowerPerAreaQuarticTemperature";
@@ -1333,6 +1334,7 @@ public final class RESOURCE {
        public static final String QUANTITY_CAPACITY = "http://data.nasa.gov/qudt/owl/quantity#Capacity";
        public static final String QUANTITY_ENERGYANDWORKPERMASSAMOUNTOFSUBSTANCE = "http://data.nasa.gov/qudt/owl/quantity#EnergyAndWorkPerMassAmountOfSubstance";
        public static final String QUANTITY_FREQUENCY = "http://data.nasa.gov/qudt/owl/quantity#Frequency";
+       public static final String QUANTITY_SIGNALSTRENGTH = "http://data.nasa.gov/qudt/owl/quantity#SignalStrength";
        public static final String QUANTITY_VELOCITY = "http://data.nasa.gov/qudt/owl/quantity#Velocity";
        public static final String QUANTUMMECHANICSQUANTITYKIND = "http://data.nasa.gov/qudt/owl/qudt#QuantumMechanicsQuantityKind";
        public static final String QUARTICCOULOMBMETERPERCUBICENERGY = "http://data.nasa.gov/qudt/owl/unit#QuarticCoulombMeterPerCubicEnergy";
@@ -1460,7 +1462,7 @@ public final class RESOURCE {
        public static final String SIEVERT = "http://data.nasa.gov/qudt/owl/unit#Sievert";
        public static final String SIGNALDETECTIONTHRESHOLD = "http://data.nasa.gov/qudt/owl/quantity#SignalDetectionThreshold";
        public static final String SIGNALDETECTIONTHRESHOLDUNIT = "http://data.nasa.gov/qudt/owl/qudt#SignalDetectionThresholdUnit";
-       public static final String SIGNALSTRENGTH = "http://data.nasa.gov/qudt/owl/quantity#SignalStrength";
+       public static final String SIGNALSTRENGTH = "http://smart-api.io/ontology/1.0/smartapi#SignalStrength";
        public static final String SILVER_OUNCETROY = "http://data.nasa.gov/qudt/owl/unit#Silver-OunceTroy";
        public static final String SINGAPOREDOLLAR = "http://data.nasa.gov/qudt/owl/unit#SingaporeDollar";
        public static final String SIUNIT = "http://data.nasa.gov/qudt/owl/qudt#SIUnit";
index 7a5dfc05b4e1044a4d588bc888041067085acae1..f69d53990614b303c4dfdf1c2f3a0d39a65771d1 100644 (file)
@@ -24,9 +24,9 @@ public abstract class GrObj extends Obj {
        }
 
        // grName accessors
-       public boolean hasGrName() { return has(PROPERTY.NAME); }       
-       public String getGrName() { return getFirstAsVariant(PROPERTY.NAME).asString(); }
-       public void setGrName(String grName) { set(PROPERTY.NAME, grName); }
+       public boolean hasGrName() { return has(PROPERTY.GR_NAME); }    
+       public String getGrName() { return getFirstAsVariant(PROPERTY.GR_NAME).asString(); }
+       public void setGrName(String grName) { set(PROPERTY.GR_NAME, grName); }
 
        // grDescription accessors
        public boolean hasGrDescription() { return has(PROPERTY.GR_DESCRIPTION); }      
index 0e874279566a7c01c413d99eaa777bcca3470ac2..75bf06539736e225ed0b91742864bf5f60010f3e 100644 (file)
@@ -30,12 +30,10 @@ public class TestConverter {
                System.out.println(Tools.currencyFromUnitToCode(RESOURCE.JAPANESEYEN));
                
                
-               runConversion(RESOURCE.POWER, RESOURCE.MEGAWATT, RESOURCE.KILOWATT, 2.2);
-               runConversion(RESOURCE.POWER,RESOURCE.KILOWATTHOUR, RESOURCE.MEGAWATTHOUR, 300);
-               runConversion(RESOURCE.POWER,RESOURCE.KILOWATT, RESOURCE.MEGAWATTHOUR, 4000.2);
+               runConversion(RESOURCE.POWER, RESOURCE.WATT, RESOURCE.KILOWATT, 2.2);
+               runConversion(RESOURCE.POWER, RESOURCE.KILOWATTHOUR, RESOURCE.WATTHOUR, 300);
+               runConversion(RESOURCE.POWER, RESOURCE.KILOWATT, RESOURCE.WATTHOUR, 4000.2);
                
-               runConversion(RESOURCE.POWER,RESOURCE.POWEROUTAGECOUNT, RESOURCE.PULSEINPUTCOUNT, 4000.2);
-
                //TODO
                // 1) units used below should be updated
                // 2) this test should automatically detect success or failure
index 3ad217d9a1b57f859b0af0f327b0014f98182877..722422e7b411547214b9e3836ceb0ff770ffa612 100644 (file)
@@ -2218,7 +2218,7 @@ public class TestSequence {
                        ValueObject vo = new ValueObject(NS.SMARTAPI + "Brightness", RESOURCE.PERCENT, null, null, "smartapi:Actuator", "smartapi:Dimmer");
                        d.addValueObject(vo);
 
-                       ValueObject vo2 = new ValueObject(NS.SMARTAPI + "PowerOnState", RESOURCE.BOOLEANUNIT, null, null, "smartapi:Actuator", "smartapi:PowerSwitch");
+                       ValueObject vo2 = new ValueObject(NS.SMARTAPI + "Powered", DATATYPE.BOOLEAN, null, null, "smartapi:Actuator", "smartapi:PowerSwitch");
                        d.addValueObject(vo2);
 
                        ValueObject vo3 = new ValueObject(null, null, DATATYPE.STRING, "String message shown on lamp screen, use the lamp keyboard to change the message", "smartapi:Sensor");
@@ -2275,7 +2275,7 @@ public class TestSequence {
                        e.turtlePrint();
                        
                        ValueObject brightness = e.getFirstValueObjectByQuantity(NS.SMARTAPI + "Brightness");
-                       ValueObject powerOnState = e.getFirstValueObjectByQuantity(NS.SMARTAPI + "PowerOnState");
+                       ValueObject powerOnState = e.getFirstValueObjectByQuantity(NS.SMARTAPI + "Powered");
                        HttpClient client = new HttpClient();
                        // enable debug mode to see printout of uri and request body
                        //client.debugMode(true);
@@ -2309,18 +2309,18 @@ public class TestSequence {
 
                        // fetch power on state value
                        updated = client.getValueObject(e, powerOnState).getEntities().get(0);
-                       powerValue = updated.getFirstValueObjectByQuantity(RESOURCE.POWERONSTATE).getValueAsBoolean();
+                       powerValue = updated.getFirstValueObjectByQuantity(RESOURCE.POWERED).getValueAsBoolean();
 
                        // set new power on value
                        powerValue = !powerValue;
                        
                        // send new power on state value
-                       updated.getFirstValueObjectByQuantity(RESOURCE.POWERONSTATE).setValue(powerValue);
-                       updated = client.setValueObject(e, updated.getFirstValueObjectByQuantity(RESOURCE.POWERONSTATE)).getEntities().get(0);
+                       updated.getFirstValueObjectByQuantity(RESOURCE.POWERED).setValue(powerValue);
+                       updated = client.setValueObject(e, updated.getFirstValueObjectByQuantity(RESOURCE.POWERED)).getEntities().get(0);
 
                        // fetch power on state value
                        updated = client.getValueObject(e, powerOnState).getEntities().get(0);
-                       boolean newPowerValue = updated.getFirstValueObjectByQuantity(RESOURCE.POWERONSTATE).getValueAsBoolean();
+                       boolean newPowerValue = updated.getFirstValueObjectByQuantity(RESOURCE.POWERED).getValueAsBoolean();
 
                        if ( powerValue != newPowerValue ) {
                                System.err.println("Standard RW test failed. Value (power on state) was not set correctly!");
@@ -2426,9 +2426,9 @@ public class TestSequence {
                System.out.println("ENERGYPRICE from e/kWh to pound/MWh");
                ValueObject vo = new ValueObject(RESOURCE.CURRENCY, RESOURCE.EURO, RESOURCE.ENERGYANDWORK, RESOURCE.KILOWATTHOUR, 0.02);
                vo.turtlePrint();
-               ValueObject vo2 = UnitConverter.convert(vo, RESOURCE.POUNDSTERLING, RESOURCE.MEGAWATTHOUR);
+               ValueObject vo2 = UnitConverter.convert(vo, RESOURCE.POUNDSTERLING, RESOURCE.WATTHOUR);
                vo2.turtlePrint();
-               if ( !vo2.getUnit().equals(RESOURCE.POUNDSTERLING) || !vo2.getSecondaryUnit().equals(RESOURCE.MEGAWATTHOUR) ||
+               if ( !vo2.getUnit().equals(RESOURCE.POUNDSTERLING) || !vo2.getSecondaryUnit().equals(RESOURCE.WATTHOUR) ||
                                vo2.getValue().equals(new Variant(0.02)) ) {
                        System.err.println("EnergyPrice conversion from e/kWh to pound/MWh failed!");
                        return false;
index 497ed42cb092d99f9381953cffcb822a27977eff..cd34ee74be9e4d79995344b5fec7ae3520c81489 100644 (file)
@@ -9,7 +9,7 @@ import smartapi.model.SomeItems;
 public class TestSomeItems {
 
        public static void main(String[] args) {
-               SomeItems items = new SomeItems(RESOURCE.PRICE, "Northern Sea wind farm", "winder energy is unstable as well", "http://my.demo2.com");
+               SomeItems items = new SomeItems(RESOURCE.PRICEUNIT, "Northern Sea wind farm", "winder energy is unstable as well", "http://my.demo2.com");
                //items.setDuration(1, 2, 3, 10, 10, 1);
                items.setDuration("P5Y2M3DT10H10M1S");
                
@@ -17,7 +17,7 @@ public class TestSomeItems {
                System.out.println("----Serialize----");
                System.out.println(serialized);
                
-               Obj parsedBack = Tools.fromStringAsObj(serialized, SERIALIZATION.TURTLE);               
+               Obj parsedBack = Tools.fromStringAsObj(serialized, SERIALIZATION.TURTLE);
                System.out.println("\n After parsing, reSerialize -----");
                String reserialized = Tools.toString(parsedBack, SERIALIZATION.TURTLE);
                System.out.println(reserialized);
index 451ca58576372b01bd0bc27a83b0538f439d9a70..c4af66047ce21231bef74abfc7cb594ebe78d8dc 100644 (file)
@@ -12,7 +12,7 @@ class GrObj(Obj):
 
     def __init__(self, uri = None):
         super(GrObj, self).__init__(uri)
-        self.init_property(PROPERTY.NAME, 'grName', self.hasGrName, self.getGrName)
+        self.init_property(PROPERTY.GR_NAME, 'grName', self.hasGrName, self.getGrName)
         self.init_property(PROPERTY.GR_DESCRIPTION, 'grDescription', self.hasGrDescription, self.getGrDescription)
     
     def hasGrName(self):
@@ -38,7 +38,7 @@ class GrObj(Obj):
         self.grDescription = gdescription
     
     def _parseStatement(self, statement, custom_classes = None):
-        self.parse_property(statement, PROPERTY.NAME, self.setGrName, Variant, custom_classes = custom_classes)
+        self.parse_property(statement, PROPERTY.GR_NAME, self.setGrName, Variant, custom_classes = custom_classes)
         self.parse_property(statement, PROPERTY.GR_DESCRIPTION, self.setGrDescription, Variant, custom_classes = custom_classes)
         super(GrObj, self)._parseStatement(statement, custom_classes = custom_classes)
     
\ No newline at end of file
index 0c610b9581b15381b6b63a8eccf033786d08aba2..37678c39b58c7acd54e4cae7e27ee3e7aa46b778 100644 (file)
@@ -66,7 +66,8 @@ smartapi:valueObject a owl:ObjectProperty ;
   rdfs:range smartapi:ValueObject;
   vs:term_status "testing".
 
-# readable, writable
+
+# basic boolean, readable, writable
 
 smartapi:Readable a owl:Class ;
   rdfs:label "Readable"@en ;
index 909b06870639f1d5385cd5798d5138e423a651a9..b694e46fb03b51a808f1e0cfb6e2082de4efc8b6 100644 (file)
@@ -393,11 +393,25 @@ smartapi:Busy a owl:Class ;
 
 smartapi:Online a owl:Class ;
   rdfs:label "Online"@en ;
-  rdfs:comment "A online status to indicate that service is online."@en ;
+  rdfs:comment "A online status to indicate that a service or device is online."@en ;
   rdfs:isDefinedBy smartapi:NetworkingOntology ;
   rdfs:subClassOf smartapi:Status;
   vs:term_status "testing" .
 
+smartapi:Powered a owl:Class ;
+  rdfs:label "Powered"@en ;
+  rdfs:comment "A powered status to indicate that a physical device has power supply."@en ;
+  rdfs:isDefinedBy smartapi:NetworkingOntology ;
+  rdfs:subClassOf smartapi:Status;
+  vs:term_status "testing" .
+
+smartapi:SignalStrength a owl:Class ;
+  rdfs:label "Powered"@en ;
+  rdfs:comment "A signal strength status to indicate how well a device (typically wireless) is sending or receiving data."@en ;
+  rdfs:isDefinedBy smartapi:NetworkingOntology ;
+  rdfs:subClassOf smartapi:Status;
+  vs:term_status "testing" .
+  
 smartapi:Pending a owl:Class ;
   rdfs:label "Pending"@en ;
   rdfs:comment "A pending status for an operation to indicate that is has been taken into queue and is waiting to get processed."@en ;
index 6ca886f298260238d65b66a307d023a6c83efd47..4ef88b0e6f756e65786789ce9118266d2440aeea 100644 (file)
@@ -42,6 +42,7 @@ smartapi:TrandingOntology a owl:Ontology , voaf:Ontology ;
   owl:versionIRI <http://smart-api.io/ontology/1.0/TradingOntology> ;
   owl:versionInfo "v1.0" .
 
+
 # boolean flags
 
 smartapi:isCurrentlyFrozen a owl:ObjectProperty ;
@@ -174,6 +175,7 @@ smartapi:percentageMarkup a owl:DatatypeProperty ;
   rdfs:isDefinedBy smartapi:TradingOntology ;
   vs:term_status "testing" .
 
+
 # vat
 
 smartapi:vatPercentage a owl:DatatypeProperty ;
@@ -321,6 +323,7 @@ smartapi:account a owl:ObjectProperty;
   rdfs:isDefinedBy smartapi:TradingOntology ;
   vs:term_status "testing" .
 
+
 # license
 
 smartapi:License a owl:Class ;
@@ -343,6 +346,7 @@ smartapi:licenseKey a owl:DatatypeProperty ;
   rdfs:isDefinedBy smartapi:TradingOntology ;
   vs:term_status "testing" .
 
+
 # offering and subscription price specification
 
 smartapi:offers a owl:ObjectProperty;