diff options
author | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
---|---|---|
committer | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
commit | 280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch) | |
tree | 9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java | |
parent | fd3821dad11780d33c5373d74c957c442489945e (diff) |
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370
Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java')
-rw-r--r-- | openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java new file mode 100644 index 0000000000..3854b32366 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java @@ -0,0 +1,102 @@ +package org.openecomp.core.migration.convertors; + +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext; +import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.model.impl.zusammen.ElementType; +import org.openecomp.sdc.model.impl.zusammen.StructureElement; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; + +import java.io.ByteArrayInputStream; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author katyr + * @since April 23, 2017 + */ + +public class VspServiceTemplateConvertor +{ + private static Set<String> serviceTemplatesLoaded = new HashSet<>(); + + + + public static CollaborationElement[] convertServiceTemplateToElement(ServiceTemplate serviceTemplate) { + + CollaborationElement[] serviceTemplateElements; + List<String> serviceTemplateNamespace = getServiceTemplateNamespace(); + + int index = 0; + String serviceTemplatesEntityId = StructureElement.Templates.name(); + String uniqueId = serviceTemplate.getVspId()+"_"+serviceTemplate.getVersion().toString(); + if (serviceTemplatesLoaded.contains(uniqueId)) { + serviceTemplateElements = new CollaborationElement[1]; + } else { + serviceTemplatesLoaded.add(uniqueId); + String vspServiceModelEntityId = StructureElement.ServiceModel.name(); + + serviceTemplateElements = new CollaborationElement[3]; + serviceTemplateElements[index] = ElementHandler.getElementEntity( + serviceTemplate.getVspId(), + serviceTemplate.getVersion().toString(), + vspServiceModelEntityId, + serviceTemplateNamespace, + ElementHandler.getServiceModelElementInfo(vspServiceModelEntityId,serviceTemplate), + null, + null, + null); + index++; + serviceTemplateNamespace.add(vspServiceModelEntityId); + serviceTemplateElements[index] = ElementHandler.getElementEntity( + serviceTemplate.getVspId(), serviceTemplate.getVersion().toString(), serviceTemplatesEntityId, + serviceTemplateNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Templates.name()), + null, + null, + null); + index++; + } + + serviceTemplateNamespace.add(serviceTemplatesEntityId); + String elementId = serviceTemplate.getVspId()+"_"+serviceTemplate.getVersion().toString() + +"_"+serviceTemplate.getName(); + serviceTemplateElements[index] = ElementHandler.getElementEntity( + serviceTemplate.getVspId(), serviceTemplate.getVersion().toString(), elementId, + serviceTemplateNamespace, + getServiceTemplateInfo(serviceTemplate), + null, + null, + FileUtils.toByteArray(serviceTemplate.getContent())); + + return serviceTemplateElements; + } + + private static Info getServiceTemplateInfo(ServiceTemplate serviceTemplateEntity) { + Info info = new Info(); + info.setName(serviceTemplateEntity.getName()); + info.addProperty("type", ElementType.Servicetemplate.name()); + info.addProperty("base", serviceTemplateEntity.getBaseName()); + + + + return info; + } + + private static List<String> getServiceTemplateNamespace() { + return ElementHandler.getElementPath(); + } + + public static ElementEntityContext convertServiceTemplateToElementContext(ServiceTemplate + serviceTemplateEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(serviceTemplateEntity.getVspId(), serviceTemplateEntity.getVersion().toString())); + } + +} |