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.ElementType;
12 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
13 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
15 import java.util.HashSet;
16 import java.util.List;
19 public class MibConvertor {
20 private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
22 private static Set<String> compMibLoaded = new HashSet<>();
25 public static CollaborationElement[] convertMibToElement(MibEntity mibEntity) {
26 CollaborationElement[] elements;
27 List<String> mibNamespace = getMibNamespace(mibEntity);
30 String mibsEntityId = StructureElement.Mibs.name() + "_" + mibEntity.getComponentId();
31 if (compMibLoaded.contains(mibsEntityId)) {
32 elements = new CollaborationElement[1];
34 compMibLoaded.add(mibsEntityId);
35 elements = new CollaborationElement[2];
36 elements[index++] = ElementHandler.getElementEntity(
37 mibEntity.getVspId(), mibEntity.getVersion().toString(), mibsEntityId, mibNamespace,
38 ElementHandler.getStructuralElementInfo(StructureElement.Mibs.name()), null, null, null);
41 mibNamespace.add(mibsEntityId);
42 elements[index] = ElementHandler.getElementEntity(
43 mibEntity.getVspId(), mibEntity.getVersion().toString(), mibEntity.getId(), mibNamespace,
44 getMibInfo(mibEntity), null, null, mibEntity.getArtifact().array());
49 private static Info getMibInfo(MibEntity mibEntity) {
50 Info info = new Info();
51 info.setName(mibEntity.getType().toString());
52 info.getProperties().put("name", mibEntity.getArtifactName());
56 private static List<String> getMibNamespace(MibEntity mibEntity) {
57 return ElementHandler.getElementPath(StructureElement.Components.name(), mibEntity
61 public static ElementEntityContext convertMibToElementContext(MibEntity mibEntity) {
63 return new ElementEntityContext("GLOBAL_USER", new
64 ElementContext(mibEntity.getVspId(), mibEntity.getVersion().toString()));