aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence')
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java28
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java36
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ParameterRepository.java39
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java26
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java141
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java136
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java171
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java31
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java21
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java21
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java26
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java44
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java33
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java29
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterEntity.java34
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterRole.java24
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterType.java25
-rw-r--r--sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java36
18 files changed, 901 insertions, 0 deletions
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java
new file mode 100644
index 00000000..f8f1d9a9
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence;
+
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+
+public interface ActivitySpecRepository {
+
+ void create(ActivitySpecEntity activitySpec);
+
+ ActivitySpecEntity get(ActivitySpecEntity activitySpec);
+
+ void update(ActivitySpecEntity activitySpec);
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
new file mode 100644
index 00000000..e10279fe
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence;
+
+
+import java.util.Optional;
+import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
+
+
+public interface ArtifactRepository {
+
+ void update(String workflowId, String versionId,ArtifactEntity artifactEntity);
+
+ Optional<ArtifactEntity> get(String workflowId, String versionId);
+
+ boolean isExist(String workflowId, String versionId);
+
+ void createStructure(String workflowId, String versionId);
+
+ void delete(String workflowId, String versionId);
+
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ParameterRepository.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ParameterRepository.java
new file mode 100644
index 00000000..9f7fb1ad
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ParameterRepository.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence;
+
+import java.util.Collection;
+import org.onap.sdc.workflow.persistence.types.ParameterEntity;
+import org.onap.sdc.workflow.persistence.types.ParameterRole;
+
+
+public interface ParameterRepository {
+
+ void createStructure(String id, String versionId);
+
+ Collection<ParameterEntity> list(String id, String versionId, ParameterRole role);
+
+ void deleteAll(String id, String versionId, ParameterRole role);
+
+ ParameterEntity get(String id, String versionId, String parameterId);
+
+ void delete(String id, String versionId, String parameterId);
+
+ ParameterEntity create(String id, String versionId , ParameterRole role, ParameterEntity parameter);
+
+ void update(String id, String versionId, ParameterRole role, ParameterEntity parameter);
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java
new file mode 100644
index 00000000..cf7b0633
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/UniqueValueRepository.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence;
+
+import org.onap.sdc.workflow.persistence.types.UniqueValueEntity;
+import org.springframework.data.cassandra.repository.CassandraRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface UniqueValueRepository extends CassandraRepository<UniqueValueEntity, UniqueValueEntity> {
+
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java
new file mode 100644
index 00000000..b304f900
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl;
+
+import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.buildStructuralElement;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Objects;
+import java.util.Optional;
+import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator;
+import org.onap.sdc.common.zusammen.services.ZusammenAdaptor;
+import org.onap.sdc.workflow.persistence.ActivitySpecRepository;
+import org.onap.sdc.workflow.persistence.impl.types.ActivitySpecData;
+import org.onap.sdc.workflow.persistence.impl.types.ActivitySpecElementType;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+import org.onap.sdc.workflow.services.ActivitySpecConstant;
+import org.onap.sdc.workflow.services.utilities.JsonUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ActivitySpecRepositoryImpl implements ActivitySpecRepository {
+
+ private final ZusammenAdaptor zusammenAdaptor;
+ private final ZusammenSessionContextCreator contextCreator;
+
+ @Autowired
+ public ActivitySpecRepositoryImpl(ZusammenAdaptor zusammenAdaptor, ZusammenSessionContextCreator contextCreator) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.contextCreator = contextCreator;
+ }
+
+ @Override
+ public void create(ActivitySpecEntity activitySpec) {
+ ZusammenElement generalElement = mapActivityDetailsToZusammenElement(activitySpec, Action.CREATE);
+
+ ElementContext elementContext = new ElementContext(activitySpec.getId(), activitySpec.getVersionId());
+ zusammenAdaptor
+ .saveElement(contextCreator.create(), elementContext, generalElement, "Create Activity Spec General Info Element");
+ }
+
+ @Override
+ public ActivitySpecEntity get(ActivitySpecEntity entity) {
+ ElementContext elementContext = new ElementContext(entity.getId(), entity.getVersionId());
+ Optional<Element> element =
+ zusammenAdaptor.getElementByName(contextCreator.create(), elementContext, null, ActivitySpecElementType.ACTIVITYSPEC.name());
+ return element.map(this::mapZusammenElementToActivityDetails).orElse(null);
+ }
+
+ @Override
+ public void update(ActivitySpecEntity entity) {
+
+ ZusammenElement generalElement = mapActivityDetailsToZusammenElement(entity, Action.UPDATE);
+
+ ElementContext elementContext = new ElementContext(entity.getId(), entity.getVersionId());
+ zusammenAdaptor
+ .saveElement(contextCreator.create(), elementContext, generalElement, "Update Activity Spec General Info Element");
+ }
+
+ private ZusammenElement mapActivityDetailsToZusammenElement(ActivitySpecEntity entity, Action action) {
+ ZusammenElement generalElement = buildStructuralElement(ActivitySpecElementType.ACTIVITYSPEC.name(), action);
+
+ enrichElementInfoFromEntity(generalElement, entity);
+ enrichElementDataFromEntity(generalElement, entity);
+ return generalElement;
+ }
+
+ private void enrichElementInfoFromEntity(ZusammenElement element, ActivitySpecEntity entity) {
+ element.getInfo().addProperty(InfoPropertyName.DESCRIPTION.getValue(), entity.getDescription());
+ element.getInfo().addProperty(InfoPropertyName.NAME.getValue(), entity.getName());
+ element.getInfo().addProperty(InfoPropertyName.CATEGORY.getValue(), entity.getCategoryList());
+ }
+
+ private void enrichElementDataFromEntity(ZusammenElement element, ActivitySpecEntity entity) {
+ ActivitySpecData activitySpecData = new ActivitySpecData();
+ activitySpecData.setInputs(entity.getInputs());
+ activitySpecData.setOutputs(entity.getOutputs());
+ activitySpecData.setType(entity.getType());
+ activitySpecData.setContent(entity.getContent());
+ element.setData(new ByteArrayInputStream(JsonUtil.object2Json(activitySpecData).getBytes()));
+ }
+
+ private ActivitySpecEntity mapZusammenElementToActivityDetails(Element element) {
+ ActivitySpecEntity entity = new ActivitySpecEntity();
+ entity.setId(element.getElementId().getValue());
+ enrichEntityFromElementData(entity, element.getData());
+ enrichEntityFromElementInfo(entity, element.getInfo());
+ return entity;
+ }
+
+ private void enrichEntityFromElementData(ActivitySpecEntity entity, InputStream data) {
+ ActivitySpecData activitySpecData = JsonUtil.json2Object(data, ActivitySpecData.class);
+ if (Objects.nonNull(activitySpecData)) {
+ entity.setInputs(activitySpecData.getInputs());
+ entity.setOutputs(activitySpecData.getOutputs());
+ entity.setType(activitySpecData.getType());
+ entity.setContent(activitySpecData.getContent());
+ }
+ }
+
+ private void enrichEntityFromElementInfo(ActivitySpecEntity entity, Info info) {
+ entity.setName(info.getProperty(InfoPropertyName.NAME.getValue()));
+ entity.setDescription(info.getProperty(InfoPropertyName.DESCRIPTION.getValue()));
+ entity.setCategoryList(info.getProperty(InfoPropertyName.CATEGORY.getValue()));
+ }
+
+ public enum InfoPropertyName {
+ DESCRIPTION("description"), NAME("name"), CATEGORY(ActivitySpecConstant.CATEGORY_ATTRIBUTE_NAME);
+
+ private final String value;
+
+ InfoPropertyName(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
new file mode 100644
index 00000000..4ad54614
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl;
+
+import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.buildStructuralElement;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Optional;
+import org.apache.commons.io.IOUtils;
+import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator;
+import org.onap.sdc.common.zusammen.services.ZusammenAdaptor;
+import org.onap.sdc.workflow.persistence.ArtifactRepository;
+import org.onap.sdc.workflow.persistence.impl.types.WorkflowElementType;
+import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ArtifactRepositoryImpl implements ArtifactRepository {
+
+ private static final String FILE_NAME_PROPERTY = "fileName";
+ private static final String EMPTY_DATA = "{}";
+
+ private final ZusammenAdaptor zusammenAdaptor;
+ private final ZusammenSessionContextCreator contextCreator;
+
+ @Autowired
+ public ArtifactRepositoryImpl(ZusammenAdaptor zusammenAdaptor, ZusammenSessionContextCreator contextCreator) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.contextCreator = contextCreator;
+ }
+
+ @Override
+ public void update(String workflowId, String versionId, ArtifactEntity artifactEntity) {
+
+ ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.UPDATE);
+ artifactElement.setData(artifactEntity.getArtifactData());
+ artifactElement.getInfo().addProperty(FILE_NAME_PROPERTY, artifactEntity.getFileName());
+
+
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ zusammenAdaptor
+ .saveElement(contextCreator.create(), elementContext, artifactElement, "Update WorkflowVersion Artifact Element");
+ }
+
+ @Override
+ public Optional<ArtifactEntity> get(String workflowId, String versionId) {
+
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ Optional<Element> elementOptional =
+ zusammenAdaptor.getElementByName(contextCreator.create(), elementContext, null, WorkflowElementType.ARTIFACT.name());
+
+ if (!elementOptional.isPresent() || hasEmptyData(elementOptional.get().getData())) {
+ return Optional.empty();
+ }
+
+ Element artifactElement = elementOptional.get();
+
+ ArtifactEntity artifact = new ArtifactEntity(artifactElement.getInfo().getProperty(FILE_NAME_PROPERTY),
+ artifactElement.getData());
+
+ return Optional.of(artifact);
+ }
+
+ @Override
+ public boolean isExist(String workflowId, String versionId) {
+
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ Optional<ElementInfo> optionalElementInfo = zusammenAdaptor.getElementInfoByName(contextCreator.create(), elementContext, null,
+ WorkflowElementType.ARTIFACT.name());
+ return optionalElementInfo.isPresent() && optionalElementInfo.get().getInfo().getProperties()
+ .containsKey(FILE_NAME_PROPERTY);
+ }
+
+ @Override
+ public void createStructure(String workflowId, String versionId) {
+
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.CREATE);
+ artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
+
+ zusammenAdaptor
+ .saveElement(contextCreator.create(), elementContext, artifactElement, "Create WorkflowVersion Artifact Element");
+
+ }
+
+ @Override
+ public void delete(String workflowId, String versionId) {
+
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.UPDATE);
+ artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
+ artifactElement.getInfo().getProperties().remove(FILE_NAME_PROPERTY);
+
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, artifactElement, "Delete WorkflowVersion Artifact Data");
+
+ }
+
+ private boolean hasEmptyData(InputStream elementData) {
+
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ return false;
+ }
+ return Arrays.equals(EMPTY_DATA.getBytes(), byteElementData);
+ }
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java
new file mode 100644
index 00000000..eeef2477
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl;
+
+import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.ELEMENT_TYPE_PROPERTY;
+import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.buildElement;
+import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.buildStructuralElement;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator;
+import org.onap.sdc.common.zusammen.services.ZusammenAdaptor;
+import org.onap.sdc.workflow.persistence.ParameterRepository;
+import org.onap.sdc.workflow.persistence.impl.types.ParameterPropertyName;
+import org.onap.sdc.workflow.persistence.impl.types.WorkflowElementType;
+import org.onap.sdc.workflow.persistence.types.ParameterEntity;
+import org.onap.sdc.workflow.persistence.types.ParameterRole;
+import org.onap.sdc.workflow.persistence.types.ParameterType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ParameterRepositoryImpl implements ParameterRepository {
+
+ private final ZusammenAdaptor zusammenAdaptor;
+ private final ZusammenSessionContextCreator contextCreator;
+
+ @Autowired
+ public ParameterRepositoryImpl(ZusammenAdaptor zusammenAdaptor, ZusammenSessionContextCreator contextCreator) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.contextCreator = contextCreator;
+ }
+
+ @Override
+ public void createStructure(String id, String versionId) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ ZusammenElement inputsElement = buildStructuralElement(WorkflowElementType.INPUTS.name(), Action.CREATE);
+ ZusammenElement outputsElement = buildStructuralElement(WorkflowElementType.OUTPUTS.name(), Action.CREATE);
+
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, inputsElement, "Create WorkflowVersion INPUTS Element");
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, outputsElement, "Create WorkflowVersion OUTPUTS Element");
+ }
+
+ @Override
+ public Collection<ParameterEntity> list(String id, String versionId, ParameterRole role) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ return zusammenAdaptor.listElementsByName(contextCreator.create(), elementContext, null, getParentElementType(role)).stream()
+ .map(this::mapElementInfoToParameter).collect(Collectors.toList());
+ }
+
+ @Override
+ public void deleteAll(String id, String versionId, ParameterRole role) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ Optional<ElementInfo> optionalParentElement =
+ zusammenAdaptor.getElementInfoByName(contextCreator.create(), elementContext, null, getParentElementType(role));
+
+ if (!optionalParentElement.isPresent()) {
+ throw new IllegalStateException(
+ String.format("Missing data for workflow id %s version id %s", id, versionId));
+ }
+ ZusammenElement parentElement = buildElement(optionalParentElement.get().getId(), Action.IGNORE);
+ parentElement.setSubElements(optionalParentElement.get().getSubElements().stream()
+ .map(parameter -> buildElement(parameter.getId(), Action.DELETE))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, parentElement, "Delete all " + role);
+ }
+
+ @Override
+ public ParameterEntity get(String id, String versionId, String parameterId) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ Optional<ElementInfo> element = zusammenAdaptor.getElementInfo(contextCreator.create(), elementContext, new Id(parameterId));
+
+ return element.map(this::mapElementInfoToParameter).orElse(null);
+ }
+
+ @Override
+ public void delete(String id, String versionId, String parameterId) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ ZusammenElement parameterElement = buildElement(new Id(parameterId), Action.DELETE);
+
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, parameterElement,
+ String.format("Delete Parameter with id %s", parameterId));
+ }
+
+ @Override
+ public ParameterEntity create(String id, String versionId, ParameterRole role, ParameterEntity parameter) {
+ ZusammenElement parameterElement = parameterToZusammenElement(parameter, role, Action.CREATE);
+ ZusammenElement parentElement = buildStructuralElement(getParentElementType(role), Action.IGNORE);
+ parentElement.addSubElement(parameterElement);
+
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ Element savedElement = zusammenAdaptor.saveElement(contextCreator.create(), elementContext, parentElement,
+ "Create WorkflowVersion Parameter Element");
+
+ parameter.setId(savedElement.getSubElements().iterator().next().getElementId().getValue());
+ return parameter;
+ }
+
+ @Override
+ public void update(String id, String versionId, ParameterRole role, ParameterEntity parameter) {
+ ElementContext elementContext = new ElementContext(id, versionId);
+
+ ZusammenElement parameterElement = parameterToZusammenElement(parameter, role, Action.UPDATE);
+
+ zusammenAdaptor.saveElement(contextCreator.create(), elementContext, parameterElement, "Update WorkflowVersion Parameter");
+ }
+
+ private ZusammenElement parameterToZusammenElement(ParameterEntity parameter, ParameterRole role, Action action) {
+ ZusammenElement parameterElement =
+ buildElement(parameter.getId() == null ? null : new Id(parameter.getId()), action);
+ Info info = new Info();
+ info.setName(parameter.getName());
+ info.addProperty(ELEMENT_TYPE_PROPERTY, WorkflowElementType.valueOf(role.name()));
+ info.addProperty(ParameterPropertyName.TYPE.name(), parameter.getType());
+ info.addProperty(ParameterPropertyName.MANDATORY.name(), parameter.isMandatory());
+ parameterElement.setInfo(info);
+
+ return parameterElement;
+ }
+
+ private ParameterEntity mapElementInfoToParameter(ElementInfo elementInfo) {
+ ParameterEntity parameterEntity = new ParameterEntity();
+ parameterEntity.setId(elementInfo.getId().getValue());
+ parameterEntity.setName(elementInfo.getInfo().getName());
+ parameterEntity
+ .setType(ParameterType.valueOf(elementInfo.getInfo().getProperty(ParameterPropertyName.TYPE.name())));
+ parameterEntity.setMandatory(elementInfo.getInfo().getProperty(ParameterPropertyName.MANDATORY.name()));
+ return parameterEntity;
+ }
+
+ private static String getParentElementType(ParameterRole role) {
+ switch (role) {
+ case INPUT:
+ return WorkflowElementType.INPUTS.name();
+ case OUTPUT:
+ return WorkflowElementType.OUTPUTS.name();
+ default:
+ throw new IllegalArgumentException("Wrong Element Type");
+ }
+ }
+
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java
new file mode 100644
index 00000000..5daba8d6
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl.types;
+
+import java.util.Collections;
+import java.util.List;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecParameter;
+
+@lombok.Data
+public class ActivitySpecData {
+
+ private List<ActivitySpecParameter> inputs = Collections.emptyList();
+ private List<ActivitySpecParameter> outputs = Collections.emptyList();
+ private String type;
+ private String content;
+}
+
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java
new file mode 100644
index 00000000..e26b8088
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl.types;
+
+public enum ActivitySpecElementType {
+ ACTIVITYSPEC
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java
new file mode 100644
index 00000000..300ddc49
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl.types;
+
+public enum ParameterPropertyName {
+ TYPE, MANDATORY
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java
new file mode 100644
index 00000000..109ce97c
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.impl.types;
+
+public enum WorkflowElementType {
+
+ ARTIFACT,
+ INPUTS,
+ OUTPUTS,
+ INPUT,
+ OUTPUT
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java
new file mode 100644
index 00000000..cf3be394
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+import java.util.List;
+import lombok.NoArgsConstructor;
+
+@lombok.Data
+@NoArgsConstructor
+public class ActivitySpecEntity {
+
+ private String id;
+ private String versionId;
+ private String name;
+ private String description;
+
+ private List<String> categoryList;
+ private List<ActivitySpecParameter> inputs;
+ private List<ActivitySpecParameter> outputs;
+ private String type;
+ private String content;
+
+ //Not to be maintained in activityspec element
+ private String status;
+
+ public ActivitySpecEntity(String id, String versionId) {
+ this.id = id;
+ this.versionId = versionId;
+ }
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java
new file mode 100644
index 00000000..ec1c2681
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.onap.sdc.workflow.api.validation.ValidName;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ValidName
+public class ActivitySpecParameter {
+
+ private String name;
+ private String type;
+ private String value;
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java
new file mode 100644
index 00000000..62819754
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ArtifactEntity.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+import java.io.InputStream;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class ArtifactEntity {
+
+ private String fileName;
+ private InputStream artifactData;
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterEntity.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterEntity.java
new file mode 100644
index 00000000..4dfd1e4f
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterEntity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class ParameterEntity {
+
+ private String id;
+ private String name;
+ private ParameterType type;
+ private boolean mandatory;
+
+ public ParameterEntity(String name) {
+ this.name = name;
+ }
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterRole.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterRole.java
new file mode 100644
index 00000000..9f5aacfe
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterRole.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+public enum ParameterRole {
+
+ INPUT,
+ OUTPUT
+
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterType.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterType.java
new file mode 100644
index 00000000..04d09c01
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterType.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+public enum ParameterType {
+ STRING,
+ INTEGER,
+ FLOAT,
+ BOOLEAN,
+ TIMESTAMP
+}
diff --git a/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java
new file mode 100644
index 00000000..faf515b7
--- /dev/null
+++ b/sdc-workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/UniqueValueEntity.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.onap.sdc.workflow.persistence.types;
+
+import static org.springframework.data.cassandra.core.cql.PrimaryKeyType.PARTITIONED;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
+import org.springframework.data.cassandra.core.mapping.Table;
+
+@Table("unique_value")
+@Data
+@AllArgsConstructor
+public class UniqueValueEntity {
+
+ @PrimaryKeyColumn(ordinal = 0, type = PARTITIONED)
+ private String type;
+
+ @PrimaryKeyColumn(ordinal = 1, type = PARTITIONED)
+ private String value;
+}