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/api/ActivitySpecController.java127
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ExceptionsHandler.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java)73
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java20
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java29
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/mappers/ActivitySpecDtoMapper.java34
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java11
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecAction.java21
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecActionRequest.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidPaginationParameterException.java)18
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecBase.java15
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecCreateResponse.java29
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecDataResponse.java27
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecRequest.java34
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecResponse.java27
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/InternalEmptyObject.java27
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java28
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java143
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryImpl.java14
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java17
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java31
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java)14
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterPropertyName.java)6
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowElementType.java)2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java45
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java31
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java5
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecConstant.java28
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecManager.java34
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java47
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java5
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java4
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java12
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java248
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java7
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ItemType.java21
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java18
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java6
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/ActivitySpecMapper.java60
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java8
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java)2
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowVersion.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersion.java)4
-rw-r--r--workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowVersionState.java (renamed from workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java)2
46 files changed, 1186 insertions, 158 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ActivitySpecController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ActivitySpecController.java
new file mode 100644
index 00000000..dca6c695
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ActivitySpecController.java
@@ -0,0 +1,127 @@
+/*
+ * 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.api;
+
+import static org.onap.sdc.workflow.api.RestParams.USER_ID_HEADER;
+import static org.onap.sdc.workflow.services.ActivitySpecConstant.VERSION_ID_DEFAULT_VALUE;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import javax.validation.Valid;
+import org.onap.sdc.workflow.api.mappers.ActivitySpecDtoMapper;
+import org.onap.sdc.workflow.api.types.CollectionResponse;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecActionRequest;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecCreateResponse;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecDataResponse;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecRequest;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecResponse;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+import org.onap.sdc.workflow.services.ActivitySpecManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping(value = "/v1.0/activity-spec")
+@Api("Activity Specs")
+@RestController("activitySpecController")
+@Validated
+public class ActivitySpecController {
+
+ private final ActivitySpecManager activitySpecManager;
+ private final ActivitySpecDtoMapper activitySpecDtoMapper;
+
+ @Autowired
+ public ActivitySpecController(@Qualifier("activitySpecManager") ActivitySpecManager activitySpecManager,
+ ActivitySpecDtoMapper activitySpecDtoMapper) {
+ this.activitySpecManager = activitySpecManager;
+ this.activitySpecDtoMapper = activitySpecDtoMapper;
+ }
+
+ @GetMapping
+ @ApiOperation(value = "List activity specs", responseContainer = "List")
+ @ApiImplicitParam(name = USER_ID_HEADER, required = true, dataType = "string", paramType = "header")
+ public CollectionResponse<ActivitySpecResponse> list(@ApiParam(value = "List activity specs based on status filter",
+ allowableValues = "Draft,Certified,Deprecated,Deleted") @RequestParam(name = "status", required = false)
+ String versionStatus) {
+ return new CollectionResponse<>(
+ activitySpecManager.list(versionStatus).stream().map(activitySpecDtoMapper::toActivitySpecResponse)
+ .collect(Collectors.toList()));
+ }
+
+ @PostMapping
+ @ApiOperation(value = "Create Activity Spec")
+ @ApiImplicitParam(name = USER_ID_HEADER, required = true, dataType = "string", paramType = "header")
+ public ResponseEntity<ActivitySpecCreateResponse> create(@Valid @RequestBody ActivitySpecRequest request) {
+ ActivitySpecEntity activitySpec =
+ activitySpecManager.createActivitySpec(activitySpecDtoMapper.fromActivitySpecRequest(request));
+ return new ResponseEntity<>(new ActivitySpecCreateResponse(activitySpec.getId(),
+ Objects.nonNull(activitySpec.getVersion()) ? activitySpec.getVersion().getId() : null),
+ HttpStatus.CREATED);
+ }
+
+ @GetMapping("/{id}/versions/{versionId}")
+ @ApiOperation(value = "Get Activity Spec")
+ @ApiImplicitParam(name = USER_ID_HEADER, required = true, dataType = "string", paramType = "header")
+ public ActivitySpecDataResponse get(@ApiParam(value = "Activity Spec Id") @PathVariable("id") String activitySpecId,
+ @ApiParam(value = "Version Id", defaultValue = VERSION_ID_DEFAULT_VALUE) @PathVariable("versionId")
+ String versionId) {
+ return activitySpecDtoMapper.toActivitySpecDataResponse(
+ activitySpecManager.get(new ActivitySpecEntity(activitySpecId, new Version(versionId))));
+ }
+
+ @PutMapping("/{id}/versions/{versionId}")
+ @ApiOperation(value = "Update Activity Spec")
+ @ApiImplicitParam(name = USER_ID_HEADER, required = true, dataType = "string", paramType = "header")
+ public void update(@Valid @RequestBody ActivitySpecRequest request,
+ @ApiParam(value = "Activity Spec Id") @PathVariable("id") String activitySpecId,
+ @ApiParam(value = "Version Id", defaultValue = VERSION_ID_DEFAULT_VALUE) @PathVariable("versionId")
+ String versionId) {
+ ActivitySpecEntity activitySpec = activitySpecDtoMapper.fromActivitySpecRequest(request);
+ activitySpec.setId(activitySpecId);
+ activitySpec.setVersion(new Version(versionId));
+
+ activitySpecManager.update(activitySpec);
+ }
+
+ @PutMapping("/{id}/versions/{versionId}/actions")
+ @ApiOperation(value = "Actions on a activity spec",
+ notes = "Performs one of the following actions on a activity spec: |" + "CERTIFY: Certifies activity spec.|"
+ + "DEPRECATE: Deprecates activity spec.|" + "DELETE: Deletes activity spec.")
+ @ApiImplicitParam(name = USER_ID_HEADER, required = true, dataType = "string", paramType = "header")
+ public void actOn(@Valid @RequestBody ActivitySpecActionRequest request,
+ @ApiParam(value = "Activity Spec Id") @PathVariable("id") String activitySpecId,
+ @ApiParam(value = "Version Id", defaultValue = VERSION_ID_DEFAULT_VALUE) @PathVariable("versionId")
+ String versionId) {
+ activitySpecManager
+ .actOnAction(new ActivitySpecEntity(activitySpecId, new Version(versionId)), request.getAction());
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ExceptionsHandler.java
index 02d68fd6..5e6fc07d 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/exceptionshandlers/CustomizedResponseEntityExceptionHandler.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/ExceptionsHandler.java
@@ -14,89 +14,76 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.api.exceptionshandlers;
+package org.onap.sdc.workflow.api;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.FORBIDDEN;
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
+import org.onap.sdc.workflow.api.types.ErrorResponse;
import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
import org.onap.sdc.workflow.services.exceptions.InvalidArtifactException;
-import org.onap.sdc.workflow.services.exceptions.InvalidPaginationParameterException;
import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
import org.onap.sdc.workflow.services.exceptions.VersionCreationException;
import org.onap.sdc.workflow.services.exceptions.VersionModificationException;
import org.onap.sdc.workflow.services.exceptions.VersionStateModificationException;
+import org.onap.sdc.workflow.services.exceptions.VersionStatusModificationException;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
@ControllerAdvice
@RestController
-public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
-
- @ExceptionHandler(UniqueValueViolationException.class)
- public final ResponseEntity<String> handleUniqueValueViolationException(
- UniqueValueViolationException exception) {
- return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
- }
+public class ExceptionsHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(EntityNotFoundException.class)
- public final ResponseEntity<String> handleWorkflowNotFoundException(
- Exception exception) {
- return new ResponseEntity<>(exception.getMessage(), NOT_FOUND);
+ public final ResponseEntity<ErrorResponse> handleNotFoundException(Exception exception) {
+ return new ResponseEntity<>(new ErrorResponse(exception.getMessage()), NOT_FOUND);
}
- @ExceptionHandler({InvalidPaginationParameterException.class})
- public final ResponseEntity<String> handlePaginationException(InvalidPaginationParameterException exception) {
- return new ResponseEntity<>(exception.getMessage(), BAD_REQUEST);
+ @ExceptionHandler({InvalidArtifactException.class, VersionModificationException.class,
+ VersionStateModificationException.class, VersionStatusModificationException.class,
+ UniqueValueViolationException.class})
+ public final ResponseEntity<ErrorResponse> handleUnprocessableEntityException(Exception exception) {
+ return new ResponseEntity<>(new ErrorResponse(exception.getMessage()), UNPROCESSABLE_ENTITY);
}
- @Override
- protected final ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgumentNotValidException exception,
- final HttpHeaders headers,
- final HttpStatus status,
- final WebRequest request) {
-
- String errorMsg = exception.getBindingResult().getFieldErrors().stream()
- .map(DefaultMessageSourceResolvable::getDefaultMessage)
- .findFirst()
- .orElse(exception.getMessage());
+ @ExceptionHandler(VersionCreationException.class)
+ public final ResponseEntity<ErrorResponse> handleVersioningErrorException(VersionCreationException exception) {
+ return new ResponseEntity<>(new ErrorResponse(exception.getMessage()), FORBIDDEN);
+ }
- return new ResponseEntity<>(errorMsg, BAD_REQUEST);
+ @ExceptionHandler(Exception.class)
+ public final ResponseEntity<ErrorResponse> handleUnexpectedException(Exception exception) {
+ return new ResponseEntity<>(new ErrorResponse(exception.getMessage()), INTERNAL_SERVER_ERROR);
}
//For missing header exceptions
@Override
public ResponseEntity<Object> handleServletRequestBindingException(ServletRequestBindingException ex,
- HttpHeaders headers, HttpStatus status,
- WebRequest request) {
- return new ResponseEntity<>(ex.getMessage(), BAD_REQUEST);
- }
-
-
- @ExceptionHandler({InvalidArtifactException.class, VersionModificationException.class,
- VersionStateModificationException.class})
- public final ResponseEntity<String> handleInvalidArtifactException(
- Exception exception) {
- return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
+ HttpHeaders headers, HttpStatus status, WebRequest request) {
+ return new ResponseEntity<>(new ErrorResponse(ex.getMessage()), BAD_REQUEST);
}
+ @Override
+ protected final ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgumentNotValidException exception,
+ final HttpHeaders headers,
+ final HttpStatus status,
+ final WebRequest request) {
- @ExceptionHandler(VersionCreationException.class)
- public final ResponseEntity<String> handleVersioningErrorException(
- VersionCreationException exception) {
- return new ResponseEntity<>(exception.getMessage(), FORBIDDEN);
+ String errorMsg = exception.getBindingResult().getFieldErrors().stream()
+ .map(DefaultMessageSourceResolvable::getDefaultMessage).findFirst()
+ .orElse(exception.getMessage());
+ return new ResponseEntity<>(new ErrorResponse(errorMsg), BAD_REQUEST);
}
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
index 690b2075..18288e27 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
@@ -31,13 +31,13 @@ import io.swagger.annotations.ApiParam;
import org.onap.sdc.workflow.api.types.Paging;
import org.onap.sdc.workflow.api.types.Sorting;
import org.onap.sdc.workflow.api.types.VersionStatesFormatter;
-import org.onap.sdc.workflow.persistence.types.Workflow;
import org.onap.sdc.workflow.services.WorkflowManager;
import org.onap.sdc.workflow.services.WorkflowVersionManager;
import org.onap.sdc.workflow.services.types.Page;
import org.onap.sdc.workflow.services.types.PagingRequest;
import org.onap.sdc.workflow.services.types.RequestSpec;
import org.onap.sdc.workflow.services.types.SortingRequest;
+import org.onap.sdc.workflow.services.types.Workflow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
@@ -55,10 +55,11 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
-@RequestMapping("/workflows")
+@RequestMapping("/wf/workflows")
@Api("Workflows")
@RestController("workflowController")
public class WorkflowController {
+
private final WorkflowManager workflowManager;
private final WorkflowVersionManager workflowVersionManager;
@@ -71,9 +72,8 @@ public class WorkflowController {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("List workflows")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "versionState", dataType = "string", paramType = "query",
- allowableValues = "DRAFT,CERTIFIED", value = "Filter by version state"),
+ @ApiImplicitParams({@ApiImplicitParam(name = "versionState", dataType = "string", paramType = "query",
+ allowableValues = "DRAFT,CERTIFIED", value = "Filter by version state"),
@ApiImplicitParam(name = OFFSET, dataType = "string", paramType = "query", defaultValue = "0",
value = "Index of the starting item"),
@ApiImplicitParam(name = LIMIT, dataType = "string", paramType = "query", defaultValue = "200",
@@ -81,10 +81,8 @@ public class WorkflowController {
@ApiImplicitParam(name = SORT, dataType = "string", paramType = "query", defaultValue = "name:asc",
value = "Sorting criteria in the format: property:(asc|desc). Default sort order is ascending.",
allowableValues = "name:asc,name:desc")})
- public Page<Workflow> list(@ApiIgnore VersionStatesFormatter versionStateFilter,
- @ApiIgnore Paging paging,
- @ApiIgnore Sorting sorting,
- @RequestHeader(USER_ID_HEADER) String user) {
+ public Page<Workflow> list(@ApiIgnore VersionStatesFormatter versionStateFilter, @ApiIgnore Paging paging,
+ @ApiIgnore Sorting sorting, @RequestHeader(USER_ID_HEADER) String user) {
return workflowManager.list(versionStateFilter.getVersionStates(), initRequestSpec(paging, sorting));
}
@@ -104,8 +102,8 @@ public class WorkflowController {
Workflow workflow = new Workflow();
workflow.setId(workflowId);
Workflow retrievedWorkflow = workflowManager.get(workflow);
- if("versions".equals(expand)){
- retrievedWorkflow.setVersions(workflowVersionManager.list(workflowId,null));
+ if ("versions".equals(expand)) {
+ retrievedWorkflow.setVersions(workflowVersionManager.list(workflowId, null));
}
return retrievedWorkflow;
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java
index 35b49599..f869ce05 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowVersionController.java
@@ -21,15 +21,14 @@ import static org.onap.sdc.workflow.api.RestParams.USER_ID_HEADER;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
import javax.validation.Valid;
import org.onap.sdc.workflow.api.types.CollectionResponse;
import org.onap.sdc.workflow.api.types.VersionStateDto;
-import org.onap.sdc.workflow.api.types.dto.ArtifactDeliveriesRequestDto;
import org.onap.sdc.workflow.api.types.VersionStatesFormatter;
+import org.onap.sdc.workflow.api.types.dto.ArtifactDeliveriesRequestDto;
import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
import org.onap.sdc.workflow.services.WorkflowVersionManager;
+import org.onap.sdc.workflow.services.types.WorkflowVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.InputStreamResource;
@@ -51,7 +50,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
-@RequestMapping("/workflows/{workflowId}/versions")
+@RequestMapping("/wf/workflows/{workflowId}/versions")
@Api("Workflow versions")
@RestController("workflowsVersionController")
public class WorkflowVersionController {
@@ -60,17 +59,16 @@ public class WorkflowVersionController {
private final ArtifactAssociationService associationHandler;
@Autowired
- public WorkflowVersionController(
- @Qualifier("workflowVersionManager") WorkflowVersionManager workflowVersionManager,
+ public WorkflowVersionController(@Qualifier("workflowVersionManager") WorkflowVersionManager workflowVersionManager,
@Qualifier("ArtifactAssociationHandler") ArtifactAssociationService artifatcAssociationHandler) {
this.workflowVersionManager = workflowVersionManager;
this.associationHandler = artifatcAssociationHandler;
}
- @ApiImplicitParam(name = "state", dataType = "string", paramType = "query", allowableValues = "DRAFT,CERTIFIED",
- value = "Filter by state")
@GetMapping
@ApiOperation("List workflow versions")
+ @ApiImplicitParam(name = "state", dataType = "string", paramType = "query", allowableValues = "DRAFT,CERTIFIED",
+ value = "Filter by state")
public CollectionResponse<WorkflowVersion> list(@PathVariable("workflowId") String workflowId,
@ApiIgnore VersionStatesFormatter stateFilter, @RequestHeader(USER_ID_HEADER) String user) {
return new CollectionResponse<>(workflowVersionManager.list(workflowId, stateFilter.getVersionStates()));
@@ -119,10 +117,11 @@ public class WorkflowVersionController {
@PostMapping("/{versionId}/artifact-deliveries")
@ApiOperation("upload of artifact to VF operation workflow")
- public ResponseEntity<String> artifactDeliveries(@RequestBody ArtifactDeliveriesRequestDto deliveriesRequestDto, @PathVariable("workflowId") String workflowId,
- @PathVariable("versionId") String versionId, @RequestHeader(USER_ID_HEADER) String user) {
- return associationHandler.execute(user, deliveriesRequestDto,
- workflowVersionManager.getArtifact(workflowId, versionId));
+ public ResponseEntity<String> artifactDeliveries(@RequestBody ArtifactDeliveriesRequestDto deliveriesRequestDto,
+ @PathVariable("workflowId") String workflowId, @PathVariable("versionId") String versionId,
+ @RequestHeader(USER_ID_HEADER) String user) {
+ return associationHandler
+ .execute(user, deliveriesRequestDto, workflowVersionManager.getArtifact(workflowId, versionId));
}
@PutMapping("/{versionId}/artifact")
@@ -139,9 +138,9 @@ public class WorkflowVersionController {
ArtifactEntity artifact = workflowVersionManager.getArtifact(workflowId, versionId);
return ResponseEntity.ok()
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + artifact.getFileName())
- .contentType(MediaType.APPLICATION_OCTET_STREAM)
- .body(new InputStreamResource(artifact.getArtifactData()));
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + artifact.getFileName())
+ .contentType(MediaType.APPLICATION_OCTET_STREAM)
+ .body(new InputStreamResource(artifact.getArtifactData()));
}
@DeleteMapping("/{versionId}/artifact")
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/mappers/ActivitySpecDtoMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/mappers/ActivitySpecDtoMapper.java
new file mode 100644
index 00000000..cea7c878
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/mappers/ActivitySpecDtoMapper.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.api.mappers;
+
+import org.mapstruct.Mapper;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecDataResponse;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecRequest;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecResponse;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+
+@Mapper(componentModel = "spring")
+public interface ActivitySpecDtoMapper {
+
+ ActivitySpecResponse toActivitySpecResponse(ActivitySpecEntity activitySpec);
+
+ ActivitySpecDataResponse toActivitySpecDataResponse(ActivitySpecEntity activitySpec);
+
+ ActivitySpecEntity fromActivitySpecRequest(ActivitySpecRequest request);
+
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java
new file mode 100644
index 00000000..1b8fb3c8
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java
@@ -0,0 +1,11 @@
+package org.onap.sdc.workflow.api.types;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class ErrorResponse {
+
+ private String message;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java
index a7f43cdd..147ca50b 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStateDto.java
@@ -18,7 +18,7 @@ package org.onap.sdc.workflow.api.types;
import java.util.List;
import lombok.Data;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
@Data
public class VersionStateDto {
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java
index c9d3bf1e..18ed50c5 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java
@@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.Getter;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecAction.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecAction.java
new file mode 100644
index 00000000..87a97fff
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecAction.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.api.types.activityspec;
+
+public enum ActivitySpecAction {
+ CERTIFY, DEPRECATE, DELETE
+} \ No newline at end of file
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidPaginationParameterException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecActionRequest.java
index a4d4a5d6..8b469da4 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/InvalidPaginationParameterException.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecActionRequest.java
@@ -1,11 +1,11 @@
/*
- * Copyright © 2018 European Support Limited
+ * 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
+ * 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,
@@ -14,11 +14,13 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.services.exceptions;
+package org.onap.sdc.workflow.api.types.activityspec;
-public class InvalidPaginationParameterException extends RuntimeException {
+import javax.validation.constraints.NotNull;
- public InvalidPaginationParameterException(String parameterName, String parameterValue, String message) {
- super(String.format("Requested %s: %s %s", parameterName, parameterValue, message));
- }
-} \ No newline at end of file
+@lombok.Data
+public class ActivitySpecActionRequest {
+
+ @NotNull
+ private ActivitySpecAction action;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecBase.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecBase.java
new file mode 100644
index 00000000..aa2a0ab2
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecBase.java
@@ -0,0 +1,15 @@
+package org.onap.sdc.workflow.api.types.activityspec;
+
+import java.util.List;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import lombok.Data;
+
+@Data
+abstract class ActivitySpecBase {
+
+ @NotBlank(message = "Mandatory name field is missing")
+ @Pattern(regexp = "^[a-zA-Z0-9-]*$", message = "name should match with \"^[a-zA-Z0-9-]*$\" pattern")
+ private String name;
+ private List<String> categoryList;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecCreateResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecCreateResponse.java
new file mode 100644
index 00000000..895c74e8
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecCreateResponse.java
@@ -0,0 +1,29 @@
+/*
+ * 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.api.types.activityspec;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public class ActivitySpecCreateResponse {
+
+ private String id;
+ private String versionId;
+}
+
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecDataResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecDataResponse.java
new file mode 100644
index 00000000..d4b1003f
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecDataResponse.java
@@ -0,0 +1,27 @@
+/*
+ * 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.api.types.activityspec;
+
+import lombok.EqualsAndHashCode;
+
+@lombok.Data
+@EqualsAndHashCode(callSuper = true)
+public class ActivitySpecDataResponse extends ActivitySpecRequest {
+
+ private String id;
+ private String status;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecRequest.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecRequest.java
new file mode 100644
index 00000000..fd29fdf3
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecRequest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.api.types.activityspec;
+
+import io.swagger.annotations.ApiModel;
+import java.util.List;
+import lombok.EqualsAndHashCode;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecParameter;
+
+@ApiModel(value = "ActivitySpecRequest")
+@lombok.Data
+@EqualsAndHashCode(callSuper = true)
+public class ActivitySpecRequest extends ActivitySpecBase {
+
+ private String description;
+ private List<ActivitySpecParameter> inputs;
+ private List<ActivitySpecParameter> outputs;
+ private String type;
+ private String content;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecResponse.java
new file mode 100644
index 00000000..a061b3fd
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/ActivitySpecResponse.java
@@ -0,0 +1,27 @@
+/*
+ * 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.api.types.activityspec;
+
+import lombok.EqualsAndHashCode;
+
+@lombok.Data
+@EqualsAndHashCode(callSuper = true)
+public class ActivitySpecResponse extends ActivitySpecBase {
+
+ private String id;
+ private String status;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/InternalEmptyObject.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/InternalEmptyObject.java
new file mode 100644
index 00000000..efbd4400
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/activityspec/InternalEmptyObject.java
@@ -0,0 +1,27 @@
+/*
+ * 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.api.types.activityspec;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+
+/**
+ * Object of this class can be used to create empty Response body like "{}".
+ */
+@JsonAutoDetect
+public class InternalEmptyObject {
+
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/ActivitySpecRepository.java
new file mode 100644
index 00000000..f8f1d9a9
--- /dev/null
+++ b/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/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java
new file mode 100644
index 00000000..05f2031b
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImpl.java
@@ -0,0 +1,143 @@
+/*
+ * 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.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+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.ZusammenElement;
+import com.amdocs.zusammen.datatypes.SessionContext;
+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.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.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class ActivitySpecRepositoryImpl implements ActivitySpecRepository {
+
+ private final ZusammenAdaptor zusammenAdaptor;
+
+ @Autowired
+ public ActivitySpecRepositoryImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void create(ActivitySpecEntity activitySpec) {
+ SessionContext context = createSessionContext();
+ ZusammenElement generalElement = mapActivityDetailsToZusammenElement(activitySpec, Action.CREATE);
+
+ ElementContext elementContext = new ElementContext(activitySpec.getId(), activitySpec.getVersion().getId());
+ zusammenAdaptor
+ .saveElement(context, elementContext, generalElement, "Create Activity Spec General Info Element");
+ }
+
+ @Override
+ public ActivitySpecEntity get(ActivitySpecEntity entity) {
+ SessionContext context = createSessionContext();
+
+ ElementContext elementContext = new ElementContext(entity.getId(), entity.getVersion().getId());
+ Optional<Element> element =
+ zusammenAdaptor.getElementByName(context, elementContext, null, ActivitySpecElementType.ACTIVITYSPEC.name());
+ return element.map(this::mapZusammenElementToActivityDetails).orElse(null);
+ }
+
+ @Override
+ public void update(ActivitySpecEntity entity) {
+ SessionContext context = createSessionContext();
+ ZusammenElement generalElement = mapActivityDetailsToZusammenElement(entity, Action.UPDATE);
+
+ ElementContext elementContext = new ElementContext(entity.getId(), entity.getVersion().getId());
+ zusammenAdaptor
+ .saveElement(context, 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/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 b49433cc..06e2a638 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
@@ -33,9 +33,9 @@ import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.onap.sdc.workflow.persistence.ArtifactRepository;
import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.onap.sdc.workflow.persistence.types.WorkflowElementType;
+import org.onap.sdc.workflow.persistence.impl.types.WorkflowElementType;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
@@ -43,8 +43,13 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
private static final String FILE_NAME_PROPERTY = "fileName";
private static final String EMPTY_DATA = "{}";
- private ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
+ private final ZusammenAdaptor zusammenAdaptor;
+
+ @Autowired
+ public ArtifactRepositoryImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
@Override
public void update(String workflowId, String versionId, ArtifactEntity artifactEntity) {
@@ -113,8 +118,7 @@ public class ArtifactRepositoryImpl implements ArtifactRepository {
artifactElement.setData(new ByteArrayInputStream(EMPTY_DATA.getBytes()));
artifactElement.getInfo().getProperties().remove(FILE_NAME_PROPERTY);
- zusammenAdaptor
- .saveElement(context, elementContext, artifactElement, "Delete WorkflowVersion Artifact Data");
+ zusammenAdaptor.saveElement(context, elementContext, artifactElement, "Delete WorkflowVersion Artifact Data");
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java
index 468e93fe..483c7097 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryImpl.java
@@ -33,19 +33,24 @@ import java.util.Optional;
import java.util.stream.Collectors;
import org.onap.sdc.workflow.persistence.ParameterRepository;
import org.onap.sdc.workflow.persistence.types.ParameterEntity;
-import org.onap.sdc.workflow.persistence.types.ParameterPropertyName;
+import org.onap.sdc.workflow.persistence.impl.types.ParameterPropertyName;
import org.onap.sdc.workflow.persistence.types.ParameterRole;
import org.onap.sdc.workflow.persistence.types.ParameterType;
-import org.onap.sdc.workflow.persistence.types.WorkflowElementType;
+import org.onap.sdc.workflow.persistence.impl.types.WorkflowElementType;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.types.ElementPropertyName;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class ParameterRepositoryImpl implements ParameterRepository {
- private ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory.getInstance().createInterface();
+ private final ZusammenAdaptor zusammenAdaptor;
+
+ @Autowired
+ public ParameterRepositoryImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
@Override
public void createStructure(String id, String versionId) {
@@ -150,7 +155,7 @@ public class ParameterRepositoryImpl implements ParameterRepository {
info.setName(parameter.getName());
info.addProperty(ElementPropertyName.elementType.name(), WorkflowElementType.valueOf(role.name()));
info.addProperty(ParameterPropertyName.TYPE.name(), parameter.getType());
- info.addProperty(ParameterPropertyName.mandatory.name(), parameter.isMandatory());
+ info.addProperty(ParameterPropertyName.MANDATORY.name(), parameter.isMandatory());
parameterElement.setInfo(info);
return parameterElement;
@@ -162,7 +167,7 @@ public class ParameterRepositoryImpl implements ParameterRepository {
parameterEntity.setName(elementInfo.getInfo().getName());
parameterEntity
.setType(ParameterType.valueOf(elementInfo.getInfo().getProperty(ParameterPropertyName.TYPE.name())));
- parameterEntity.setMandatory(elementInfo.getInfo().getProperty(ParameterPropertyName.mandatory.name()));
+ parameterEntity.setMandatory(elementInfo.getInfo().getProperty(ParameterPropertyName.MANDATORY.name()));
return parameterEntity;
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecData.java b/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/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/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java
index 90fb3085..e26b8088 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowProperty.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ActivitySpecElementType.java
@@ -1,11 +1,11 @@
/*
- * Copyright © 2018 European Support Limited
+ * 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
+ * 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,
@@ -14,12 +14,8 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.persistence.impl.types;
-public final class WorkflowProperty {
-
- private WorkflowProperty() {
- }
-
- public static final String CATEGORY = "category";
+public enum ActivitySpecElementType {
+ ACTIVITYSPEC
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterPropertyName.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java
index fa17bf69..300ddc49 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ParameterPropertyName.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/ParameterPropertyName.java
@@ -14,10 +14,8 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.persistence.impl.types;
public enum ParameterPropertyName {
-
- TYPE,
- mandatory
+ TYPE, MANDATORY
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowElementType.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java
index 10de37e0..109ce97c 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowElementType.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/impl/types/WorkflowElementType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.persistence.impl.types;
public enum WorkflowElementType {
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java
new file mode 100644
index 00000000..cf2db9a1
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecEntity.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+@lombok.Data
+@NoArgsConstructor
+public class ActivitySpecEntity {
+
+ private String id;
+ private Version version;
+ 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, Version version) {
+ this.id = id;
+ this.version = version;
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.java
new file mode 100644
index 00000000..3f2562e3
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/ActivitySpecParameter.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.types;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ActivitySpecParameter {
+
+ private String name;
+ private String type;
+ private String value;
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java
index 5105114f..f17cea1f 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java
@@ -16,9 +16,8 @@ public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
- .select()
- .apis(RequestHandlerSelectors.basePackage("org.onap.sdc.workflow.api"))
- .paths(regex("/workflows.*"))
+ .select().apis(RequestHandlerSelectors.basePackage("org.onap.sdc.workflow.api"))
+ .paths(regex("/(wf/workflows|v1.0/activity-spec).*"))
.build();
}
} \ No newline at end of file
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecConstant.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecConstant.java
new file mode 100644
index 00000000..bee916aa
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecConstant.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.services;
+
+public class ActivitySpecConstant {
+
+ public static final String CATEGORY_ATTRIBUTE_NAME = "category";
+ public static final String VERSION_ID_DEFAULT_VALUE = "latest";
+ public static final String ACTIVITY_SPEC_NOT_FOUND = "No Activity Spec found for the given identifiers";
+
+ private ActivitySpecConstant() {
+ //Utility Class declaring constants does not require instantiation.
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecManager.java
new file mode 100644
index 00000000..b93a8dc8
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/ActivitySpecManager.java
@@ -0,0 +1,34 @@
+/*
+ * 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.services;
+
+import java.util.Collection;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecAction;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+
+public interface ActivitySpecManager {
+
+ ActivitySpecEntity createActivitySpec(ActivitySpecEntity activitySpec);
+
+ ActivitySpecEntity get(ActivitySpecEntity activitySpec);
+
+ void update(ActivitySpecEntity activitySpec);
+
+ void actOnAction(ActivitySpecEntity activitySpec, ActivitySpecAction action);
+
+ Collection<ActivitySpecEntity> list(String versionStatus);
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java
index 0a8b640a..0a789829 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/UniqueValueService.java
@@ -17,18 +17,17 @@
package org.onap.sdc.workflow.services;
import java.util.Optional;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.onap.sdc.workflow.persistence.UniqueValueRepository;
import org.onap.sdc.workflow.persistence.types.UniqueValueEntity;
import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
-import org.openecomp.core.utilities.CommonMethods; // todo get rid of
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("uniqueValueService")
public class UniqueValueService {
- private static final char FORMATTED_UNIQUE_VALUE_SEPARATOR = '_';
+ private static final String FORMATTED_UNIQUE_VALUE_SEPARATOR = "_";
private final UniqueValueRepository uniqueValueRepository;
@@ -43,7 +42,7 @@ public class UniqueValueService {
* @param type the type
* @param uniqueCombination the unique combination
*/
- public void createUniqueValue(String type, String[] uniqueCombination) {
+ public void createUniqueValue(String type, String... uniqueCombination) {
formatValue(uniqueCombination).ifPresent(formattedValue -> {
validateUniqueValue(type, formattedValue, uniqueCombination);
uniqueValueRepository.insert(new UniqueValueEntity(type, formattedValue));
@@ -56,7 +55,7 @@ public class UniqueValueService {
* @param type the type
* @param uniqueCombination the unique combination
*/
- public void deleteUniqueValue(String type, String[] uniqueCombination) {
+ public void deleteUniqueValue(String type, String... uniqueCombination) {
formatValue(uniqueCombination)
.ifPresent(formattedValue -> uniqueValueRepository.delete(new UniqueValueEntity(type, formattedValue)));
@@ -70,10 +69,10 @@ public class UniqueValueService {
* @param newValue the new value
* @param uniqueContext the unique context
*/
- public void updateUniqueValue(String type, String oldValue, String newValue, String ... uniqueContext) {
+ public void updateUniqueValue(String type, String oldValue, String newValue, String... uniqueContext) {
if (newValue == null || !newValue.equalsIgnoreCase(oldValue)) {
- createUniqueValue(type, CommonMethods.concat(uniqueContext, new String[] {newValue}));
- deleteUniqueValue(type, CommonMethods.concat(uniqueContext, new String[] {oldValue}));
+ createUniqueValue(type, ArrayUtils.addAll(uniqueContext, newValue));
+ deleteUniqueValue(type, ArrayUtils.addAll(uniqueContext, oldValue));
}
}
@@ -83,19 +82,18 @@ public class UniqueValueService {
* @param type the type
* @param uniqueCombination the unique combination
*/
- public void validateUniqueValue(String type, String[] uniqueCombination) {
+ public void validateUniqueValue(String type, String... uniqueCombination) {
formatValue(uniqueCombination)
.ifPresent(formattedValue -> validateUniqueValue(type, formattedValue, uniqueCombination));
}
- /**
- * Checks if a unique value is taken.
- *
- * @return true if the unique value is occupied, false otherwise
- */
- public boolean isUniqueValueOccupied(String type, String[] uniqueCombination) {
- return formatValue(uniqueCombination).map(formattedValue -> isUniqueValueOccupied(type, formattedValue))
- .orElse(false);
+ private Optional<String> formatValue(String[] uniqueCombination) {
+ if (ArrayUtils.isEmpty(uniqueCombination) || getValueWithoutContext(uniqueCombination) == null) {
+ return Optional.empty();
+ }
+
+ uniqueCombination[uniqueCombination.length - 1] = getValueWithoutContext(uniqueCombination).toLowerCase();
+ return Optional.of(String.join(FORMATTED_UNIQUE_VALUE_SEPARATOR, uniqueCombination));
}
private void validateUniqueValue(String type, String formattedValue, String[] uniqueCombination) {
@@ -108,13 +106,14 @@ public class UniqueValueService {
return uniqueValueRepository.findById(new UniqueValueEntity(type, formattedValue)).isPresent();
}
- private Optional<String> formatValue(String[] uniqueCombination) {
- if (ArrayUtils.isEmpty(uniqueCombination) || getValueWithoutContext(uniqueCombination) == null) {
- return Optional.empty();
- }
-
- uniqueCombination[uniqueCombination.length - 1] = getValueWithoutContext(uniqueCombination).toLowerCase();
- return Optional.of(CommonMethods.arrayToSeparatedString(uniqueCombination, FORMATTED_UNIQUE_VALUE_SEPARATOR));
+ /**
+ * Checks if a unique value is taken.
+ *
+ * @return true if the unique value is occupied, false otherwise
+ */
+ public boolean isUniqueValueOccupied(String type, String... uniqueCombination) {
+ return formatValue(uniqueCombination).map(formattedValue -> isUniqueValueOccupied(type, formattedValue))
+ .orElse(false);
}
private String getValueWithoutContext(String[] uniqueCombination) {
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java
index fcae232a..3ef38d75 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowManager.java
@@ -16,10 +16,9 @@
package org.onap.sdc.workflow.services;
-import java.util.Collection;
import java.util.Set;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.Workflow;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.onap.sdc.workflow.services.types.Page;
import org.onap.sdc.workflow.services.types.RequestSpec;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java
index 8effb647..a7f5c421 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/WorkflowVersionManager.java
@@ -19,8 +19,8 @@ package org.onap.sdc.workflow.services;
import java.util.Collection;
import java.util.Set;
import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersion;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.springframework.web.multipart.MultipartFile;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java
index 87027a58..011b2746 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStateModificationException.java
@@ -16,7 +16,7 @@
package org.onap.sdc.workflow.services.exceptions;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
public class VersionStateModificationException extends RuntimeException {
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java
new file mode 100644
index 00000000..7264682a
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java
@@ -0,0 +1,12 @@
+package org.onap.sdc.workflow.services.exceptions;
+
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+
+public class VersionStatusModificationException extends RuntimeException {
+
+ public VersionStatusModificationException(String activitySpecId, String versionId, VersionStatus sourceState,
+ VersionStatus targetState) {
+ super(String.format("Activity spec %s, version %s: status can not be changed from %s to %s", activitySpecId,
+ versionId, sourceState.name(), targetState.name()));
+ }
+} \ No newline at end of file
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java
new file mode 100644
index 00000000..3cfaf4ae
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImpl.java
@@ -0,0 +1,248 @@
+/*
+ * 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.services.impl;
+
+import static org.onap.sdc.workflow.services.ActivitySpecConstant.ACTIVITY_SPEC_NOT_FOUND;
+import static org.onap.sdc.workflow.services.ActivitySpecConstant.VERSION_ID_DEFAULT_VALUE;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deleted;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Deprecated;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Draft;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import org.onap.sdc.workflow.api.types.activityspec.ActivitySpecAction;
+import org.onap.sdc.workflow.persistence.ActivitySpecRepository;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+import org.onap.sdc.workflow.services.ActivitySpecManager;
+import org.onap.sdc.workflow.services.UniqueValueService;
+import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
+import org.onap.sdc.workflow.services.exceptions.VersionStatusModificationException;
+import org.onap.sdc.workflow.services.impl.mappers.ActivitySpecMapper;
+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.ItemManager;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+@Service("activitySpecManager")
+public class ActivitySpecManagerImpl implements ActivitySpecManager {
+
+ private static final String ACTIVITY_SPEC_NAME = "ActivitySpec.Name";
+ private static final Logger LOGGER = LoggerFactory.getLogger(ActivitySpecManagerImpl.class);
+ private static final Map<VersionStatus, VersionStatus> EXPECTED_PREV_STATUS;
+
+ static {
+ EXPECTED_PREV_STATUS = new EnumMap<>(VersionStatus.class);
+ EXPECTED_PREV_STATUS.put(Certified, Draft);
+ EXPECTED_PREV_STATUS.put(Deprecated, Certified);
+ EXPECTED_PREV_STATUS.put(Deleted, Deprecated);
+ }
+
+ private final ItemManager itemManager;
+ private final VersioningManager versioningManager;
+ private final ActivitySpecRepository activitySpecDao;
+ private final UniqueValueService uniqueValueService;
+ private final ActivitySpecMapper activitySpecMapper;
+
+
+ @Autowired
+ public ActivitySpecManagerImpl(ItemManager itemManager, VersioningManager versioningManager,
+ ActivitySpecRepository activitySpecDao,
+ @Qualifier("uniqueValueService") UniqueValueService uniqueValueService,
+ ActivitySpecMapper activitySpecMapper) {
+ this.itemManager = itemManager;
+ this.versioningManager = versioningManager;
+ this.activitySpecDao = activitySpecDao;
+ this.uniqueValueService = uniqueValueService;
+ this.activitySpecMapper = activitySpecMapper;
+ }
+
+ @Override
+ public ActivitySpecEntity createActivitySpec(ActivitySpecEntity activitySpec) {
+
+ uniqueValueService.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpec.getName());
+
+ Item item = activitySpecMapper.activitySpecToItem(activitySpec);
+ item = itemManager.create(item);
+
+ Version version = getActivitySpecVersion(activitySpec);
+ versioningManager.create(item.getId(), version, VersionCreationMethod.major);
+
+ enrichActivitySpec(item, version, activitySpec);
+ activitySpecDao.create(activitySpec);
+
+ uniqueValueService.createUniqueValue(ACTIVITY_SPEC_NAME, activitySpec.getName());
+ return activitySpec;
+ }
+
+ @Override
+ public ActivitySpecEntity get(ActivitySpecEntity activitySpec) {
+ activitySpec.setVersion(calculateLatestVersion(activitySpec));
+ ActivitySpecEntity retrieved;
+ try {
+ retrieved = activitySpecDao.get(activitySpec);
+ } catch (SdcRuntimeException runtimeException) {
+ LOGGER.debug(
+ "Failed to retrieve activity spec for activitySpecId: " + activitySpec.getId() + " and version: "
+ + activitySpec.getVersion().getId(), runtimeException);
+ throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND);
+ }
+ if (retrieved != null) {
+ final Version retrievedVersion = versioningManager.get(activitySpec.getId(), activitySpec.getVersion());
+ retrieved.setStatus(Objects.nonNull(retrievedVersion) ? retrievedVersion.getStatus().name() : null);
+ }
+ return retrieved;
+ }
+
+ @Override
+ public void update(ActivitySpecEntity activitySpec) {
+ Item retrievedItem = itemManager.get(activitySpec.getId());
+ if (retrievedItem == null) {
+ LOGGER.error(String.format("Activity Spec with id %s was not found", activitySpec.getId()));
+ throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND);
+ }
+ uniqueValueService.updateUniqueValue(ACTIVITY_SPEC_NAME, retrievedItem.getName(), activitySpec.getName());
+
+ Item item = activitySpecMapper.activitySpecToItem(activitySpec);
+ item.setId(activitySpec.getId());
+ item.setStatus(retrievedItem.getStatus());
+ item.setVersionStatusCounters(retrievedItem.getVersionStatusCounters());
+ itemManager.update(item);
+
+ activitySpec.setVersion(calculateLatestVersion(activitySpec));
+ activitySpecDao.update(activitySpec);
+ }
+
+ @Override
+ public void actOnAction(ActivitySpecEntity activitySpec, ActivitySpecAction action) {
+ Version version = calculateLatestVersion(activitySpec);
+ if (action == ActivitySpecAction.CERTIFY) {
+ version.setStatus(Certified);
+ }
+ if (action == ActivitySpecAction.DEPRECATE) {
+ version.setStatus(Deprecated);
+ }
+ if (action == ActivitySpecAction.DELETE) {
+ version.setStatus(Deleted);
+ }
+
+ updateVersionStatus(activitySpec.getId(), action, version);
+ if (action == ActivitySpecAction.DELETE) {
+ final String activitySpecName = get(new ActivitySpecEntity(activitySpec.getId(), version)).getName();
+ uniqueValueService.deleteUniqueValue(ACTIVITY_SPEC_NAME, activitySpecName);
+ }
+ }
+
+ private void updateVersionStatus(String activitySpecId, ActivitySpecAction action, Version version) {
+ VersionStatus prevVersionStatus = null;
+ Version retrievedVersion;
+ try {
+ retrievedVersion = versioningManager.get(activitySpecId, version);
+ } catch (SdcRuntimeException exception) {
+ LOGGER.debug(
+ "Failed to get version for activitySpecId: " + activitySpecId + " and version: " + version.getId(),
+ exception);
+ throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND);
+
+ }
+
+ VersionStatus status = version.getStatus();
+ VersionStatus expectedPrevStatus = EXPECTED_PREV_STATUS.get(status);
+ if (expectedPrevStatus != null) {
+
+ VersionStatus retrievedStatus = Objects.nonNull(retrievedVersion) ? retrievedVersion.getStatus() : null;
+ if (retrievedStatus != expectedPrevStatus) {
+ LOGGER.debug("Failed to " + version.getStatus() + " since activity spec is in " + retrievedStatus);
+ throw new VersionStatusModificationException(activitySpecId, version.getId(), retrievedStatus, status);
+ }
+ prevVersionStatus = expectedPrevStatus;
+ }
+
+ if (Objects.nonNull(retrievedVersion)) {
+ retrievedVersion.setStatus(status);
+ versioningManager.updateVersion(activitySpecId, retrievedVersion);
+ itemManager.updateVersionStatus(activitySpecId, status, prevVersionStatus);
+ versioningManager.publish(activitySpecId, retrievedVersion, "actionOnActivitySpec :" + action.name());
+ }
+ }
+
+ @Override
+ public Collection<ActivitySpecEntity> list(String versionStatus) {
+ Predicate<Item> itemPredicate;
+ if (Objects.nonNull(versionStatus)) {
+ VersionStatus statusEnumValue;
+
+ try {
+ statusEnumValue = VersionStatus.valueOf(versionStatus);
+ } catch (IllegalArgumentException e) {
+ LOGGER.debug("Unexpected value of VersionStatus {}", versionStatus);
+ return Collections.emptyList();
+ }
+ itemPredicate =
+ item -> ItemType.ACTIVITYSPEC.name().equals(item.getType()) && item.getVersionStatusCounters()
+ .containsKey(
+ statusEnumValue);
+ } else {
+ itemPredicate = item -> ItemType.ACTIVITYSPEC.name().equals(item.getType());
+ }
+
+ return itemManager.list(itemPredicate).stream()
+ .sorted(Comparator.comparing(Item::getModificationTime).reversed())
+ .map(activitySpecMapper::itemToActivitySpec).collect(Collectors.toList());
+ }
+
+ private Version calculateLatestVersion(ActivitySpecEntity activitySpec) {
+ if (VERSION_ID_DEFAULT_VALUE.equalsIgnoreCase(activitySpec.getVersion().getId())) {
+ List<Version> list;
+ try {
+ list = versioningManager.list(activitySpec.getId());
+ } catch (SdcRuntimeException runtimeException) {
+ LOGGER.debug("Failed to list versions for activitySpecId " + activitySpec.getId(), runtimeException);
+ throw new EntityNotFoundException(ACTIVITY_SPEC_NOT_FOUND);
+ }
+ if (Objects.nonNull(list) && !list.isEmpty()) {
+ return list.get(0);
+ }
+ }
+ return activitySpec.getVersion();
+ }
+
+ private Version getActivitySpecVersion(ActivitySpecEntity activitySpecEntity) {
+ return activitySpecEntity.getVersion() == null ? new Version() : activitySpecEntity.getVersion();
+
+ }
+
+ private void enrichActivitySpec(Item item, Version version, ActivitySpecEntity activitySpecEntity) {
+ activitySpecEntity.setId(item.getId());
+ activitySpecEntity.setVersion(version);
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java
index 80b969cf..c0612436 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/CollaborationConfiguration.java
@@ -16,6 +16,8 @@
package org.onap.sdc.workflow.services.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.versioning.ItemManager;
import org.openecomp.sdc.versioning.ItemManagerFactory;
import org.openecomp.sdc.versioning.VersioningManager;
@@ -35,4 +37,9 @@ public class CollaborationConfiguration {
public VersioningManager versioningManager() {
return VersioningManagerFactory.getInstance().createInterface();
}
+
+ @Bean
+ public ZusammenAdaptor zusammenAdaptor() {
+ return ZusammenAdaptorFactory.getInstance().createInterface();
+ }
}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ItemType.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ItemType.java
new file mode 100644
index 00000000..8a05d88d
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/ItemType.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.services.impl;
+
+public enum ItemType {
+ WORKFLOW, ACTIVITYSPEC
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
index a3092042..e16c7b41 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
@@ -16,6 +16,7 @@
package org.onap.sdc.workflow.services.impl;
+import static org.onap.sdc.workflow.services.impl.ItemType.WORKFLOW;
import static org.onap.sdc.workflow.services.types.PagingConstants.DEFAULT_LIMIT;
import static org.onap.sdc.workflow.services.types.PagingConstants.DEFAULT_OFFSET;
import static org.onap.sdc.workflow.services.types.PagingConstants.MAX_LIMIT;
@@ -26,8 +27,8 @@ import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.Workflow;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.onap.sdc.workflow.services.UniqueValueService;
import org.onap.sdc.workflow.services.WorkflowManager;
import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
@@ -51,10 +52,9 @@ import org.springframework.stereotype.Service;
@Service("workflowManager")
public class WorkflowManagerImpl implements WorkflowManager {
- public static final String WORKFLOW_TYPE = "WORKFLOW";
private static final String WORKFLOW_NOT_FOUND_ERROR_MSG = "Workflow with id '%s' does not exist";
private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME";
- private static final Predicate<Item> WORKFLOW_ITEM_FILTER = item -> WORKFLOW_TYPE.equals(item.getType());
+ private static final Predicate<Item> WORKFLOW_ITEM_FILTER = item -> WORKFLOW.name().equals(item.getType());
private static final String WORKSPACES_SORT_PROPERTY = "name";
private static final RequestSpec WORKSPACES_DEFAULT_REQUEST_SPEC =
new RequestSpec(new PagingRequest(DEFAULT_OFFSET, DEFAULT_LIMIT),
@@ -84,7 +84,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
Set<VersionStatus> versionStatusesFilter =
versionStatesFilter == null ? null :
versionStatesFilter.stream().map(versionStateMapper::workflowVersionStateToVersionStatus)
- .collect(Collectors.toSet());
+ .collect(Collectors.toSet());
Collection<Item> workflowItems = itemManager.list(getFilter(versionStatusesFilter));
@@ -111,9 +111,9 @@ public class WorkflowManagerImpl implements WorkflowManager {
Item item = workflowMapper.workflowToItem(workflow);
item.setStatus(ItemStatus.ACTIVE);
- uniqueValueService.validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()});
+ uniqueValueService.validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, workflow.getName());
Item createdItem = itemManager.create(item);
- uniqueValueService.createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflow.getName()});
+ uniqueValueService.createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, workflow.getName());
return workflowMapper.itemToWorkflow(createdItem);
}
@@ -163,8 +163,8 @@ public class WorkflowManagerImpl implements WorkflowManager {
private static Comparator<Workflow> getWorkflowComparator(SortingRequest sorting) {
Boolean byNameAscending = sorting.getSorts().stream()
- .filter(sort -> WORKSPACES_SORT_PROPERTY.equalsIgnoreCase(sort.getProperty()))
- .findFirst().map(Sort::isAscendingOrder).orElse(true);
+ .filter(sort -> WORKSPACES_SORT_PROPERTY.equalsIgnoreCase(sort.getProperty()))
+ .findFirst().map(Sort::isAscendingOrder).orElse(true);
Comparator<Workflow> byName = Comparator.comparing(Workflow::getName);
return byNameAscending ? byName : byName.reversed();
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 14e28744..14a6722e 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
@@ -16,7 +16,7 @@
package org.onap.sdc.workflow.services.impl;
-import static org.onap.sdc.workflow.persistence.types.WorkflowVersionState.CERTIFIED;
+import static org.onap.sdc.workflow.services.types.WorkflowVersionState.CERTIFIED;
import java.io.IOException;
import java.io.InputStream;
@@ -34,8 +34,8 @@ import org.onap.sdc.workflow.persistence.ParameterRepository;
import org.onap.sdc.workflow.persistence.types.ArtifactEntity;
import org.onap.sdc.workflow.persistence.types.ParameterEntity;
import org.onap.sdc.workflow.persistence.types.ParameterRole;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersion;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.onap.sdc.workflow.services.WorkflowVersionManager;
import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
import org.onap.sdc.workflow.services.exceptions.InvalidArtifactException;
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/ActivitySpecMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/ActivitySpecMapper.java
new file mode 100644
index 00000000..d9e5a109
--- /dev/null
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/ActivitySpecMapper.java
@@ -0,0 +1,60 @@
+/*
+ * 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.services.impl.mappers;
+
+import static org.onap.sdc.workflow.services.ActivitySpecConstant.CATEGORY_ATTRIBUTE_NAME;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.mapstruct.InheritInverseConfiguration;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity;
+import org.onap.sdc.workflow.services.ActivitySpecConstant;
+import org.onap.sdc.workflow.services.impl.ItemType;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+
+@Mapper(componentModel = "spring", imports = {ItemType.class, ActivitySpecConstant.class})
+public interface ActivitySpecMapper {
+
+ @Mappings({@Mapping(source = "versionStatusCounters", target = "status"),
+ @Mapping(source = "properties", target = "categoryList")})
+ ActivitySpecEntity itemToActivitySpec(Item item);
+
+ @InheritInverseConfiguration
+ @Mappings({@Mapping(expression = "java(ItemType.ACTIVITYSPEC.name())", target = "type"),
+ @Mapping(target = "versionStatusCounters", ignore = true), @Mapping(target = "status", ignore = true),
+ @Mapping(source = "categoryList", target = "properties")})
+ Item activitySpecToItem(ActivitySpecEntity activitySpec);
+
+ default String versionStatusCountersToStatus(Map<VersionStatus, Integer> versionStatusCounters) {
+ return versionStatusCounters.keySet().stream().findFirst().map(Enum::name).orElse(null);
+ }
+
+ default Map<String, Object> categoriesToProperties(List<String> categories) {
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(CATEGORY_ATTRIBUTE_NAME, categories);
+ return properties;
+ }
+
+ default List<String> propertiesToCategories(Map<String, Object> properties) {
+ return (List<String>) properties.get(CATEGORY_ATTRIBUTE_NAME);
+ }
+}
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java
index a3a1cdcc..6dffb369 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapper.java
@@ -19,7 +19,7 @@ package org.onap.sdc.workflow.services.impl.mappers;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersion;
+import org.onap.sdc.workflow.services.types.WorkflowVersion;
import org.openecomp.sdc.versioning.dao.types.Version;
@Mapper(componentModel = "spring", uses = VersionStateMapper.class)
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java
index 45012b57..82f5814b 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapper.java
@@ -23,7 +23,7 @@ import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.ValueMapping;
import org.mapstruct.ValueMappings;
-import org.onap.sdc.workflow.persistence.types.WorkflowVersionState;
+import org.onap.sdc.workflow.services.types.WorkflowVersionState;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
@Mapper(componentModel = "spring")
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java
index 5cfcd7ed..1ca7c713 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapper.java
@@ -20,18 +20,18 @@ import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
-import org.onap.sdc.workflow.persistence.types.Workflow;
-import org.onap.sdc.workflow.services.impl.WorkflowManagerImpl;
+import org.onap.sdc.workflow.services.types.Workflow;
+import org.onap.sdc.workflow.services.impl.ItemType;
import org.openecomp.sdc.versioning.types.Item;
-@Mapper(componentModel = "spring", imports = WorkflowManagerImpl.class, uses = VersionStateMapper.class)
+@Mapper(componentModel = "spring", imports = ItemType.class, uses = VersionStateMapper.class)
public interface WorkflowMapper {
@Mapping(source = "versionStatusCounters", target = "versionStates")
Workflow itemToWorkflow(Item item);
@InheritInverseConfiguration
- @Mappings({@Mapping(expression = "java(WorkflowManagerImpl.WORKFLOW_TYPE)", target = "type"),
+ @Mappings({@Mapping(expression = "java(ItemType.WORKFLOW.name())", target = "type"),
@Mapping(target = "versionStatusCounters", ignore = true)})
Item workflowToItem(Workflow workflow);
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java
index 4b9f3449..dde708da 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.services.types;
import java.util.Collection;
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/services/types/WorkflowVersion.java
index b19f4a98..8a68db25 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/services/types/WorkflowVersion.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.services.types;
import java.util.Collection;
import java.util.Collections;
@@ -22,6 +22,8 @@ import java.util.Date;
import javax.validation.Valid;
import lombok.Data;
import org.onap.sdc.workflow.api.validation.NoDuplicates;
+import org.onap.sdc.workflow.persistence.types.ParameterEntity;
+
@Data
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowVersionState.java
index 2be1d4da..cccdd5c7 100644
--- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/WorkflowVersionState.java
+++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowVersionState.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.sdc.workflow.persistence.types;
+package org.onap.sdc.workflow.services.types;
import java.util.Arrays;
import java.util.Collections;