2828import de .fraunhofer .iosb .ilt .frostclient .model .Entity ;
2929import de .fraunhofer .iosb .ilt .frostclient .model .EntityType ;
3030import de .fraunhofer .iosb .ilt .frostclient .model .ModelRegistry ;
31+ import de .fraunhofer .iosb .ilt .frostclient .model .property .EntityProperty ;
3132import de .fraunhofer .iosb .ilt .frostclient .model .property .EntityPropertyMain ;
3233import de .fraunhofer .iosb .ilt .frostclient .model .property .NavigationPropertyEntity ;
3334import de .fraunhofer .iosb .ilt .frostclient .model .property .NavigationPropertyEntitySet ;
34- import de .fraunhofer .iosb .ilt .frostclient .models .SensorThingsSensingV11 ;
35+ import de .fraunhofer .iosb .ilt .frostclient .models .DataModel ;
3536import de .fraunhofer .iosb .ilt .frostclient .models .ext .MapValue ;
3637import java .util .Map ;
3738
3839/**
3940 *
4041 */
41- public class SensorThingsUserModel {
42+ public class SensorThingsUserModel implements DataModel {
4243
4344 private static final String NAME_USER = "User" ;
4445 private static final String NAME_USERS = "Users" ;
@@ -53,9 +54,9 @@ public class SensorThingsUserModel {
5354 private static final String NAME_EP_USERPASS = "userpass" ;
5455 private static final String NAME_EP_ROLENAME = "rolename" ;
5556
56- public static final EntityPropertyMain <String > EP_USERNAME = new EntityPropertyMain <>(NAME_EP_USERNAME , EDM_STRING );
57- public static final EntityPropertyMain <String > EP_USERPASS = new EntityPropertyMain <>(NAME_EP_USERPASS , EDM_STRING );
58- public static final EntityPropertyMain <String > EP_ROLENAME = new EntityPropertyMain <>(NAME_EP_ROLENAME , EDM_STRING );
57+ public static final EntityProperty <String > EP_USERNAME = new EntityPropertyMain <>(NAME_EP_USERNAME , EDM_STRING );
58+ public static final EntityProperty <String > EP_USERPASS = new EntityPropertyMain <>(NAME_EP_USERPASS , EDM_STRING );
59+ public static final EntityProperty <String > EP_ROLENAME = new EntityPropertyMain <>(NAME_EP_ROLENAME , EDM_STRING );
5960
6061 public final NavigationPropertyEntitySet npUserRoles = new NavigationPropertyEntitySet (NAME_ROLES );
6162 public final NavigationPropertyEntitySet npUserUserprojectroles = new NavigationPropertyEntitySet (NAME_USERPROJECTROLES );
@@ -77,14 +78,19 @@ public class SensorThingsUserModel {
7778 public final EntityType etProject = new EntityType (NAME_PROJECT , NAME_PROJECTS );
7879 public final EntityType etUserProjectRole = new EntityType (NAME_USERPROJECTROLE , NAME_USERPROJECTROLES );
7980
80- public final ModelRegistry mr ;
81+ public ModelRegistry mr ;
8182
82- public SensorThingsUserModel (SensorThingsSensingV11 modelSensing ) {
83- this (modelSensing .getModelRegistry ());
83+ public SensorThingsUserModel () {
8484 }
8585
86- public SensorThingsUserModel (ModelRegistry mrSensing ) {
87- this .mr = mrSensing ;
86+ @ Override
87+ public final void init (ModelRegistry modelRegistry ) {
88+ if (this .mr != null ) {
89+ throw new IllegalArgumentException ("Already initialised." );
90+ }
91+ this .mr = modelRegistry ;
92+ mr .addDataModel (this );
93+
8894 mr .registerEntityType (etUser );
8995 mr .registerEntityType (etRole );
9096 mr .registerEntityType (etProject );
@@ -120,6 +126,11 @@ public SensorThingsUserModel(ModelRegistry mrSensing) {
120126 mr .getEntityTypeForName (NAME_THING ).registerProperty (npThingProjects );
121127 }
122128
129+ @ Override
130+ public boolean isInitialised () {
131+ return mr != null ;
132+ }
133+
123134 public ModelRegistry getModelRegistry () {
124135 return mr ;
125136 }
0 commit comments