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 | |
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')
43 files changed, 3792 insertions, 19 deletions
diff --git a/openecomp-be/tools/migration/1607_to_1610.py b/openecomp-be/tools/migration/1607_to_1610.py index 2cec48b04d..f46cb3a4b8 100644 --- a/openecomp-be/tools/migration/1607_to_1610.py +++ b/openecomp-be/tools/migration/1607_to_1610.py @@ -52,7 +52,7 @@ def main(argv): Service.server(host) webHandler=WebHandler(host=host, port=DEFAULT_PORT) - response, headers = webHandler.rest(url=VSP_LIST_PATH, method='GET', data=None, attuid=username) + response, headers = webHandler.rest(url=VSP_LIST_PATH, method='GET', data=None, userId=username) jResult = json.loads(response) jSrvices = jResult["results"] reportFileName = 'upgradereport.csv' #datetime.now() @@ -137,24 +137,24 @@ class Service(object): def line(self): return '{0},{1},{2},{3},{4}\n'.format(self.serviceName, self.vspId ,self.vendorName, self.lockingUser, self.uploadStatus) - def Checkout(self, attuid): + def Checkout(self, userId): # /v1.0/vendor-software-products/{vspId}/actions urlpath=VSP_ACTIONS_PATH.format(vspId=self.vspId) - response, headers = self.webHandler.rest( url=urlpath, method='PUT', data={"action": "Checkout"}, attuid=attuid) - self.lockingUser=attuid #we will later use this user to checkin + response, headers = self.webHandler.rest( url=urlpath, method='PUT', data={"action": "Checkout"}, userId=userId) + self.lockingUser=userId #we will later use this user to checkin return response def Checkin(self): # /v1.0/vendor-software-products/{vspId}/actions urlpath = VSP_ACTIONS_PATH.format(vspId=self.vspId) - response, headers = self.webHandler.rest(url=urlpath, method='PUT', data={"action": "Checkin"}, attuid=self.lockingUser) + response, headers = self.webHandler.rest(url=urlpath, method='PUT', data={"action": "Checkin"}, userId=self.lockingUser) return response def Get(self): # /v1.0/vendor-software-products/{vspId} urlpath = VSP_GET_URL.format(vspId=self.vspId) try: - response, headers = self.webHandler.rest(url=urlpath, method='GET', data=None, attuid=self.lockingUser) + response, headers = self.webHandler.rest(url=urlpath, method='GET', data=None, userId=self.lockingUser) except HttpError as e: print e.message response = e.status @@ -178,7 +178,7 @@ class Service(object): def DownloadHeat(self): urlpath=VSP_DOWNLOAD_PATH.format(vspId=self.vspId) try: - response, headers = self.webHandler.rest(url=urlpath, method='Get', data=None, attuid=self.lockingUser, accept='application/octet-stream') + response, headers = self.webHandler.rest(url=urlpath, method='Get', data=None, userId=self.lockingUser, accept='application/octet-stream') except HttpError as e: if e.status == 404: return "" @@ -204,12 +204,12 @@ class WebHandler(object): self.host = host self.port = port - def rest(self, url, method, data, attuid, accept='application/json', content_type='application/json'): + def rest(self, url, method, data, userId, accept='application/json', content_type='application/json'): connection = httplib.HTTPConnection(host=self.host, port=self.port) try: headers = {'Content-Type':content_type ,'Accept':accept} - headers['USER_ID'] = attuid + headers['USER_ID'] = userId connection.request(method=method, headers=headers, body=json.dumps(data), url=url) response = connection.getresponse() @@ -220,7 +220,7 @@ class WebHandler(object): finally: connection.close() - def post_multipart(self, scheme, selector, fields, files, attuid): + def post_multipart(self, scheme, selector, fields, files, userId): """ Post fields and files to an http host as multipart/form-data. fields is a sequence of (name, value) elements for regular form fields. @@ -236,7 +236,7 @@ class WebHandler(object): h.putheader('content-type', content_type) h.putheader('content-length', str(len(body))) h.putheader('Accept', 'application/json') - h.putheader('USER_ID', attuid) + h.putheader('USER_ID', userId) h.endheaders() h.send(body) diff --git a/openecomp-be/tools/migration/1702_to_1707.sh b/openecomp-be/tools/migration/1702_to_1707.sh new file mode 100644 index 0000000000..587d045f03 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +########################################################################################################### +# script name - 1702_to_1707.sh +# run script - ./1702_to_1707.sh +# this script replaces tosca namespace to org.openecomp in translated files from 1702 version +########################################################################################################### + + +# change exist package and service templates in db +java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=/apps/jetty/base/be/config/catalog-be/configuration.yaml -jar openecomp-migration-lib-1707.0.0-SNAPSHOT.jar org.openecomp.sdc.migration.ToscaNamespaceMigration + +STATUS="${?}" +echo "${STATUS}" +echo "All log messages for the migration proccess are in /apps/jetty/base/be/logs/ASDC/ASDC-BE/migration_debug.log" diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml b/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml new file mode 100644 index 0000000000..145a3fb4ab --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml @@ -0,0 +1,241 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <properties> + + <groovy.version>2.4.7</groovy.version> + <janino.version>2.7.7</janino.version> + + </properties> + + + + <name>openecomp-zusammen-migration</name> + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <artifactId>openecomp-zusammen-plugin</artifactId> + <groupId>org.openecomp.core</groupId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-model-impl</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-zusammen-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.amdocs.zusammen.plugin</groupId> + <artifactId>zusammen-state-store-cassandra-plugin</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <version>RELEASE</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-core</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <artifactId>openecomp-zusammen-migration</artifactId> + <groupId>org.openecomp.core.migration</groupId> + <version>1.1.0-SNAPSHOT</version> + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-lib</artifactId> + <relativePath>../../../lib</relativePath> + <version>1.1.0-SNAPSHOT</version> + </parent> + <build> + <plugins> + + <!-- ================================================== --> + <!-- Set the JDK compiler version. --> + <!-- ================================================== --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.5.1</version> + <inherited>true</inherited> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>license-maven-plugin</artifactId> + <version>1.10</version> + <configuration> + <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage> + <processStartTag> + ============LICENSE_START======================================================= + </processStartTag> + <processEndTag> + ============LICENSE_END========================================================= + </processEndTag> + <sectionDelimiter> + ================================================================================ + </sectionDelimiter> + <licenseName>apache_v2</licenseName> + <inceptionYear>2017</inceptionYear> + <organizationName>AT&T Intellectual Property. All rights reserved. + </organizationName> + <projectName>SDC</projectName> + <canUpdateCopyright>true</canUpdateCopyright> + <canUpdateDescription>true</canUpdateDescription> + <canUpdateLicense>true</canUpdateLicense> + <emptyLineAfterHeader>true</emptyLineAfterHeader> + <verbose>false</verbose> + <includes> + <include>**/*.java</include> + <include>**/*.js</include> + <include>**/*.ts</include> + </includes> + <roots> + <root>src</root> + <root>app</root> + <root>server-mock</root> + <root>typings</root> + </roots> + </configuration> + <executions> + <execution> + <id>first</id> + <goals> + <goal>update-file-header</goal> + </goals> + <!--phase>process-sources</phase--> + </execution> + </executions> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>install</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/lib</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>false</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <!--includeScope>runtime</includeScope--> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <executions> + <execution> + <phase>package</phase> + </execution> + </executions> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <classpathLayoutType>custom</classpathLayoutType> + <customClasspathLayout> + lib/${artifact.artifactId}-${baseVersion}.${artifact.extension} + </customClasspathLayout> + <mainClass>org.openecomp.core.migration.MigrationMain + </mainClass> + </manifest> + <manifestEntries> + <Class-Path>lib/</Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>ant-test</id> + <phase>package</phase> + <configuration> + <tasks> + <fixcrlf srcdir="./" eol="unix" + includes="cassandra2zusammen.sh"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>${mvn.assembly.version}</version> + <executions> + <execution> + <id>Generate assembly</id> + <phase>install</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <descriptors> + <descriptor>${basedir}/src/main/assembly/migration-lib-assembly.xml + </descriptor> + </descriptors> + <finalName>openecomp-zusammen-migration-lib</finalName> + </configuration> + </plugin> + + </plugins> + </build> + +</project> diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml new file mode 100644 index 0000000000..42296baa6e --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml @@ -0,0 +1,41 @@ +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> + + <formats> + <format>zip</format> + </formats> + + <includeBaseDirectory>false</includeBaseDirectory> + + <!--files> + <file> + <source>../cassandra2zusammen.sh</source> + </file> + </files--> + + <fileSets> + <fileSet> + <directory>${basedir}/..</directory> + <includes> + <include>cassandra2zusammen.sh</include> + </includes> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + </fileSet> + <fileSet> + <directory>${basedir}/target</directory> + <includes> + <include> + openecomp-zusammen*.jar + </include> + </includes> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>${basedir}/target/lib</directory> + <outputDirectory>/lib</outputDirectory> + </fileSet> + </fileSets> +</assembly> + diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java new file mode 100644 index 0000000000..283c9cf25d --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java @@ -0,0 +1,485 @@ +package org.openecomp.core.migration; + +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.UserInfo; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.ItemCassandraDao; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao; +import org.openecomp.core.migration.convertors.ComponentConvertor; +import org.openecomp.core.migration.convertors.EntitlementPoolConvertor; +import org.openecomp.core.migration.convertors.FeatureGroupConvertor; +import org.openecomp.core.migration.convertors.LKGConvertor; +import org.openecomp.core.migration.convertors.LicenseAgreementConvertor; +import org.openecomp.core.migration.convertors.MibConvertor; +import org.openecomp.core.migration.convertors.NetworkConvertor; +import org.openecomp.core.migration.convertors.NicConvertor; +import org.openecomp.core.migration.convertors.OrchestrationTemplateCandidateConvertor; +import org.openecomp.core.migration.convertors.ProcessConvertor; +import org.openecomp.core.migration.convertors.VlmConvertor; +import org.openecomp.core.migration.convertors.VspInformationConvertor; +import org.openecomp.core.migration.convertors.VspServiceArtifactConvertor; +import org.openecomp.core.migration.convertors.VspServiceTemplateConvertor; +import org.openecomp.core.migration.loaders.ComponentCassandraLoader; +import org.openecomp.core.migration.loaders.EntitlementPoolCassandraLoader; +import org.openecomp.core.migration.loaders.FeatureGroupCassandraLoader; +import org.openecomp.core.migration.loaders.LKGCassandraLoader; +import org.openecomp.core.migration.loaders.LicenseAgreementCassandraLoader; +import org.openecomp.core.migration.loaders.MibCassandraLoader; +import org.openecomp.core.migration.loaders.NetworkCassandraLoader; +import org.openecomp.core.migration.loaders.NicCassandraLoader; +import org.openecomp.core.migration.loaders.OrchestrationTemplateCandidateCassandraLoader; +import org.openecomp.core.migration.loaders.ProcessCassandraLoader; +import org.openecomp.core.migration.loaders.ServiceArtifactCassandraLoader; +import org.openecomp.core.migration.loaders.ServiceTemplateCassandraLoader; +import org.openecomp.core.migration.loaders.VendorLicenseModelCassandraLoader; +import org.openecomp.core.migration.loaders.VendorSoftwareProductInfoLoader; +import org.openecomp.core.migration.loaders.VersionInfoCassandraLoader; +import org.openecomp.core.migration.loaders.VspInformation; +import org.openecomp.core.migration.store.ElementHandler; +import org.openecomp.core.migration.store.ItemHandler; +import org.openecomp.core.migration.util.marker.MigrationMarker; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer; +import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity; + +import java.time.Duration; +import java.time.Instant; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import static org.openecomp.core.migration.util.Utils.printMessage; + +public class MigrationMain { + private static final String GLOBAL_USER = "GLOBAL_USER"; + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + private static int status = 0; + + public static Map<String, VersionInfoEntity> versionInfoMap = new HashMap<>(); + + public static void main(String[] args) { + CassandraElementRepository cassandraElementRepository = new CassandraElementRepository(); + CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem(); + printMessage(logger, "Checking whether a migration has already been run."); + if (MigrationMarker.isMigrated()) { + printMessage(logger, "The DB has already been migrated, this script will now exit."); + return; + } + ItemCassandraDao itemCassandraDao = new ItemCassandraDao(); + VersionCassandraDao versionCassandraDao = new VersionCassandraDao(); + SessionContext context = new SessionContext(); + context.setUser(new UserInfo(GLOBAL_USER)); + context.setTenant("dox"); + printMessage(logger, "Starting migration.\n"); + Instant startTime = Instant.now(); + + migrateToZusammen(cassandraElementRepository, itemCassandraDao, versionCassandraDao, context); + + Instant stopTime = Instant.now(); + Duration duration = Duration.between(startTime, stopTime); + long minutesPart = duration.toMinutes(); + long secondsPart = duration.minusMinutes(minutesPart).getSeconds(); + + if (status == 0) { + MigrationMarker.markMigrated(); + } + printMessage(logger, + "Migration finished . Total run time was : " + minutesPart + ":" + secondsPart + + " minutes"); + System.exit(status); + } + + + private static void migrateToZusammen(CassandraElementRepository cassandraElementRepository, + ItemCassandraDao itemCassandraDao, + VersionCassandraDao versionCassandraDao, + SessionContext context) { + loadVersionInfo(); + + + try { + convertVsp(context, itemCassandraDao, versionCassandraDao, cassandraElementRepository); + printMessage(logger, "Converted VSPs\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for VSPs ,the error is :"); + e.printStackTrace(); + status = -1; + } + + try { + convertOrchestrationTemplateCandidate(context, cassandraElementRepository); + printMessage(logger, "Converted OrchestrationTemplateCandidates\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for OrchestrationTemplateCandidates ,the error is :"); + e.printStackTrace(); + status = -1; + } + + + try { + convertComponent(context, cassandraElementRepository); + printMessage(logger, "Converted Components\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for Components ,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertNic(context, cassandraElementRepository); + printMessage(logger, "Converted Nics\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for Nics ,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertNetwork(context, cassandraElementRepository); + printMessage(logger, "Converted Networks\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for Networks ,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertMibs(context, cassandraElementRepository); + printMessage(logger, "Converted MIBs\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for MIBs,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertServiceArtifact(context, cassandraElementRepository); + printMessage(logger, "Converted Service Artifacts\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for Service Artifacts,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertServiceTemplate(context, cassandraElementRepository); + printMessage(logger, "Converted Service Templates\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for Service Templates,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertProcesses(context, cassandraElementRepository); + printMessage(logger, "Converted Processes\n"); + } catch (Exception e) { + printMessage(logger, + "Could not perform migration for Processes,the error is :"); + e.printStackTrace(); + status = -1; + } + + + try { + convertVlm(context, itemCassandraDao, versionCassandraDao, cassandraElementRepository); + printMessage(logger, "Converted VLMs\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for VLMs,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertLKG(context, cassandraElementRepository); + printMessage(logger, "Converted LKGs\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for LKGs,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertFeatureGroup(context, cassandraElementRepository); + printMessage(logger, "Converted Feature Groups\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for Feature Groups,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertEP(context, cassandraElementRepository); + printMessage(logger, "Converted EPs\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for EPs,the error is :"); + e.printStackTrace(); + status = -1; + } + try { + convertLicenseAgreement(context, cassandraElementRepository); + printMessage(logger, "Converted License Agreements\n"); + } catch (Exception e) { + printMessage(logger, "Could not perform migration for License Agreements,the error is :"); + e.printStackTrace(); + status = -1; + } + } + + private static void convertOrchestrationTemplateCandidate(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + OrchestrationTemplateCandidateCassandraLoader orchestrationTemplateCandidateCassandraLoader = + new OrchestrationTemplateCandidateCassandraLoader(); + + orchestrationTemplateCandidateCassandraLoader.list().stream() + .filter(entity -> needMigration(entity.getId(), entity.getVersion())) + .forEach(entity -> ElementHandler + .save(context, cassandraElementRepository, entity.getId(), entity.getVersion(), + OrchestrationTemplateCandidateConvertor + .convertOrchestrationTemplateCandidateToElement(entity))); + } + + private static void loadVersionInfo() { + + VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader(); + Collection<VersionInfoEntity> versions = + versionInfoCassandraLoader.list(); + + versions.forEach(versionInfoEntity -> versionInfoMap.put(versionInfoEntity.getEntityId + (), versionInfoEntity)); + + + } + + private static void convertMibs(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + MibCassandraLoader cassandraLoader = new MibCassandraLoader(); + Collection<MibEntity> mibs = cassandraLoader.list(); + mibs.stream().filter(mibEntity -> needMigration(mibEntity.getVspId(), mibEntity.getVersion())) + .forEach + (mibEntity -> { + ElementHandler.save(context, cassandraElementRepository, + mibEntity + .getVspId(), mibEntity.getVersion(), + MibConvertor.convertMibToElement + (mibEntity)); + }); + } + + private static void convertProcesses(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + ProcessCassandraLoader cassandraLoader = new ProcessCassandraLoader(); + Collection<ProcessEntity> processes = cassandraLoader.list(); + processes.stream() + .filter(processEntity -> needMigration(processEntity.getVspId(), processEntity.getVersion + ())).forEach(processEntity -> { + ElementHandler.save( + context, + cassandraElementRepository, + processEntity + .getId(), processEntity.getVersion(), + ProcessConvertor.convertProcessToElement(processEntity)); + }); + } + + private static void convertVsp(SessionContext context, ItemCassandraDao itemCassandraDao, + VersionCassandraDao versionCassandraDao, + CassandraElementRepository cassandraElementRepository) { + VendorSoftwareProductInfoLoader vendorSoftwareProductInfoLoader = new + VendorSoftwareProductInfoLoader(); + Collection<VspInformation> vsps = + vendorSoftwareProductInfoLoader.list(); + vsps.stream().filter(vspInformation -> needMigration(vspInformation.getId(), + vspInformation.getVersion())).forEach + (vspInformation + -> + ItemHandler.save(context, + itemCassandraDao, + versionCassandraDao, + vspInformation.getId(), vspInformation + .getVersion(), + VspInformationConvertor + .getVspInfo + (vspInformation), + VspInformationConvertor.getItemVersionData(vspInformation), + vspInformation.getWritetimeMicroSeconds())); + + vsps.stream().filter(vspInformation -> needMigration(vspInformation.getId(), + vspInformation.getVersion())) + .forEach(vspInformation -> ElementHandler.save(context, cassandraElementRepository, + vspInformation.getId(), vspInformation.getVersion(), + VspInformationConvertor.convertVspToElement + (vspInformation))); + } + + private static void convertVlm(SessionContext context, ItemCassandraDao itemCassandraDao, + VersionCassandraDao versionCassandraDao, + CassandraElementRepository cassandraElementRepository) { + VendorLicenseModelCassandraLoader + vendorLicenseModelCassandraDao = new VendorLicenseModelCassandraLoader(); + Collection<VendorLicenseModelEntity> vlms = + vendorLicenseModelCassandraDao.list(); + vlms.stream().filter(vlm -> needMigration(vlm.getId(), vlm.getVersion())).forEach(vlmEntity -> + ItemHandler.save + (context, itemCassandraDao, + versionCassandraDao, + vlmEntity.getId(), vlmEntity.getVersion(), + VlmConvertor.getVlmInfo + (vlmEntity), + VlmConvertor.getItemVersionData(vlmEntity), new Date().getTime())); + vlms.stream().filter(vlm -> needMigration(vlm.getId(), vlm.getVersion())) + .forEach(vlmEntity -> ElementHandler.save(context, cassandraElementRepository, + vlmEntity.getId(), vlmEntity.getVersion(), + VlmConvertor.convertVlmToElement + (vlmEntity))); + + } + + private static void convertNic(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + NicCassandraLoader nicCassandraLoader = new NicCassandraLoader(); + Collection<NicEntity> nics = nicCassandraLoader.list(); + nics.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion + ())).forEach(nicEntity -> ElementHandler.save(context, cassandraElementRepository, + nicEntity.getVspId(), nicEntity.getVersion(), NicConvertor.convertNicToElement + (nicEntity))); + + } + + private static void convertNetwork(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + NetworkCassandraLoader networkCassandraLoader = new NetworkCassandraLoader(); + Collection<NetworkEntity> networks = networkCassandraLoader.list(); + networks.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion + ())).forEach(networkEntity -> ElementHandler.save(context, cassandraElementRepository, + networkEntity.getVspId(), networkEntity.getVersion(), NetworkConvertor + .convertNetworkToElement(networkEntity))); + + } + + private static void convertComponent(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + ComponentCassandraLoader componentCassandraLoader = new ComponentCassandraLoader(); + Collection<ComponentEntity> components = componentCassandraLoader.list(); + components.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion + ())).forEach(componentEntity -> ElementHandler.save(context, cassandraElementRepository, + componentEntity + .getVspId(), componentEntity.getVersion(), ComponentConvertor + .convertComponentToElement(componentEntity))); + + } + + private static void convertServiceArtifact(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + ServiceArtifactCassandraLoader serviceArtifactCassandraLoader = + new ServiceArtifactCassandraLoader(); + Collection<ServiceArtifact> serviceArtifacts = serviceArtifactCassandraLoader.list(); + serviceArtifacts.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion + ())).forEach(serviceArtifact -> ElementHandler.save(context, + cassandraElementRepository, + serviceArtifact + .getVspId(), serviceArtifact.getVersion(), + VspServiceArtifactConvertor + .convertServiceArtifactToElement(serviceArtifact))); + + } + + private static void convertServiceTemplate(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + ServiceTemplateCassandraLoader serviceTemplateCassandraLoader = + new ServiceTemplateCassandraLoader(); + Collection<ServiceTemplate> serviceTemplates = serviceTemplateCassandraLoader.list(); + serviceTemplates.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion + ())).forEach(serviceTemplate -> ElementHandler.save(context, + cassandraElementRepository, + serviceTemplate + .getVspId(), serviceTemplate.getVersion(), + VspServiceTemplateConvertor + .convertServiceTemplateToElement(serviceTemplate))); + + } + + private static void convertLKG(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + LKGCassandraLoader LKGCassandraLoader = new LKGCassandraLoader(); + Collection<LicenseKeyGroupEntity> lkgs = LKGCassandraLoader.list(); + lkgs.stream().filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion + ())) + .forEach(licenseKeyGroupEntity -> ElementHandler.save(context, cassandraElementRepository, + licenseKeyGroupEntity + .getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion(), + LKGConvertor.convertLKGToElement + (licenseKeyGroupEntity))); + } + + private static void convertEP(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + EntitlementPoolCassandraLoader entitlementPoolCassandraLoader = + new EntitlementPoolCassandraLoader(); + Collection<EntitlementPoolEntity> entitlementPools = entitlementPoolCassandraLoader.list(); + entitlementPools.stream() + .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion + ())) + .forEach(entitlementPoolEntity -> ElementHandler.save(context, cassandraElementRepository, + entitlementPoolEntity + .getVendorLicenseModelId(), entitlementPoolEntity.getVersion(), + EntitlementPoolConvertor.convertEntitlementPoolToElement(entitlementPoolEntity))); + } + + private static void convertFeatureGroup(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + FeatureGroupCassandraLoader featureGroupCassandraLoader = new FeatureGroupCassandraLoader(); + Collection<FeatureGroupEntity> featureGroupEntities = featureGroupCassandraLoader.list(); + featureGroupEntities.stream() + .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion + ())) + .forEach(featureGroupEntity -> ElementHandler.save(context, cassandraElementRepository, + featureGroupEntity + .getVendorLicenseModelId(), featureGroupEntity.getVersion(), + FeatureGroupConvertor.convertFeatureGroupToElement(featureGroupEntity))); + } + + private static void convertLicenseAgreement(SessionContext context, + CassandraElementRepository cassandraElementRepository) { + LicenseAgreementCassandraLoader licenseAgreementCassandraLoader = + new LicenseAgreementCassandraLoader(); + Collection<LicenseAgreementEntity> licenseAgreementEntities = + licenseAgreementCassandraLoader.list(); + licenseAgreementEntities.stream() + .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion + ())) + .forEach(licenseAgreementEntity -> ElementHandler.save(context, cassandraElementRepository, + licenseAgreementEntity + .getVendorLicenseModelId(), licenseAgreementEntity.getVersion(), + LicenseAgreementConvertor.convertLicenseAgreementToElement(licenseAgreementEntity))); + } + + + private static boolean needMigration(String itemId, Version versionId) { + + VersionInfoEntity versionInfo = + MigrationMain.versionInfoMap.get(itemId); + if (versionInfo == null) { + printMessage(logger, "ItemId: " + itemId + " is not in version_info table."); + return false; + } + return (versionInfo.getCandidate() != null && versionId.equals(versionInfo.getCandidate() + .getVersion())) + || (versionInfo + .getViewableVersions() != null && versionInfo + .getViewableVersions().contains(versionId)); + } + + +} 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())); + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java new file mode 100644 index 0000000000..3e00f9d2bc --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; + +import java.util.Collection; + +public class ComponentCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final ComponentAccessor accessor = + noSqlDb.getMappingManager().createAccessor(ComponentAccessor.class); + + + public Collection<ComponentEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface ComponentAccessor { + + @Query( + "select * from vsp_component ") + Result<ComponentEntity> list(); + + + } + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java new file mode 100644 index 0000000000..c307bfcdf6 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java @@ -0,0 +1,31 @@ +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; + +import java.util.Collection; + +/** + * Created by ayalaben on 4/24/2017 + */ +public class EntitlementPoolCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + + private static final EntitlementPoolCassandraLoader.EntitlementPoolAccessor accessor = + noSqlDb.getMappingManager().createAccessor(EntitlementPoolCassandraLoader.EntitlementPoolAccessor.class); + + public Collection<EntitlementPoolEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface EntitlementPoolAccessor { + @Query("select * from entitlement_pool ") + Result<EntitlementPoolEntity> list(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java new file mode 100644 index 0000000000..0c7627f177 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java @@ -0,0 +1,30 @@ +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; + +import java.util.Collection; + +/** + * Created by ayalaben on 4/25/2017. + */ +public class FeatureGroupCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final FeatureGroupCassandraLoader.FGAccessor accessor = + noSqlDb.getMappingManager().createAccessor(FeatureGroupCassandraLoader.FGAccessor.class); + + public Collection<FeatureGroupEntity> list() { + return accessor.getAll().all(); + } + + @Accessor + interface FGAccessor { + @Query("SELECT * FROM feature_group") + Result<FeatureGroupEntity> getAll(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java new file mode 100644 index 0000000000..891a69eb14 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java @@ -0,0 +1,31 @@ +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; + +import java.util.Collection; + +/** + * Created by ayalaben on 4/24/2017 + */ +public class LKGCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final LKGCassandraLoader.LKGAccessor accessor = + noSqlDb.getMappingManager().createAccessor(LKGCassandraLoader.LKGAccessor.class); + + public Collection<LicenseKeyGroupEntity> list() { + return accessor.getAll().all(); + } + + @Accessor + interface LKGAccessor { + @Query("SELECT * FROM license_key_group") + Result<LicenseKeyGroupEntity> getAll(); + + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java new file mode 100644 index 0000000000..ca44209bdb --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java @@ -0,0 +1,31 @@ +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; + +import java.util.Collection; + +/** + * Created by ayalaben on 4/25/2017. + */ +public class LicenseAgreementCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final LicenseAgreementCassandraLoader.LicenseAgreementAccessor accessor = + noSqlDb.getMappingManager().createAccessor(LicenseAgreementCassandraLoader.LicenseAgreementAccessor.class); + + public Collection<LicenseAgreementEntity> list() { + return accessor.getAll().all(); + } + + @Accessor + interface LicenseAgreementAccessor { + @Query("SELECT * FROM license_agreement") + Result<LicenseAgreementEntity> getAll(); + + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java new file mode 100644 index 0000000000..fdb534df32 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity; + +import java.util.Collection; + +public class MibCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final MibAccessor accessor = + noSqlDb.getMappingManager().createAccessor(MibAccessor.class); + + + public Collection<MibEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface MibAccessor { + + @Query( + "select * from vsp_component_artifact") + Result<MibEntity> list(); + + + } + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java new file mode 100644 index 0000000000..7ce93bccf2 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java @@ -0,0 +1,35 @@ +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; + +import java.util.Collection; + +/** + * @author katyr + * @since April 23, 2017 + */ + +public class NetworkCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final NetworkCassandraLoader.NetworkAccessor accessor = + noSqlDb.getMappingManager().createAccessor(NetworkCassandraLoader.NetworkAccessor.class); + + + public Collection<NetworkEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface NetworkAccessor { + + @Query( + "select * from vsp_network ") + Result<NetworkEntity> list(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java new file mode 100644 index 0000000000..fea9c089b5 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Mapper; +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.UDTMapper; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public class NicCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper<NicEntity> mapper = + noSqlDb.getMappingManager().mapper(NicEntity.class); + private static final NicAccessor accessor = + noSqlDb.getMappingManager().createAccessor(NicAccessor.class); + private static final UDTMapper<Version> versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + + public Collection<NicEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface NicAccessor { + + @Query( + "select vsp_id, version, component_id, nic_id, composition_data,questionnaire_data " + + " from vsp_component_nic ") + Result<NicEntity> list(); + + + } + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java new file mode 100644 index 0000000000..b8c173843d --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateDataEntity; + +import java.util.Collection; + +public class OrchestrationTemplateCandidateCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final OrchestrationTemplateCandidateAccessor accessor = + noSqlDb.getMappingManager().createAccessor(OrchestrationTemplateCandidateAccessor.class); + + + public Collection<OrchestrationTemplateCandidateDataEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface OrchestrationTemplateCandidateAccessor { + + @Query( + "select * from vsp_orchestration_template_candidate ") + Result<OrchestrationTemplateCandidateDataEntity> list(); + + + } + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java new file mode 100644 index 0000000000..6672af5fb4 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; + +import java.util.Collection; + +public class ProcessCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final ProcessAccessor accessor = + noSqlDb.getMappingManager().createAccessor(ProcessAccessor.class); + + + public Collection<ProcessEntity> list() { + return accessor.list().all(); + } + + @Accessor + interface ProcessAccessor { + + @Query( + "select * from vsp_process") + Result<ProcessEntity> list(); + + + } + + + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java new file mode 100644 index 0000000000..523166205a --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.model.types.ServiceArtifactEntity; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class ServiceArtifactCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final VspServiceArtifactAccessor accessor = + noSqlDb.getMappingManager().createAccessor( + VspServiceArtifactAccessor.class); + + + public Collection<ServiceArtifact> list() { + + + List<ServiceArtifactEntity> entityList = accessor.listAll().all(); + + return entityList.stream().map(entity -> entity.getServiceArtifact()) + .collect(Collectors.toList()); + } + + @Accessor + interface VspServiceArtifactAccessor { + + @Query("SELECT * FROM vsp_service_artifact") + Result<ServiceArtifactEntity> listAll(); + + + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java new file mode 100644 index 0000000000..f7e5853ffb --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.model.types.ServiceTemplateEntity; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class ServiceTemplateCassandraLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final VspServiceTemplateAccessor accessor = + noSqlDb.getMappingManager().createAccessor( + VspServiceTemplateAccessor.class); + + + public Collection<ServiceTemplate> list() { + + + List<ServiceTemplateEntity> entityList = accessor.listAll().all(); + + return entityList.stream().map(entity -> entity.getServiceTemplate()) + .collect(Collectors.toList()); + } + + @Accessor + interface VspServiceTemplateAccessor { + + @Query("SELECT * FROM vsp_service_template") + Result<ServiceTemplateEntity> listAll(); + + + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java new file mode 100644 index 0000000000..c02cc1e4ef --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; + +import java.util.Collection; + +public class VendorLicenseModelCassandraLoader { + + private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static VendorLicenseModelAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VendorLicenseModelAccessor.class); + + + public Collection<VendorLicenseModelEntity> list() { + return accessor.getAll().all(); + } + + @Accessor + interface VendorLicenseModelAccessor { + + @Query("SELECT * FROM vendor_license_model") + Result<VendorLicenseModelEntity> getAll(); + + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java new file mode 100644 index 0000000000..bac4b6e440 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.core.ResultSet; +import com.datastax.driver.core.UDTValue; +import com.datastax.driver.mapping.Mapper; +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.UDTMapper; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.dao.impl.CassandraBaseDao; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; + +import java.util.Collection; + +public class VendorSoftwareProductInfoLoader { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper<VspInformation> mapper = + noSqlDb.getMappingManager().mapper(VspInformation.class); + private static final VendorSoftwareProductInfoAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VendorSoftwareProductInfoAccessor.class); + private static final UDTMapper<Version> versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + + public Collection<VspInformation> list() { + return accessor.listAll().all(); + } + + + @Accessor + interface VendorSoftwareProductInfoAccessor { + + @Query( + "SELECT * " + + "FROM " + + "vsp_information") + Result<VspInformation> listAll(); + + + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java new file mode 100644 index 0000000000..2a6efd22f3 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.Mapper; +import com.datastax.driver.mapping.Result; +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.dao.impl.CassandraBaseDao; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.versioning.dao.VersionInfoDao; +import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity; + +import java.util.Collection; + +public class VersionInfoCassandraLoader { + + private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static Mapper<VersionInfoEntity> mapper = + noSqlDb.getMappingManager().mapper(VersionInfoEntity.class); + private static VersionInfoAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VersionInfoAccessor.class); + + + + + public Collection<VersionInfoEntity> list() { + return accessor.getAll().all(); + } + + @Accessor + interface VersionInfoAccessor { + @Query("select * from version_info ") + Result<VersionInfoEntity> getAll(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java new file mode 100644 index 0000000000..2db1b09db3 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java @@ -0,0 +1,276 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.core.migration.loaders; + +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Computed; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.nio.ByteBuffer; +import java.util.List; + +@Table(keyspace = "dox", name = "vsp_information") +public class VspInformation { + public static final String ENTITY_TYPE = "Vendor Software Product"; + + @PartitionKey + @Column(name = "vsp_id") + private String id; + + @PartitionKey(value = 1) + @Frozen + private Version version; + + private String name; + private String description; + + private String category; + + @Column(name = "sub_category") + private String subCategory; + + private String icon; + + @Column(name = "vendor_name") + private String vendorName; + + @Column(name = "vendor_id") + private String vendorId; + + @Column(name = "vlm_version") + @Frozen + private Version vlmVersion; + + @Column(name = "license_agreement") + private String licenseAgreement; + + @Column(name = "feature_groups") + private List<String> featureGroups; + + @Column(name = "package_name") + private String packageName; + + @Column(name = "package_version") + private String packageVersion; + + @Column(name = "validation_data") + private String validationData; + + @Column(name = "is_old_version") + private String isOldVersion; + + @Column(name = "questionnaire_data") + private String questionnaireData; + + @Column(name = "content_data") + private ByteBuffer contentData; + + + @Computed("writetime(name)") + private Long writetimeMicroSeconds; + + + public VspInformation() { + } + + public VspInformation(String id, Version version) { + this.id = id; + this.version = version; + } + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorId() { + return vendorId; + } + + public void setVendorId(String vendorId) { + this.vendorId = vendorId; + } + + public Version getVlmVersion() { + return vlmVersion; + } + + public void setVlmVersion(Version vlmVersion) { + this.vlmVersion = vlmVersion; + } + + public String getLicenseAgreement() { + return licenseAgreement; + } + + public void setLicenseAgreement(String licenseAgreement) { + this.licenseAgreement = licenseAgreement; + } + + public List<String> getFeatureGroups() { + return featureGroups; + } + + public void setFeatureGroups(List<String> featureGroups) { + this.featureGroups = featureGroups; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getPackageVersion() { + return packageVersion; + } + + public void setPackageVersion(String packageVersion) { + this.packageVersion = packageVersion; + } + + public String getValidationData() { + return validationData; + } + + public void setValidationData(String validationData) { + this.validationData = validationData; + } + + public ValidationStructureList getValidationDataStructure() { + return validationData == null ? null + : JsonUtil.json2Object(validationData, ValidationStructureList.class); + } + + public void setValidationDataStructure(ValidationStructureList validationData) { + this.validationData = validationData == null ? null + : JsonUtil.object2Json(validationData); + } + + public Long getWritetimeMicroSeconds() { + return this.writetimeMicroSeconds; + } + + public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) { + this.writetimeMicroSeconds = writetimeMicroSeconds; + } + + public String getIsOldVersion() { + return this.isOldVersion; + } + + public void setIsOldVersion(String oldVersion) { + this.isOldVersion = oldVersion; + } + + public void setVersion(Version version) { + this.version = version; + } + + public Version getVersion() { + return version; + } + + public String getQuestionnaireData() { + return questionnaireData; + } + + public void setQuestionnaireData(String questionnaireData) { + this.questionnaireData = questionnaireData; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Vsp id = ").append(this.id); + sb.append("Version = ").append(this.version); + + return sb.toString(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java new file mode 100644 index 0000000000..34e7d79001 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java @@ -0,0 +1,136 @@ +package org.openecomp.core.migration.store; + +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.Namespace; +import com.amdocs.zusammen.datatypes.SessionContext; +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.MigrationMain; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil; +import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository; +import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ElementHandler { + + private static final String GLOBAL_USER = "GLOBAL_USER"; + + public static void save(SessionContext context, + CassandraElementRepository cassandraElementRepository, + String itemId, Version versionId, + CollaborationElement[] elements) { + + ElementEntityContext elementContext; + for (CollaborationElement element : elements) { + + elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId), getVersionId(itemId, + versionId)); + ElementEntity elementEntity = ZusammenPluginUtil.getElementEntity(element); + + cassandraElementRepository.createNamespace(context, elementContext, elementEntity); + + cassandraElementRepository.create(context, elementContext, elementEntity); + + if (isActiveVersion(itemId, versionId)) { + elementContext = + new ElementEntityContext(GLOBAL_USER, new Id(itemId), new Id(versionId.toString())); + cassandraElementRepository.create(context, elementContext, elementEntity); + + } + } + } + + public static CollaborationElement getElementEntity(String itemId, + String versionId, + String elementId, + List<String> elementPath, + Info info, + Collection<Relation> relations, + List<String> subElements, + byte[] data) { + Namespace namespace = new Namespace(); + for (String pathElementId : elementPath) { + namespace = new Namespace(namespace, new Id(pathElementId)); + } + if (namespace.getValue() == null || namespace.getValue().equals("")) { + namespace = Namespace.ROOT_NAMESPACE; + } + CollaborationElement elementEntity = new CollaborationElement(new Id(itemId), new Id(versionId), + namespace, new Id(elementId)); + + Id parentId = namespace.getParentElementId() != null ? namespace.getParentElementId() : Id.ZERO; + elementEntity.setParentId(parentId); + elementEntity.setInfo(info); + elementEntity.setRelations(relations); + if (subElements != null) { + Set<Id> subElementSet = new HashSet<>(); + + subElements.forEach(subElement -> subElementSet.add(new Id(subElement))); + + } + if (data != null) { + elementEntity.setData(new ByteArrayInputStream(data)); + } + + return elementEntity; + } + + public static List<String> getElementPath(String... paths) { + List<String> pathList = new ArrayList<>(); + if (paths != null) { + Collections.addAll(pathList, paths); + } + return pathList; + } + + public static Info getStructuralElementInfo(String elementName) { + Info info = new Info(); + info.setName(elementName); + return info; + } + + + private static Id getVersionId(String itemId, Version versionId) { + VersionInfoEntity versionInfo = + MigrationMain.versionInfoMap.get(itemId); + if (versionInfo == null) { + return new Id(versionId.toString()); + } + Version lastVersion = versionInfo.getCandidate() != null ? versionInfo.getCandidate() + .getVersion() + : versionInfo.getActiveVersion(); + + if (lastVersion.equals(versionId)) { + return new Id(itemId); + } else { + return new Id(versionId.toString()); + } + } + + private static boolean isActiveVersion(String itemId, Version versionId) { + VersionInfoEntity versionInfo = + MigrationMain.versionInfoMap.get(itemId); + return versionInfo != null && versionInfo.getActiveVersion().equals(versionId); + } + + + public static Info getServiceModelElementInfo(String vspServiceModelEntityId, + ServiceTemplate serviceTemplate) { + Info info = ElementHandler.getStructuralElementInfo(vspServiceModelEntityId); + info.addProperty("base", serviceTemplate.getBaseName()); + return info; + + } +}
\ No newline at end of file diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java new file mode 100644 index 0000000000..97f5aaf265 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java @@ -0,0 +1,122 @@ +package org.openecomp.core.migration.store; + +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.Namespace; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.ItemVersionData; +import com.amdocs.zusammen.datatypes.item.Relation; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.ItemCassandraDao; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao; +import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntity; + +import org.openecomp.core.migration.MigrationMain; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ItemHandler { + + public static ElementEntity getElementEntity(String id, List<String> + elementPath, Info info, Collection<Relation> relations, List<String> subElements, + byte[] data) { + ElementEntity elementEntity = new ElementEntity(new Id(id)); + + Namespace namespace = new Namespace(); + for (String elementId : elementPath) { + namespace = new Namespace(namespace, new Id(elementId)); + } + elementEntity.setNamespace(namespace); + elementEntity.setParentId(namespace.getParentElementId()); + elementEntity.setInfo(info); + elementEntity.setRelations(relations); + if(subElements!=null) { + Set<Id> subElementSet = new HashSet<>(); + + subElements.forEach(subElement -> subElementSet.add(new Id(subElement))); + + elementEntity.setSubElementIds(subElementSet); + } + + //elementEntity.setData(new ByteArrayInputStream(data)); + return elementEntity; + } + + public static List<String> getElementPath(String... paths) { + List<String> pathList = new ArrayList<>(); + for (String path : paths) { + pathList.add(path); + } + return pathList; + } + + public static Info getStractualElementInfo(String elementName) { + Info info = new Info(); + info.setName(elementName); + return info; + } + + public static void save(SessionContext context, ItemCassandraDao itemCassandraDao, + VersionCassandraDao versionCassandraDao, + String itemId, Version versionId, Info info, + ItemVersionData itemVersionData, Long writetimeMicroSeconds) { + + Date date = writetimeMicroSeconds==null?new Date():new Date(writetimeMicroSeconds); + itemCassandraDao.create(context,new Id(itemId),info,date); + + versionCassandraDao.create(context, context.getUser().getUserName(),new Id(itemId), + null,getVersionId(itemId,versionId),itemVersionData,date); + + if(isActiveVersion(itemId,versionId)){ + versionCassandraDao.create(context, context.getUser().getUserName(),new Id(itemId), + null,new Id(versionId.toString()),itemVersionData,date); + } + } + + + + private static Info getInfo(VendorLicenseModelEntity vlmEntity) { + Info info = new Info(); + + info.setName(vlmEntity.getVendorName()); + info.setDescription(vlmEntity.getDescription()); + info.addProperty("iconRef",vlmEntity.getIconRef()); + info.addProperty("type",vlmEntity.getIconRef()); + return info; + } + + private static Id getVersionId(String itemId, Version versionId) { + VersionInfoEntity versionInfo = + MigrationMain.versionInfoMap.get(itemId); + if (versionInfo == null) { + return new Id(versionId.toString()); + } + Version lastVersion = versionInfo.getCandidate() != null ? versionInfo.getCandidate() + .getVersion() + : versionInfo.getActiveVersion(); + + if (lastVersion.equals(versionId)) { + return new Id(itemId); + } else { + return new Id(versionId.toString()); + } + } + private static boolean isActiveVersion(String itemId, Version versionId) { + VersionInfoEntity versionInfo = + MigrationMain.versionInfoMap.get(itemId); + if (versionInfo == null) { + return false; + } + + return versionInfo.getActiveVersion().equals(versionId); + } + + +}
\ No newline at end of file diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java new file mode 100644 index 0000000000..ea026e5d4f --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java @@ -0,0 +1,15 @@ +package org.openecomp.core.migration.util; + +import org.openecomp.sdc.logging.api.Logger; + +/** + * @author Avrahamg + * @since April 24, 2017 + */ +public class Utils { + public static void printMessage(Logger logger, String message) { + System.out.println(message); + logger.debug(message); + } +} + diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java new file mode 100644 index 0000000000..4481b431ec --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java @@ -0,0 +1,49 @@ +package org.openecomp.core.migration.util.marker; + +import com.datastax.driver.mapping.annotations.Accessor; +import com.datastax.driver.mapping.annotations.Query; +import org.openecomp.core.migration.MigrationMain; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; + +/** + * @author katyr + * @since May 01, 2017 + */ + +public class MigrationMarker { + + private static Logger logger = LoggerFactory.getLogger(MigrationMain.class); + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final MigrationTableAccessor accessor = + noSqlDb.getMappingManager().createAccessor(MigrationMarker.MigrationTableAccessor.class); + + public static Boolean isMigrated() { + + MigrationMarkerEntity result = accessor.isMigrated(); + if (result == null) { + return false; + } else { + return result.getMigrated(); + } + } + + public static void markMigrated() { + accessor.markMigrated(); + } + + @Accessor + interface MigrationTableAccessor { + @Query("SELECT * FROM migration where id='1'") + MigrationMarkerEntity isMigrated(); + + + @Query("insert into migration (id,isMigrated) values('1',true)") + void markMigrated(); + + } + +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java new file mode 100644 index 0000000000..47bb91dc49 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java @@ -0,0 +1,45 @@ +package org.openecomp.core.migration.util.marker; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Table; + +/** + * @author katyr + * @since May 03, 2017 + */ + +@Table(keyspace = "dox", name = "migration") +public class MigrationMarkerEntity { + + @ClusteringColumn + private String id; + + @Column(name = "ismigrated") + private Boolean migrated; + + public Boolean getMigrated() { + return migrated; + } + + public void setMigrated(Boolean migrated) { + this.migrated = migrated; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("MigrationMarkerEntity{"); + sb.append("id='").append(id).append('\''); + sb.append(", migrated=").append(migrated); + sb.append('}'); + return sb.toString(); + } +} diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml new file mode 100644 index 0000000000..b1c1335302 --- /dev/null +++ b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration scan="true" scanPeriod="5 seconds"> + + <property scope="system" name="ECOMP-component-name" value="ASDC" /> + <property scope="system" name="ECOMP-subcomponent-name" value="ASDC-BE" /> + <property file="${config.home}/catalog-be/configuration.yaml" /> + <property scope="context" name="enable-all-log" value="false" /> + + <!--statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /> + <include resource="asdc_debug_logback.xml"/--> + + <!-- value used by pattern field list (| - is inter-field separator, || - unavailable or not applicable field value) (m - mandatory, o- optional)--> + <!--timestamp(m)| requestID(m)| serviceInstanceID(o)| threadID(m)| physicalServerName(o)| serviceName(m)| userID(m)| logLevel(m)| severity(o)| serverIpAddress(m)| serverName(m)| clientIpAddress(o)| className(m)| timer(o)| detailedMessage(o)--> + <property name="default-log-pattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{uuid}|%X{serviceInstanceID}|%thread||${ECOMP-subcomponent-name}|%X{userId}|%level|%X{alarmSeverity}|%X{localAddr}|${beFqdn}|%X{remoteAddr}|%logger{35}|%X{timer}|ActivityType=<%M>, Desc=<%msg>%n" /> + + <property name="asdc-debug-log-pattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%msg %n"/> + + <!-- All log --> + <if condition='property("enable-all-log").equalsIgnoreCase("true")'> + <then> + <appender name="ALL_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/all.log + </file> + + <rollingPolicy + class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/all.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${default-log-pattern}</pattern> + </encoder> + </appender> + + <appender name="ASYNC_ALL" class="ch.qos.logback.classic.AsyncAppender"> + <appender-ref ref="ALL_ROLLING" /> + </appender> + </then> + </if> + + <!-- Error log --> + <appender name="ERROR_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/Error.log + </file> + + <!-- Audit messages filter - deny audit messages --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>AUDIT_MARKER</marker> + </evaluator> + <onMismatch>NEUTRAL</onMismatch> + <onMatch>DENY</onMatch> + </filter> + + <!-- Transaction messages filter - deny Transaction messages --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>TRANSACTION_MARKER</marker> + </evaluator> + <onMismatch>NEUTRAL</onMismatch> + <onMatch>DENY</onMatch> + </filter> + + <!-- deny all events with a level below INFO, that is TRACE and DEBUG --> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/Error.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${default-log-pattern}</pattern> + </encoder> + </appender> + + <!-- Debug log --> + <appender name="DEBUG_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/debug.log + </file> + + <!-- No need to deny audit messages - they are INFO only, will be denied + anyway --> + <!-- Transaction messages filter - deny Transaction messages, there are + some DEBUG level messages among them --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>TRANSACTION_MARKER</marker> + </evaluator> + <onMismatch>NEUTRAL</onMismatch> + <onMatch>DENY</onMatch> + </filter> + + <!-- accept DEBUG and TRACE level --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator"> + <expression> + e.level.toInt() <= DEBUG.toInt() + </expression> + </evaluator> + <OnMismatch>DENY</OnMismatch> + <OnMatch>NEUTRAL</OnMatch> + </filter> + + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/debug.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${default-log-pattern}</pattern> + </encoder> + </appender> + + <!-- Debug log --> + <appender name="MIGRATION_DEBUG_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/cassandra2zusammen_migration_debug.log + </file> + + <!-- No need to deny audit messages - they are INFO only, will be denied + anyway --> + <!-- Transaction messages filter - deny Transaction messages, there are + some DEBUG level messages among them --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>TRANSACTION_MARKER</marker> + </evaluator> + <onMismatch>NEUTRAL</onMismatch> + <onMatch>DENY</onMatch> + </filter> + + <!-- accept DEBUG and TRACE level --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator"> + <expression> + e.level.toInt() <= DEBUG.toInt() + </expression> + </evaluator> + <OnMismatch>DENY</OnMismatch> + <OnMatch>NEUTRAL</OnMatch> + </filter> + + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/debug_by_package.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${asdc-debug-log-pattern}</pattern> + </encoder> + </appender> + + <!-- Audit log --> + <appender name="AUDIT_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/audit.log + </file> + + <!-- Audit messages filter - accept audit messages --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>AUDIT_MARKER</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/audit.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${default-log-pattern}</pattern> + </encoder> + </appender> + + <!-- SdncTransaction log --> + <appender name="TRANSACTION_ROLLING" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + + <file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/transaction.log + </file> + + <!-- Transaction messages filter - accept audit messages --> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>TRANSACTION_MARKER</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/transaction.log.%i + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>10</maxIndex> + </rollingPolicy> + + <triggeringPolicy + class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>20MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${default-log-pattern}</pattern> + </encoder> + </appender> + + <!-- Asynchronicity Configurations --> + <appender name="ASYNC_DEBUG" class="ch.qos.logback.classic.AsyncAppender"> + <appender-ref ref="DEBUG_ROLLING" /> + </appender> + + <appender name="ASYNC_TRANSACTION" class="ch.qos.logback.classic.AsyncAppender"> + <appender-ref ref="TRANSACTION_ROLLING" /> + </appender> + + <appender name="ASYNC_ERROR" class="ch.qos.logback.classic.AsyncAppender"> + <appender-ref ref="ERROR_ROLLING" /> + </appender> + + + <root level="INFO"> + <appender-ref ref="ASYNC_ERROR" /> + <appender-ref ref="ASYNC_DEBUG" /> + <appender-ref ref="AUDIT_ROLLING" /> + <appender-ref ref="ASYNC_TRANSACTION" /> + <if condition='property("enable-all-log").equalsIgnoreCase("true")'> + <then> + <appender-ref ref="ALL_ROLLING" /> + </then> + </if> + </root> + + <logger name="org.openecomp.sdc" level="INFO" /> + + <logger name="org.openecomp.core" level="DEBUG" additivity="false"> + <appender-ref ref="MIGRATION_DEBUG_ROLLING" /> + </logger> +</configuration> + + diff --git a/openecomp-be/tools/migration/README b/openecomp-be/tools/migration/README index 7bca1f3f5e..2245aafb99 100644 --- a/openecomp-be/tools/migration/README +++ b/openecomp-be/tools/migration/README @@ -44,9 +44,9 @@ Usage - Exmample for a valid output: - Name: VSP-OK, Id: 9DB0E1563B22481D911ECD33989E1FDD, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP-OK, Id: 9DB0E1563B22481D911ECD33989E1FDD, Vendor: ABC, locked by: None, status not started Service VSP-OK was tested and does not need a migration - Name: VSP02-Checkout, Id: 8DF8D65535414AAAA23682E2532675E6, Vendor: OPENECOMP, locked by: cs0008, status not started + Name: VSP02-Checkout, Id: 8DF8D65535414AAAA23682E2532675E6, Vendor: ABC, locked by: cs0008, status not started Server Error Service VSP02-Checkout was tested and it needs a migration Service VSP02 - Migration start @@ -59,9 +59,9 @@ Usage - done upload Doing new checkin Service VSP-EMPTY - Migration end - Name: VSP-EMPTY, Id: D26892D2839746E18075EF49C4586320, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP-EMPTY, Id: D26892D2839746E18075EF49C4586320, Vendor: ABC, locked by: None, status not started Service VSP-EMPTY was tested and does not need a migration - Name: VSP01, Id: 98F5DDFD4F684086801E86A88A0D77AB, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP01, Id: 98F5DDFD4F684086801E86A88A0D77AB, Vendor: ABC, locked by: None, status not started Server Error Service VSP01 was tested and it needs a migration Service VSP-EMPTY - Migration start @@ -76,13 +76,13 @@ Usage - Example for a case with no migration needed: - Name: VSP-OK, Id: 9DB0E1563B22481D911ECD33989E1FDD, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP-OK, Id: 9DB0E1563B22481D911ECD33989E1FDD, Vendor: ABC, locked by: None, status not started Service VSP-OK was tested and does not need a migration - Name: VSP02-Checkout, Id: 8DF8D65535414AAAA23682E2532675E6, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP02-Checkout, Id: 8DF8D65535414AAAA23682E2532675E6, Vendor: ABC, locked by: None, status not started Service VSP02-Checkout was tested and does not need a migration - Name: VSP-EMPTY, Id: D26892D2839746E18075EF49C4586320, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP-EMPTY, Id: D26892D2839746E18075EF49C4586320, Vendor: ABC, locked by: None, status not started Service VSP-EMPTY was tested and does not need a migration - Name: VSP01, Id: 98F5DDFD4F684086801E86A88A0D77AB, Vendor: OPENECOMP, locked by: None, status not started + Name: VSP01, Id: 98F5DDFD4F684086801E86A88A0D77AB, Vendor: ABC, locked by: None, status not started Service VSP01 was tested and does not need a migration diff --git a/openecomp-be/tools/migration/cassandra2zusammen.sh b/openecomp-be/tools/migration/cassandra2zusammen.sh new file mode 100644 index 0000000000..4765fc3684 --- /dev/null +++ b/openecomp-be/tools/migration/cassandra2zusammen.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +########################################################################################################### +# script name - cassandra2zusammen.sh +# run script - ./cassandra2zusammen.sh +# This script migrates ASDC 1st class citizen entities and their sub-entities from Cassandra to +# Zusammen. +# This script should be run when upgrading from 1702 to 1707 +########################################################################################################### + + +# change exist package and service templates in db +java -Dlog.home=/apps/jetty/base/be/logs -Dconfiguration.yaml=/apps/jetty/base/be/config/catalog-be/configuration.yaml -jar openecomp-zusammen-migration-1.0-SNAPSHOT.jar org.openecomp.core.migration.MigrationMain + +STATUS="${?}" echo "${STATUS}" echo "All log messages for the Cassandra2Zusammen +migration process are in /apps/jetty/base/be/logs/ASDC/ASDC- +BE/cassandra2zusammen_migration_debug.log" |