summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java57
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java62
2 files changed, 117 insertions, 2 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
new file mode 100644
index 00000000..b383c18b
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.model.dcae;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * This class stores the multiple DcaeInventoryResponse coming back from DCAE.
+ * The structure is a map of list indexed by asdcServiceId. The list is sorted
+ * by asdcResourceId. Therefore it's possible to retrieve all the loops defined
+ * in the DCAE inventory and created by DCAE Mod.
+ */
+public class DcaeInventoryCache {
+
+ private Map<String, Set<DcaeInventoryResponse>> blueprintsMap = new ConcurrentHashMap<>();
+
+ public void addDcaeInventoryResponse(DcaeInventoryResponse inventoryResponse) {
+ Set<DcaeInventoryResponse> responsesSet = blueprintsMap.get(inventoryResponse.getAsdcServiceId());
+ if (responsesSet == null) {
+ responsesSet = new TreeSet<DcaeInventoryResponse>();
+ blueprintsMap.put(inventoryResponse.getAsdcServiceId(), responsesSet);
+ }
+ responsesSet.add(inventoryResponse);
+ }
+
+ public Set<String> getAllLoopIds() {
+ return this.blueprintsMap.keySet();
+ }
+
+ public Set<DcaeInventoryResponse> getAllBlueprintsPerLoopId(String loopId) {
+ return blueprintsMap.getOrDefault(loopId, new TreeSet<>());
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
index 97245066..bdf6e70f 100644
--- a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
@@ -3,7 +3,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,7 +29,7 @@ import com.google.gson.annotations.Expose;
/**
* This class maps the DCAE inventory answer to a nice pojo.
*/
-public class DcaeInventoryResponse {
+public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse> {
@Expose
private String typeName;
@@ -37,6 +37,25 @@ public class DcaeInventoryResponse {
@Expose
private String typeId;
+ @Expose
+ private String blueprintTemplate;
+
+ /**
+ * This field will be used to know all blueprints associated a loop.
+ */
+ @Expose
+ private String asdcServiceId;
+
+ /**
+ * This field will be used to know to order of each blueprint microservice in a
+ * loop.
+ */
+ @Expose
+ private String asdcResourceId;
+
+ @Expose
+ private String selfLink;
+
public String getTypeName() {
return typeName;
}
@@ -52,4 +71,43 @@ public class DcaeInventoryResponse {
public void setTypeId(String typeId) {
this.typeId = typeId;
}
+
+ public String getBlueprintTemplate() {
+ return blueprintTemplate;
+ }
+
+ public void setBlueprintTemplate(String blueprintTemplate) {
+ this.blueprintTemplate = blueprintTemplate;
+ }
+
+ public String getAsdcServiceId() {
+ return asdcServiceId;
+ }
+
+ public void setAsdcServiceId(String asdcServiceId) {
+ this.asdcServiceId = asdcServiceId;
+ }
+
+ public String getAsdcResourceId() {
+ return asdcResourceId;
+ }
+
+ public void setAsdcResourceId(String asdcResourceId) {
+ this.asdcResourceId = asdcResourceId;
+ }
+
+ public String getSelfLink() {
+ return selfLink;
+ }
+
+ public void setSelfLink(String selfLink) {
+ this.selfLink = selfLink;
+ }
+
+ @Override
+ public int compareTo(DcaeInventoryResponse otherResponse) {
+ int thisResourceId = Integer.parseInt(this.asdcResourceId);
+ int otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
+ return (thisResourceId < otherResourceId ? -1 : (thisResourceId > otherResourceId ? 1 : 0));
+ }
}