From f5f13c4f6b6fe3b4d98e349dfd7db59339803436 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:35:04 +0200 Subject: push addional code Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando --- .../openecomp-sdc-model-api/pom.xml | 49 ++++++ .../core/model/dao/EnrichedServiceArtifactDao.java | 28 +++ .../dao/EnrichedServiceArtifactDaoFactory.java | 32 ++++ .../core/model/dao/EnrichedServiceModelDao.java | 42 +++++ .../model/dao/EnrichedServiceModelDaoFactory.java | 32 ++++ .../core/model/dao/EnrichedServiceTemplateDao.java | 26 +++ .../dao/EnrichedServiceTemplateDaoFactory.java | 32 ++++ .../core/model/dao/ServiceArtifactDao.java | 44 +++++ .../core/model/dao/ServiceArtifactDaoFactory.java | 32 ++++ .../core/model/dao/ServiceArtifactDaoInter.java | 44 +++++ .../openecomp/core/model/dao/ServiceModelDao.java | 40 +++++ .../core/model/dao/ServiceModelDaoFactory.java | 31 ++++ .../core/model/dao/ServiceTemplateDao.java | 44 +++++ .../core/model/dao/ServiceTemplateDaoFactory.java | 32 ++++ .../core/model/dao/ServiceTemplateDaoInter.java | 46 +++++ .../model/types/EnrichedServiceArtifactEntity.java | 136 +++++++++++++++ .../model/types/EnrichedServiceTemplateEntity.java | 154 +++++++++++++++++ .../core/model/types/ServiceArtifact.java | 29 ++++ .../core/model/types/ServiceArtifactEntity.java | 136 +++++++++++++++ .../openecomp/core/model/types/ServiceElement.java | 77 +++++++++ .../core/model/types/ServiceElementEntity.java | 31 ++++ .../core/model/types/ServiceTemplate.java | 38 ++++ .../core/model/types/ServiceTemplateEntity.java | 154 +++++++++++++++++ .../src/main/resources/factoryConfiguration.json | 8 + .../openecomp-sdc-model-core/pom.xml | 65 +++++++ .../sdc/model/impl/AbstractServiceModelDao.java | 191 +++++++++++++++++++++ .../openecomp-sdc-model-impl/pom.xml | 61 +++++++ ...chedServiceArtifactDaoCassandraFactoryImpl.java | 36 ++++ .../EnrichedServiceArtifactDaoCassandraImpl.java | 137 +++++++++++++++ .../impl/EnrichedServiceModelDaoFactoryImpl.java | 34 ++++ .../model/impl/EnrichedServiceModelDaoImpl.java | 44 +++++ ...chedServiceTemplateDaoCassandraFactoryImpl.java | 36 ++++ .../EnrichedServiceTemplateDaoCassandraImpl.java | 147 ++++++++++++++++ .../ServiceArtifactDaoCassandraFactoryImpl.java | 34 ++++ .../impl/ServiceArtifactDaoCassandraImpl.java | 139 +++++++++++++++ .../sdc/model/impl/ServiceModelDaoFactoryImpl.java | 34 ++++ .../sdc/model/impl/ServiceModelDaoImpl.java | 38 ++++ .../ServiceTemplateDaoCassandraFactoryImpl.java | 34 ++++ .../impl/ServiceTemplateDaoCassandraImpl.java | 145 ++++++++++++++++ openecomp-be/lib/openecomp-sdc-model-lib/pom.xml | 43 +++++ 40 files changed, 2535 insertions(+) create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoInter.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoInter.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifact.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElement.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElementEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplate.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/resources/factoryConfiguration.json create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/pom.xml create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-model-lib/pom.xml (limited to 'openecomp-be/lib/openecomp-sdc-model-lib') diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml new file mode 100644 index 0000000000..81016a413b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-lib + 1.0.0-SNAPSHOT + ../.. + + + openecomp-sdc-model-api + openecomp-sdc-model-api + + + + org.openecomp.core + openecomp-facade-core + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-validation-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-versioning-core + ${project.version} + + + io.swagger + swagger-annotations + 1.5.3 + + + org.openecomp.core + openecomp-heat-lib + ${project.version} + + + org.openecomp.core + openecomp-tosca-lib + ${project.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDao.java new file mode 100644 index 0000000000..e25845d319 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDao.java @@ -0,0 +1,28 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.sdc.versioning.dao.types.Version; + +public interface EnrichedServiceArtifactDao extends ServiceArtifactDaoInter { + ServiceArtifact getArtifactInfo(String vspId, Version version, String name); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDaoFactory.java new file mode 100644 index 0000000000..3852e983e5 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceArtifactDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class EnrichedServiceArtifactDaoFactory + extends AbstractComponentFactory { + + public static EnrichedServiceArtifactDaoFactory getInstance() { + return AbstractFactory.getInstance(EnrichedServiceArtifactDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java new file mode 100644 index 0000000000..d547316ebf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java @@ -0,0 +1,42 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; + +public interface EnrichedServiceModelDao extends VersionableDao { + + M getServiceModel(String vspId, Version version); + + void storeServiceModel(String vspId, Version version, M serviceModel); + + void storeExternalArtifact(ServiceArtifact serviceArtifact); + + List getExternalArtifacts(String vspId, Version version); + + E getServiceModelInfo(String vspId, Version version, String name); + + List getServiceModelContentNames(); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDaoFactory.java new file mode 100644 index 0000000000..9d18d6c9cf --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class EnrichedServiceModelDaoFactory + extends AbstractComponentFactory { + + public static EnrichedServiceModelDaoFactory getInstance() { + return AbstractFactory.getInstance(EnrichedServiceModelDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDao.java new file mode 100644 index 0000000000..5ea2de7fd9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDao.java @@ -0,0 +1,26 @@ +/*- + * ============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.model.dao; + + +public interface EnrichedServiceTemplateDao extends ServiceTemplateDaoInter { + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDaoFactory.java new file mode 100644 index 0000000000..cab3ca6247 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceTemplateDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class EnrichedServiceTemplateDaoFactory + extends AbstractComponentFactory { + + public static EnrichedServiceTemplateDaoFactory getInstance() { + return AbstractFactory.getInstance(EnrichedServiceTemplateDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDao.java new file mode 100644 index 0000000000..48f59d06ae --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDao.java @@ -0,0 +1,44 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public interface ServiceArtifactDao extends ServiceArtifactDaoInter { + + Collection list(String vspId, Version version); + + void create(ServiceArtifact entity); + + void update(ServiceArtifact entity); + + ServiceArtifact get(String vspId, Version version); + + void delete(String vspId, Version version); + + Object[] getKeys(String vspId, Version version); + + ServiceArtifact getArtifactInfo(String vspId, Version version, String name); + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoFactory.java new file mode 100644 index 0000000000..07c2191a7c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class ServiceArtifactDaoFactory + extends AbstractComponentFactory { + + public static ServiceArtifactDaoFactory getInstance() { + return AbstractFactory.getInstance(ServiceArtifactDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoInter.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoInter.java new file mode 100644 index 0000000000..20d0c56c1b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceArtifactDaoInter.java @@ -0,0 +1,44 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public interface ServiceArtifactDaoInter extends VersionableDao { + + Collection list(String vspId, Version version); + + void create(ServiceArtifact entity); + + void update(ServiceArtifact entity); + + ServiceArtifact get(String vspId, Version version); + + void delete(String vspId, Version version); + + Object[] getKeys(String vspId, Version version); + + ServiceArtifact getArtifactInfo(String vspId, Version version, String name); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java new file mode 100644 index 0000000000..30bb79c100 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java @@ -0,0 +1,40 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; + +public interface ServiceModelDao extends VersionableDao { + + M getServiceModel(String vspId, Version version); + + void storeServiceModel(String vspId, Version version, M serviceModel); + + E getServiceModelInfo(String vspId, Version version, String name); + + void storeExternalArtifact(ServiceArtifact serviceArtifact); + + List getServiceModelContentNames(); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDaoFactory.java new file mode 100644 index 0000000000..19f6cb5c8c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDaoFactory.java @@ -0,0 +1,31 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class ServiceModelDaoFactory extends AbstractComponentFactory { + + public static ServiceModelDaoFactory getInstance() { + return AbstractFactory.getInstance(ServiceModelDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDao.java new file mode 100644 index 0000000000..c0c919b8a0 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDao.java @@ -0,0 +1,44 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public interface ServiceTemplateDao extends ServiceTemplateDaoInter { + void create(ServiceTemplate entity); + + void update(ServiceTemplate entity); + + ServiceTemplate get(String vspId, Version version); + + void delete(String vspId, Version version); + + Object[] getKeys(String vspId, Version version); + + ServiceTemplate getTemplateInfo(String vspId, Version version, String name); + + Collection list(String vspId, Version version); + + String getBase(String vspId, Version version); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoFactory.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoFactory.java new file mode 100644 index 0000000000..65aad1bb97 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoFactory.java @@ -0,0 +1,32 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; + +public abstract class ServiceTemplateDaoFactory + extends AbstractComponentFactory { + + public static ServiceTemplateDaoFactory getInstance() { + return AbstractFactory.getInstance(ServiceTemplateDaoFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoInter.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoInter.java new file mode 100644 index 0000000000..c4c4cb19b7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceTemplateDaoInter.java @@ -0,0 +1,46 @@ +/*- + * ============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.model.dao; + +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; + +public interface ServiceTemplateDaoInter extends VersionableDao { + void create(ServiceTemplate entity); + + void update(ServiceTemplate entity); + + ServiceTemplate get(String vspId, Version version); + + void delete(String vspId, Version version); + + Object[] getKeys(String vspId, Version version); + + ServiceTemplate getTemplateInfo(String vspId, Version version, String name); + + Collection list(String vspId, Version version); + + String getBase(String vspId, Version version); + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java new file mode 100644 index 0000000000..87e25613fc --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java @@ -0,0 +1,136 @@ +/*- + * ============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.model.types; + +import com.google.common.io.ByteStreams; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.IOException; +import java.nio.ByteBuffer; + +@Table(keyspace = "dox", name = "vsp_enriched_service_artifact") +public class EnrichedServiceArtifactEntity implements ServiceElementEntity { + private static final String ENTITY_TYPE; + + static { + ENTITY_TYPE = "Vendor Software Product Service artifact"; + } + + @PartitionKey + @Column(name = "vsp_id") + public String id; + + @PartitionKey(value = 1) + @Frozen + public Version version; + + @ClusteringColumn + @Column(name = "name") + public String name; + + @Column(name = "content_data") + public ByteBuffer contentData; + + public EnrichedServiceArtifactEntity() { + } + + /** + * Instantiates a new Enriched service artifact entity. + * + * @param entity the entity + */ + public EnrichedServiceArtifactEntity(ServiceArtifact entity) { + this.id = entity.getVspId(); + this.version = entity.getVersion(); + this.name = entity.getName(); + + try { + this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent())); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + /** + * Gets service artifact. + * + * @return the service artifact + */ + public ServiceArtifact getServiceArtifact() { + ServiceArtifact serviceArtifact = new ServiceArtifact(); + serviceArtifact.setName(this.getName()); + serviceArtifact.setVersion(this.getVersion()); + serviceArtifact.setContentData(this.getContentData().array()); + serviceArtifact.setVspId(this.getId()); + return serviceArtifact; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java new file mode 100644 index 0000000000..526a901e47 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java @@ -0,0 +1,154 @@ +/*- + * ============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.model.types; + +import com.google.common.io.ByteStreams; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.IOException; +import java.nio.ByteBuffer; + +@Table(keyspace = "dox", name = "vsp_enriched_service_template") +public class EnrichedServiceTemplateEntity implements ServiceElementEntity { + + private static final String ENTITY_TYPE; + + static { + ENTITY_TYPE = "Vendor Software Product Service model"; + } + + @PartitionKey + @Column(name = "vsp_id") + public String id; + + @PartitionKey(value = 1) + @Frozen + public Version version; + + @ClusteringColumn + @Column(name = "name") + public String name; + + @Column(name = "content_data") + public ByteBuffer contentData; + + + @Column(name = "base_name") + private String baseName; + + public EnrichedServiceTemplateEntity() { + } + + /** + * Instantiates a new Enriched service template entity. + * + * @param entity the entity + */ + public EnrichedServiceTemplateEntity(ServiceTemplate entity) { + this.id = entity.getVspId(); + this.version = entity.getVersion(); + this.name = entity.getName(); + this.setBaseName(entity.getBaseName()); + try { + this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent())); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + + } + + + public String getBaseName() { + return baseName; + } + + public void setBaseName(String baseName) { + this.baseName = baseName; + } + + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + + /** + * Gets service template. + * + * @return the service template + */ + public ServiceTemplate getServiceTemplate() { + ServiceTemplate serviceTemplate = new ServiceTemplate(); + serviceTemplate.setName(this.getName()); + serviceTemplate.setVersion(this.getVersion()); + serviceTemplate.setContentData(this.getContentData().array()); + serviceTemplate.setVspId(this.getId()); + serviceTemplate.setBaseName(this.getBaseName()); + return serviceTemplate; + + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifact.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifact.java new file mode 100644 index 0000000000..fad3e604d6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifact.java @@ -0,0 +1,29 @@ +/*- + * ============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.model.types; + +public class ServiceArtifact extends ServiceElement { + + + public ServiceArtifact() { + super(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java new file mode 100644 index 0000000000..c5dfeced8a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java @@ -0,0 +1,136 @@ +/*- + * ============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.model.types; + +import com.google.common.io.ByteStreams; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.IOException; +import java.nio.ByteBuffer; + +@Table(keyspace = "dox", name = "vsp_service_artifact") +public class ServiceArtifactEntity implements ServiceElementEntity { + private static final String ENTITY_TYPE; + + static { + ENTITY_TYPE = "Vendor Software Product Service artifact"; + } + + @PartitionKey + @Column(name = "vsp_id") + public String id; + + @PartitionKey(value = 1) + @Frozen + public Version version; + + @ClusteringColumn + @Column(name = "name") + public String name; + + @Column(name = "content_data") + public ByteBuffer contentData; + + public ServiceArtifactEntity() { + } + + /** + * Instantiates a new Service artifact entity. + * + * @param entity the entity + */ + public ServiceArtifactEntity(ServiceArtifact entity) { + this.id = entity.getVspId(); + this.version = entity.getVersion(); + this.name = entity.getName(); + + try { + this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent())); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + + } + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + /** + * Gets service artifact. + * + * @return the service artifact + */ + public ServiceArtifact getServiceArtifact() { + ServiceArtifact serviceArtifact = new ServiceArtifact(); + serviceArtifact.setName(this.getName()); + serviceArtifact.setVersion(this.getVersion()); + serviceArtifact.setContentData(this.getContentData().array()); + serviceArtifact.setVspId(this.getId()); + return serviceArtifact; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElement.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElement.java new file mode 100644 index 0000000000..114cf03a39 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElement.java @@ -0,0 +1,77 @@ +/*- + * ============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.model.types; + +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +public class ServiceElement { + + private String vspId; + private Version version; + private String name; + private byte[] contentData; + + public ServiceElement() { + } + + public String getVspId() { + return vspId; + } + + public void setVspId(String vspId) { + this.vspId = vspId; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Gets content. + * + * @return the content + */ + public InputStream getContent() { + if (this.contentData == null) { + return null; + } + return new ByteArrayInputStream(contentData); + } + + public void setContentData(byte[] contentData) { + this.contentData = contentData; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElementEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElementEntity.java new file mode 100644 index 0000000000..02249039f8 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceElementEntity.java @@ -0,0 +1,31 @@ +/*- + * ============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.model.types; + +import org.openecomp.sdc.versioning.dao.types.VersionableEntity; + +import java.nio.ByteBuffer; + +public interface ServiceElementEntity extends VersionableEntity { + String getName(); + + ByteBuffer getContentData(); +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplate.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplate.java new file mode 100644 index 0000000000..aa0285d6a9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplate.java @@ -0,0 +1,38 @@ +/*- + * ============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.model.types; + +public class ServiceTemplate extends ServiceElement { + private String baseName; + + public ServiceTemplate() { + } + + + public String getBaseName() { + return baseName; + } + + + public void setBaseName(String baseName) { + this.baseName = baseName; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java new file mode 100644 index 0000000000..f29334678f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java @@ -0,0 +1,154 @@ +/*- + * ============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.model.types; + +import com.google.common.io.ByteStreams; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.Frozen; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.IOException; +import java.nio.ByteBuffer; + +@Table(keyspace = "dox", name = "vsp_service_template") +public class ServiceTemplateEntity implements ServiceElementEntity { + + private static final String ENTITY_TYPE; + + static { + ENTITY_TYPE = "Vendor Software Product Service model"; + } + + @PartitionKey + @Column(name = "vsp_id") + public String id; + + @PartitionKey(value = 1) + @Frozen + public Version version; + + @ClusteringColumn + @Column(name = "name") + public String name; + + @Column(name = "content_data") + public ByteBuffer contentData; + + + @Column(name = "base_name") + private String baseName; + + public ServiceTemplateEntity() { + } + + /** + * Instantiates a new Service template entity. + * + * @param entity the entity + */ + public ServiceTemplateEntity(ServiceTemplate entity) { + this.id = entity.getVspId(); + this.version = entity.getVersion(); + this.name = entity.getName(); + this.setBaseName(entity.getBaseName()); + try { + this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent())); + } catch (IOException ioException) { + throw new RuntimeException(ioException); + } + + } + + + public String getBaseName() { + return baseName; + } + + public void setBaseName(String baseName) { + this.baseName = baseName; + } + + + @Override + public String getEntityType() { + return ENTITY_TYPE; + } + + @Override + public String getFirstClassCitizenId() { + return getId(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public Version getVersion() { + return version; + } + + @Override + public void setVersion(Version version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ByteBuffer getContentData() { + return contentData; + } + + public void setContentData(ByteBuffer contentData) { + this.contentData = contentData; + } + + + /** + * Gets service template. + * + * @return the service template + */ + public ServiceTemplate getServiceTemplate() { + ServiceTemplate serviceTemplate = new ServiceTemplate(); + serviceTemplate.setName(this.getName()); + serviceTemplate.setVersion(this.getVersion()); + serviceTemplate.setContentData(this.getContentData().array()); + serviceTemplate.setVspId(this.getId()); + serviceTemplate.setBaseName(this.getBaseName()); + return serviceTemplate; + + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/resources/factoryConfiguration.json new file mode 100644 index 0000000000..c228b29c57 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/resources/factoryConfiguration.json @@ -0,0 +1,8 @@ +{ + "org.openecomp.core.model.dao.ServiceModelDaoFactory":"org.openecomp.sdc.model.impl.ServiceModelDaoFactoryImpl", + "org.openecomp.core.model.dao.ServiceTemplateDaoFactory":"org.openecomp.sdc.model.impl.ServiceTemplateDaoCassandraFactoryImpl", + "org.openecomp.core.model.dao.ServiceArtifactDaoFactory":"org.openecomp.sdc.model.impl.ServiceArtifactDaoCassandraFactoryImpl", + "org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory":"org.openecomp.sdc.model.impl.EnrichedServiceModelDaoFactoryImpl", + "org.openecomp.core.model.dao.EnrichedServiceTemplateDaoFactory":"org.openecomp.sdc.model.impl.EnrichedServiceTemplateDaoCassandraFactoryImpl", + "org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory":"org.openecomp.sdc.model.impl.EnrichedServiceArtifactDaoCassandraFactoryImpl" +} \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/pom.xml new file mode 100644 index 0000000000..ba4d404ae7 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-lib + 1.0.0-SNAPSHOT + ../.. + + + openecomp-sdc-model-core + openecomp-sdc-model-core + + + + org.slf4j + slf4j-api + 1.7.10 + + + + ch.qos.logback + logback-classic + 1.1.2 + + + + + + org.openecomp.core + openecomp-utilities-lib + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-model-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-versioning-core + ${project.version} + + + + org.openecomp.sdc + openecomp-sdc-datatypes-lib + ${project.version} + + + org.mockito + mockito-all + test + 1.10.19 + + + com.google.guava + guava + 19.0 + + + + + \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java new file mode 100644 index 0000000000..eb993f6fb1 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-core/src/main/java/org/openecomp/sdc/model/impl/AbstractServiceModelDao.java @@ -0,0 +1,191 @@ +/*- + * ============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.sdc.model.impl; + +import org.openecomp.core.model.dao.ServiceArtifactDaoInter; +import org.openecomp.core.model.dao.ServiceTemplateDaoInter; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.model.types.ServiceElement; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import org.openecomp.sdc.versioning.dao.VersionableDao; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.InputStream; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class AbstractServiceModelDao implements VersionableDao { + + protected ServiceTemplateDaoInter templateDao; + protected ServiceArtifactDaoInter artifactDao; + + @Override + public void registerVersioning(String versionableEntityType) { + templateDao.registerVersioning(versionableEntityType); + artifactDao.registerVersioning(versionableEntityType); + } + + + /** + * Gets service model. + * + * @param vspId the vsp id + * @param version the version + * @return the service model + */ + public ToscaServiceModel getServiceModel(String vspId, Version version) { + if (vspId == null || version == null) { + //throw new CoreException() + throw new RuntimeException("missing service model key"); + } + + + FileContentHandler artifactFiles = getArtifacts(vspId, version); + Map serviceTemplates = + getTemplates(vspId, version); + String entryDefinitionServiceTemplate = getServiceBase(vspId, version); + return new ToscaServiceModel(artifactFiles, serviceTemplates, entryDefinitionServiceTemplate); + } + + + public void storeExternalArtifact(ServiceArtifact serviceArtifact) { + artifactDao.create(serviceArtifact); + //TODO: update last modification time + } + + + /** + * Store service model. + * + * @param vspId the vsp id + * @param version the version + * @param toscaServiceModel the tosca service model + */ + public void storeServiceModel(String vspId, Version version, + ToscaServiceModel toscaServiceModel) { + ServiceArtifact entityArt; + + for (String fileName : toscaServiceModel.getArtifactFiles().getFileList()) { + entityArt = new ServiceArtifact(); + entityArt.setContentData( + FileUtils.toByteArray(toscaServiceModel.getArtifactFiles().getFileContent(fileName))); + entityArt.setVspId(vspId); + entityArt.setVersion(version); + entityArt.setName(fileName); + + artifactDao.create(entityArt); + } + + ServiceTemplate entityTmp; + String yaml; + for (Map.Entry + entryTemplate : toscaServiceModel + .getServiceTemplates().entrySet()) { + entityTmp = new ServiceTemplate(); + + yaml = new ToscaExtensionYamlUtil().objectToYaml(entryTemplate.getValue()); + entityTmp.setContentData(yaml.getBytes()); + entityTmp.setVspId(vspId); + entityTmp.setVersion(version); + entityTmp.setName(entryTemplate.getKey()); + entityTmp.setBaseName(toscaServiceModel.getEntryDefinitionServiceTemplate()); + + templateDao.create(entityTmp); + } + + //TODO: update last modification time + } + + + /** + * Gets service model info. + * + * @param vspId the vsp id + * @param version the version + * @param name the name + * @return the service model info + */ + public ServiceElement getServiceModelInfo(String vspId, Version version, String name) { + ServiceElement element = templateDao.getTemplateInfo(vspId, version, name); + if (element != null) { + return element; + } + + element = artifactDao.getArtifactInfo(vspId, version, name); + if (element != null) { + return element; + } + return null; + } + + + /** + * Gets service model content names. + * + * @return the service model content names + */ + public List getServiceModelContentNames() { + + + return null; + } + + + private String getServiceBase(String vspId, Version version) { + return templateDao.getBase(vspId, version); + } + + private Map getTemplates( + String vspId, Version version) { + + Collection templates = templateDao.list(vspId, version); + if (templates == null) { + return null; + } + return templates.stream().collect(Collectors.toMap(template -> template.getName(), + template -> getServiceTemplate(template.getContent()))); + } + + private org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate getServiceTemplate( + InputStream content) { + return new ToscaExtensionYamlUtil() + .yamlToObject(content, org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate.class); + } + + private FileContentHandler getArtifacts(String vspId, Version version) { + Collection templates = artifactDao.list(vspId, version); + if (templates == null) { + return null; + } + + FileContentHandler fileContentHandler = new FileContentHandler(); + templates.stream().forEach(serviceArtifact -> fileContentHandler + .addFile(serviceArtifact.getName(), serviceArtifact.getContent())); + + return fileContentHandler; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml new file mode 100644 index 0000000000..ff376f1e7d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-lib + 1.0.0-SNAPSHOT + ../.. + + + openecomp-sdc-model-impl + openecomp-sdc-model-impl + + + + org.slf4j + slf4j-api + 1.7.10 + + + + ch.qos.logback + logback-classic + 1.1.2 + + + + + + org.openecomp.core + openecomp-utilities-lib + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-model-core + ${project.version} + + + + + org.openecomp.sdc + openecomp-sdc-datatypes-lib + ${project.version} + + + org.mockito + mockito-all + test + 1.10.19 + + + com.google.guava + guava + 19.0 + + + + + \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java new file mode 100644 index 0000000000..13e351c257 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraFactoryImpl.java @@ -0,0 +1,36 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.EnrichedServiceArtifactDao; +import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory; + +public class EnrichedServiceArtifactDaoCassandraFactoryImpl + extends EnrichedServiceArtifactDaoFactory { + private static final EnrichedServiceArtifactDao INSTANCE = + new EnrichedServiceArtifactDaoCassandraImpl(); + + @Override + public EnrichedServiceArtifactDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java new file mode 100644 index 0000000000..d9ebe849e3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceArtifactDaoCassandraImpl.java @@ -0,0 +1,137 @@ +/*- + * ============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.sdc.model.impl; + +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.model.dao.EnrichedServiceArtifactDao; +import org.openecomp.core.model.types.EnrichedServiceArtifactEntity; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +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; +import java.util.List; +import java.util.stream.Collectors; + +public class EnrichedServiceArtifactDaoCassandraImpl implements EnrichedServiceArtifactDao { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper mapper = + noSqlDb.getMappingManager().mapper(EnrichedServiceArtifactEntity.class); + private static final VspServiceArtifactAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VspServiceArtifactAccessor.class); + private static final UDTMapper versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + @Override + public void registerVersioning(String versionableEntityType) { + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, new VersionableEntityMetadata( + mapper.getTableMetadata().getName(), + mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName())); + } + + @Override + public Collection list(String vspId, Version version) { + List entityList; + if (vspId != null && version != null) { + entityList = accessor.list(vspId, versionMapper.toUDT(version)).all(); + } else { + entityList = accessor.listAll().all(); + } + + return entityList.stream().map(entity -> entity.getServiceArtifact()) + .collect(Collectors.toList()); + } + + @Override + public void create(ServiceArtifact entity) { + EnrichedServiceArtifactEntity vspEnrichedServiceArtifactEntity = + new EnrichedServiceArtifactEntity(entity); + mapper.save(vspEnrichedServiceArtifactEntity); + } + + @Override + public void update(ServiceArtifact entity) { + EnrichedServiceArtifactEntity vspEnrichedServiceArtifactEntity = + new EnrichedServiceArtifactEntity(entity); + mapper.save(vspEnrichedServiceArtifactEntity); + } + + @Override + public ServiceArtifact get(String vspId, Version version) { + return mapper.get(getKeys(vspId, version)).getServiceArtifact(); + } + + @Override + public void delete(String vspId, Version version) { + accessor.delete(vspId, versionMapper.toUDT(version)); + } + + @Override + public Object[] getKeys(String vspId, Version version) { + return new Object[]{vspId, versionMapper.toUDT(version)}; + } + + @Override + public ServiceArtifact getArtifactInfo(String vspId, Version version, String name) { + EnrichedServiceArtifactEntity enrichedServiceArtifactEntity = + accessor.getArtifactInfo(vspId, versionMapper.toUDT(version), name).one(); + if (enrichedServiceArtifactEntity == null) { + return null; + } + + return enrichedServiceArtifactEntity.getServiceArtifact(); + } + + + @Accessor + interface VspServiceArtifactAccessor { + + @Query("SELECT vsp_id, version, name ,content_data FROM vsp_enriched_service_artifact") + Result listAll(); + + @Query( + "SELECT vsp_id, version, name ,content_data FROM vsp_enriched_service_artifact " + + "where vsp_id=? and version=? ") + Result list(String vspId, UDTValue version); + + + @Query( + "SELECT vsp_id,version,name,content_data FROM vsp_enriched_service_artifact " + + "where vsp_id=? and version=? and name=?") + Result getArtifactInfo(String vspId, UDTValue version, + String name); + + @Query("DELETE from vsp_enriched_service_artifact where vsp_id=? and version=?") + ResultSet delete(String vspId, UDTValue version); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java new file mode 100644 index 0000000000..326e5e78fc --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoFactoryImpl.java @@ -0,0 +1,34 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.EnrichedServiceModelDao; +import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory; + +public class EnrichedServiceModelDaoFactoryImpl extends EnrichedServiceModelDaoFactory { + private static final EnrichedServiceModelDao INSTANCE = new EnrichedServiceModelDaoImpl(); + + @Override + public EnrichedServiceModelDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java new file mode 100644 index 0000000000..9e784c7fef --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java @@ -0,0 +1,44 @@ +/*- + * ============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.sdc.model.impl; + +import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory; +import org.openecomp.core.model.dao.EnrichedServiceModelDao; +import org.openecomp.core.model.dao.EnrichedServiceTemplateDaoFactory; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.model.types.ServiceElement; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.List; + +public class EnrichedServiceModelDaoImpl extends AbstractServiceModelDao + implements EnrichedServiceModelDao { + public EnrichedServiceModelDaoImpl() { + templateDao = EnrichedServiceTemplateDaoFactory.getInstance().createInterface(); + artifactDao = EnrichedServiceArtifactDaoFactory.getInstance().createInterface(); + } + + @Override + public List getExternalArtifacts(String vspId, Version version) { + return (List) artifactDao.list(vspId, version); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java new file mode 100644 index 0000000000..8103b2cea6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraFactoryImpl.java @@ -0,0 +1,36 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.EnrichedServiceTemplateDao; +import org.openecomp.core.model.dao.EnrichedServiceTemplateDaoFactory; + +public class EnrichedServiceTemplateDaoCassandraFactoryImpl + extends EnrichedServiceTemplateDaoFactory { + private static final EnrichedServiceTemplateDao INSTANCE = + new EnrichedServiceTemplateDaoCassandraImpl(); + + @Override + public EnrichedServiceTemplateDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java new file mode 100644 index 0000000000..f0d4b56204 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceTemplateDaoCassandraImpl.java @@ -0,0 +1,147 @@ +/*- + * ============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.sdc.model.impl; + +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.model.dao.EnrichedServiceTemplateDao; +import org.openecomp.core.model.types.EnrichedServiceTemplateEntity; +import org.openecomp.core.model.types.ServiceTemplate; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +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; +import java.util.List; +import java.util.stream.Collectors; + +public class EnrichedServiceTemplateDaoCassandraImpl implements EnrichedServiceTemplateDao { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper mapper = + noSqlDb.getMappingManager().mapper(EnrichedServiceTemplateEntity.class); + private static final VspServiceTemplateAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VspServiceTemplateAccessor.class); + private static final UDTMapper versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + @Override + public void registerVersioning(String versionableEntityType) { + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, new VersionableEntityMetadata( + mapper.getTableMetadata().getName(), + mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName())); + } + + @Override + public Collection list(String vspId, Version version) { + + List entityList = accessor.list(vspId, version).all(); + return entityList.stream().map(entity -> entity.getServiceTemplate()) + .collect(Collectors.toList()); + } + + @Override + public void create(ServiceTemplate entity) { + EnrichedServiceTemplateEntity vspEnrichedServiceTemplateEntity = + new EnrichedServiceTemplateEntity(entity); + mapper.save(vspEnrichedServiceTemplateEntity); + } + + @Override + public void update(ServiceTemplate entity) { + EnrichedServiceTemplateEntity vspEnrichedServiceTemplateEntity = + new EnrichedServiceTemplateEntity(entity); + mapper.save(vspEnrichedServiceTemplateEntity); + } + + @Override + public ServiceTemplate get(String vspId, Version version) { + return (mapper.get(getKeys(vspId, version))).getServiceTemplate(); + } + + @Override + public void delete(String vspId, Version version) { + mapper.delete(vspId, version); + } + + + @Override + public Object[] getKeys(String vspId, Version version) { + return new Object[]{vspId, versionMapper.toUDT(version)}; + } + + @Override + public ServiceTemplate getTemplateInfo(String vspId, Version version, String name) { + EnrichedServiceTemplateEntity enrichedServiceTemplateEntity = + accessor.getTemplateInfo(vspId, versionMapper.toUDT(version), name).one(); + if (enrichedServiceTemplateEntity == null) { + return null; + } + return enrichedServiceTemplateEntity.getServiceTemplate(); + } + + @Override + public String getBase(String vspId, Version version) { + Result element = + accessor.getBase(vspId, versionMapper.toUDT(version)); + if (element != null) { + EnrichedServiceTemplateEntity vspEnrichedServiceTemplateEntity = element.one(); + if (vspEnrichedServiceTemplateEntity != null) { + return element.one().getBaseName(); + } + } + return null; + } + + + @Accessor + interface VspServiceTemplateAccessor { + + @Query( + "SELECT vsp_id, version, name, base_name ,content_data FROM vsp_enriched_service_template") + Result listAll(); + + @Query( + "SELECT vsp_id, version, name, base_name ,content_data FROM vsp_enriched_service_template " + + "where vsp_id=? and version=?") + Result list(String vspId, Version version); + + + @Query( + "SELECT vsp_id, version, name, base_name ,content_data FROM vsp_enriched_service_template " + + "where vsp_id=? and version=? and name=?") + Result getTemplateInfo(String vspId, UDTValue version, + String name); + + @Query( + "SELECT vsp_id, version, name, base_name FROM vsp_enriched_service_template " + + "where vsp_id=? and version=?") + Result getBase(String vspId, UDTValue version); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java new file mode 100644 index 0000000000..f24fb1b475 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraFactoryImpl.java @@ -0,0 +1,34 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.ServiceArtifactDao; +import org.openecomp.core.model.dao.ServiceArtifactDaoFactory; + +public class ServiceArtifactDaoCassandraFactoryImpl extends ServiceArtifactDaoFactory { + private static final ServiceArtifactDao INSTANCE = new ServiceArtifactDaoCassandraImpl(); + + @Override + public ServiceArtifactDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java new file mode 100644 index 0000000000..c7851c0fd9 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceArtifactDaoCassandraImpl.java @@ -0,0 +1,139 @@ +/*- + * ============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.sdc.model.impl; + +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.model.dao.ServiceArtifactDao; +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 org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class ServiceArtifactDaoCassandraImpl implements ServiceArtifactDao { + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper mapper = + noSqlDb.getMappingManager().mapper(ServiceArtifactEntity.class); + private static final VspServiceArtifactAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VspServiceArtifactAccessor.class); + private static final UDTMapper versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + @Override + public void registerVersioning(String versionableEntityType) { + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, new VersionableEntityMetadata( + mapper.getTableMetadata().getName(), + mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName())); + } + + @Override + public Collection list(String vspId, Version version) { + List entityList; + if (vspId != null && version != null) { + entityList = accessor.list(vspId, versionMapper.toUDT(version)).all(); + } else { + entityList = accessor.listAll().all(); + } + + return entityList.stream().map(entity -> entity.getServiceArtifact()) + .collect(Collectors.toList()); + } + + @Override + public void create(ServiceArtifact entity) { + ServiceArtifactEntity vspServiceArtifactEntity = new ServiceArtifactEntity(entity); + mapper.save(vspServiceArtifactEntity); + } + + @Override + public void update(ServiceArtifact entity) { + ServiceArtifactEntity vspServiceArtifactEntity = new ServiceArtifactEntity(entity); + mapper.save(vspServiceArtifactEntity); + } + + @Override + public ServiceArtifact get(String vspId, Version version) { + return mapper.get(getKeys(vspId, version)).getServiceArtifact(); + } + + @Override + public void delete(String vspId, Version version) { + accessor.delete(vspId, versionMapper.toUDT(version)); + } + + // @Override + // public void deleteArtifacts(String vspId, Version version){ + // accessor.delete(vspId, versionMapper.toUDT(version)); + // } + + @Override + public Object[] getKeys(String vspId, Version version) { + return new Object[]{vspId, versionMapper.toUDT(version)}; + } + + @Override + public ServiceArtifact getArtifactInfo(String vspId, Version version, String name) { + ServiceArtifactEntity serviceArtifactEntity = + accessor.getArtifactInfo(vspId, versionMapper.toUDT(version), name).one(); + if (serviceArtifactEntity == null) { + return null; + } + + return serviceArtifactEntity.getServiceArtifact(); + } + + + @Accessor + interface VspServiceArtifactAccessor { + + @Query("SELECT vsp_id, version, name ,content_data FROM vsp_service_artifact") + Result listAll(); + + @Query( + "SELECT vsp_id, version, name ,content_data " + + "FROM vsp_service_artifact where vsp_id=? and version=? ") + Result list(String vspId, UDTValue version); + + @Query( + "SELECT vsp_id,version,name,content_data FROM " + + "vsp_service_artifact where vsp_id=? and version=? and name=?") + Result getArtifactInfo(String vspId, UDTValue version, String name); + + @Query("DELETE from vsp_service_artifact where vsp_id=? and version=?") + ResultSet delete(String vspId, UDTValue version); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java new file mode 100644 index 0000000000..1347636bf1 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoFactoryImpl.java @@ -0,0 +1,34 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.ServiceModelDao; +import org.openecomp.core.model.dao.ServiceModelDaoFactory; + +public class ServiceModelDaoFactoryImpl extends ServiceModelDaoFactory { + private static final ServiceModelDao INSTANCE = new ServiceModelDaoImpl(); + + @Override + public ServiceModelDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java new file mode 100644 index 0000000000..c397aec61d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceModelDaoImpl.java @@ -0,0 +1,38 @@ +/*- + * ============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.sdc.model.impl; + +import org.openecomp.core.model.dao.ServiceArtifactDaoFactory; +import org.openecomp.core.model.dao.ServiceModelDao; +import org.openecomp.core.model.dao.ServiceTemplateDaoFactory; +import org.openecomp.core.model.types.ServiceElement; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; + +public class ServiceModelDaoImpl extends AbstractServiceModelDao + implements ServiceModelDao { + + + public ServiceModelDaoImpl() { + templateDao = ServiceTemplateDaoFactory.getInstance().createInterface(); + artifactDao = ServiceArtifactDaoFactory.getInstance().createInterface(); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java new file mode 100644 index 0000000000..23c43b76d3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraFactoryImpl.java @@ -0,0 +1,34 @@ +/*- + * ============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.sdc.model.impl; + + +import org.openecomp.core.model.dao.ServiceTemplateDao; +import org.openecomp.core.model.dao.ServiceTemplateDaoFactory; + +public class ServiceTemplateDaoCassandraFactoryImpl extends ServiceTemplateDaoFactory { + private static final ServiceTemplateDao INSTANCE = new ServiceTemplateDaoCassandraImpl(); + + @Override + public ServiceTemplateDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java new file mode 100644 index 0000000000..ffc9a24677 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/ServiceTemplateDaoCassandraImpl.java @@ -0,0 +1,145 @@ +/*- + * ============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.sdc.model.impl; + +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.model.dao.ServiceTemplateDao; +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 org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityMetadata; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class ServiceTemplateDaoCassandraImpl implements ServiceTemplateDao { + + + private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static final Mapper mapper = + noSqlDb.getMappingManager().mapper(ServiceTemplateEntity.class); + private static final VspServiceTemplateAccessor accessor = + noSqlDb.getMappingManager().createAccessor(VspServiceTemplateAccessor.class); + private static final UDTMapper versionMapper = + noSqlDb.getMappingManager().udtMapper(Version.class); + + @Override + public void registerVersioning(String versionableEntityType) { + VersioningManagerFactory.getInstance().createInterface() + .register(versionableEntityType, new VersionableEntityMetadata( + mapper.getTableMetadata().getName(), + mapper.getTableMetadata().getPartitionKey().get(0).getName(), + mapper.getTableMetadata().getPartitionKey().get(1).getName())); + } + + @Override + public Collection list(String vspId, Version version) { + + List entityList = accessor.list(vspId, version).all(); + return entityList.stream().map(entity -> entity.getServiceTemplate()) + .collect(Collectors.toList()); + } + + @Override + public void create(ServiceTemplate entity) { + ServiceTemplateEntity vspServiceTemplateEntity = new ServiceTemplateEntity(entity); + mapper.save(vspServiceTemplateEntity); + } + + @Override + public void update(ServiceTemplate entity) { + ServiceTemplateEntity vspServiceTemplateEntity = new ServiceTemplateEntity(entity); + mapper.save(vspServiceTemplateEntity); + } + + @Override + public ServiceTemplate get(String vspId, Version version) { + return (mapper.get(getKeys(vspId, version))).getServiceTemplate(); + } + + @Override + public void delete(String vspId, Version version) { + mapper.delete(vspId, version); + } + + + @Override + public Object[] getKeys(String vspId, Version version) { + return new Object[]{vspId, versionMapper.toUDT(version)}; + } + + @Override + public ServiceTemplate getTemplateInfo(String vspId, Version version, String name) { + ServiceTemplateEntity serviceTemplateEntity = + accessor.getTemplateInfo(vspId, versionMapper.toUDT(version), name).one(); + if (serviceTemplateEntity == null) { + return null; + } + return serviceTemplateEntity.getServiceTemplate(); + } + + @Override + public String getBase(String vspId, Version version) { + Result element = accessor.getBase(vspId, versionMapper.toUDT(version)); + if (element != null) { + ServiceTemplateEntity vspServiceTemplateEntity = element.one(); + if (vspServiceTemplateEntity != null) { + return element.one().getBaseName(); + } + } + return null; + } + + + @Accessor + interface VspServiceTemplateAccessor { + + @Query("SELECT vsp_id, version, name, base_name ,content_data FROM vsp_service_template") + Result listAll(); + + @Query( + "SELECT vsp_id, version, name, base_name ,content_data" + + " FROM vsp_service_template where vsp_id=? and version=?") + Result list(String vspId, Version version); + + + @Query( + "SELECT vsp_id, version, name, base_name ,content_data " + + "FROM vsp_service_template where vsp_id=? and version=? and name=?") + Result getTemplateInfo(String vspId, UDTValue version, String name); + + @Query( + "SELECT vsp_id, version, name, base_name " + + "FROM vsp_service_template where vsp_id=? and version=?") + Result getBase(String vspId, UDTValue version); + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml new file mode 100644 index 0000000000..e8b51d8a49 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + + pom + + openecomp-sdc-lib + org.openecomp.sdc + 1.0.0-SNAPSHOT + + + openecomp-sdc-model-lib + openecomp-sdc-model-lib + + + openecomp-sdc-model-api + openecomp-sdc-model-core + openecomp-sdc-model-impl + + + + + org.openecomp.sdc + openecomp-sdc-model-api + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-model-core + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-model-impl + ${project.version} + + + + \ No newline at end of file -- cgit 1.2.3-korg