summaryrefslogtreecommitdiffstats
path: root/workflow-designer-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'workflow-designer-be/src/main/java')
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java10
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java28
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java1
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java11
4 files changed, 37 insertions, 13 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
index ed9371e6..e10279fe 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ArtifactRepository.java
@@ -23,12 +23,14 @@ import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
public interface ArtifactRepository {
- void update(String id, String versionId,ArtifactEntity artifactEntity);
+ void update(String workflowId, String versionId,ArtifactEntity artifactEntity);
- Optional<ArtifactEntity> get(String id, String versionId);
+ Optional<ArtifactEntity> get(String workflowId, String versionId);
- void createStructure(String id, String versionId);
+ boolean isExist(String workflowId, String versionId);
- void delete(String id, String versionId);
+ void createStructure(String workflowId, String versionId);
+
+ void delete(String workflowId, String versionId);
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
index 3c528db1..b49433cc 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java
@@ -20,6 +20,7 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElemen
import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
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.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
@@ -46,23 +47,23 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
@Override
- public void update(String id, String versionId, ArtifactEntity artifactEntity) {
+ 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());
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
zusammenAdaptor
.saveElement(context, elementContext, artifactElement, "Update WorkflowVersion Artifact Element");
}
@Override
- public Optional<ArtifactEntity> get(String id, String versionId) {
+ public Optional<ArtifactEntity> get(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
Optional<Element> elementOptional =
zusammenAdaptor.getElementByName(context, elementContext, null, WorkflowElementType.ARTIFACT.name());
@@ -80,9 +81,20 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
}
@Override
- public void createStructure(String id, String versionId) {
+ public boolean isExist(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
+
+ Optional<ElementInfo> optionalElementInfo = zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ WorkflowElementType.ARTIFACT.name());
+ return optionalElementInfo.isPresent() && optionalElementInfo.get().getInfo().getProperties()
+ .containsKey(FILE_NAME_PROPERTY);
+ }
+
+ @Override
+ public void createStructure(String workflowId, String versionId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.CREATE);
artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
@@ -93,9 +105,9 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
}
@Override
- public void delete(String id, String versionId) {
+ public void delete(String workflowId, String versionId) {
SessionContext context = createSessionContext();
- ElementContext elementContext = new ElementContext(id, versionId);
+ ElementContext elementContext = new ElementContext(workflowId, versionId);
ZusammenElement artifactElement = buildStructuralElement(WorkflowElementType.ARTIFACT.name(), Action.UPDATE);
artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
index 1c828d43..17f95ae1 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java
@@ -30,6 +30,7 @@ public class WorkflowVersion {
private String description;
private String baseId;
private WorkflowVersionState state;
+ private boolean hasArtifact;
private Collection<ParameterEntity> inputs = Collections.emptyList();
private Collection<ParameterEntity> outputs = Collections.emptyList();
private Date creationTime;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
index 484c598a..0f7c993d 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
@@ -18,6 +18,7 @@ package org.onap.sdc.workflow.services.impl;
import static org.onap.sdc.workflow.persistence.types.WorkflowVersionState.CERTIFIED;
+import com.amdocs.zusammen.datatypes.response.ErrorCode;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
@@ -43,6 +44,7 @@ import org.onap.sdc.workflow.services.exceptions.VersionModificationException;
import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
import org.onap.sdc.workflow.services.impl.mappers.VersionMapper;
import org.onap.sdc.workflow.services.impl.mappers.VersionStateMapper;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.versioning.VersioningManager;
@@ -95,6 +97,7 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
public WorkflowVersion get(String workflowId, String versionId) {
WorkflowVersion workflowVersion = versionMapper.versionToWorkflowVersion(getVersion(workflowId, versionId));
loadAndAddParameters(workflowId, workflowVersion);
+ workflowVersion.setHasArtifact(artifactRepository.isExist(workflowId,versionId));
return workflowVersion;
}
@@ -140,9 +143,14 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
updateParameters(workflowId, version.getId(), workflowVersion.getInputs(), workflowVersion.getOutputs());
versioningManager.updateVersion(workflowId, version);
- versioningManager.publish(workflowId, version, "Update version");
+
+ Version updatedVersion = versioningManager.get(workflowId, version);
+ if(updatedVersion.getState().isDirty()) {
+ versioningManager.publish(workflowId, version, "Update version");
+ }
}
+
@Override
public WorkflowVersionState getState(String workflowId, String versionId) {
return versionStateMapper.versionStatusToWorkflowVersionState(getVersion(workflowId, versionId).getStatus());
@@ -274,4 +282,5 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
private static Optional<Version> findVersion(List<Version> versions, String versionId) {
return versions.stream().filter(version -> versionId.equals(version.getId())).findFirst();
}
+
} \ No newline at end of file