[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 / OrchestrationTemplateCandidateConvertor.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.MigrationMain;
9 import org.openecomp.core.migration.loaders.VspInformation;
10 import org.openecomp.core.migration.store.ElementHandler;
11 import org.openecomp.sdc.logging.api.Logger;
12 import org.openecomp.sdc.logging.api.LoggerFactory;
13 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
14 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName;
15 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
16 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
17 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
18 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateDataEntity;
19
20 import java.util.HashSet;
21 import java.util.List;
22 import java.util.Set;
23
24 public class OrchestrationTemplateCandidateConvertor {
25
26
27
28
29   private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
30
31   public static CollaborationElement[] convertOrchestrationTemplateCandidateToElement(
32       OrchestrationTemplateCandidateDataEntity entity) {
33
34
35     CollaborationElement[] orchestrationTemplateCandidateElements = new CollaborationElement[2];
36     List<String> orchestrationTemplateCandidateNamespace =
37         getOrchestrationTemplateCandidateNamespace();
38
39
40
41     orchestrationTemplateCandidateElements[0] = ElementHandler.getElementEntity(
42         entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidate.name(),
43         orchestrationTemplateCandidateNamespace,
44         ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidate.name()),
45         null,
46         null,
47         entity.getFilesDataStructure().getBytes());
48
49     orchestrationTemplateCandidateNamespace.add(StructureElement.OrchestrationTemplateCandidate.name());
50     orchestrationTemplateCandidateElements[1] = ElementHandler.getElementEntity(
51         entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidateContent.name(),
52         orchestrationTemplateCandidateNamespace,
53         ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidateContent.name()),
54         null,
55         null,
56         entity.getContentData().array());
57
58
59
60     return orchestrationTemplateCandidateElements;
61   }
62
63
64   private static List<String> getOrchestrationTemplateCandidateNamespace() {
65     return ElementHandler.getElementPath();
66   }
67
68   public static ElementEntityContext convertComponentToElementContext(
69       ComponentEntity componentEntity) {
70
71     return new ElementEntityContext("GLOBAL_USER", new
72         ElementContext(componentEntity.getVspId(), componentEntity.getVersion().toString()));
73   }
74
75
76
77
78 }