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