fix incorrect dependency
[sdc.git] / openecomp-be / tools / migration / 1702_to_1707_zusammen / src / main / java / org / openecomp / core / migration / convertors / VlmConvertor.java
1 package org.openecomp.core.migration.convertors;
2
3 import com.amdocs.zusammen.datatypes.item.ElementContext;
4 import com.amdocs.zusammen.datatypes.item.Info;
5 import com.amdocs.zusammen.datatypes.item.ItemVersionData;
6 import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
7 import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
8 import org.openecomp.core.migration.store.ElementHandler;
9 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
10 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
11
12 import java.util.HashSet;
13 import java.util.List;
14 import java.util.Set;
15
16 public class VlmConvertor {
17
18   private static Set<String> compNicLoaded = new HashSet<>();
19
20   public static CollaborationElement[] convertVlmToElement(VendorLicenseModelEntity vendorLicenseModel) {
21
22     CollaborationElement[] vspElements = new CollaborationElement[1];
23     List<String> vspNamespace = getVlmNamespace(vendorLicenseModel);
24
25
26     String vspEntityId = StructureElement.General.name();
27
28     vspElements[0] = ElementHandler.getElementEntity(
29         vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString(),
30         vspEntityId,
31         vspNamespace,
32         getVlmGeneralInfo(vendorLicenseModel),
33         null,
34         null,
35         null);
36     return vspElements;
37   }
38
39
40   public static ItemVersionData getItemVersionData(
41       VendorLicenseModelEntity vendorLicenseModel) {
42     ItemVersionData itemVersionData = new ItemVersionData();
43     Info info = new Info();
44     info.setName("main version");
45     itemVersionData.setInfo(info);
46     return itemVersionData;
47   }
48
49   public static Info getVlmInfo(VendorLicenseModelEntity vendorLicenseModel) {
50
51     Info info = new Info();
52     info.setName(vendorLicenseModel.getVendorName());
53     info.setDescription(vendorLicenseModel.getDescription());
54     info.addProperty("type", "vlm");
55     info.addProperty("version", vendorLicenseModel.getVersion());
56     info.addProperty("iconRef", vendorLicenseModel.getIconRef());
57     return info;
58   }
59
60   private static List<String> getVlmNamespace(VendorLicenseModelEntity vlmEntity) {
61     return ElementHandler.getElementPath("");
62   }
63
64   private static Info getVlmGeneralInfo(VendorLicenseModelEntity vendorLicenseModel) {
65
66
67     Info info = new Info();
68     info.setName(StructureElement.General.name());
69     info.addProperty(InfoPropertyName.type.name(), InfoPropertyName.vlm.name());
70     info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
71     info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
72     info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
73     return info;
74   }
75
76   public static ElementEntityContext convertVlmToElementContext(VendorLicenseModelEntity
77                                                                    vendorLicenseModel) {
78
79     return new ElementEntityContext("GLOBAL_USER", new
80         ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString()));
81   }
82
83
84   private enum InfoPropertyName {
85     name,
86     description,
87     iconRef,
88     type,
89     vlm
90   }
91
92 }