diff options
author | 2017-06-09 02:39:56 +0300 | |
---|---|---|
committer | 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 | |
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')
14 files changed, 1312 insertions, 0 deletions
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.java new file mode 100644 index 0000000000..fb597d5a3e --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.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.MigrationMain; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author katyr + * @since April 23, 2017 + */ + +public class ComponentConvertor { + + private static Set<String> componentsLoaded = new HashSet<>(); + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + public static CollaborationElement[] convertComponentToElement(ComponentEntity componentEntity) { + + CollaborationElement[] componentElements; + List<String> componentNamespace = getComponentNamespace(); + + int index = 0; + String componentsEntityId = StructureElement.Components.name(); + String uniqueId = componentEntity.getVspId()+"_"+componentEntity.getVersion().toString(); + if (componentsLoaded.contains(uniqueId)) { +// printMessage(logger, "Components structural elements exist for component " + +// componentEntity.getId()); + componentElements = new CollaborationElement[2]; + } else { + componentsLoaded.add(uniqueId); +// printMessage(logger, "Creating Components structural elements for component " + +// componentEntity.getId()); + componentElements = new CollaborationElement[3]; + componentElements[index] = ElementHandler.getElementEntity( + componentEntity.getVspId(), componentEntity.getVersion().toString(), componentsEntityId, + componentNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Components.name()), + null, + null, + null); + index++; + } + + componentNamespace.add(componentsEntityId); + componentElements[index] = ElementHandler.getElementEntity( + componentEntity.getVspId(), componentEntity.getVersion().toString(), + componentEntity.getId(), + componentNamespace, + getComponentInfo(componentEntity), + null, + null, + (componentEntity.getCompositionData() != null) ? componentEntity.getCompositionData().getBytes() + : null); + index++; + + componentNamespace.add(componentEntity.getId()); + componentElements[index] = ElementHandler.getElementEntity( + componentEntity.getVspId(), componentEntity.getVersion().toString(),StructureElement.Questionnaire.name() + "_" + componentEntity.getId(), + componentNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Questionnaire.name()), + null, + null, + (componentEntity.getQuestionnaireData() != null) ? componentEntity.getQuestionnaireData().getBytes() + : null); + + return componentElements; + } + + private static Info getComponentInfo(ComponentEntity componentEntity) { + Info info = new Info(); + info.addProperty(ElementPropertyName.type.name(), ElementType.Component); + info.addProperty(ElementPropertyName.compositionData.name(), + componentEntity.getCompositionData()); + + return info; + } + + private static List<String> getComponentNamespace() { + return ElementHandler.getElementPath(); + } + + public static ElementEntityContext convertComponentToElementContext( + ComponentEntity componentEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(componentEntity.getVspId(), componentEntity.getVersion().toString())); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java new file mode 100644 index 0000000000..4c667f6708 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java @@ -0,0 +1,96 @@ +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.sdc.vendorlicense.dao.impl.zusammen.RelationType; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Created by ayalaben on 4/24/2017 + */ +public class EntitlementPoolConvertor { + + private static Set<String> EntitlementPoolsLoaded = new HashSet<>(); + + public static ElementEntityContext convertEntitlementPoolToElementContext( + EntitlementPoolEntity entitlementPoolEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(entitlementPoolEntity.getVendorLicenseModelId(), + entitlementPoolEntity.getVersion().toString())); + } + + public static CollaborationElement[] convertEntitlementPoolToElement( + EntitlementPoolEntity entitlementPoolEntity) { +// printMessage(logger, "source EntitlementPoolEntity -> " + entitlementPoolEntity.toString()); + CollaborationElement[] elements; + List<String> entitlementPoolNamespace = getEntitlementPoolNamespace(entitlementPoolEntity); + + int index = 0; + String entitlememtPoolsEntityId = StructureElement.EntitlementPools.name(); + String uniqueId = entitlementPoolEntity.getVendorLicenseModelId() + "_" + + entitlementPoolEntity.getVersion().toString(); + + if (EntitlementPoolsLoaded.contains(uniqueId)) { + elements = new CollaborationElement[1]; + } else { + EntitlementPoolsLoaded.add(uniqueId); + elements = new CollaborationElement[2]; + elements[index] = ElementHandler.getElementEntity( + entitlementPoolEntity.getVendorLicenseModelId(), + entitlementPoolEntity.getVersion().toString(), + entitlememtPoolsEntityId, entitlementPoolNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.EntitlementPools.name()), + null, null, null); + index++; + } + + entitlementPoolNamespace.add(entitlememtPoolsEntityId); + + elements[index] = ElementHandler.getElementEntity( + entitlementPoolEntity.getVendorLicenseModelId(), + entitlementPoolEntity.getVersion().toString(), + entitlementPoolEntity.getId(), entitlementPoolNamespace, + getEntitelementPoolInfo(entitlementPoolEntity), + entitlementPoolEntity.getReferencingFeatureGroups().stream().map(rel -> + VlmZusammenUtil + .createRelation( RelationType.EntitlmentPoolToReferencingFeatureGroup, rel)) + .collect(Collectors.toList()), null, null); + + return elements; + } + + private static Info getEntitelementPoolInfo(EntitlementPoolEntity entitlementPool) { + + Info info = new Info(); + info.setName(entitlementPool.getName()); + info.setDescription(entitlementPool.getDescription()); + info.addProperty("thresholdValue", entitlementPool.getThresholdValue()); + info.addProperty("threshold_unit", entitlementPool.getThresholdUnit()); + info.addProperty("entitlement_metric", entitlementPool.getEntitlementMetric()); + info.addProperty("increments", entitlementPool.getIncrements()); + info.addProperty("aggregation_func", entitlementPool.getAggregationFunction()); + info.addProperty("operational_scope", entitlementPool.getOperationalScope()); + info.addProperty("EntitlementTime", entitlementPool.getTime()); + info.addProperty("manufacturerReferenceNumber", + entitlementPool.getManufacturerReferenceNumber()); + + return info; + } + + private static List<String> getEntitlementPoolNamespace( + EntitlementPoolEntity entitlementPoolEntity) { + return ElementHandler.getElementPath(""); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java new file mode 100644 index 0000000000..dd3fbe0485 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java @@ -0,0 +1,100 @@ +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.Relation; +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.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Created by ayalaben on 4/25/2017 + */ +public class FeatureGroupConvertor { + + private static Logger logger = LoggerFactory.getLogger(FeatureGroupConvertor.class); + private static Set<String> FeatureGroupsLoaded = new HashSet<>(); + + public static ElementEntityContext convertFeatureGroupToElementContext(FeatureGroupEntity featureGroupEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString())); + } + + public static CollaborationElement[] convertFeatureGroupToElement(FeatureGroupEntity featureGroupEntity) { +// printMessage(logger, "source FeatureGroupEntity -> " + featureGroupEntity.toString()); + CollaborationElement[] elements; + List<String> featureGroupNamespace = getFeatureGroupNamespace(featureGroupEntity); + + int index = 0; + String featureGroupsEntityId = StructureElement.FeatureGroups.name(); + String uniqueId = featureGroupEntity.getVendorLicenseModelId() + "_" + featureGroupEntity.getVersion().toString(); + + if (FeatureGroupsLoaded.contains(uniqueId)) { + elements = new CollaborationElement[1]; + } else { + FeatureGroupsLoaded.add(uniqueId); + elements = new CollaborationElement[2]; + elements[index] = ElementHandler.getElementEntity( + featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString(), + featureGroupsEntityId, featureGroupNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.FeatureGroups.name()), + null, null, null); + index++; + } + + featureGroupNamespace.add(featureGroupsEntityId); + + elements[index] = ElementHandler.getElementEntity( + featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString(), + featureGroupEntity.getId(), featureGroupNamespace, getFeatureGroupInfo(featureGroupEntity), + getAllFeatureGroupRelations(featureGroupEntity), null, null); + + return elements; + } + + private static Collection<Relation> getAllFeatureGroupRelations(FeatureGroupEntity featureGroup) { + Collection<Relation> relations = new ArrayList<>(); + + relations.addAll(featureGroup.getEntitlementPoolIds().stream().map(rel -> + VlmZusammenUtil.createRelation( RelationType.FeatureGroupToEntitlmentPool, rel)) + .collect(Collectors.toList())); + + relations.addAll(featureGroup.getLicenseKeyGroupIds().stream().map(rel -> + VlmZusammenUtil.createRelation( RelationType.FeatureGroupToLicenseKeyGroup, rel)) + .collect(Collectors.toList())); + + relations.addAll(featureGroup.getReferencingLicenseAgreements().stream().map(rel -> + VlmZusammenUtil.createRelation( RelationType.FeatureGroupToReferencingLicenseAgreement, + rel)).collect(Collectors.toList())); + + return relations; + } + + private static Info getFeatureGroupInfo(FeatureGroupEntity featureGroup) { + + Info info = new Info(); + info.setName(featureGroup.getName()); + info.setDescription(featureGroup.getDescription()); + info.addProperty("partNumber", featureGroup.getPartNumber()); + return info; + } + + + private static List<String> getFeatureGroupNamespace(FeatureGroupEntity featureGroupEntity) { + return ElementHandler.getElementPath(""); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java new file mode 100644 index 0000000000..7fd640b12d --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java @@ -0,0 +1,79 @@ +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.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Created by ayalaben on 4/24/2017 + */ +public class LKGConvertor { + + private static Logger logger = LoggerFactory.getLogger(LKGConvertor.class); + private static Set<String> compLKGLoaded = new HashSet<>(); + + public static CollaborationElement[] convertLKGToElement(LicenseKeyGroupEntity licenseKeyGroupEntity) { + CollaborationElement[] elements; + List<String> lkgNamespace = getLKGNamespace(licenseKeyGroupEntity); + + int index = 0; + String lkgsEntityId = StructureElement.LicenseKeyGroups.name(); + String uniqueId = licenseKeyGroupEntity.getVendorLicenseModelId() + "_" + licenseKeyGroupEntity.getVersion().toString(); + + if (compLKGLoaded.contains(uniqueId)) { + elements = new CollaborationElement[1]; + } else { + compLKGLoaded.add(uniqueId); + elements = new CollaborationElement[2]; + elements[index] = ElementHandler.getElementEntity( + licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString(), lkgsEntityId, lkgNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.LicenseKeyGroups.name()), null, null, null); + index++; + } + + lkgNamespace.add(lkgsEntityId); + + elements[index] = ElementHandler.getElementEntity( + licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString(), licenseKeyGroupEntity.getId(), lkgNamespace, + getLKGInfo(licenseKeyGroupEntity), licenseKeyGroupEntity.getReferencingFeatureGroups().stream().map(rel -> + VlmZusammenUtil.createRelation( RelationType.LicenseKeyGroupToReferencingFeatureGroup, rel)) + .collect(Collectors.toList()), null, null); + + return elements; + } + + private static Info getLKGInfo(LicenseKeyGroupEntity licenseKeyGroupEntity) { + + Info info = new Info(); + info.setName(licenseKeyGroupEntity.getName()); + info.setDescription(licenseKeyGroupEntity.getDescription()); + info.addProperty("LicenseKeyType", licenseKeyGroupEntity.getType()); + info.addProperty("operational_scope", licenseKeyGroupEntity.getOperationalScope()); + + return info; + } + + private static List<String> getLKGNamespace(LicenseKeyGroupEntity LKGEntity) { + return ElementHandler.getElementPath(""); + } + + public static ElementEntityContext convertLKGToElementContext(LicenseKeyGroupEntity licenseKeyGroupEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString())); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java new file mode 100644 index 0000000000..25564c3138 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java @@ -0,0 +1,84 @@ +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.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Created by ayalaben on 4/25/2017 + */ +public class LicenseAgreementConvertor { + + private static Logger logger = LoggerFactory.getLogger(LicenseAgreementConvertor.class); + private static Set<String> LicenseAgreementsLoaded = new HashSet<>(); + + public static ElementEntityContext convertLicenseAgreementToElementContext(LicenseAgreementEntity licenseAgreementEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString())); + } + + + public static CollaborationElement[] convertLicenseAgreementToElement(LicenseAgreementEntity licenseAgreementEntity) { +// printMessage(logger, "source LicenseAgreementEntity -> " + licenseAgreementEntity.toString()); + CollaborationElement[] elements; + List<String> featureGroupNamespace = getLicenseAgreementNamespace(licenseAgreementEntity); + + int index = 0; + String featureGroupsEntityId = StructureElement.LicenseAgreements.name(); + String uniqueId = licenseAgreementEntity.getVendorLicenseModelId() + "_" + licenseAgreementEntity.getVersion().toString(); + + if (LicenseAgreementsLoaded.contains(uniqueId)) { + elements = new CollaborationElement[1]; + } else { + LicenseAgreementsLoaded.add(uniqueId); + elements = new CollaborationElement[2]; + elements[index] = ElementHandler.getElementEntity( + licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString(), + featureGroupsEntityId, featureGroupNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.LicenseAgreements.name()), + null, null, null); + index++; + } + + featureGroupNamespace.add(featureGroupsEntityId); + + elements[index] = ElementHandler.getElementEntity( + licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString(), + licenseAgreementEntity.getId(), featureGroupNamespace, getLicenseAgreementInfo(licenseAgreementEntity), + licenseAgreementEntity.getFeatureGroupIds().stream().map(rel -> + VlmZusammenUtil.createRelation( RelationType.LicenseAgreementToFeatureGroup, rel)) + .collect(Collectors.toList()), null, null); + + return elements; + } + + private static Info getLicenseAgreementInfo(LicenseAgreementEntity licenseAgreement) { + + Info info = new Info(); + info.setName(licenseAgreement.getName()); + info.setDescription(licenseAgreement.getDescription()); + info.addProperty("licenseTerm", licenseAgreement.getLicenseTerm()); + info.addProperty("requirementsAndConstrains", licenseAgreement.getRequirementsAndConstrains()); + + return info; + } + + private static List<String> getLicenseAgreementNamespace(LicenseAgreementEntity licenseAgreement) { + return ElementHandler.getElementPath(""); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java new file mode 100644 index 0000000000..88b9dce95f --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java @@ -0,0 +1,66 @@ +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.MigrationMain; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class MibConvertor { + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + private static Set<String> compMibLoaded = new HashSet<>(); + + + public static CollaborationElement[] convertMibToElement(MibEntity mibEntity) { + CollaborationElement[] elements; + List<String> mibNamespace = getMibNamespace(mibEntity); + + int index = 0; + String mibsEntityId = StructureElement.Mibs.name() + "_" + mibEntity.getComponentId(); + if (compMibLoaded.contains(mibsEntityId)) { + elements = new CollaborationElement[1]; + } else { + compMibLoaded.add(mibsEntityId); + elements = new CollaborationElement[2]; + elements[index++] = ElementHandler.getElementEntity( + mibEntity.getVspId(), mibEntity.getVersion().toString(), mibsEntityId, mibNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Mibs.name()), null, null, null); + } + + mibNamespace.add(mibsEntityId); + elements[index] = ElementHandler.getElementEntity( + mibEntity.getVspId(), mibEntity.getVersion().toString(), mibEntity.getId(), mibNamespace, + getMibInfo(mibEntity), null, null, mibEntity.getArtifact().array()); + + return elements; + } + + private static Info getMibInfo(MibEntity mibEntity) { + Info info = new Info(); + info.setName(mibEntity.getType().toString()); + info.getProperties().put("name", mibEntity.getArtifactName()); + return info; + } + + private static List<String> getMibNamespace(MibEntity mibEntity) { + return ElementHandler.getElementPath(StructureElement.Components.name(), mibEntity + .getComponentId()); + } + + public static ElementEntityContext convertMibToElementContext(MibEntity mibEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(mibEntity.getVspId(), mibEntity.getVersion().toString())); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java new file mode 100644 index 0000000000..3d4f1575fc --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java @@ -0,0 +1,91 @@ +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.MigrationMain; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author katyr + * @since April 23, 2017 + */ + +public class NetworkConvertor { + + private static Set<String> networksLoaded = new HashSet<>(); + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + + + public static CollaborationElement[] convertNetworkToElement(NetworkEntity networkEntity) { + + CollaborationElement[] networkElements; + List<String> networkNamespace = getNetworkNamespace(); + + int index = 0; + String networksEntityId = StructureElement.Networks.name(); + String uniqueId = networkEntity.getVspId()+"_"+networkEntity.getVersion().toString(); + if (networksLoaded.contains(uniqueId)) { +// printMessage(logger, "Networks structural elements exist for network " + +// networkEntity.getId()); + networkElements = new CollaborationElement[1]; + } else { +// printMessage(logger, "Creating Networks structural element for network " + +// networkEntity.getId()); + networksLoaded.add(uniqueId); + networkElements = new CollaborationElement[2]; + networkElements[index] = ElementHandler.getElementEntity( + networkEntity.getVspId(), networkEntity.getVersion().toString(), networksEntityId, + networkNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Networks.name()), + null, + null, + null); + index++; + } + + networkNamespace.add(networksEntityId); + + networkElements[index] = ElementHandler.getElementEntity( + networkEntity.getVspId(), networkEntity.getVersion().toString(), networkEntity.getId(), + networkNamespace, + getNetworkInfo(networkEntity), + null, + null, + networkEntity.getCompositionData().getBytes()); + + + return networkElements; + } + + private static Info getNetworkInfo(NetworkEntity networkEntity) { + Info info = new Info(); + info.addProperty(ElementPropertyName.type.name(), ElementType.Network); + info.addProperty(ElementPropertyName.compositionData.name(), networkEntity.getCompositionData()); + + return info; + } + + private static List<String> getNetworkNamespace() { + return ElementHandler.getElementPath(); + } + + public static ElementEntityContext convertNetworkToElementContext(NetworkEntity networkEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(networkEntity.getVspId(), networkEntity.getVersion().toString())); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java new file mode 100644 index 0000000000..b17e68c0e5 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java @@ -0,0 +1,95 @@ +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.MigrationMain; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class NicConvertor { + + + private static Set<String> compNicLoaded = new HashSet<>(); + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + + + public static CollaborationElement[] convertNicToElement(NicEntity nicEntity) { + + CollaborationElement[] nicElements; + List<String> nicNamespace = getNicNamespace(nicEntity); + + int index = 0; + String nicsEntityId = StructureElement.Nics.name() + "_" + nicEntity.getComponentId(); + if (compNicLoaded.contains(nicsEntityId)) { +// printMessage(logger, "Nics structural element exists for nic " + +// nicEntity.getId()); + nicElements = new CollaborationElement[2]; + } else { +// printMessage(logger, "Creating Nics structural element for nic " + +// nicEntity.getId()); + compNicLoaded.add(nicsEntityId); + nicElements = new CollaborationElement[3]; + nicElements[index] = ElementHandler.getElementEntity( + nicEntity.getVspId(), nicEntity.getVersion().toString(), nicsEntityId, + nicNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Nics.name()), + null, + null, + null); + index++; + } + + nicNamespace.add(nicsEntityId); + nicElements[index] = ElementHandler.getElementEntity( + nicEntity.getVspId(), nicEntity.getVersion().toString(), nicEntity.getId(), + nicNamespace, + getNicInfo(nicEntity), + null, + null, + nicEntity.getCompositionData().getBytes()); + index++; + + nicNamespace.add(nicEntity.getId()); + nicElements[index] = ElementHandler.getElementEntity( + nicEntity.getVspId(), nicEntity.getVersion().toString(),StructureElement.Questionnaire.name() + "_" + nicEntity.getId(), + nicNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Questionnaire.name()), + null, + null, + (nicEntity.getQuestionnaireData() != null) ? nicEntity.getQuestionnaireData().getBytes() + : null); + return nicElements; + } + + private static Info getNicInfo(NicEntity nicEntity) { + Info info = new Info(); + info.addProperty(ElementPropertyName.type.name(), ElementType.Nic); + info.addProperty(ElementPropertyName.compositionData.name(), nicEntity.getCompositionData()); + return info; + } + + private static List<String> getNicNamespace(NicEntity nicEntity) { + return ElementHandler.getElementPath(StructureElement.Components.name(), nicEntity + .getComponentId()); + } + + public static ElementEntityContext convertNicToElementContext(NicEntity nicEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(nicEntity.getVspId(), nicEntity.getVersion().toString())); + } + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java new file mode 100644 index 0000000000..c6778544fd --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java @@ -0,0 +1,78 @@ +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.MigrationMain; +import org.openecomp.core.migration.loaders.VspInformation; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateDataEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class OrchestrationTemplateCandidateConvertor { + + + + + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + public static CollaborationElement[] convertOrchestrationTemplateCandidateToElement( + OrchestrationTemplateCandidateDataEntity entity) { + + + CollaborationElement[] orchestrationTemplateCandidateElements = new CollaborationElement[2]; + List<String> orchestrationTemplateCandidateNamespace = + getOrchestrationTemplateCandidateNamespace(); + + + + orchestrationTemplateCandidateElements[0] = ElementHandler.getElementEntity( + entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidate.name(), + orchestrationTemplateCandidateNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidate.name()), + null, + null, + entity.getFilesDataStructure().getBytes()); + + orchestrationTemplateCandidateNamespace.add(StructureElement.OrchestrationTemplateCandidate.name()); + orchestrationTemplateCandidateElements[1] = ElementHandler.getElementEntity( + entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidateContent.name(), + orchestrationTemplateCandidateNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidateContent.name()), + null, + null, + entity.getContentData().array()); + + + + return orchestrationTemplateCandidateElements; + } + + + private static List<String> getOrchestrationTemplateCandidateNamespace() { + return ElementHandler.getElementPath(); + } + + public static ElementEntityContext convertComponentToElementContext( + ComponentEntity componentEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(componentEntity.getVspId(), componentEntity.getVersion().toString())); + } + + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java new file mode 100644 index 0000000000..0a145c49f7 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java @@ -0,0 +1,98 @@ +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.MigrationMain; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ProcessConvertor { + private static final String NAME = "name"; + private static final String ELEMENT_TYPE = "type"; + private static final String ARTIFACT_NAME = "artifactName"; + private static final String DESCRIPTION = "description"; + private static final String PROCESS_TYPE = "processType"; + private static Set<String> compProcessesLoaded = new HashSet<>(); + + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + + public static CollaborationElement[] convertProcessToElement(ProcessEntity processEntity) { + CollaborationElement[] elements; + boolean isGeneralComponentId = isGeneralComponentId(processEntity); + List<String> processNamespace = getProcessNamespace(processEntity); + int index = 0; + String uniqueId = getUniqueId(processEntity, isGeneralComponentId); + String processesEntityId = isGeneralComponentId ? StructureElement.Processes.name() : + (StructureElement.Processes.name() + "_" +processEntity.getComponentId()); + if (compProcessesLoaded.contains(uniqueId)) { + elements = new CollaborationElement[1]; + } else { + compProcessesLoaded.add(uniqueId); + elements = new CollaborationElement[2]; + elements[index++] = ElementHandler.getElementEntity( + processEntity.getVspId(), processEntity.getVersion().toString(), processesEntityId, + processNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Processes.name()), null, null, null); + } + + processNamespace.add(processesEntityId); + elements[index] = ElementHandler.getElementEntity( + processEntity.getVspId(), processEntity.getVersion().toString(), processEntity.getId(), + processNamespace, + getProcessInfo(processEntity), null, null, processEntity.getArtifact() == + null ? null : processEntity.getArtifact().array()); + + return elements; + } + + private static String getUniqueId(ProcessEntity processEntity, boolean isGeneralComponentId) { + if (isGeneralComponentId) { + return processEntity.getVspId() + "_" + processEntity.getVersion().toString(); + } else { + return StructureElement.Processes.name() + "_" + processEntity + .getComponentId(); + } + } + + private static Info getProcessInfo(ProcessEntity processEntity) { + Info info = new Info(); + info.setName(processEntity.getName()); + info.addProperty(NAME, processEntity.getName()); + info.addProperty(ELEMENT_TYPE, ElementType.Process); + info.addProperty(ARTIFACT_NAME, processEntity.getArtifactName()); + info.addProperty(DESCRIPTION, processEntity.getDescription()); + info.addProperty(PROCESS_TYPE, + processEntity.getType() != null ? processEntity.getType().name() : null); + return info; + } + + private static List<String> getProcessNamespace(ProcessEntity processEntity) { + if (isGeneralComponentId(processEntity)) { + return ElementHandler.getElementPath(); + } else { + return ElementHandler + .getElementPath(StructureElement.Components.name(), processEntity.getComponentId()); + } + } + + private static boolean isGeneralComponentId(ProcessEntity processEntity) { + return processEntity.getComponentId().equals("General"); + } + + public static ElementEntityContext convertProcessToElementContext(ProcessEntity processEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(processEntity.getVspId(), processEntity.getVersion().toString())); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java new file mode 100644 index 0000000000..2e5fac830e --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java @@ -0,0 +1,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 + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java new file mode 100644 index 0000000000..b7a1d42386 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java @@ -0,0 +1,141 @@ +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.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement; + +import java.util.List; + +public class VspInformationConvertor { + + public static ItemVersionData getItemVersionData( + VspInformation vspInformation) { + Info info = new Info(); + info.setName("main version"); + ItemVersionData itemVersionData = new ItemVersionData(); + itemVersionData.setInfo(info); + return itemVersionData; + } + + public static Info getVspInfo(VspInformation vspInformation) { + + Info info = new Info(); + info.setName(vspInformation.getName()); + info.setDescription(vspInformation.getDescription()); + info.addProperty("type", "vsp"); + addVspDetailsToInfo(info, vspInformation); + return info; + } + + private static List<String> getVspNamespace(VendorLicenseModelEntity vlmEntity) { + return ElementHandler.getElementPath(""); + } + + private static void addVspDetailsToInfo(Info info, VspInformation vspInformation) { + info.addProperty("name", vspInformation.getName()); + info.addProperty("description", vspInformation.getDescription()); + info.addProperty("category", vspInformation.getCategory()); + info.addProperty("subCategory", vspInformation.getSubCategory()); + info.addProperty("vendorId", vspInformation.getVendorId()); + info.addProperty("vendorName", vspInformation.getVendorName()); + if (vspInformation.getVlmVersion() != null) { + info.addProperty("vendorVersion", vspInformation.getVlmVersion().toString()); + } + info.addProperty("featureGroups", vspInformation.getFeatureGroups()); + info.addProperty("licenseAgreement", vspInformation.getLicenseAgreement()); + String oldVersion = vspInformation.getIsOldVersion() == null? "1702":"1610"; + info.addProperty("oldVersion", oldVersion); + } + + public static CollaborationElement[] convertVspToElement(VspInformation vspInformation) { + + CollaborationElement[] vspElements = new CollaborationElement[4]; + List<String> vspNamespace = getVspNamespace(vspInformation); + + + String vspEntityId = StructureElement.General.name(); + + vspElements[0] = ElementHandler.getElementEntity( + vspInformation.getId(), vspInformation.getVersion().toString(), + vspEntityId, + vspNamespace, + getVspGeneralInfo(vspInformation), + null, + null, + null); + + String vspOrchestrationTemplateEntityId = StructureElement.OrchestrationTemplate.name(); + vspElements[1] = ElementHandler.getElementEntity( + vspInformation.getId(), vspInformation.getVersion().toString(), + vspOrchestrationTemplateEntityId, + vspNamespace, + ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateEntityId), + null, + null, + null); + + + vspNamespace.add(vspOrchestrationTemplateEntityId); + + String vspOrchestrationTemplateValidationDataEntityId = StructureElement.OrchestrationTemplateValidationData.name(); + vspElements[2] = ElementHandler.getElementEntity( + vspInformation.getId(), vspInformation.getVersion().toString(), + vspOrchestrationTemplateValidationDataEntityId, + vspNamespace, + ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateValidationDataEntityId), + null, + null, + vspInformation.getValidationData()!= null?vspInformation.getValidationData().getBytes() + :null); + + String vspOrchestrationTemplateContentEntityId = StructureElement.OrchestrationTemplateContent.name(); + vspElements[3] = ElementHandler.getElementEntity( + vspInformation.getId(), vspInformation.getVersion().toString(), + vspOrchestrationTemplateContentEntityId, + vspNamespace, + ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateContentEntityId), + null, + null, + vspInformation.getContentData()!= null?vspInformation.getContentData().array() + :null); + + return vspElements; + } + + private static Info getVspGeneralInfo(VspInformation vspInformation) { + + + Info info = new Info(); + info.setName(StructureElement.General.name()); + info.addProperty("name", vspInformation.getName()); + info.addProperty("description", vspInformation.getDescription()); + info.addProperty("category", vspInformation.getCategory()); + info.addProperty("subCategory", vspInformation.getSubCategory()); + info.addProperty("vendorId", vspInformation.getVendorId()); + info.addProperty("vendorName", vspInformation.getVendorName()); + if (vspInformation.getVlmVersion() != null) { + info.addProperty("vendorVersion", vspInformation.getVlmVersion().toString()); + } + info.addProperty("featureGroups", vspInformation.getFeatureGroups()); + info.addProperty("licenseAgreement", vspInformation.getLicenseAgreement()); + String oldVersion = vspInformation.getIsOldVersion() == null? "1702":"1610"; + info.addProperty("oldVersion", oldVersion); + return info; + } + + private static List<String> getVspNamespace(VspInformation vspEntity) { + return ElementHandler.getElementPath(""); + } + + public static ElementEntityContext convertVspToElementContext(VspInformation vspEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(vspEntity.getId(), vspEntity.getVersion().toString())); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java new file mode 100644 index 0000000000..76e35b56c4 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java @@ -0,0 +1,86 @@ +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.ServiceArtifact; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType; +import org.openecomp.sdc.model.impl.zusammen.StructureElement; + + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author katyr + * @since April 23, 2017 + */ + +public class VspServiceArtifactConvertor +{ + private static Set<String> serviceArtifactsLoaded = new HashSet<>(); + + + + public static CollaborationElement[] convertServiceArtifactToElement(ServiceArtifact serviceArtifact) { + + CollaborationElement[] serviceArtifactElements; + List<String> serviceArtifactNamespace = getServiceArtifactNamespace(); + + int index = 0; + String serviceArtifactsEntityId = StructureElement.Artifacts.name(); + String uniqueId = serviceArtifact.getVspId()+"_"+serviceArtifact.getVersion().toString(); + if (serviceArtifactsLoaded.contains(uniqueId)) { + serviceArtifactElements = new CollaborationElement[1]; + } else { + serviceArtifactsLoaded.add(uniqueId); + serviceArtifactElements = new CollaborationElement[2]; + serviceArtifactElements[index] = ElementHandler.getElementEntity( + serviceArtifact.getVspId(), serviceArtifact.getVersion().toString(), serviceArtifactsEntityId, + serviceArtifactNamespace, + ElementHandler.getStructuralElementInfo(StructureElement.Artifacts.name()), + null, + null, + null); + index++; + } + + serviceArtifactNamespace.add(serviceArtifactsEntityId); + String elementId = serviceArtifact.getVspId()+"_"+serviceArtifact.getVersion().toString() + +"_"+serviceArtifact.getName(); + serviceArtifactElements[index] = ElementHandler.getElementEntity( + serviceArtifact.getVspId(), serviceArtifact.getVersion().toString(), elementId, + serviceArtifactNamespace, + getServiceArtifactInfo(serviceArtifact), + null, + null, + FileUtils.toByteArray(serviceArtifact.getContent())); + + return serviceArtifactElements; + } + + private static Info getServiceArtifactInfo(ServiceArtifact serviceArtifactEntity) { + Info info = new Info(); + info.setName(serviceArtifactEntity.getName()); + info.addProperty("type", org.openecomp.sdc.model.impl.zusammen.ElementType.Artifact.name()); + + return info; + } + + private static List<String> getServiceArtifactNamespace() { + return ElementHandler.getElementPath(StructureElement.ServiceModel.name()); + } + + public static ElementEntityContext convertServiceArtifactToElementContext(ServiceArtifact + serviceArtifactEntity) { + + return new ElementEntityContext("GLOBAL_USER", new + ElementContext(serviceArtifactEntity.getVspId(), serviceArtifactEntity.getVersion().toString())); + } + +} 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())); + } + +} |