Search in sources :

Example 1 with PhysicalSpecDefinition

use of org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition in project waltz by khartec.

the class PhysicalSpecDefinitionService method updateStatus.

public boolean updateStatus(String userName, long specDefinitionId, ReleaseLifecycleStatusChangeCommand command) {
    checkNotNull(userName, "userName cannot be null");
    checkNotNull(command, "command cannot be null");
    PhysicalSpecDefinition specDefinition = physicalSpecDefinitionDao.getById(specDefinitionId);
    checkNotNull(specDefinition, "specDefinition cannot be null");
    ensureNewStatusIsValid(specDefinition, command.newStatus());
    if (command.newStatus() == ACTIVE) {
        physicalSpecDefinitionDao.markExistingActiveAsDeprecated(specDefinition.specificationId(), userName);
    }
    int result = physicalSpecDefinitionDao.updateStatus(specDefinitionId, command.newStatus(), userName);
    changeLogService.write(ImmutableChangeLog.builder().operation(Operation.UPDATE).userId(userName).parentReference(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specDefinition.specificationId())).message("Spec Definition Id: " + specDefinitionId + " status changed to " + command.newStatus()).build());
    return result == 1;
}
Also used : PhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition) ImmutablePhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.ImmutablePhysicalSpecDefinition)

Example 2 with PhysicalSpecDefinition

use of org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition in project waltz by khartec.

the class PhysicalSpecDefinitionService method delete.

public int delete(String userName, long specDefinitionId) {
    checkNotNull(userName, "userName cannot be null");
    PhysicalSpecDefinition specDefinition = physicalSpecDefinitionDao.getById(specDefinitionId);
    checkNotNull(specDefinition, "specDefinition cannot be null");
    int defDelCount = physicalSpecDefinitionDao.delete(specDefinitionId);
    int fieldDelCount = physicalSpecDefinitionFieldDao.deleteForSpecDefinition(specDefinitionId);
    int fileDelCount = physicalSpecDefinitionSampleFileDao.deleteForSpecDefinition(specDefinitionId);
    changeLogService.write(ImmutableChangeLog.builder().operation(Operation.REMOVE).userId(userName).parentReference(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specDefinition.specificationId())).message("Spec Definition Id: " + specDefinitionId + " removed").build());
    return defDelCount + fieldDelCount + fileDelCount;
}
Also used : PhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition) ImmutablePhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.ImmutablePhysicalSpecDefinition)

Example 3 with PhysicalSpecDefinition

use of org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition in project waltz by khartec.

the class PhysicalSpecDefinitionEndpoint method register.

@Override
public void register() {
    String findForSpecificationPath = WebUtilities.mkPath(BASE_URL, "specification", ":id");
    String findBySelectorPath = WebUtilities.mkPath(BASE_URL, "selector");
    String createPath = WebUtilities.mkPath(BASE_URL, "specification", ":id");
    String updateStatusPath = WebUtilities.mkPath(BASE_URL, "specification", ":id", "status");
    String deletePath = WebUtilities.mkPath(BASE_URL, "specification", ":id");
    ListRoute<PhysicalSpecDefinition> findForSpecificationRoute = (req, res) -> specDefinitionService.findForSpecification(WebUtilities.getId(req));
    ListRoute<PhysicalSpecDefinition> findBySelectorRoute = (req, res) -> specDefinitionService.findBySelector(WebUtilities.readIdSelectionOptionsFromBody(req));
    DatumRoute<Long> createRoute = (req, res) -> {
        WebUtilities.requireRole(userRoleService, req, SystemRole.LOGICAL_DATA_FLOW_EDITOR);
        PhysicalSpecDefinitionChangeCommand physicalSpecDefinitionChangeCommand = WebUtilities.readBody(req, PhysicalSpecDefinitionChangeCommand.class);
        long physicalSpecificationId = WebUtilities.getId(req);
        Set<String> existingVersions = map(specDefinitionService.findForSpecification(physicalSpecificationId), d -> d.version());
        if (existingVersions.contains(physicalSpecDefinitionChangeCommand.version())) {
            throw new DuplicateKeyException("Cannot create physical specification definition with version that already exists");
        }
        return specDefinitionService.create(WebUtilities.getUsername(req), physicalSpecificationId, physicalSpecDefinitionChangeCommand);
    };
    DatumRoute<Boolean> updateStatusRoute = (req, res) -> {
        WebUtilities.requireRole(userRoleService, req, SystemRole.LOGICAL_DATA_FLOW_EDITOR);
        return specDefinitionService.updateStatus(WebUtilities.getUsername(req), WebUtilities.getId(req), WebUtilities.readBody(req, ReleaseLifecycleStatusChangeCommand.class));
    };
    DatumRoute<Integer> deleteRoute = (req, res) -> {
        WebUtilities.requireRole(userRoleService, req, SystemRole.LOGICAL_DATA_FLOW_EDITOR);
        return specDefinitionService.delete(WebUtilities.getUsername(req), WebUtilities.getId(req));
    };
    EndpointUtilities.getForList(findForSpecificationPath, findForSpecificationRoute);
    EndpointUtilities.postForList(findBySelectorPath, findBySelectorRoute);
    EndpointUtilities.postForDatum(createPath, createRoute);
    EndpointUtilities.putForDatum(updateStatusPath, updateStatusRoute);
    EndpointUtilities.deleteForDatum(deletePath, deleteRoute);
}
Also used : ListRoute(org.finos.waltz.web.ListRoute) Endpoint(org.finos.waltz.web.endpoints.Endpoint) DatumRoute(org.finos.waltz.web.DatumRoute) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) PhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition) ReleaseLifecycleStatusChangeCommand(org.finos.waltz.model.ReleaseLifecycleStatusChangeCommand) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) UserRoleService(org.finos.waltz.service.user.UserRoleService) PhysicalSpecDefinitionService(org.finos.waltz.service.physical_specification_definition.PhysicalSpecDefinitionService) Service(org.springframework.stereotype.Service) WebUtilities(org.finos.waltz.web.WebUtilities) SystemRole(org.finos.waltz.model.user.SystemRole) DuplicateKeyException(org.finos.waltz.common.exception.DuplicateKeyException) PhysicalSpecDefinitionChangeCommand(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinitionChangeCommand) EndpointUtilities(org.finos.waltz.web.endpoints.EndpointUtilities) PhysicalSpecDefinitionChangeCommand(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinitionChangeCommand) Set(java.util.Set) DuplicateKeyException(org.finos.waltz.common.exception.DuplicateKeyException) PhysicalSpecDefinition(org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition)

Aggregations

PhysicalSpecDefinition (org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinition)3 ImmutablePhysicalSpecDefinition (org.finos.waltz.model.physical_specification_definition.ImmutablePhysicalSpecDefinition)2 Set (java.util.Set)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)1 DuplicateKeyException (org.finos.waltz.common.exception.DuplicateKeyException)1 ReleaseLifecycleStatusChangeCommand (org.finos.waltz.model.ReleaseLifecycleStatusChangeCommand)1 PhysicalSpecDefinitionChangeCommand (org.finos.waltz.model.physical_specification_definition.PhysicalSpecDefinitionChangeCommand)1 SystemRole (org.finos.waltz.model.user.SystemRole)1 PhysicalSpecDefinitionService (org.finos.waltz.service.physical_specification_definition.PhysicalSpecDefinitionService)1 UserRoleService (org.finos.waltz.service.user.UserRoleService)1 DatumRoute (org.finos.waltz.web.DatumRoute)1 ListRoute (org.finos.waltz.web.ListRoute)1 WebUtilities (org.finos.waltz.web.WebUtilities)1 Endpoint (org.finos.waltz.web.endpoints.Endpoint)1 EndpointUtilities (org.finos.waltz.web.endpoints.EndpointUtilities)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1