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.MigrationMain;
8 import org.openecomp.core.migration.store.ElementHandler;
9 import org.openecomp.sdc.logging.api.Logger;
10 import org.openecomp.sdc.logging.api.LoggerFactory;
11 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName;
12 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
13 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
14 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
16 import java.util.HashSet;
17 import java.util.List;
20 public class NicConvertor {
23 private static Set<String> compNicLoaded = new HashSet<>();
24 private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
28 public static CollaborationElement[] convertNicToElement(NicEntity nicEntity) {
30 CollaborationElement[] nicElements;
31 List<String> nicNamespace = getNicNamespace(nicEntity);
34 String nicsEntityId = StructureElement.Nics.name() + "_" + nicEntity.getComponentId();
35 if (compNicLoaded.contains(nicsEntityId)) {
36 // printMessage(logger, "Nics structural element exists for nic " +
37 // nicEntity.getId());
38 nicElements = new CollaborationElement[2];
40 // printMessage(logger, "Creating Nics structural element for nic " +
41 // nicEntity.getId());
42 compNicLoaded.add(nicsEntityId);
43 nicElements = new CollaborationElement[3];
44 nicElements[index] = ElementHandler.getElementEntity(
45 nicEntity.getVspId(), nicEntity.getVersion().toString(), nicsEntityId,
47 ElementHandler.getStructuralElementInfo(StructureElement.Nics.name()),
54 nicNamespace.add(nicsEntityId);
55 nicElements[index] = ElementHandler.getElementEntity(
56 nicEntity.getVspId(), nicEntity.getVersion().toString(), nicEntity.getId(),
58 getNicInfo(nicEntity),
61 nicEntity.getCompositionData().getBytes());
64 nicNamespace.add(nicEntity.getId());
65 nicElements[index] = ElementHandler.getElementEntity(
66 nicEntity.getVspId(), nicEntity.getVersion().toString(),StructureElement.Questionnaire.name() + "_" + nicEntity.getId(),
68 ElementHandler.getStructuralElementInfo(StructureElement.Questionnaire.name()),
71 (nicEntity.getQuestionnaireData() != null) ? nicEntity.getQuestionnaireData().getBytes()
76 private static Info getNicInfo(NicEntity nicEntity) {
77 Info info = new Info();
78 info.addProperty(ElementPropertyName.type.name(), ElementType.Nic);
79 info.addProperty(ElementPropertyName.compositionData.name(), nicEntity.getCompositionData());
83 private static List<String> getNicNamespace(NicEntity nicEntity) {
84 return ElementHandler.getElementPath(StructureElement.Components.name(), nicEntity
88 public static ElementEntityContext convertNicToElementContext(NicEntity nicEntity) {
90 return new ElementEntityContext("GLOBAL_USER", new
91 ElementContext(nicEntity.getVspId(), nicEntity.getVersion().toString()));