1 package org.openecomp.core.migration.convertors;
3 import com.amdocs.zusammen.datatypes.item.ElementContext;
4 import com.amdocs.zusammen.datatypes.item.Info;
5 import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
6 import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
7 import org.openecomp.core.migration.store.ElementHandler;
8 import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
9 import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement;
10 import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil;
11 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
13 import java.util.HashSet;
14 import java.util.List;
16 import java.util.stream.Collectors;
19 * Created by ayalaben on 4/24/2017
21 public class EntitlementPoolConvertor {
23 private static Set<String> EntitlementPoolsLoaded = new HashSet<>();
25 public static ElementEntityContext convertEntitlementPoolToElementContext(
26 EntitlementPoolEntity entitlementPoolEntity) {
28 return new ElementEntityContext("GLOBAL_USER", new
29 ElementContext(entitlementPoolEntity.getVendorLicenseModelId(),
30 entitlementPoolEntity.getVersion().toString()));
33 public static CollaborationElement[] convertEntitlementPoolToElement(
34 EntitlementPoolEntity entitlementPoolEntity) {
35 // printMessage(logger, "source EntitlementPoolEntity -> " + entitlementPoolEntity.toString());
36 CollaborationElement[] elements;
37 List<String> entitlementPoolNamespace = getEntitlementPoolNamespace(entitlementPoolEntity);
40 String entitlememtPoolsEntityId = StructureElement.EntitlementPools.name();
41 String uniqueId = entitlementPoolEntity.getVendorLicenseModelId() + "_" +
42 entitlementPoolEntity.getVersion().toString();
44 if (EntitlementPoolsLoaded.contains(uniqueId)) {
45 elements = new CollaborationElement[1];
47 EntitlementPoolsLoaded.add(uniqueId);
48 elements = new CollaborationElement[2];
49 elements[index] = ElementHandler.getElementEntity(
50 entitlementPoolEntity.getVendorLicenseModelId(),
51 entitlementPoolEntity.getVersion().toString(),
52 entitlememtPoolsEntityId, entitlementPoolNamespace,
53 ElementHandler.getStructuralElementInfo(StructureElement.EntitlementPools.name()),
58 entitlementPoolNamespace.add(entitlememtPoolsEntityId);
60 elements[index] = ElementHandler.getElementEntity(
61 entitlementPoolEntity.getVendorLicenseModelId(),
62 entitlementPoolEntity.getVersion().toString(),
63 entitlementPoolEntity.getId(), entitlementPoolNamespace,
64 getEntitelementPoolInfo(entitlementPoolEntity),
65 entitlementPoolEntity.getReferencingFeatureGroups().stream().map(rel ->
67 .createRelation( RelationType.EntitlmentPoolToReferencingFeatureGroup, rel))
68 .collect(Collectors.toList()), null, null);
73 private static Info getEntitelementPoolInfo(EntitlementPoolEntity entitlementPool) {
75 Info info = new Info();
76 info.setName(entitlementPool.getName());
77 info.setDescription(entitlementPool.getDescription());
78 info.addProperty("thresholdValue", entitlementPool.getThresholdValue());
79 info.addProperty("threshold_unit", entitlementPool.getThresholdUnit());
80 //info.addProperty("entitlement_metric", entitlementPool.getEntitlementMetric());
81 info.addProperty("increments", entitlementPool.getIncrements());
82 info.addProperty("operational_scope", entitlementPool.getOperationalScope());
87 private static List<String> getEntitlementPoolNamespace(
88 EntitlementPoolEntity entitlementPoolEntity) {
89 return ElementHandler.getElementPath("");