Java: add servedby to Entity
authorjani <jani@asema.com>
Wed, 10 Jul 2019 22:09:13 +0000 (01:09 +0300)
committerjani <jani@asema.com>
Wed, 10 Jul 2019 22:09:13 +0000 (01:09 +0300)
Common/Java/SmartAPI/src/smartapi/model/Entity.java

index e047ac7334229aabe4e585d82ae805f9e640d9d5..e102be68c3b089d33a33bf226e05e6e6c94b632f 100644 (file)
@@ -41,17 +41,25 @@ public class Entity extends Obj
                int propertyIndex = PROPERTY.add(stmt.getPredicate().toString());
 
                switch (propertyIndex) {
-               case PROPERTY.ISMANAGEDBY:
-                       if ( hasProperties(stmt) ) {
-                               this.setManagedBy(parseObjectProperty(stmt)); return;
-                       } else {
-                               this.setManagedBy(parseObjectPropertyAsURL(stmt)); return;
-                       }
-               case PROPERTY.MANAGES:
-                       this.addManagedEntity(parseObjectPropertyAsURL(stmt)); return;
-               default:
-                       // pass on to Obj
-                       super.parse(stmt);
+                       case PROPERTY.ISMANAGEDBY:
+                               if ( hasProperties(stmt) ) {
+                                       this.setManagedBy(parseObjectProperty(stmt)); return;
+                               } else {
+                                       this.setManagedBy(parseObjectPropertyAsURL(stmt)); return;
+                               }
+                       
+                       case PROPERTY.MANAGES:
+                               this.addManagedEntity(parseObjectPropertyAsURL(stmt)); return;
+                       
+                       case PROPERTY.ISSERVEDBY:
+                               if ( hasProperties(stmt) ) {
+                                       this.setServedBy(parseObjectProperty(stmt)); return;
+                               } else {
+                                       this.setServedBy(parseObjectPropertyAsURL(stmt)); return;
+                               }
+                       default:
+                               // pass on to Obj
+                               super.parse(stmt);
                }
        }
 
@@ -209,6 +217,12 @@ public class Entity extends Obj
                return this.getManagedBy();
        }
 
+       public boolean hasServedBy() { return has(PROPERTY.ISSERVEDBY); }
+       public String getServedBy() { return getFirstAsIdentifier(PROPERTY.ISSERVEDBY); }
+       public void setServedBy(URL url) { set(PROPERTY.ISSERVEDBY, url); }
+       public void setServedBy(Obj obj) { set(PROPERTY.ISSERVEDBY, obj); }
+       public void setServedBy(String uri) { setAsUrl(PROPERTY.ISSERVEDBY, uri); }
+       
        public boolean hasInterface() { return has(PROPERTY.INTERFACE); }
        public List<InterfaceAddress> getInterfaces() { return getAs(InterfaceAddress.class, PROPERTY.INTERFACE); }
        public void addInterface(InterfaceAddress interfaceAddress) { add(PROPERTY.INTERFACE, interfaceAddress); }