aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java
blob: 2e5fac830e48ceda2503e39cf81e9ac3254bbdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package org.openecomp.core.migration.convertors;

import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
import org.openecomp.core.migration.loaders.VspInformation;
import org.openecomp.core.migration.store.ElementHandler;
import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class VlmConvertor {

  private static Set<String> compNicLoaded = new HashSet<>();

  public static CollaborationElement[] convertVlmToElement(VendorLicenseModelEntity vendorLicenseModel) {

    CollaborationElement[] vspElements = new CollaborationElement[1];
    List<String> vspNamespace = getVlmNamespace(vendorLicenseModel);


    String vspEntityId = StructureElement.General.name();

    vspElements[0] = ElementHandler.getElementEntity(
        vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString(),
        vspEntityId,
        vspNamespace,
        getVlmGeneralInfo(vendorLicenseModel),
        null,
        null,
        null);
    return vspElements;
  }


  public static ItemVersionData getItemVersionData(
      VendorLicenseModelEntity vendorLicenseModel) {
    ItemVersionData itemVersionData = new ItemVersionData();
    Info info = new Info();
    info.setName("main version");
    itemVersionData.setInfo(info);
    return itemVersionData;
  }

  public static Info getVlmInfo(VendorLicenseModelEntity vendorLicenseModel) {

    Info info = new Info();
    info.setName(vendorLicenseModel.getVendorName());
    info.setDescription(vendorLicenseModel.getDescription());
    info.addProperty("type", "vlm");
    info.addProperty("version", vendorLicenseModel.getVersion());
    info.addProperty("iconRef", vendorLicenseModel.getIconRef());
    return info;
  }

  private static List<String> getVlmNamespace(VendorLicenseModelEntity vlmEntity) {
    return ElementHandler.getElementPath("");
  }

  private static Info getVlmGeneralInfo(VendorLicenseModelEntity vendorLicenseModel) {


    Info info = new Info();
    info.setName(StructureElement.General.name());
    info.addProperty(InfoPropertyName.type.name(), InfoPropertyName.vlm.name());
    info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
    info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
    info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
    return info;
  }

  public static ElementEntityContext convertVlmToElementContext(VendorLicenseModelEntity
                                                                   vendorLicenseModel) {

    return new ElementEntityContext("GLOBAL_USER", new
        ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString()));
  }


  private enum InfoPropertyName {
    name,
    description,
    iconRef,
    type,
    vlm
  }

}