Docs for the distributed datastructures in cps and ncmp
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / inventory / CompositeStateBuilder.java
index 91e92ea..d6a3330 100644 (file)
@@ -32,6 +32,7 @@ public class CompositeStateBuilder {
     private LockReason lockReason;
     private DataStores datastores;
     private String lastUpdatedTime;
+    private Boolean dataSyncEnabled;
 
     /**
      * To create the {@link CompositeState}.
@@ -44,6 +45,7 @@ public class CompositeStateBuilder {
         compositeState.setLockReason(lockReason);
         compositeState.setDataStores(datastores);
         compositeState.setLastUpdateTime(lastUpdatedTime);
+        compositeState.setDataSyncEnabled(dataSyncEnabled);
         return compositeState;
     }
 
@@ -94,13 +96,14 @@ public class CompositeStateBuilder {
     /**
      * To use attributes for creating {@link CompositeState}.
      *
-     * @param syncState for the locked state
+     * @param dataStoreSyncState for the locked state
      * @param lastSyncTime for the locked state
      * @return CompositeStateBuilder
      */
-    public CompositeStateBuilder withOperationalDataStores(final SyncState syncState, final String lastSyncTime) {
+    public CompositeStateBuilder withOperationalDataStores(final DataStoreSyncState dataStoreSyncState,
+                                                           final String lastSyncTime) {
         this.datastores = DataStores.builder().operationalDataStore(
-            Operational.builder().syncState(syncState).lastSyncTime(lastSyncTime).build()).build();
+            Operational.builder().dataStoreSyncState(dataStoreSyncState).lastSyncTime(lastSyncTime).build()).build();
         return this;
     }
 
@@ -114,6 +117,9 @@ public class CompositeStateBuilder {
         this.cmHandleState = CmHandleState.valueOf((String) dataNode.getLeaves()
             .get("cm-handle-state"));
         this.lastUpdatedTime = (String) dataNode.getLeaves().get("last-update-time");
+        if (this.cmHandleState == CmHandleState.READY) {
+            this.dataSyncEnabled = (Boolean) dataNode.getLeaves().get("data-sync-enabled");
+        }
         for (final DataNode stateChildNode : dataNode.getChildDataNodes()) {
             if (stateChildNode.getXpath().endsWith("/lock-reason")) {
                 this.lockReason = getLockReason(stateChildNode);
@@ -133,7 +139,7 @@ public class CompositeStateBuilder {
 
     private Operational getOperationalDataStore(final DataNode dataStoreNodes) {
         return Operational.builder()
-                .syncState(SyncState.valueOf((String) dataStoreNodes.getLeaves().get("sync-state")))
+                .dataStoreSyncState(DataStoreSyncState.valueOf((String) dataStoreNodes.getLeaves().get("sync-state")))
                 .lastSyncTime((String) dataStoreNodes.getLeaves().get("last-sync-time"))
                 .build();
     }