From 2158ba7a1c146fae914b2e22910257b945ade8dd Mon Sep 17 00:00:00 2001 From: Jhon Rondon Date: Fri, 8 Apr 2022 17:47:17 -0500 Subject: [PATCH 1/4] feat: Add tracing to controllers --- pom.xml | 50 +- .../StMicroserviceTaskApplicationStartup.java | 132 --- .../tasks/StMicroserviceTasksApplication.java | 6 +- .../tasks/business/TaskBusiness.java | 849 +++++++++--------- .../tasks/business/TaskCategoryBusiness.java | 6 +- .../tasks/business/TaskStateBusiness.java | 28 +- .../tasks/business/TaskTypeStepBusiness.java | 4 +- .../tasks/clients/UserFeignClient.java | 8 +- .../controllers/v1/TaskV1Controller.java | 466 +++++----- .../tasks/dto/BasicResponseDto.java | 45 - .../microservice/tasks/dto/CancelTaskDto.java | 24 +- .../microservice/tasks/dto/CreateTaskDto.java | 148 +-- .../tasks/dto/CreateTaskMetadataDto.java | 40 +- .../tasks/dto/CreateTaskPropertyDto.java | 46 +- .../tasks/dto/CreateTaskStepDto.java | 53 +- .../st/microservice/tasks/dto/ErrorDto.java | 45 - .../tasks/dto/TaskCategoryDto.java | 48 +- .../ai/st/microservice/tasks/dto/TaskDto.java | 210 ++--- .../microservice/tasks/dto/TaskMemberDto.java | 54 +- .../tasks/dto/TaskMetadataDto.java | 56 +- .../tasks/dto/TaskMetadataPropertyDto.java | 64 +- .../microservice/tasks/dto/TaskStateDto.java | 46 +- .../microservice/tasks/dto/TaskStepDto.java | 86 +- .../tasks/dto/TaskTypeStepDto.java | 48 +- .../ai/st/microservice/tasks/dto/UserDto.java | 168 ++-- .../entities/MetadataPropertyEntity.java | 74 +- .../tasks/entities/TaskCategoryEntity.java | 40 +- .../tasks/entities/TaskEntity.java | 210 ++--- .../tasks/entities/TaskMemberEntity.java | 76 +- .../tasks/entities/TaskMetadataEntity.java | 74 +- .../tasks/entities/TaskStateEntity.java | 40 +- .../tasks/entities/TaskStepEntity.java | 126 +-- .../tasks/entities/TaskTypeStepEntity.java | 56 +- .../tasks/exceptions/BusinessException.java | 28 +- .../exceptions/InputValidationException.java | 26 +- .../repositories/TaskMemberRepository.java | 5 +- .../tasks/repositories/TaskRepository.java | 66 +- .../tasks/services/ITaskCategoryService.java | 6 +- .../tasks/services/ITaskMemberService.java | 6 +- .../tasks/services/ITaskService.java | 26 +- .../tasks/services/ITaskStateService.java | 6 +- .../tasks/services/ITaskTypeStepService.java | 6 +- .../tasks/services/TaskCategoryService.java | 36 +- .../tasks/services/TaskMemberService.java | 40 +- .../tasks/services/TaskService.java | 132 +-- .../tasks/services/TaskStateService.java | 36 +- .../tasks/services/TaskTypeStepService.java | 36 +- .../tasks/services/tracing/SCMTracing.java | 27 + .../services/tracing/TracingKeyword.java | 17 + .../tasks/swagger/SwaggerConfig.java | 28 +- .../migration/V1_0_0__database_definition.sql | 219 +++++ .../StMicroserviceTasksApplicationTests.java | 6 +- 52 files changed, 2172 insertions(+), 2006 deletions(-) delete mode 100644 src/main/java/com/ai/st/microservice/tasks/StMicroserviceTaskApplicationStartup.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/dto/BasicResponseDto.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/dto/ErrorDto.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/services/tracing/SCMTracing.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java create mode 100644 src/main/resources/db/migration/V1_0_0__database_definition.sql diff --git a/pom.xml b/pom.xml index f5a427c..cb31745 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ Microservice Tasks - 1.8 + 11 Hoxton.RC1 @@ -91,6 +91,25 @@ org.springframework.cloud spring-cloud-starter-openfeign + + + com.ai.st.microservice.common + st-common + 1.1.6 + + + + com.newrelic.logging + logback + 2.3.2 + + + + com.newrelic.agent.java + newrelic-api + 7.5.0 + + @@ -111,6 +130,35 @@ org.springframework.boot spring-boot-maven-plugin + + net.revelc.code.formatter + formatter-maven-plugin + 2.18.0 + + LF + UTF-8 + + + + + format + + + + + + org.flywaydb + flyway-maven-plugin + 8.5.4 + + postgres + 123456 + jdbc:postgresql://localhost:54321/sistema-transicion + + tasks + + + diff --git a/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTaskApplicationStartup.java b/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTaskApplicationStartup.java deleted file mode 100644 index 0c63c29..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTaskApplicationStartup.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.ai.st.microservice.tasks; - -import com.ai.st.microservice.tasks.business.TaskCategoryBusiness; -import com.ai.st.microservice.tasks.business.TaskStateBusiness; -import com.ai.st.microservice.tasks.business.TaskTypeStepBusiness; -import com.ai.st.microservice.tasks.entities.TaskCategoryEntity; -import com.ai.st.microservice.tasks.entities.TaskStateEntity; -import com.ai.st.microservice.tasks.entities.TaskTypeStepEntity; -import com.ai.st.microservice.tasks.services.ITaskCategoryService; -import com.ai.st.microservice.tasks.services.ITaskStateService; -import com.ai.st.microservice.tasks.services.ITaskTypeStepService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.stereotype.Component; - -@Component -public class StMicroserviceTaskApplicationStartup implements ApplicationListener { - - private static final Logger log = LoggerFactory.getLogger(StMicroserviceTaskApplicationStartup.class); - - @Autowired - private ITaskStateService taskStateService; - - @Autowired - private ITaskCategoryService taskCategoryService; - - @Autowired - private ITaskTypeStepService typeStepService; - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - log.info("ST - Loading Domains ... "); - this.initTasksStates(); - this.initTypeSteps(); - this.initTasksCategories(); - } - - public void initTasksStates() { - Long countStates = taskStateService.getAllCount(); - if (countStates == 0) { - - try { - - TaskStateEntity taskStateAssiged = new TaskStateEntity(); - taskStateAssiged.setId(TaskStateBusiness.TASK_STATE_ASSIGNED); - taskStateAssiged.setName("ASIGNADA"); - taskStateService.createTaskState(taskStateAssiged); - - TaskStateEntity taskStateClosed = new TaskStateEntity(); - taskStateClosed.setId(TaskStateBusiness.TASK_STATE_CLOSED); - taskStateClosed.setName("CERRADA"); - taskStateService.createTaskState(taskStateClosed); - - TaskStateEntity taskStateCancelled = new TaskStateEntity(); - taskStateCancelled.setId(TaskStateBusiness.TASK_STATE_CANCELLED); - taskStateCancelled.setName("CANCELADA"); - taskStateService.createTaskState(taskStateCancelled); - - TaskStateEntity taskStateStarted = new TaskStateEntity(); - taskStateStarted.setId(TaskStateBusiness.TASK_STATE_STARTED); - taskStateStarted.setName("INICIADA"); - taskStateService.createTaskState(taskStateStarted); - - log.info("The domains have been loaded!"); - - } catch (Exception e) { - log.error("Failed to load domains"); - } - - } - } - - public void initTasksCategories() { - Long countCategories = taskCategoryService.getCount(); - if (countCategories == 0) { - - try { - - TaskCategoryEntity categoryIntegration = new TaskCategoryEntity(); - categoryIntegration.setId(TaskCategoryBusiness.TASK_CATEGORY_INTEGRATION); - categoryIntegration.setName("INTEGRACIÓN DE INSUMOS"); - taskCategoryService.createTaskCategory(categoryIntegration); - - TaskCategoryEntity categoryGeneration = new TaskCategoryEntity(); - categoryGeneration.setId(TaskCategoryBusiness.TASK_CATEGORY_CADASTRAL_INPUT_GENERATION); - categoryGeneration.setName("GENERACIÓN INSUMO CATASTRAL"); - taskCategoryService.createTaskCategory(categoryGeneration); - - TaskCategoryEntity categoryXTFQuality = new TaskCategoryEntity(); - categoryXTFQuality.setId(TaskCategoryBusiness.TASK_CATEGORY_XTF_QUALITY_RULES); - categoryXTFQuality.setName("CONTROL DE CALIDAD XTF"); - taskCategoryService.createTaskCategory(categoryXTFQuality); - - log.info("The domains 'categories' have been loaded!"); - } catch (Exception e) { - System.out.println("ERROR: " + e.getMessage()); - log.error("Failed to load 'categories' domains"); - } - - } - } - - public void initTypeSteps() { - - Long countTypes = typeStepService.getCount(); - if (countTypes == 0) { - - try { - - TaskTypeStepEntity step1 = new TaskTypeStepEntity(); - step1.setId(TaskTypeStepBusiness.TASK_TYPE_STEP_ONCE); - step1.setName("ÚNICA VEZ"); - typeStepService.createTypeStep(step1); - - TaskTypeStepEntity step2 = new TaskTypeStepEntity(); - step2.setId(TaskTypeStepBusiness.TASK_TYPE_STEP_ALWAYS); - step2.setName("SIEMPRE"); - typeStepService.createTypeStep(step2); - - log.info("The domains 'types steps' have been loaded!"); - } catch (Exception e) { - log.error("Failed to load 'types steps' domains"); - } - - } - - } - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplication.java b/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplication.java index 830dc07..09f8ffc 100644 --- a/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplication.java +++ b/src/main/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplication.java @@ -10,8 +10,8 @@ @SpringBootApplication public class StMicroserviceTasksApplication { - public static void main(String[] args) { - SpringApplication.run(StMicroserviceTasksApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(StMicroserviceTasksApplication.class, args); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java index ada1123..463980a 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java @@ -5,6 +5,9 @@ import java.util.List; import java.util.stream.Collectors; +import com.ai.st.microservice.tasks.services.tracing.SCMTracing; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -36,467 +39,489 @@ @Component public class TaskBusiness { - @Autowired - private ITaskService taskService; - - @Autowired - private TaskStateBusiness taskStateBusiness; - - @Autowired - private TaskCategoryService taskCategoryService; - - @Autowired - private TaskTypeStepService taskTypeStepService; - - @Autowired - private ITaskMemberService taskMemberService; - - public List getAllTasks() { - - List listTasksDto = new ArrayList(); - - List listTasksEntity = taskService.getAllTasks(); - for (TaskEntity taskEntity : listTasksEntity) { - TaskDto taskDto = entityParseDto(taskEntity); - listTasksDto.add(taskDto); - } - - return listTasksDto; - } - - public TaskDto createTask(String name, String description, List users, Date deadline, List categories, - List metadata, List steps) throws BusinessException { - - TaskDto taskDto = null; - - Date currentDate = new Date(); - - // validate if the deadline is greater than the current date - if (deadline != null) { - if (!deadline.after(currentDate)) { - throw new BusinessException("The deadline must be greater than the current date."); - } - } - - // set task state - TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_ASSIGNED); - if (taskStateDto == null) { - throw new BusinessException("Task state not found."); - } - - List listUsers = users.stream().distinct().collect(Collectors.toList()); - List listCategories = categories.stream().distinct().collect(Collectors.toList()); - - // validate categories - for (Long categoryId : listCategories) { - TaskCategoryEntity categoryEntity = taskCategoryService.getCategoryById(categoryId); - if (!(categoryEntity instanceof TaskCategoryEntity)) { - throw new BusinessException("No se ha encontrado la cagegoría."); - } - } - - // validate metadata - if (metadata.size() > 0) { - for (CreateTaskMetadataDto meta : metadata) { - if (meta.getKey().isEmpty() || meta.getKey() == null) { - throw new BusinessException("Metadato inválido."); - } - if (meta.getProperties().size() == 0) { - throw new BusinessException("El metadato debe tener al menos una propiedad."); - } - } - } - - // validate steps - if (steps.size() > 0) { - for (CreateTaskStepDto stepDto : steps) { - if (stepDto.getTitle().isEmpty() || stepDto.getTitle() == null) { - throw new BusinessException("El título del paso es requerido."); - } - if (stepDto.getDescription().isEmpty() || stepDto.getDescription() == null) { - throw new BusinessException("La descripción del paso es requerido."); - } - if (stepDto.getTypeStepId() == null) { - throw new BusinessException("La tipo de paso es requerido."); - } - TaskTypeStepEntity typeStepEntity = taskTypeStepService.getTypeStepById(stepDto.getTypeStepId()); - if (!(typeStepEntity instanceof TaskTypeStepEntity)) { - throw new BusinessException("La tipo de paso no existe."); - } - } - } - - try { - TaskEntity taskEntity = new TaskEntity(); - taskEntity.setName(name); - taskEntity.setDescription(description); - taskEntity.setDeadline(deadline); - taskEntity.setCreatedAt(currentDate); - - TaskStateEntity taskStateEntity = new TaskStateEntity(); - taskStateEntity.setId(taskStateDto.getId()); - taskEntity.setTaskState(taskStateEntity); - - // set categories - List categoriesEntity = new ArrayList(); - for (Long categoryId : listCategories) { - TaskCategoryEntity category = new TaskCategoryEntity(); - category.setId(categoryId); - categoriesEntity.add(category); - } - taskEntity.setCategories(categoriesEntity); - - // set metadata - if (metadata.size() > 0) { - List listMetadataEntity = new ArrayList(); - for (CreateTaskMetadataDto meta : metadata) { - TaskMetadataEntity metadataEntity = new TaskMetadataEntity(); - metadataEntity.setKey(meta.getKey()); - metadataEntity.setTask(taskEntity); - - // set properties - List propertiesEntity = new ArrayList<>(); - for (CreateTaskPropertyDto propertyDto : meta.getProperties()) { - MetadataPropertyEntity propertyEntity = new MetadataPropertyEntity(); - propertyEntity.setKey(propertyDto.getKey()); - propertyEntity.setValue(propertyDto.getValue()); - propertyEntity.setMetadata(metadataEntity); - propertiesEntity.add(propertyEntity); - } + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private ITaskService taskService; + + @Autowired + private TaskStateBusiness taskStateBusiness; + + @Autowired + private TaskCategoryService taskCategoryService; + + @Autowired + private TaskTypeStepService taskTypeStepService; + + @Autowired + private ITaskMemberService taskMemberService; + + public List getAllTasks() { + + List listTasksDto = new ArrayList<>(); + + List listTasksEntity = taskService.getAllTasks(); + for (TaskEntity taskEntity : listTasksEntity) { + TaskDto taskDto = entityParseDto(taskEntity); + listTasksDto.add(taskDto); + } + + return listTasksDto; + } + + public TaskDto createTask(String name, String description, List users, Date deadline, List categories, + List metadata, List steps) throws BusinessException { + + TaskDto taskDto; + + Date currentDate = new Date(); + + // validate if the deadline is greater than the current date + if (deadline != null) { + if (!deadline.after(currentDate)) { + throw new BusinessException("La fecha límite debe ser mayor a la fecha actual"); + } + } + + // set task state + TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_ASSIGNED); + if (taskStateDto == null) { + throw new BusinessException("No se ha encontrado el estado de la tarea."); + } + + List listUsers = users.stream().distinct().collect(Collectors.toList()); + List listCategories = categories.stream().distinct().collect(Collectors.toList()); + + // validate categories + for (Long categoryId : listCategories) { + TaskCategoryEntity categoryEntity = taskCategoryService.getCategoryById(categoryId); + if (categoryEntity == null) { + throw new BusinessException("No se ha encontrado la cagegoría."); + } + } + + // validate metadata + if (metadata.size() > 0) { + for (CreateTaskMetadataDto meta : metadata) { + if (meta.getKey().isEmpty() || meta.getKey() == null) { + throw new BusinessException("Metadato inválido."); + } + if (meta.getProperties().size() == 0) { + throw new BusinessException("El metadato debe tener al menos una propiedad."); + } + } + } + + // validate steps + if (steps.size() > 0) { + for (CreateTaskStepDto stepDto : steps) { + if (stepDto.getTitle().isEmpty() || stepDto.getTitle() == null) { + throw new BusinessException("El título del paso es requerido."); + } + if (stepDto.getDescription().isEmpty() || stepDto.getDescription() == null) { + throw new BusinessException("La descripción del paso es requerido."); + } + if (stepDto.getTypeStepId() == null) { + throw new BusinessException("La tipo de paso es requerido."); + } + TaskTypeStepEntity typeStepEntity = taskTypeStepService.getTypeStepById(stepDto.getTypeStepId()); + if (typeStepEntity == null) { + throw new BusinessException("La tipo de paso no existe."); + } + } + } + + try { + TaskEntity taskEntity = new TaskEntity(); + taskEntity.setName(name); + taskEntity.setDescription(description); + taskEntity.setDeadline(deadline); + taskEntity.setCreatedAt(currentDate); + + TaskStateEntity taskStateEntity = new TaskStateEntity(); + taskStateEntity.setId(taskStateDto.getId()); + taskEntity.setTaskState(taskStateEntity); + + // set categories + List categoriesEntity = new ArrayList<>(); + for (Long categoryId : listCategories) { + TaskCategoryEntity category = new TaskCategoryEntity(); + category.setId(categoryId); + categoriesEntity.add(category); + } + taskEntity.setCategories(categoriesEntity); + + // set metadata + if (metadata.size() > 0) { + List listMetadataEntity = new ArrayList<>(); + for (CreateTaskMetadataDto meta : metadata) { + TaskMetadataEntity metadataEntity = new TaskMetadataEntity(); + metadataEntity.setKey(meta.getKey()); + metadataEntity.setTask(taskEntity); + + // set properties + List propertiesEntity = new ArrayList<>(); + for (CreateTaskPropertyDto propertyDto : meta.getProperties()) { + MetadataPropertyEntity propertyEntity = new MetadataPropertyEntity(); + propertyEntity.setKey(propertyDto.getKey()); + propertyEntity.setValue(propertyDto.getValue()); + propertyEntity.setMetadata(metadataEntity); + propertiesEntity.add(propertyEntity); + } + + metadataEntity.setProperties(propertiesEntity); + + listMetadataEntity.add(metadataEntity); + } + taskEntity.setMetadata(listMetadataEntity); + } + + if (steps.size() > 0) { + + List listStepsEntity = new ArrayList<>(); + for (CreateTaskStepDto stepDto : steps) { + + TaskStepEntity stepEntity = new TaskStepEntity(); + stepEntity.setCode("N/A"); + stepEntity.setDescription(stepDto.getDescription()); + stepEntity.setStatus(false); + stepEntity.setTask(taskEntity); + TaskTypeStepEntity typeStepEntity = taskTypeStepService.getTypeStepById(stepDto.getTypeStepId()); + stepEntity.setTypeStep(typeStepEntity); - metadataEntity.setProperties(propertiesEntity); - - listMetadataEntity.add(metadataEntity); - } - taskEntity.setMetadata(listMetadataEntity); - } - - if (steps.size() > 0) { - - List listStepsEntity = new ArrayList<>(); - for (CreateTaskStepDto stepDto : steps) { - - TaskStepEntity stepEntity = new TaskStepEntity(); - stepEntity.setCode("N/A"); - stepEntity.setDescription(stepDto.getDescription()); - stepEntity.setStatus(false); - stepEntity.setTask(taskEntity); - TaskTypeStepEntity typeStepEntity = taskTypeStepService.getTypeStepById(stepDto.getTypeStepId()); - stepEntity.setTypeStep(typeStepEntity); + listStepsEntity.add(stepEntity); + } + + taskEntity.setSteps(listStepsEntity); + } + + TaskEntity newTaskEntity = taskService.createTask(taskEntity); - listStepsEntity.add(stepEntity); - } + for (Long userCode : listUsers) { + this.addMemberToTask(newTaskEntity, userCode); + } + + taskDto = this.getTaskById(newTaskEntity.getId()); + + } catch (Exception e) { + String messageError = String.format("Error creando tarea: %s", e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido crear la tarea"); + } - taskEntity.setSteps(listStepsEntity); - } + return taskDto; + } - TaskEntity newTaskEntity = taskService.createTask(taskEntity); + public TaskDto getTaskById(Long id) { - for (Long userCode : listUsers) { - this.addMemberToTask(newTaskEntity, userCode); - } - - taskDto = this.getTaskById(newTaskEntity.getId()); + TaskDto taskDto = null; - } catch (Exception e) { - throw new BusinessException("The task could not be created.: " + e.getMessage()); - } + TaskEntity taskEntity = taskService.getById(id); - return taskDto; - } + if (taskEntity != null) { + taskDto = entityParseDto(taskEntity); + } - public TaskDto getTaskById(Long id) { + return taskDto; + } - TaskDto taskDto = null; + public List getTasksByFilters(Long memberCode, List taskStates, List taskCategories) { - TaskEntity taskEntity = taskService.getById(id); + List listTasksDto = new ArrayList<>(); - if (taskEntity instanceof TaskEntity) { - taskDto = entityParseDto(taskEntity); - } + List listTasksEntity; - return taskDto; - } + if (memberCode != null && taskStates != null && taskStates.size() > 0 && taskCategories != null + && taskCategories.size() > 0) { - public List getTasksByFilters(Long memberCode, List taskStates, List taskCategories) { + // all filters + listTasksEntity = taskService.getTasksByStatesAndMemberAndCategories(taskStates, taskCategories, + memberCode); - List listTasksDto = new ArrayList(); + } else if (memberCode != null && taskStates != null && taskStates.size() > 0) { - List listTasksEntity = new ArrayList(); + // filter by states and member + listTasksEntity = taskService.getTasksByStatesAndMember(taskStates, memberCode); - if (memberCode != null && taskStates != null && taskStates.size() > 0 && taskCategories != null - && taskCategories.size() > 0) { + } else if (memberCode != null && taskCategories != null && taskCategories.size() > 0) { - // all filters - listTasksEntity = taskService.getTasksByStatesAndMemberAndCategories(taskStates, taskCategories, - memberCode); + // filter by categories and member + listTasksEntity = taskService.getTasksByMemberAndCategories(taskCategories, memberCode); - } else if (memberCode != null && taskStates != null && taskStates.size() > 0) { + } else if (taskCategories != null && taskCategories.size() > 0 && taskStates != null && taskStates.size() > 0) { - // filter by states and member - listTasksEntity = taskService.getTasksByStatesAndMember(taskStates, memberCode); + // filter by categories and state + listTasksEntity = taskService.getTasksByStatesAndCategories(taskCategories, taskStates); - } else if (memberCode != null && taskCategories != null && taskCategories.size() > 0) { + } else if (memberCode != null) { - // filter by categories and member - listTasksEntity = taskService.getTasksByMemberAndCategories(taskCategories, memberCode); + // filter by member + listTasksEntity = taskService.getTasksByMember(memberCode); - } else if (taskCategories != null && taskCategories.size() > 0 && taskStates != null && taskStates.size() > 0) { + } else if (taskStates != null && taskStates.size() > 0) { - // filter by categories and state - listTasksEntity = taskService.getTasksByStatesAndCategories(taskCategories, taskStates); + // filter by states + listTasksEntity = taskService.getTasksByStates(taskStates); - } else if (memberCode != null) { + } else if (taskCategories != null && taskCategories.size() > 0) { - // filter by member - listTasksEntity = taskService.getTasksByMember(memberCode); + // filter by categories + listTasksEntity = taskService.getTasksByCategories(taskCategories); - } else if (taskStates != null && taskStates.size() > 0) { + } else { - // filter by states - listTasksEntity = taskService.getTasksByStates(taskStates); + // no filters + listTasksEntity = taskService.getAllTasks(); + } - } else if (taskCategories != null && taskCategories.size() > 0) { + for (TaskEntity taskEntity : listTasksEntity) { + TaskDto taskDto = entityParseDto(taskEntity); + listTasksDto.add(taskDto); + } - // filter by categories - listTasksEntity = taskService.getTasksByCategories(taskCategories); + return listTasksDto; + } - } else { + public TaskDto closeTask(Long taskId) throws BusinessException { - // no filters - listTasksEntity = taskService.getAllTasks(); - } + TaskDto taskDto; - for (TaskEntity taskEntity : listTasksEntity) { - TaskDto taskDto = entityParseDto(taskEntity); - listTasksDto.add(taskDto); - } + // verify task exists + TaskEntity taskEntity = taskService.getById(taskId); + if (taskEntity == null) { + throw new BusinessException("No se ha encontrado la tarea"); + } - return listTasksDto; - } + Date currentDate = new Date(); + taskEntity.setClosingDate(currentDate); - public TaskDto closeTask(Long taskId) throws BusinessException { + // set task state + TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_CLOSED); + if (taskStateDto == null) { + throw new BusinessException("No se ha encontrado el estado de tarea"); + } + TaskStateEntity taskStateEntity = new TaskStateEntity(); + taskStateEntity.setId(taskStateDto.getId()); + taskEntity.setTaskState(taskStateEntity); - TaskDto taskDto = null; + try { - // verify task exists - TaskEntity taskEntity = taskService.getById(taskId); - if (!(taskEntity instanceof TaskEntity)) { - throw new BusinessException("Task not found."); - } + TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); + taskDto = getTaskById(taskUpdatedEntity.getId()); - Date currentDate = new Date(); - taskEntity.setClosingDate(currentDate); + } catch (Exception e) { + String messageError = String.format("Error cerrando la tarea %d: %s", taskId, e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido cerrar la tarea."); + } - // set task state - TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_CLOSED); - if (taskStateDto == null) { - throw new BusinessException("Task state not found."); - } - TaskStateEntity taskStateEntity = new TaskStateEntity(); - taskStateEntity.setId(taskStateDto.getId()); - taskEntity.setTaskState(taskStateEntity); + return taskDto; + } - try { + public TaskDto startTask(Long taskId) throws BusinessException { - TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); - taskDto = getTaskById(taskUpdatedEntity.getId()); + TaskDto taskDto; - } catch (Exception e) { - throw new BusinessException("The task could not be updated."); - } + // verify task exists + TaskEntity taskEntity = taskService.getById(taskId); + if (taskEntity == null) { + throw new BusinessException("No se ha encontrado la tarea"); + } - return taskDto; - } + // set task state + TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_STARTED); + if (taskStateDto == null) { + throw new BusinessException("No se ha encontrado el estado de tarea"); + } + TaskStateEntity taskStateEntity = new TaskStateEntity(); + taskStateEntity.setId(taskStateDto.getId()); + taskEntity.setTaskState(taskStateEntity); - public TaskDto startTask(Long taskId) throws BusinessException { + try { - TaskDto taskDto = null; + TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); + taskDto = this.getTaskById(taskUpdatedEntity.getId()); - // verify task exists - TaskEntity taskEntity = taskService.getById(taskId); - if (!(taskEntity instanceof TaskEntity)) { - throw new BusinessException("Task not found."); - } + } catch (Exception e) { + String messageError = String.format("Error iniciando la tarea %d: %s", taskId, e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido iniciar la tarea."); + } - // set task state - TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_STARTED); - if (taskStateDto == null) { - throw new BusinessException("Task state not found."); - } - TaskStateEntity taskStateEntity = new TaskStateEntity(); - taskStateEntity.setId(taskStateDto.getId()); - taskEntity.setTaskState(taskStateEntity); + return taskDto; + } - try { + public TaskDto cancelTask(Long taskId, String reason) throws BusinessException { - TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); - taskDto = this.getTaskById(taskUpdatedEntity.getId()); + TaskDto taskDto; - } catch (Exception e) { - throw new BusinessException("The task could not be updated."); - } + // verify task exists + TaskEntity taskEntity = taskService.getById(taskId); + if (taskEntity == null) { + throw new BusinessException("No se ha encontrado la tarea"); + } - return taskDto; - } - - public TaskDto cancelTask(Long taskId, String reason) throws BusinessException { - - TaskDto taskDto = null; - - // verify task exists - TaskEntity taskEntity = taskService.getById(taskId); - if (!(taskEntity instanceof TaskEntity)) { - throw new BusinessException("Task not found."); - } - - // set task state - TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_CANCELLED); - if (taskStateDto == null) { - throw new BusinessException("Task state not found."); - } - TaskStateEntity taskStateEntity = new TaskStateEntity(); - taskStateEntity.setId(taskStateDto.getId()); - taskEntity.setTaskState(taskStateEntity); - taskEntity.setReason(reason); - - try { - - TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); - taskDto = getTaskById(taskUpdatedEntity.getId()); - - } catch (Exception e) { - throw new BusinessException("The task could not be updated."); - } - - return taskDto; - } - - public TaskDto removeUserFromTask(Long taskId, Long memberCode) throws BusinessException { - - TaskDto taskDto = null; - - // verify task exists - TaskEntity taskEntity = taskService.getById(taskId); - if (!(taskEntity instanceof TaskEntity)) { - throw new BusinessException("Task not found."); - } - - // find member - List taskMembers = taskEntity.getMembers(); - TaskMemberEntity memberFound = taskMembers.stream() - .filter(memberEntity -> memberEntity.getMemberCode().equals(memberCode)).findAny().orElse(null); - if (!(memberFound instanceof TaskMemberEntity)) { - throw new BusinessException("Task member not found."); - } - - try { - - taskMemberService.removeMemberById(memberFound.getId()); - taskDto = this.getTaskById(taskId); - - } catch (Exception e) { - throw new BusinessException("The task could not be updated."); - } - - return taskDto; - } - - public void addMemberToTask(TaskEntity taskEntity, Long memberCode) throws BusinessException { - - // find member - List taskMembers = taskEntity.getMembers(); - TaskMemberEntity memberFound = taskMembers.stream() - .filter(memberEntity -> memberEntity.getMemberCode().equals(memberCode)).findAny().orElse(null); - if (memberFound instanceof TaskMemberEntity) { - throw new BusinessException("The member has already registered in the task."); - } - - try { - - TaskMemberEntity taskMemberEntity = new TaskMemberEntity(); - taskMemberEntity.setMemberCode(memberCode); - taskMemberEntity.setCreatedAt(new Date()); - taskMemberEntity.setTask(taskEntity); - - taskMemberService.addMemberToTask(taskMemberEntity); - - } catch (Exception e) { - throw new BusinessException("The task could not be updated."); - } - - } - - public TaskDto entityParseDto(TaskEntity taskEntity) { - - TaskDto taskDto = null; - - if (taskEntity instanceof TaskEntity) { - taskDto = new TaskDto(); - - taskDto.setId(taskEntity.getId()); - taskDto.setName(taskEntity.getName()); - taskDto.setDescription(taskEntity.getDescription()); - taskDto.setCreatedAt(taskEntity.getCreatedAt()); - taskDto.setDeadline(taskEntity.getDeadline()); - taskDto.setClosingDate(taskEntity.getClosingDate()); - taskDto.setReason(taskEntity.getReason()); - - // set state - TaskStateEntity taskStateEntity = taskEntity.getTaskState(); - if (taskStateEntity.getName() == null) { - taskDto.setTaskState(taskStateBusiness.getById(taskStateEntity.getId())); - } else { - taskDto.setTaskState(new TaskStateDto(taskStateEntity.getId(), taskStateEntity.getName())); - } - - // set members - for (TaskMemberEntity taskMemberEntity : taskEntity.getMembers()) { - TaskMemberDto member = new TaskMemberDto(); - member.setId(taskMemberEntity.getId()); - member.setMemberCode(taskMemberEntity.getMemberCode()); - member.setCreatedAt(taskMemberEntity.getCreatedAt()); - taskDto.getMembers().add(member); - } - - // set categories - for (TaskCategoryEntity categoryEntity : taskEntity.getCategories()) { - TaskCategoryDto categoryDto = new TaskCategoryDto(); - categoryDto.setId(categoryEntity.getId()); - categoryDto.setName(categoryEntity.getName()); - taskDto.getCategories().add(categoryDto); - } - - // set metadata - for (TaskMetadataEntity metadata : taskEntity.getMetadata()) { - TaskMetadataDto metadataDto = new TaskMetadataDto(); - metadataDto.setId(metadata.getId()); - metadataDto.setKey(metadata.getKey()); - - for (MetadataPropertyEntity propertyEntity : metadata.getProperties()) { - - metadataDto.getProperties().add(new TaskMetadataPropertyDto(propertyEntity.getId(), - propertyEntity.getKey(), propertyEntity.getValue())); - } - - taskDto.getMetadata().add(metadataDto); - } - - // set steps - for (TaskStepEntity stepEntity : taskEntity.getSteps()) { - TaskStepDto stepDto = new TaskStepDto(); - stepDto.setCode(stepEntity.getCode()); - stepDto.setDescription(stepEntity.getDescription()); - stepDto.setId(stepEntity.getId()); - stepDto.setStatus(stepEntity.getStatus()); - stepDto.setTypeStep( - new TaskTypeStepDto(stepEntity.getTypeStep().getId(), stepEntity.getTypeStep().getName())); - taskDto.getSteps().add(stepDto); - } - - } - - return taskDto; - } + // set task state + TaskStateDto taskStateDto = taskStateBusiness.getById(TaskStateBusiness.TASK_STATE_CANCELLED); + if (taskStateDto == null) { + throw new BusinessException("No se ha encontrado el estado de tarea"); + } + TaskStateEntity taskStateEntity = new TaskStateEntity(); + taskStateEntity.setId(taskStateDto.getId()); + taskEntity.setTaskState(taskStateEntity); + taskEntity.setReason(reason); + + try { + + TaskEntity taskUpdatedEntity = taskService.updateTask(taskEntity); + taskDto = getTaskById(taskUpdatedEntity.getId()); + + } catch (Exception e) { + String messageError = String.format("Error cancelando la tarea %d: %s", taskId, e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido cancelar la tarea."); + } + + return taskDto; + } + + public TaskDto removeUserFromTask(Long taskId, Long memberCode) throws BusinessException { + + TaskDto taskDto; + + // verify task exists + TaskEntity taskEntity = taskService.getById(taskId); + if (taskEntity == null) { + throw new BusinessException("No se ha encontrado la tarea"); + } + + // find member + List taskMembers = taskEntity.getMembers(); + TaskMemberEntity memberFound = taskMembers.stream() + .filter(memberEntity -> memberEntity.getMemberCode().equals(memberCode)).findAny().orElse(null); + if (memberFound == null) { + throw new BusinessException("No se ha encontrado el miembro"); + } + + try { + + taskMemberService.removeMemberById(memberFound.getId()); + taskDto = this.getTaskById(taskId); + + } catch (Exception e) { + String messageError = String.format("Error quitando el usuario %d de la tarea %d: %s", memberCode, taskId, + e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido quitar el usuario de la tarea."); + } + + return taskDto; + } + + public void addMemberToTask(TaskEntity taskEntity, Long memberCode) throws BusinessException { + + // find member + List taskMembers = taskEntity.getMembers(); + TaskMemberEntity memberFound = taskMembers.stream() + .filter(memberEntity -> memberEntity.getMemberCode().equals(memberCode)).findAny().orElse(null); + if (memberFound != null) { + throw new BusinessException("El miembro ya se encuentra registrado en la tarea"); + } + + try { + + TaskMemberEntity taskMemberEntity = new TaskMemberEntity(); + taskMemberEntity.setMemberCode(memberCode); + taskMemberEntity.setCreatedAt(new Date()); + taskMemberEntity.setTask(taskEntity); + + taskMemberService.addMemberToTask(taskMemberEntity); + + } catch (Exception e) { + String messageError = String.format("Error agregando el usuario %d de la tarea %d: %s", memberCode, + taskEntity.getId(), e.getMessage()); + SCMTracing.sendError(messageError); + log.error(messageError); + throw new BusinessException("No se ha podido agregar el usuario a la tarea."); + } + + } + + public TaskDto entityParseDto(TaskEntity taskEntity) { + + TaskDto taskDto = null; + + if (taskEntity != null) { + taskDto = new TaskDto(); + + taskDto.setId(taskEntity.getId()); + taskDto.setName(taskEntity.getName()); + taskDto.setDescription(taskEntity.getDescription()); + taskDto.setCreatedAt(taskEntity.getCreatedAt()); + taskDto.setDeadline(taskEntity.getDeadline()); + taskDto.setClosingDate(taskEntity.getClosingDate()); + taskDto.setReason(taskEntity.getReason()); + + // set state + TaskStateEntity taskStateEntity = taskEntity.getTaskState(); + if (taskStateEntity.getName() == null) { + taskDto.setTaskState(taskStateBusiness.getById(taskStateEntity.getId())); + } else { + taskDto.setTaskState(new TaskStateDto(taskStateEntity.getId(), taskStateEntity.getName())); + } + + // set members + for (TaskMemberEntity taskMemberEntity : taskEntity.getMembers()) { + TaskMemberDto member = new TaskMemberDto(); + member.setId(taskMemberEntity.getId()); + member.setMemberCode(taskMemberEntity.getMemberCode()); + member.setCreatedAt(taskMemberEntity.getCreatedAt()); + taskDto.getMembers().add(member); + } + + // set categories + for (TaskCategoryEntity categoryEntity : taskEntity.getCategories()) { + TaskCategoryDto categoryDto = new TaskCategoryDto(); + categoryDto.setId(categoryEntity.getId()); + categoryDto.setName(categoryEntity.getName()); + taskDto.getCategories().add(categoryDto); + } + + // set metadata + for (TaskMetadataEntity metadata : taskEntity.getMetadata()) { + TaskMetadataDto metadataDto = new TaskMetadataDto(); + metadataDto.setId(metadata.getId()); + metadataDto.setKey(metadata.getKey()); + + for (MetadataPropertyEntity propertyEntity : metadata.getProperties()) { + + metadataDto.getProperties().add(new TaskMetadataPropertyDto(propertyEntity.getId(), + propertyEntity.getKey(), propertyEntity.getValue())); + } + + taskDto.getMetadata().add(metadataDto); + } + + // set steps + for (TaskStepEntity stepEntity : taskEntity.getSteps()) { + TaskStepDto stepDto = new TaskStepDto(); + stepDto.setCode(stepEntity.getCode()); + stepDto.setDescription(stepEntity.getDescription()); + stepDto.setId(stepEntity.getId()); + stepDto.setStatus(stepEntity.getStatus()); + stepDto.setTypeStep( + new TaskTypeStepDto(stepEntity.getTypeStep().getId(), stepEntity.getTypeStep().getName())); + taskDto.getSteps().add(stepDto); + } + + } + + return taskDto; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskCategoryBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskCategoryBusiness.java index b451ddc..2665fd7 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskCategoryBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskCategoryBusiness.java @@ -5,8 +5,8 @@ @Component public class TaskCategoryBusiness { - public static final Long TASK_CATEGORY_INTEGRATION = (long) 1; - public static final Long TASK_CATEGORY_CADASTRAL_INPUT_GENERATION = (long) 2; - public static final Long TASK_CATEGORY_XTF_QUALITY_RULES = (long) 3; + public static final Long TASK_CATEGORY_INTEGRATION = (long) 1; + public static final Long TASK_CATEGORY_CADASTRAL_INPUT_GENERATION = (long) 2; + public static final Long TASK_CATEGORY_XTF_QUALITY_RULES = (long) 3; } diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java index e093791..e876a2c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java @@ -10,24 +10,24 @@ @Component public class TaskStateBusiness { - public static final Long TASK_STATE_ASSIGNED = (long) 1; - public static final Long TASK_STATE_CLOSED = (long) 2; - public static final Long TASK_STATE_CANCELLED = (long) 3; - public static final Long TASK_STATE_STARTED = (long) 4; + public static final Long TASK_STATE_ASSIGNED = (long) 1; + public static final Long TASK_STATE_CLOSED = (long) 2; + public static final Long TASK_STATE_CANCELLED = (long) 3; + public static final Long TASK_STATE_STARTED = (long) 4; - @Autowired - private ITaskStateService taskStateService; + @Autowired + private ITaskStateService taskStateService; - public TaskStateDto getById(Long id) { + public TaskStateDto getById(Long id) { - TaskStateDto taskStateDto = null; + TaskStateDto taskStateDto = null; - TaskStateEntity taskStateEntity = taskStateService.getById(id); - if (taskStateEntity instanceof TaskStateEntity) { - taskStateDto = new TaskStateDto(taskStateEntity.getId(), taskStateEntity.getName()); - } + TaskStateEntity taskStateEntity = taskStateService.getById(id); + if (taskStateEntity instanceof TaskStateEntity) { + taskStateDto = new TaskStateDto(taskStateEntity.getId(), taskStateEntity.getName()); + } - return taskStateDto; - } + return taskStateDto; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskTypeStepBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskTypeStepBusiness.java index d1a1662..37eec5c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskTypeStepBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskTypeStepBusiness.java @@ -5,7 +5,7 @@ @Component public class TaskTypeStepBusiness { - public static final Long TASK_TYPE_STEP_ONCE = (long) 1; - public static final Long TASK_TYPE_STEP_ALWAYS = (long) 2; + public static final Long TASK_TYPE_STEP_ONCE = (long) 1; + public static final Long TASK_TYPE_STEP_ALWAYS = (long) 2; } diff --git a/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java b/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java index 08e6a25..a8b647f 100644 --- a/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java +++ b/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java @@ -10,10 +10,10 @@ @FeignClient(name = "st-microservice-administration") public interface UserFeignClient { - @GetMapping("/api/administration/users/{id}") - public UserDto findById(@PathVariable Long id); + @GetMapping("/api/administration/users/{id}") + public UserDto findById(@PathVariable Long id); - @GetMapping("/api/administration/users/token") - public UserDto findByToken(@RequestParam(name = "token") String token); + @GetMapping("/api/administration/users/token") + public UserDto findByToken(@RequestParam(name = "token") String token); } diff --git a/src/main/java/com/ai/st/microservice/tasks/controllers/v1/TaskV1Controller.java b/src/main/java/com/ai/st/microservice/tasks/controllers/v1/TaskV1Controller.java index 760a6eb..18fe09c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/controllers/v1/TaskV1Controller.java +++ b/src/main/java/com/ai/st/microservice/tasks/controllers/v1/TaskV1Controller.java @@ -5,9 +5,11 @@ import java.util.Date; import java.util.List; +import com.ai.st.microservice.common.dto.general.BasicResponseDto; +import com.ai.st.microservice.tasks.services.tracing.SCMTracing; +import com.ai.st.microservice.tasks.services.tracing.TracingKeyword; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -21,10 +23,8 @@ import org.springframework.web.bind.annotation.RestController; import com.ai.st.microservice.tasks.business.TaskBusiness; -import com.ai.st.microservice.tasks.dto.BasicResponseDto; import com.ai.st.microservice.tasks.dto.CancelTaskDto; import com.ai.st.microservice.tasks.dto.CreateTaskDto; -import com.ai.st.microservice.tasks.dto.ErrorDto; import com.ai.st.microservice.tasks.dto.TaskDto; import com.ai.st.microservice.tasks.exceptions.BusinessException; import com.ai.st.microservice.tasks.exceptions.InputValidationException; @@ -34,223 +34,255 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -@Api(value = "Manage Tasks", description = "Manage Tasks", tags = { "Tasks" }) +@Api(value = "Manage Tasks", tags = { "Tasks" }) @RestController @RequestMapping("api/tasks/v1/tasks") public class TaskV1Controller { - private final Logger log = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private TaskBusiness taskBusiness; - - @GetMapping("") - @ApiOperation(value = "Get all tasks") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Get tasks", response = TaskDto.class), - @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity> getAllTasks(@RequestParam(required = false, name = "member") Long memberCode, - @RequestParam(required = false, name = "states") List taskStates, - @RequestParam(required = false, name = "categories") List categories) { - - HttpStatus httpStatus = null; - List listTasks = new ArrayList(); - - try { - listTasks = taskBusiness.getTasksByFilters(memberCode, taskStates, categories); - - httpStatus = HttpStatus.OK; - } catch (Exception e) { - log.error("Error TaskController@getAllTasks ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - } - - return new ResponseEntity<>(listTasks, httpStatus); - } - - @PostMapping("") - @ApiOperation(value = "Create task") - @ApiResponses(value = { @ApiResponse(code = 201, message = "Task created", response = TaskDto.class), - @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity createTask(@RequestBody(required = true) CreateTaskDto taskRequest) { - - HttpStatus httpStatus = null; - Object responseDto = null; - - try { - - // validation name - String taskName = taskRequest.getName(); - if (taskName.isEmpty() || taskName == null) { - throw new InputValidationException("El nombre de la tarea es requerido"); - } - - // validation deadline - Date taskDeadline = null; - String taskDeadlineString = taskRequest.getDeadline(); - if (taskDeadlineString != null && !taskDeadlineString.isEmpty()) { - try { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - taskDeadline = sdf.parse(taskDeadlineString); - } catch (Exception e) { - throw new InputValidationException("La fecha límite es inválida."); - } - } - - // validation users - List taskUsers = taskRequest.getUsers(); - if (taskUsers.size() == 0) { - throw new InputValidationException("La tarea debe tener al menos un usuario."); - } - - // validation categories - List taskCategories = taskRequest.getCategories(); - if (taskCategories.size() == 0) { - throw new InputValidationException("La tarea debe tener al menos una categoria."); - } - - responseDto = taskBusiness.createTask(taskName, taskRequest.getDescription(), taskUsers, taskDeadline, - taskCategories, taskRequest.getMetadata(), taskRequest.getSteps()); - httpStatus = HttpStatus.CREATED; - - } catch (InputValidationException e) { - log.error("Error TaskController@createTask#Validation ---> " + e.getMessage()); - httpStatus = HttpStatus.BAD_REQUEST; - responseDto = new ErrorDto(e.getMessage(), 1); - } catch (BusinessException e) { - log.error("Error TaskController@createTask#Business ---> " + e.getMessage()); - httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; - responseDto = new ErrorDto(e.getMessage(), 2); - } catch (Exception e) { - log.error("Error TaskController@createTask#General ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - responseDto = new ErrorDto(e.getMessage(), 3); - } - - return new ResponseEntity<>(responseDto, httpStatus); - } - - @GetMapping("/{id}") - @ApiOperation(value = "Get task by id") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Get tasks", response = TaskDto.class), - @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity getTaskById(@PathVariable(required = true, name = "id") Long id) { - - HttpStatus httpStatus = null; - TaskDto taskDto = null; - - try { - taskDto = taskBusiness.getTaskById(id); - httpStatus = (taskDto instanceof TaskDto) ? HttpStatus.OK : HttpStatus.NOT_FOUND; - } catch (Exception e) { - log.error("Error TaskController@getTaskById ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - } - - return new ResponseEntity<>(taskDto, httpStatus); - } - - @PutMapping("/{id}/close") - @ApiOperation(value = "Close task") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), - @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity closeTask(@PathVariable(required = true) Long id) { - - HttpStatus httpStatus = null; - TaskDto taskDtoResponse = null; - - try { - - taskDtoResponse = taskBusiness.closeTask(id); - httpStatus = HttpStatus.OK; - - } catch (BusinessException e) { - log.error("Error TaskController@closeTask1 ---> " + e.getMessage()); - httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; - } catch (Exception e) { - log.error("Error TaskController@closeTask2 ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - } - - return new ResponseEntity<>(taskDtoResponse, httpStatus); - } - - @PutMapping("/{id}/start") - @ApiOperation(value = "Start task") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), - @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity startTask(@PathVariable(required = true) Long id) { - - HttpStatus httpStatus = null; - TaskDto taskDtoResponse = null; - - try { - - taskDtoResponse = taskBusiness.startTask(id); - httpStatus = HttpStatus.OK; - - } catch (BusinessException e) { - log.error("Error TaskController@closeTask#Business ---> " + e.getMessage()); - httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; - } catch (Exception e) { - log.error("Error TaskController@closeTask#General ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - } - - return new ResponseEntity<>(taskDtoResponse, httpStatus); - } - - @PutMapping("/{id}/cancel") - @ApiOperation(value = "Cancel task") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), - @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity cancelTask(@PathVariable(required = true) Long id, - @RequestBody(required = true) CancelTaskDto cancelTaskRequest) { - - HttpStatus httpStatus = null; - TaskDto taskDtoResponse = null; - - try { - - taskDtoResponse = taskBusiness.cancelTask(id, cancelTaskRequest.getReason()); - httpStatus = HttpStatus.OK; - - } catch (BusinessException e) { - log.error("Error TaskController@closeTask#Business ---> " + e.getMessage()); - httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; - } catch (Exception e) { - log.error("Error TaskController@closeTask#General ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - } - - return new ResponseEntity<>(taskDtoResponse, httpStatus); - } - - @DeleteMapping("/{taskId}/members/{memberId}/") - @ApiOperation(value = "Remove member from task") - @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), - @ApiResponse(code = 404, message = "Member removed"), @ApiResponse(code = 500, message = "Error Server") }) - public ResponseEntity removeMemberFromTask(@PathVariable(required = true) Long taskId, - @PathVariable(required = true) Long memberId) { - - HttpStatus httpStatus = null; - Object responseDto = null; - - try { - - responseDto = taskBusiness.removeUserFromTask(taskId, memberId); - httpStatus = HttpStatus.OK; - - } catch (BusinessException e) { - log.error("Error TaskController@removeMemberFromTask#Business ---> " + e.getMessage()); - httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; - responseDto = new BasicResponseDto(e.getMessage(), 2); - } catch (Exception e) { - log.error("Error TaskController@removeMemberFromTask#General ---> " + e.getMessage()); - httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; - responseDto = new BasicResponseDto(e.getMessage(), 1); - } - - return new ResponseEntity<>(responseDto, httpStatus); - } + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + private final TaskBusiness taskBusiness; + + public TaskV1Controller(TaskBusiness taskBusiness) { + this.taskBusiness = taskBusiness; + } + + @GetMapping("") + @ApiOperation(value = "Get all tasks") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Get tasks", response = TaskDto.class), + @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity> getAllTasks(@RequestParam(required = false, name = "member") Long memberCode, + @RequestParam(required = false, name = "states") List taskStates, + @RequestParam(required = false, name = "categories") List categories) { + + HttpStatus httpStatus; + List listTasks = new ArrayList<>(); + + try { + + SCMTracing.setTransactionName("getAllTasks"); + + listTasks = taskBusiness.getTasksByFilters(memberCode, taskStates, categories); + + httpStatus = HttpStatus.OK; + } catch (Exception e) { + log.error("Error TaskController@getAllTasks#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(listTasks, httpStatus); + } + + @PostMapping("") + @ApiOperation(value = "Create task") + @ApiResponses(value = { @ApiResponse(code = 201, message = "Task created", response = TaskDto.class), + @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity createTask(@RequestBody CreateTaskDto taskRequest) { + + HttpStatus httpStatus; + Object responseDto; + + try { + + SCMTracing.setTransactionName("createTask"); + SCMTracing.addCustomParameter(TracingKeyword.BODY_REQUEST, taskRequest.toString()); + + // validation name + String taskName = taskRequest.getName(); + if (taskName == null || taskName.isEmpty()) { + throw new InputValidationException("El nombre de la tarea es requerido"); + } + + // validation deadline + Date taskDeadline = null; + String taskDeadlineString = taskRequest.getDeadline(); + if (taskDeadlineString != null && !taskDeadlineString.isEmpty()) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + taskDeadline = sdf.parse(taskDeadlineString); + } catch (Exception e) { + throw new InputValidationException("La fecha límite es inválida."); + } + } + + // validation users + List taskUsers = taskRequest.getUsers(); + if (taskUsers.size() == 0) { + throw new InputValidationException("La tarea debe tener al menos un usuario."); + } + + // validation categories + List taskCategories = taskRequest.getCategories(); + if (taskCategories.size() == 0) { + throw new InputValidationException("La tarea debe tener al menos una categoría."); + } + + responseDto = taskBusiness.createTask(taskName, taskRequest.getDescription(), taskUsers, taskDeadline, + taskCategories, taskRequest.getMetadata(), taskRequest.getSteps()); + httpStatus = HttpStatus.CREATED; + + } catch (InputValidationException e) { + log.error("Error TaskController@createTask#Validation ---> " + e.getMessage()); + httpStatus = HttpStatus.BAD_REQUEST; + responseDto = new BasicResponseDto(e.getMessage()); + SCMTracing.sendError(e.getMessage()); + } catch (BusinessException e) { + log.error("Error TaskController@createTask#Business ---> " + e.getMessage()); + httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; + responseDto = new BasicResponseDto(e.getMessage()); + SCMTracing.sendError(e.getMessage()); + } catch (Exception e) { + log.error("Error TaskController@createTask#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + responseDto = new BasicResponseDto(e.getMessage()); + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(responseDto, httpStatus); + } + + @GetMapping("/{id}") + @ApiOperation(value = "Get task by id") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Get tasks", response = TaskDto.class), + @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity getTaskById(@PathVariable(name = "id") Long id) { + + HttpStatus httpStatus; + TaskDto taskDto = null; + + try { + + SCMTracing.setTransactionName("getTaskById"); + + taskDto = taskBusiness.getTaskById(id); + httpStatus = (taskDto != null) ? HttpStatus.OK : HttpStatus.NOT_FOUND; + } catch (Exception e) { + log.error("Error TaskController@getTaskById#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(taskDto, httpStatus); + } + + @PutMapping("/{id}/close") + @ApiOperation(value = "Close task") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), + @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity closeTask(@PathVariable Long id) { + + HttpStatus httpStatus; + TaskDto taskDtoResponse = null; + + try { + + SCMTracing.setTransactionName("closeTask"); + + taskDtoResponse = taskBusiness.closeTask(id); + httpStatus = HttpStatus.OK; + + } catch (BusinessException e) { + log.error("Error TaskController@closeTask#Business ---> " + e.getMessage()); + httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; + SCMTracing.sendError(e.getMessage()); + } catch (Exception e) { + log.error("Error TaskController@closeTask#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(taskDtoResponse, httpStatus); + } + + @PutMapping("/{id}/start") + @ApiOperation(value = "Start task") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), + @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity startTask(@PathVariable Long id) { + + HttpStatus httpStatus; + TaskDto taskDtoResponse = null; + + try { + + SCMTracing.setTransactionName("startTask"); + + taskDtoResponse = taskBusiness.startTask(id); + httpStatus = HttpStatus.OK; + + } catch (BusinessException e) { + log.error("Error TaskController@startTask#Business ---> " + e.getMessage()); + httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; + SCMTracing.sendError(e.getMessage()); + } catch (Exception e) { + log.error("Error TaskController@startTask#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(taskDtoResponse, httpStatus); + } + + @PutMapping("/{id}/cancel") + @ApiOperation(value = "Cancel task") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), + @ApiResponse(code = 404, message = "Task not found"), @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity cancelTask(@PathVariable Long id, @RequestBody CancelTaskDto cancelTaskRequest) { + + HttpStatus httpStatus; + TaskDto taskDtoResponse = null; + + try { + + SCMTracing.setTransactionName("cancelTask"); + SCMTracing.addCustomParameter(TracingKeyword.BODY_REQUEST, cancelTaskRequest.toString()); + + taskDtoResponse = taskBusiness.cancelTask(id, cancelTaskRequest.getReason()); + httpStatus = HttpStatus.OK; + + } catch (BusinessException e) { + log.error("Error TaskController@cancelTask#Business ---> " + e.getMessage()); + httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; + SCMTracing.sendError(e.getMessage()); + } catch (Exception e) { + log.error("Error TaskController@cancelTask#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(taskDtoResponse, httpStatus); + } + + @DeleteMapping("/{taskId}/members/{memberId}/") + @ApiOperation(value = "Remove member from task") + @ApiResponses(value = { @ApiResponse(code = 200, message = "Task updated", response = TaskDto.class), + @ApiResponse(code = 404, message = "Member removed"), @ApiResponse(code = 500, message = "Error Server") }) + public ResponseEntity removeMemberFromTask(@PathVariable Long taskId, @PathVariable Long memberId) { + + HttpStatus httpStatus; + Object responseDto; + + try { + + SCMTracing.setTransactionName("removeMemberFromTask"); + + responseDto = taskBusiness.removeUserFromTask(taskId, memberId); + httpStatus = HttpStatus.OK; + + } catch (BusinessException e) { + log.error("Error TaskController@removeMemberFromTask#Business ---> " + e.getMessage()); + httpStatus = HttpStatus.UNPROCESSABLE_ENTITY; + responseDto = new BasicResponseDto(e.getMessage()); + SCMTracing.sendError(e.getMessage()); + } catch (Exception e) { + log.error("Error TaskController@removeMemberFromTask#General ---> " + e.getMessage()); + httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; + responseDto = new BasicResponseDto(e.getMessage()); + SCMTracing.sendError(e.getMessage()); + } + + return new ResponseEntity<>(responseDto, httpStatus); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/BasicResponseDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/BasicResponseDto.java deleted file mode 100644 index be10238..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/dto/BasicResponseDto.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.ai.st.microservice.tasks.dto; - -import java.io.Serializable; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel(value = "ErrorDto", description = "Error Dto") -public class BasicResponseDto implements Serializable { - - private static final long serialVersionUID = 5898345343466699696L; - - @ApiModelProperty(required = true, notes = "Message error") - private String message; - - @ApiModelProperty(required = true, notes = "Code error") - private Integer code; - - public BasicResponseDto() { - - } - - public BasicResponseDto(String message, Integer code) { - super(); - this.message = message; - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/CancelTaskDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/CancelTaskDto.java index 60257e9..1bc253d 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/CancelTaskDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/CancelTaskDto.java @@ -4,20 +4,24 @@ public class CancelTaskDto implements Serializable { - private static final long serialVersionUID = -8968447263161444063L; + private static final long serialVersionUID = -8968447263161444063L; - private String reason; + private String reason; - public CancelTaskDto() { + public CancelTaskDto() { - } + } - public String getReason() { - return reason; - } + public String getReason() { + return reason; + } - public void setReason(String reason) { - this.reason = reason; - } + public void setReason(String reason) { + this.reason = reason; + } + @Override + public String toString() { + return "CancelTaskDto{" + "reason='" + reason + '\'' + '}'; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskDto.java index bbdc225..bce6c4c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskDto.java @@ -6,75 +6,81 @@ public class CreateTaskDto implements Serializable { - private static final long serialVersionUID = 8405437490199078160L; - - private String name; - private String description; - private String deadline; - private List users; - private List categories; - private List metadata; - private List steps; - - public CreateTaskDto() { - this.users = new ArrayList(); - this.steps = new ArrayList<>(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeadline() { - return deadline; - } - - public void setDeadline(String deadline) { - this.deadline = deadline; - } - - public List getUsers() { - return users; - } - - public void setUsers(List users) { - this.users = users; - } - - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; - } - - public List getMetadata() { - return metadata; - } - - public void setMetadata(List metadata) { - this.metadata = metadata; - } - - public List getSteps() { - return steps; - } - - public void setSteps(List steps) { - this.steps = steps; - } - + private static final long serialVersionUID = 8405437490199078160L; + + private String name; + private String description; + private String deadline; + private List users; + private List categories; + private List metadata; + private List steps; + + public CreateTaskDto() { + this.users = new ArrayList(); + this.steps = new ArrayList<>(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeadline() { + return deadline; + } + + public void setDeadline(String deadline) { + this.deadline = deadline; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getMetadata() { + return metadata; + } + + public void setMetadata(List metadata) { + this.metadata = metadata; + } + + public List getSteps() { + return steps; + } + + public void setSteps(List steps) { + this.steps = steps; + } + + @Override + public String toString() { + return "CreateTaskDto{" + "name='" + name + '\'' + ", description='" + description + '\'' + ", deadline='" + + deadline + '\'' + ", users=" + users + ", categories=" + categories + ", metadata=" + metadata + + ", steps=" + steps + '}'; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskMetadataDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskMetadataDto.java index c0f2e0a..733be0c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskMetadataDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskMetadataDto.java @@ -6,29 +6,33 @@ public class CreateTaskMetadataDto implements Serializable { - private static final long serialVersionUID = 3915775195611030554L; + private static final long serialVersionUID = 3915775195611030554L; - private String key; - private List properties; + private String key; + private List properties; - public CreateTaskMetadataDto() { - this.properties = new ArrayList<>(); - } + public CreateTaskMetadataDto() { + this.properties = new ArrayList<>(); + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public List getProperties() { - return properties; - } + public List getProperties() { + return properties; + } - public void setProperties(List properties) { - this.properties = properties; - } + public void setProperties(List properties) { + this.properties = properties; + } + @Override + public String toString() { + return "CreateTaskMetadataDto{" + "key='" + key + '\'' + ", properties=" + properties + '}'; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskPropertyDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskPropertyDto.java index d3869e1..1476e99 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskPropertyDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskPropertyDto.java @@ -4,34 +4,38 @@ public class CreateTaskPropertyDto implements Serializable { - private static final long serialVersionUID = -4791673243561643847L; + private static final long serialVersionUID = -4791673243561643847L; - private String key; - private String value; + private String key; + private String value; - public CreateTaskPropertyDto() { + public CreateTaskPropertyDto() { - } + } - public CreateTaskPropertyDto(String key, String value) { - this.key = key; - this.value = value; - } + public CreateTaskPropertyDto(String key, String value) { + this.key = key; + this.value = value; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = value; - } + public void setValue(String value) { + this.value = value; + } + @Override + public String toString() { + return "CreateTaskPropertyDto{" + "key='" + key + '\'' + ", value='" + value + '\'' + '}'; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskStepDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskStepDto.java index 0183208..1951ce2 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskStepDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/CreateTaskStepDto.java @@ -4,38 +4,43 @@ public class CreateTaskStepDto implements Serializable { - private static final long serialVersionUID = 2220658679258020082L; + private static final long serialVersionUID = 2220658679258020082L; - private String title; - private String description; - private Long typeStepId; + private String title; + private String description; + private Long typeStepId; - public CreateTaskStepDto() { + public CreateTaskStepDto() { - } + } - public String getTitle() { - return title; - } + public String getTitle() { + return title; + } - public void setTitle(String title) { - this.title = title; - } + public void setTitle(String title) { + this.title = title; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Long getTypeStepId() { - return typeStepId; - } + public Long getTypeStepId() { + return typeStepId; + } - public void setTypeStepId(Long typeStepId) { - this.typeStepId = typeStepId; - } + public void setTypeStepId(Long typeStepId) { + this.typeStepId = typeStepId; + } + @Override + public String toString() { + return "CreateTaskStepDto{" + "title='" + title + '\'' + ", description='" + description + '\'' + + ", typeStepId=" + typeStepId + '}'; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/ErrorDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/ErrorDto.java deleted file mode 100644 index ccbb708..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/dto/ErrorDto.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.ai.st.microservice.tasks.dto; - -import java.io.Serializable; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel(value = "ErrorDto", description = "Error Dto") -public class ErrorDto implements Serializable { - - private static final long serialVersionUID = 5898345343466699696L; - - @ApiModelProperty(required = true, notes = "Message error") - private String message; - - @ApiModelProperty(required = true, notes = "Code error") - private Integer code; - - public ErrorDto() { - - } - - public ErrorDto(String message, Integer code) { - super(); - this.message = message; - this.code = code; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskCategoryDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskCategoryDto.java index 46f2226..2bf9b3f 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskCategoryDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskCategoryDto.java @@ -8,38 +8,38 @@ @ApiModel(value = "TaskCategoryDto", description = "Task Category Dto") public class TaskCategoryDto implements Serializable { - private static final long serialVersionUID = 7237234886460619822L; + private static final long serialVersionUID = 7237234886460619822L; - @ApiModelProperty(required = true, notes = "Category ID") - private Long id; + @ApiModelProperty(required = true, notes = "Category ID") + private Long id; - @ApiModelProperty(required = true, notes = "Name") - private String name; + @ApiModelProperty(required = true, notes = "Name") + private String name; - public TaskCategoryDto() { + public TaskCategoryDto() { - } + } - public TaskCategoryDto(Long id, String name) { - super(); - this.id = id; - this.name = name; - } + public TaskCategoryDto(Long id, String name) { + super(); + this.id = id; + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskDto.java index 3c760ff..149a93f 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskDto.java @@ -11,145 +11,145 @@ @ApiModel(value = "TaskDto", description = "Task") public class TaskDto implements Serializable { - private static final long serialVersionUID = -572797587427843121L; + private static final long serialVersionUID = -572797587427843121L; - @ApiModelProperty(required = true, notes = "Task ID") - private Long id; + @ApiModelProperty(required = true, notes = "Task ID") + private Long id; - @ApiModelProperty(required = true, notes = "Name") - private String name; + @ApiModelProperty(required = true, notes = "Name") + private String name; - @ApiModelProperty(required = false, notes = "Description") - private String description; + @ApiModelProperty(required = false, notes = "Description") + private String description; - @ApiModelProperty(required = false, notes = "Reason") - private String reason; + @ApiModelProperty(required = false, notes = "Reason") + private String reason; - @ApiModelProperty(required = false, notes = "Deadline") - private Date deadline; + @ApiModelProperty(required = false, notes = "Deadline") + private Date deadline; - @ApiModelProperty(required = true, notes = "Date creation") - private Date createdAt; + @ApiModelProperty(required = true, notes = "Date creation") + private Date createdAt; - @ApiModelProperty(required = false, notes = "Closing Date") - private Date closingDate; + @ApiModelProperty(required = false, notes = "Closing Date") + private Date closingDate; - @ApiModelProperty(required = true, notes = "Task state") - private TaskStateDto taskState; + @ApiModelProperty(required = true, notes = "Task state") + private TaskStateDto taskState; - @ApiModelProperty(required = true, notes = "Members") - private List members; + @ApiModelProperty(required = true, notes = "Members") + private List members; - @ApiModelProperty(required = true, notes = "Categories") - private List categories; + @ApiModelProperty(required = true, notes = "Categories") + private List categories; - @ApiModelProperty(required = true, notes = "Metadata") - private List metadata; + @ApiModelProperty(required = true, notes = "Metadata") + private List metadata; - @ApiModelProperty(required = false, notes = "Steps") - private List steps; + @ApiModelProperty(required = false, notes = "Steps") + private List steps; - public TaskDto() { - this.members = new ArrayList(); - this.categories = new ArrayList(); - this.metadata = new ArrayList(); - this.steps = new ArrayList(); - } + public TaskDto() { + this.members = new ArrayList(); + this.categories = new ArrayList(); + this.metadata = new ArrayList(); + this.steps = new ArrayList(); + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Date getDeadline() { - return deadline; - } + public Date getDeadline() { + return deadline; + } - public void setDeadline(Date deadline) { - this.deadline = deadline; - } + public void setDeadline(Date deadline) { + this.deadline = deadline; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } - public Date getClosingDate() { - return closingDate; - } + public Date getClosingDate() { + return closingDate; + } - public void setClosingDate(Date closingDate) { - this.closingDate = closingDate; - } + public void setClosingDate(Date closingDate) { + this.closingDate = closingDate; + } - public TaskStateDto getTaskState() { - return taskState; - } + public TaskStateDto getTaskState() { + return taskState; + } - public void setTaskState(TaskStateDto taskState) { - this.taskState = taskState; - } + public void setTaskState(TaskStateDto taskState) { + this.taskState = taskState; + } - public List getMembers() { - return members; - } + public List getMembers() { + return members; + } - public void setMembers(List members) { - this.members = members; - } + public void setMembers(List members) { + this.members = members; + } - public List getCategories() { - return categories; - } + public List getCategories() { + return categories; + } - public void setCategories(List categories) { - this.categories = categories; - } + public void setCategories(List categories) { + this.categories = categories; + } - public List getMetadata() { - return metadata; - } + public List getMetadata() { + return metadata; + } - public void setMetadata(List metadata) { - this.metadata = metadata; - } + public void setMetadata(List metadata) { + this.metadata = metadata; + } - public List getSteps() { - return steps; - } + public List getSteps() { + return steps; + } - public void setSteps(List steps) { - this.steps = steps; - } - - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } + public void setSteps(List steps) { + this.steps = steps; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMemberDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMemberDto.java index 2737a12..993f116 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMemberDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMemberDto.java @@ -9,43 +9,43 @@ @ApiModel(value = "TaskMemberDto", description = "Task Member") public class TaskMemberDto implements Serializable { - private static final long serialVersionUID = 7581006574042957605L; + private static final long serialVersionUID = 7581006574042957605L; - @ApiModelProperty(required = true, notes = "Task member ID") - private Long id; + @ApiModelProperty(required = true, notes = "Task member ID") + private Long id; - @ApiModelProperty(required = true, notes = "Member code") - private Long memberCode; + @ApiModelProperty(required = true, notes = "Member code") + private Long memberCode; - @ApiModelProperty(required = true, notes = "Date creation") - private Date createdAt; + @ApiModelProperty(required = true, notes = "Date creation") + private Date createdAt; - public TaskMemberDto() { + public TaskMemberDto() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public Long getMemberCode() { - return memberCode; - } + public Long getMemberCode() { + return memberCode; + } - public void setMemberCode(Long memberCode) { - this.memberCode = memberCode; - } + public void setMemberCode(Long memberCode) { + this.memberCode = memberCode; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataDto.java index e3f43ed..5266503 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataDto.java @@ -10,43 +10,43 @@ @ApiModel(value = "TaskMedataDto", description = "Task Metadata") public class TaskMetadataDto implements Serializable { - private static final long serialVersionUID = 5451686139173510244L; + private static final long serialVersionUID = 5451686139173510244L; - @ApiModelProperty(required = true, notes = "Id") - private Long id; + @ApiModelProperty(required = true, notes = "Id") + private Long id; - @ApiModelProperty(required = true, notes = "Key") - private String key; + @ApiModelProperty(required = true, notes = "Key") + private String key; - @ApiModelProperty(required = true, notes = "Properties") - private List properties; + @ApiModelProperty(required = true, notes = "Properties") + private List properties; - public TaskMetadataDto() { - this.properties = new ArrayList<>(); - } + public TaskMetadataDto() { + this.properties = new ArrayList<>(); + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public List getProperties() { - return properties; - } + public List getProperties() { + return properties; + } - public void setProperties(List properties) { - this.properties = properties; - } + public void setProperties(List properties) { + this.properties = properties; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataPropertyDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataPropertyDto.java index 3562ff0..38d3287 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataPropertyDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskMetadataPropertyDto.java @@ -8,49 +8,49 @@ @ApiModel(value = "TaskMetadataPropertyDto", description = "Task Metadata Property Dto") public class TaskMetadataPropertyDto implements Serializable { - private static final long serialVersionUID = 3708739121137799257L; + private static final long serialVersionUID = 3708739121137799257L; - @ApiModelProperty(required = true, notes = "Id") - private Long id; + @ApiModelProperty(required = true, notes = "Id") + private Long id; - @ApiModelProperty(required = true, notes = "Key") - private String key; + @ApiModelProperty(required = true, notes = "Key") + private String key; - @ApiModelProperty(required = true, notes = "Value") - private String value; + @ApiModelProperty(required = true, notes = "Value") + private String value; - public TaskMetadataPropertyDto() { + public TaskMetadataPropertyDto() { - } + } - public TaskMetadataPropertyDto(Long id, String key, String value) { - this.id = id; - this.key = key; - this.value = value; - } + public TaskMetadataPropertyDto(Long id, String key, String value) { + this.id = id; + this.key = key; + this.value = value; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = value; - } + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskStateDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskStateDto.java index ee56a6b..52bde83 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskStateDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskStateDto.java @@ -8,37 +8,37 @@ @ApiModel(value = "TaskStateDto", description = "Task State") public class TaskStateDto implements Serializable { - private static final long serialVersionUID = 1648940408334070826L; + private static final long serialVersionUID = 1648940408334070826L; - @ApiModelProperty(required = true, notes = "Task state ID") - private Long id; + @ApiModelProperty(required = true, notes = "Task state ID") + private Long id; - @ApiModelProperty(required = true, notes = "Task state name") - private String name; + @ApiModelProperty(required = true, notes = "Task state name") + private String name; - public TaskStateDto() { + public TaskStateDto() { - } + } - public TaskStateDto(Long id, String name) { - this.id = id; - this.name = name; - } + public TaskStateDto(Long id, String name) { + this.id = id; + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskStepDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskStepDto.java index ab862ec..713d33a 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskStepDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskStepDto.java @@ -8,65 +8,65 @@ @ApiModel(value = "TaskStepDto", description = "Task Step Dto") public class TaskStepDto implements Serializable { - private static final long serialVersionUID = 927981596792722859L; + private static final long serialVersionUID = 927981596792722859L; - @ApiModelProperty(required = true, notes = "Step ID") - private Long id; + @ApiModelProperty(required = true, notes = "Step ID") + private Long id; - @ApiModelProperty(required = true, notes = "Step Code") - private String code; + @ApiModelProperty(required = true, notes = "Step Code") + private String code; - @ApiModelProperty(required = true, notes = "Step Description") - private String description; + @ApiModelProperty(required = true, notes = "Step Description") + private String description; - @ApiModelProperty(required = true, notes = "Step Status") - private Boolean status; + @ApiModelProperty(required = true, notes = "Step Status") + private Boolean status; - @ApiModelProperty(required = true, notes = "Type Step") - private TaskTypeStepDto typeStep; + @ApiModelProperty(required = true, notes = "Type Step") + private TaskTypeStepDto typeStep; - public TaskStepDto() { + public TaskStepDto() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getCode() { - return code; - } + public String getCode() { + return code; + } - public void setCode(String code) { - this.code = code; - } + public void setCode(String code) { + this.code = code; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Boolean getStatus() { - return status; - } + public Boolean getStatus() { + return status; + } - public void setStatus(Boolean status) { - this.status = status; - } + public void setStatus(Boolean status) { + this.status = status; + } - public TaskTypeStepDto getTypeStep() { - return typeStep; - } + public TaskTypeStepDto getTypeStep() { + return typeStep; + } - public void setTypeStep(TaskTypeStepDto typeStep) { - this.typeStep = typeStep; - } + public void setTypeStep(TaskTypeStepDto typeStep) { + this.typeStep = typeStep; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/TaskTypeStepDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/TaskTypeStepDto.java index 91cfa17..9edf2bb 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/TaskTypeStepDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/TaskTypeStepDto.java @@ -8,38 +8,38 @@ @ApiModel(value = "TaskTypeStepDto", description = "Task Type Step Dto") public class TaskTypeStepDto implements Serializable { - private static final long serialVersionUID = 5382565385513050513L; + private static final long serialVersionUID = 5382565385513050513L; - @ApiModelProperty(required = true, notes = "Task type step ID") - private Long id; + @ApiModelProperty(required = true, notes = "Task type step ID") + private Long id; - @ApiModelProperty(required = true, notes = "Task type step name") - private String name; + @ApiModelProperty(required = true, notes = "Task type step name") + private String name; - public TaskTypeStepDto() { + public TaskTypeStepDto() { - } + } - public TaskTypeStepDto(Long id, String name) { - super(); - this.id = id; - this.name = name; - } + public TaskTypeStepDto(Long id, String name) { + super(); + this.id = id; + this.name = name; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/dto/UserDto.java b/src/main/java/com/ai/st/microservice/tasks/dto/UserDto.java index 9f49f96..affb832 100644 --- a/src/main/java/com/ai/st/microservice/tasks/dto/UserDto.java +++ b/src/main/java/com/ai/st/microservice/tasks/dto/UserDto.java @@ -9,120 +9,118 @@ @ApiModel(value = "UserDto", description = "User") public class UserDto implements Serializable { - private static final long serialVersionUID = -5121529899322990688L; + private static final long serialVersionUID = -5121529899322990688L; - @ApiModelProperty(required = true, notes = "User ID") - private Long id; + @ApiModelProperty(required = true, notes = "User ID") + private Long id; - @ApiModelProperty(required = true, notes = "First Name") - private String firstName; + @ApiModelProperty(required = true, notes = "First Name") + private String firstName; - @ApiModelProperty(required = true, notes = "Last Name") - private String lastName; + @ApiModelProperty(required = true, notes = "Last Name") + private String lastName; - @ApiModelProperty(required = true, notes = "Email") - private String email; + @ApiModelProperty(required = true, notes = "Email") + private String email; - @ApiModelProperty(required = true, notes = "Username") - private String username; + @ApiModelProperty(required = true, notes = "Username") + private String username; - @ApiModelProperty(required = true, notes = "Password") - private String password; + @ApiModelProperty(required = true, notes = "Password") + private String password; - @ApiModelProperty(required = true, notes = "Is the user enabled?") - private Boolean enabled; + @ApiModelProperty(required = true, notes = "Is the user enabled?") + private Boolean enabled; - @ApiModelProperty(required = true, notes = "Creation date") - private Date createdAt; + @ApiModelProperty(required = true, notes = "Creation date") + private Date createdAt; - @ApiModelProperty(required = true, notes = "Update date") - private Date updatedAt; + @ApiModelProperty(required = true, notes = "Update date") + private Date updatedAt; - public UserDto() { + public UserDto() { - } - - + } - public UserDto(Long id, String firstName, String lastName, String email, String username) { - super(); - this.id = id; - this.firstName = firstName; - this.lastName = lastName; - this.email = email; - this.username = username; - } + public UserDto(Long id, String firstName, String lastName, String email, String username) { + super(); + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.username = username; + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getFirstName() { - return firstName; - } + public String getFirstName() { + return firstName; + } - public void setFirstName(String firstName) { - this.firstName = firstName; - } + public void setFirstName(String firstName) { + this.firstName = firstName; + } - public String getLastName() { - return lastName; - } + public String getLastName() { + return lastName; + } - public void setLastName(String lastName) { - this.lastName = lastName; - } + public void setLastName(String lastName) { + this.lastName = lastName; + } - public String getEmail() { - return email; - } + public String getEmail() { + return email; + } - public void setEmail(String email) { - this.email = email; - } + public void setEmail(String email) { + this.email = email; + } - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } - public Date getUpdatedAt() { - return updatedAt; - } + public Date getUpdatedAt() { + return updatedAt; + } - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/MetadataPropertyEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/MetadataPropertyEntity.java index efedcaa..4a70839 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/MetadataPropertyEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/MetadataPropertyEntity.java @@ -14,55 +14,55 @@ @Table(name = "tasks_metadata_properties", schema = "tasks") public class MetadataPropertyEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "key", nullable = false, length = 255) - private String key; + @Column(name = "key", nullable = false, length = 255) + private String key; - @Column(name = "value", nullable = false, length = 255) - private String value; + @Column(name = "value", nullable = false, length = 255) + private String value; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "metadata_id", referencedColumnName = "id", nullable = false) - private TaskMetadataEntity metadata; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "metadata_id", referencedColumnName = "id", nullable = false) + private TaskMetadataEntity metadata; - public MetadataPropertyEntity() { + public MetadataPropertyEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = value; - } + public void setValue(String value) { + this.value = value; + } - public TaskMetadataEntity getMetadata() { - return metadata; - } + public TaskMetadataEntity getMetadata() { + return metadata; + } - public void setMetadata(TaskMetadataEntity metadata) { - this.metadata = metadata; - } + public void setMetadata(TaskMetadataEntity metadata) { + this.metadata = metadata; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskCategoryEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskCategoryEntity.java index 7831d00..4f6ba8c 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskCategoryEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskCategoryEntity.java @@ -11,32 +11,32 @@ @Table(name = "tasks_categories", schema = "tasks") public class TaskCategoryEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "name", nullable = false, length = 255) - private String name; + @Column(name = "name", nullable = false, length = 255) + private String name; - public TaskCategoryEntity() { + public TaskCategoryEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskEntity.java index f40a760..07c4117 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskEntity.java @@ -24,147 +24,147 @@ @Table(name = "tasks", schema = "tasks") public class TaskEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "name", nullable = false, length = 255) - private String name; + @Column(name = "name", nullable = false, length = 255) + private String name; - @Column(name = "description", nullable = true, length = 500) - private String description; + @Column(name = "description", nullable = true, length = 500) + private String description; - @Column(name = "reason", nullable = true, length = 500) - private String reason; + @Column(name = "reason", nullable = true, length = 500) + private String reason; - @Column(name = "deadline", nullable = true) - @Temporal(TemporalType.TIMESTAMP) - private Date deadline; + @Column(name = "deadline", nullable = true) + @Temporal(TemporalType.TIMESTAMP) + private Date deadline; - @Column(name = "created_at", nullable = false) - @Temporal(TemporalType.TIMESTAMP) - private Date createdAt; + @Column(name = "created_at", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date createdAt; - @Column(name = "closing_date", nullable = true) - @Temporal(TemporalType.TIMESTAMP) - private Date closingDate; + @Column(name = "closing_date", nullable = true) + @Temporal(TemporalType.TIMESTAMP) + private Date closingDate; - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "task_state_id", referencedColumnName = "id", nullable = false) - private TaskStateEntity taskState; + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "task_state_id", referencedColumnName = "id", nullable = false) + private TaskStateEntity taskState; - @OneToMany(mappedBy = "task") - private List members = new ArrayList(); + @OneToMany(mappedBy = "task") + private List members = new ArrayList(); - @OneToMany(mappedBy = "task", cascade = CascadeType.ALL) - private List metadata = new ArrayList(); + @OneToMany(mappedBy = "task", cascade = CascadeType.ALL) + private List metadata = new ArrayList(); - @ManyToMany(fetch = FetchType.LAZY) - @JoinTable(schema = "tasks", name = "tasks_x_categories", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "category_id")) - List categories; + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(schema = "tasks", name = "tasks_x_categories", joinColumns = @JoinColumn(name = "task_id"), inverseJoinColumns = @JoinColumn(name = "category_id")) + List categories; - @OneToMany(mappedBy = "task", cascade = CascadeType.ALL) - private List steps = new ArrayList(); + @OneToMany(mappedBy = "task", cascade = CascadeType.ALL) + private List steps = new ArrayList(); - public TaskEntity() { + public TaskEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public Date getDeadline() { - return deadline; - } + public Date getDeadline() { + return deadline; + } - public void setDeadline(Date deadline) { - this.deadline = deadline; - } + public void setDeadline(Date deadline) { + this.deadline = deadline; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } - public Date getClosingDate() { - return closingDate; - } + public Date getClosingDate() { + return closingDate; + } - public void setClosingDate(Date closingDate) { - this.closingDate = closingDate; - } + public void setClosingDate(Date closingDate) { + this.closingDate = closingDate; + } - public TaskStateEntity getTaskState() { - return taskState; - } + public TaskStateEntity getTaskState() { + return taskState; + } - public void setTaskState(TaskStateEntity taskState) { - this.taskState = taskState; - } + public void setTaskState(TaskStateEntity taskState) { + this.taskState = taskState; + } - public List getCategories() { - return categories; - } + public List getCategories() { + return categories; + } - public void setCategories(List categories) { - this.categories = categories; - } + public void setCategories(List categories) { + this.categories = categories; + } - public List getMembers() { - return members; - } + public List getMembers() { + return members; + } - public void setMembers(List members) { - this.members = members; - } + public void setMembers(List members) { + this.members = members; + } - public List getMetadata() { - return metadata; - } + public List getMetadata() { + return metadata; + } - public void setMetadata(List metadata) { - this.metadata = metadata; - } + public void setMetadata(List metadata) { + this.metadata = metadata; + } - public List getSteps() { - return steps; - } + public List getSteps() { + return steps; + } - public void setSteps(List steps) { - this.steps = steps; - } + public void setSteps(List steps) { + this.steps = steps; + } - public String getReason() { - return reason; - } + public String getReason() { + return reason; + } - public void setReason(String reason) { - this.reason = reason; - } + public void setReason(String reason) { + this.reason = reason; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskMemberEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskMemberEntity.java index 49736c4..a905055 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskMemberEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskMemberEntity.java @@ -18,56 +18,56 @@ @Table(name = "tasks_members", schema = "tasks") public class TaskMemberEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) - private TaskEntity task; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) + private TaskEntity task; - @Column(name = "member_code", nullable = false) - private Long memberCode; + @Column(name = "member_code", nullable = false) + private Long memberCode; - @Column(name = "created_at", nullable = false) - @Temporal(TemporalType.TIMESTAMP) - private Date createdAt; + @Column(name = "created_at", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date createdAt; - public TaskMemberEntity() { + public TaskMemberEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public TaskEntity getTask() { - return task; - } + public TaskEntity getTask() { + return task; + } - public void setTask(TaskEntity task) { - this.task = task; - } + public void setTask(TaskEntity task) { + this.task = task; + } - public Long getMemberCode() { - return memberCode; - } + public Long getMemberCode() { + return memberCode; + } - public void setMemberCode(Long memberCode) { - this.memberCode = memberCode; - } + public void setMemberCode(Long memberCode) { + this.memberCode = memberCode; + } - public Date getCreatedAt() { - return createdAt; - } + public Date getCreatedAt() { + return createdAt; + } - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskMetadataEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskMetadataEntity.java index 439c6c5..110cff2 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskMetadataEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskMetadataEntity.java @@ -19,55 +19,55 @@ @Table(name = "tasks_metadata", schema = "tasks") public class TaskMetadataEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "key", nullable = false, length = 255) - private String key; + @Column(name = "key", nullable = false, length = 255) + private String key; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) - private TaskEntity task; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) + private TaskEntity task; - @OneToMany(mappedBy = "metadata", cascade = CascadeType.ALL) - private List properties = new ArrayList(); + @OneToMany(mappedBy = "metadata", cascade = CascadeType.ALL) + private List properties = new ArrayList(); - public TaskMetadataEntity() { + public TaskMetadataEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public TaskEntity getTask() { - return task; - } + public TaskEntity getTask() { + return task; + } - public void setTask(TaskEntity task) { - this.task = task; - } + public void setTask(TaskEntity task) { + this.task = task; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public List getProperties() { - return properties; - } + public List getProperties() { + return properties; + } - public void setProperties(List properties) { - this.properties = properties; - } + public void setProperties(List properties) { + this.properties = properties; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskStateEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskStateEntity.java index cd09bfb..5dba747 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskStateEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskStateEntity.java @@ -11,32 +11,32 @@ @Table(name = "tasks_states", schema = "tasks") public class TaskStateEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "name", nullable = false, length = 255) - private String name; + @Column(name = "name", nullable = false, length = 255) + private String name; - public TaskStateEntity() { + public TaskStateEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskStepEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskStepEntity.java index ccc4d81..949ceeb 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskStepEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskStepEntity.java @@ -14,90 +14,90 @@ @Table(name = "tasks_steps", schema = "tasks") public class TaskStepEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; - @Column(name = "description", nullable = false, length = 1000) - private String description; + @Column(name = "description", nullable = false, length = 1000) + private String description; - @Column(name = "code", nullable = false, length = 20) - private String code; + @Column(name = "code", nullable = false, length = 20) + private String code; - @Column(name = "status", nullable = false) - private Boolean status; + @Column(name = "status", nullable = false) + private Boolean status; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "task_type_step_id", referencedColumnName = "id", nullable = false) - private TaskTypeStepEntity typeStep; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "task_type_step_id", referencedColumnName = "id", nullable = false) + private TaskTypeStepEntity typeStep; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) - private TaskEntity task; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "task_id", referencedColumnName = "id", nullable = false) + private TaskEntity task; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "step_id", referencedColumnName = "id", nullable = true) - private TaskStepEntity step; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "step_id", referencedColumnName = "id", nullable = true) + private TaskStepEntity step; - public TaskStepEntity() { + public TaskStepEntity() { - } + } - public Long getId() { - return id; - } + public Long getId() { + return id; + } - public void setId(Long id) { - this.id = id; - } + public void setId(Long id) { + this.id = id; + } - public Boolean getStatus() { - return status; - } + public Boolean getStatus() { + return status; + } - public void setStatus(Boolean status) { - this.status = status; - } + public void setStatus(Boolean status) { + this.status = status; + } - public TaskTypeStepEntity getTypeStep() { - return typeStep; - } + public TaskTypeStepEntity getTypeStep() { + return typeStep; + } - public void setTypeStep(TaskTypeStepEntity typeStep) { - this.typeStep = typeStep; - } + public void setTypeStep(TaskTypeStepEntity typeStep) { + this.typeStep = typeStep; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public TaskStepEntity getStep() { - return step; - } + public TaskStepEntity getStep() { + return step; + } - public void setStep(TaskStepEntity step) { - this.step = step; - } + public void setStep(TaskStepEntity step) { + this.step = step; + } - public String getCode() { - return code; - } + public String getCode() { + return code; + } - public void setCode(String code) { - this.code = code; - } + public void setCode(String code) { + this.code = code; + } - public TaskEntity getTask() { - return task; - } + public TaskEntity getTask() { + return task; + } - public void setTask(TaskEntity task) { - this.task = task; - } + public void setTask(TaskEntity task) { + this.task = task; + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/entities/TaskTypeStepEntity.java b/src/main/java/com/ai/st/microservice/tasks/entities/TaskTypeStepEntity.java index 333f28f..8166afa 100644 --- a/src/main/java/com/ai/st/microservice/tasks/entities/TaskTypeStepEntity.java +++ b/src/main/java/com/ai/st/microservice/tasks/entities/TaskTypeStepEntity.java @@ -11,32 +11,32 @@ @Table(name = "tasks_types_steps", schema = "tasks") public class TaskTypeStepEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) - private Long id; - - @Column(name = "name", nullable = false, length = 255) - private String name; - - public TaskTypeStepEntity() { - - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; + + @Column(name = "name", nullable = false, length = 255) + private String name; + + public TaskTypeStepEntity() { + + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } diff --git a/src/main/java/com/ai/st/microservice/tasks/exceptions/BusinessException.java b/src/main/java/com/ai/st/microservice/tasks/exceptions/BusinessException.java index 43cace5..edcfdd2 100644 --- a/src/main/java/com/ai/st/microservice/tasks/exceptions/BusinessException.java +++ b/src/main/java/com/ai/st/microservice/tasks/exceptions/BusinessException.java @@ -2,22 +2,22 @@ public class BusinessException extends Exception { - private static final long serialVersionUID = 4026596642770023028L; + private static final long serialVersionUID = 4026596642770023028L; - private String messageError; + private String messageError; - public BusinessException(String message) { - super(); - this.messageError = message; - } + public BusinessException(String message) { + super(); + this.messageError = message; + } - public String getMessageError() { - return messageError; - } - - @Override - public String getMessage() { - return this.getMessageError(); - } + public String getMessageError() { + return messageError; + } + + @Override + public String getMessage() { + return this.getMessageError(); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/exceptions/InputValidationException.java b/src/main/java/com/ai/st/microservice/tasks/exceptions/InputValidationException.java index 9d590b3..c6568c7 100644 --- a/src/main/java/com/ai/st/microservice/tasks/exceptions/InputValidationException.java +++ b/src/main/java/com/ai/st/microservice/tasks/exceptions/InputValidationException.java @@ -2,22 +2,22 @@ public class InputValidationException extends Exception { - private static final long serialVersionUID = 6631825550389136362L; + private static final long serialVersionUID = 6631825550389136362L; - private String messageError; + private String messageError; - public InputValidationException(String message) { - super(); - this.messageError = message; - } + public InputValidationException(String message) { + super(); + this.messageError = message; + } - public String getMessageError() { - return messageError; - } + public String getMessageError() { + return messageError; + } - @Override - public String getMessage() { - return this.getMessageError(); - } + @Override + public String getMessage() { + return this.getMessageError(); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java b/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java index 0ad2f35..5183120 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java @@ -5,8 +5,7 @@ import com.ai.st.microservice.tasks.entities.TaskMemberEntity; public interface TaskMemberRepository extends CrudRepository { - - Long deleteByMemberCode(Long memberCode); - + + Long deleteByMemberCode(Long memberCode); } diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java b/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java index 31edbab..6d26542 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java @@ -10,38 +10,38 @@ public interface TaskRepository extends CrudRepository { - @Override - List findAll(); - - @Query("SELECT t FROM TaskEntity t JOIN TaskMemberEntity tm ON t.id = tm.task.id AND tm.memberCode = :memberCode WHERE t.taskState.id IN :taskStates") - List getTasksByMemberAndStates(@Param("memberCode") Long memberCode, - @Param("taskStates") List taskStates); - - @Query("SELECT t FROM TaskEntity t JOIN TaskMemberEntity tm ON t.id = tm.task.id AND tm.memberCode = :memberCode") - List getTasksByMember(@Param("memberCode") Long memberCode); - - @Query("SELECT t FROM TaskEntity t WHERE t.taskState.id IN :taskStates") - List getTasksByStates(@Param("taskStates") List taskStates); - - @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t JOIN tasks.tasks_members tm ON t.id = tm.task_id AND tm.member_code = :memberCode " - + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories " - + "WHERE t.task_state_id IN :taskStates") - List getTasksByMemberAndStatesAndCategories(@Param("memberCode") Long memberCode, - @Param("taskStates") List taskStates, @Param("taskCategories") List taskCategories); - - @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t JOIN tasks.tasks_members tm ON t.id = tm.task_id AND tm.member_code = :memberCode " - + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories") - List getTasksByMemberAndCategories(@Param("memberCode") Long memberCode, - @Param("taskCategories") List taskCategories); - - @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t " - + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories " - + "WHERE t.task_state_id IN :taskStates") - List getTasksByStatesAndCategories(@Param("taskStates") List taskStates, - @Param("taskCategories") List taskCategories); - - @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t " - + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories") - List getTasksByCategories(@Param("taskCategories") List taskCategories); + @Override + List findAll(); + + @Query("SELECT t FROM TaskEntity t JOIN TaskMemberEntity tm ON t.id = tm.task.id AND tm.memberCode = :memberCode WHERE t.taskState.id IN :taskStates") + List getTasksByMemberAndStates(@Param("memberCode") Long memberCode, + @Param("taskStates") List taskStates); + + @Query("SELECT t FROM TaskEntity t JOIN TaskMemberEntity tm ON t.id = tm.task.id AND tm.memberCode = :memberCode") + List getTasksByMember(@Param("memberCode") Long memberCode); + + @Query("SELECT t FROM TaskEntity t WHERE t.taskState.id IN :taskStates") + List getTasksByStates(@Param("taskStates") List taskStates); + + @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t JOIN tasks.tasks_members tm ON t.id = tm.task_id AND tm.member_code = :memberCode " + + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories " + + "WHERE t.task_state_id IN :taskStates") + List getTasksByMemberAndStatesAndCategories(@Param("memberCode") Long memberCode, + @Param("taskStates") List taskStates, @Param("taskCategories") List taskCategories); + + @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t JOIN tasks.tasks_members tm ON t.id = tm.task_id AND tm.member_code = :memberCode " + + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories") + List getTasksByMemberAndCategories(@Param("memberCode") Long memberCode, + @Param("taskCategories") List taskCategories); + + @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t " + + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories " + + "WHERE t.task_state_id IN :taskStates") + List getTasksByStatesAndCategories(@Param("taskStates") List taskStates, + @Param("taskCategories") List taskCategories); + + @Query(nativeQuery = true, value = "SELECT t.* FROM tasks.tasks t " + + "JOIN tasks.tasks_x_categories tc ON t.id = tc.task_id AND tc.category_id IN :taskCategories") + List getTasksByCategories(@Param("taskCategories") List taskCategories); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java index a988030..7decd84 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java @@ -4,10 +4,10 @@ public interface ITaskCategoryService { - public TaskCategoryEntity getCategoryById(Long id); + public TaskCategoryEntity getCategoryById(Long id); - public Long getCount(); + public Long getCount(); - public TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity); + public TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java index 547e691..ec2eca0 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java @@ -4,10 +4,10 @@ public interface ITaskMemberService { - public void removeMemberById(Long memberId); + public void removeMemberById(Long memberId); - public void removeMemberByCode(Long memberCode); + public void removeMemberByCode(Long memberCode); - public TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity); + public TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java index 2ea17f7..bf1786b 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java @@ -6,29 +6,29 @@ public interface ITaskService { - public List getAllTasks(); + public List getAllTasks(); - public TaskEntity createTask(TaskEntity task); + public TaskEntity createTask(TaskEntity task); - public TaskEntity getById(Long id); + public TaskEntity getById(Long id); - public List getTasksByStatesAndMember(List taskStates, Long memberCode); + public List getTasksByStatesAndMember(List taskStates, Long memberCode); - public List getTasksByStates(List taskStates); + public List getTasksByStates(List taskStates); - public List getTasksByMember(Long memberCode); + public List getTasksByMember(Long memberCode); - public TaskEntity updateTask(TaskEntity task); + public TaskEntity updateTask(TaskEntity task); - public Long getCount(); + public Long getCount(); - public List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, - Long memberCode); + public List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, + Long memberCode); - public List getTasksByMemberAndCategories(List taskCategories, Long memberCode); + public List getTasksByMemberAndCategories(List taskCategories, Long memberCode); - public List getTasksByStatesAndCategories(List taskCategories, List taskStates); + public List getTasksByStatesAndCategories(List taskCategories, List taskStates); - public List getTasksByCategories(List taskCategories); + public List getTasksByCategories(List taskCategories); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java index 92e806a..e90da21 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java @@ -4,10 +4,10 @@ public interface ITaskStateService { - public TaskStateEntity getById(Long id); + public TaskStateEntity getById(Long id); - public Long getAllCount(); + public Long getAllCount(); - public TaskStateEntity createTaskState(TaskStateEntity taskEntity); + public TaskStateEntity createTaskState(TaskStateEntity taskEntity); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java index 061e93e..2c59f43 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java @@ -4,10 +4,10 @@ public interface ITaskTypeStepService { - public Long getCount(); + public Long getCount(); - public TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity); + public TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity); - public TaskTypeStepEntity getTypeStepById(Long id); + public TaskTypeStepEntity getTypeStepById(Long id); } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java b/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java index 8577231..8f4c061 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java @@ -11,23 +11,23 @@ @Service public class TaskCategoryService implements ITaskCategoryService { - @Autowired - private TaskCategoryRepository taskCategoryRepository; - - @Override - public TaskCategoryEntity getCategoryById(Long id) { - return taskCategoryRepository.findById(id).orElse(null); - } - - @Override - public Long getCount() { - return taskCategoryRepository.count(); - } - - @Override - @Transactional - public TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity) { - return taskCategoryRepository.save(categoryEntity); - } + @Autowired + private TaskCategoryRepository taskCategoryRepository; + + @Override + public TaskCategoryEntity getCategoryById(Long id) { + return taskCategoryRepository.findById(id).orElse(null); + } + + @Override + public Long getCount() { + return taskCategoryRepository.count(); + } + + @Override + @Transactional + public TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity) { + return taskCategoryRepository.save(categoryEntity); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java b/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java index e17a5c1..83732eb 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java @@ -11,25 +11,25 @@ @Service public class TaskMemberService implements ITaskMemberService { - @Autowired - private TaskMemberRepository taskMemberRepository; - - @Override - @Transactional - public void removeMemberById(Long memberId) { - taskMemberRepository.deleteById(memberId); - } - - @Override - @Transactional - public void removeMemberByCode(Long memberCode) { - taskMemberRepository.deleteByMemberCode(memberCode); - } - - @Override - @Transactional - public TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity) { - return taskMemberRepository.save(memberEntity); - } + @Autowired + private TaskMemberRepository taskMemberRepository; + + @Override + @Transactional + public void removeMemberById(Long memberId) { + taskMemberRepository.deleteById(memberId); + } + + @Override + @Transactional + public void removeMemberByCode(Long memberCode) { + taskMemberRepository.deleteByMemberCode(memberCode); + } + + @Override + @Transactional + public TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity) { + return taskMemberRepository.save(memberEntity); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java b/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java index 448c88d..91ba968 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java @@ -13,71 +13,71 @@ @Service public class TaskService implements ITaskService { - @Autowired - private TaskRepository taskRepository; - - @Override - @Transactional - public List getAllTasks() { - return taskRepository.findAll(); - } - - @Override - @Transactional - public TaskEntity createTask(TaskEntity taskEntity) { - return taskRepository.save(taskEntity); - } - - @Override - @Transactional - public TaskEntity getById(Long id) { - return taskRepository.findById(id).orElse(null); - } - - @Override - public TaskEntity updateTask(TaskEntity task) { - return taskRepository.save(task); - } - - @Override - public List getTasksByMember(Long memberCode) { - return taskRepository.getTasksByMember(memberCode); - } - - @Override - public Long getCount() { - return taskRepository.count(); - } - - @Override - public List getTasksByStates(List taskStates) { - return taskRepository.getTasksByStates(taskStates); - } - - @Override - public List getTasksByStatesAndMember(List taskStates, Long memberCode) { - return taskRepository.getTasksByMemberAndStates(memberCode, taskStates); - } - - @Override - public List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, - Long memberCode) { - return taskRepository.getTasksByMemberAndStatesAndCategories(memberCode, taskStates, taskCategories); - } - - @Override - public List getTasksByMemberAndCategories(List taskCategories, Long memberCode) { - return taskRepository.getTasksByMemberAndCategories(memberCode, taskCategories); - } - - @Override - public List getTasksByStatesAndCategories(List taskCategories, List taskStates) { - return taskRepository.getTasksByStatesAndCategories(taskStates, taskCategories); - } - - @Override - public List getTasksByCategories(List taskCategories) { - return taskRepository.getTasksByCategories(taskCategories); - } + @Autowired + private TaskRepository taskRepository; + + @Override + @Transactional + public List getAllTasks() { + return taskRepository.findAll(); + } + + @Override + @Transactional + public TaskEntity createTask(TaskEntity taskEntity) { + return taskRepository.save(taskEntity); + } + + @Override + @Transactional + public TaskEntity getById(Long id) { + return taskRepository.findById(id).orElse(null); + } + + @Override + public TaskEntity updateTask(TaskEntity task) { + return taskRepository.save(task); + } + + @Override + public List getTasksByMember(Long memberCode) { + return taskRepository.getTasksByMember(memberCode); + } + + @Override + public Long getCount() { + return taskRepository.count(); + } + + @Override + public List getTasksByStates(List taskStates) { + return taskRepository.getTasksByStates(taskStates); + } + + @Override + public List getTasksByStatesAndMember(List taskStates, Long memberCode) { + return taskRepository.getTasksByMemberAndStates(memberCode, taskStates); + } + + @Override + public List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, + Long memberCode) { + return taskRepository.getTasksByMemberAndStatesAndCategories(memberCode, taskStates, taskCategories); + } + + @Override + public List getTasksByMemberAndCategories(List taskCategories, Long memberCode) { + return taskRepository.getTasksByMemberAndCategories(memberCode, taskCategories); + } + + @Override + public List getTasksByStatesAndCategories(List taskCategories, List taskStates) { + return taskRepository.getTasksByStatesAndCategories(taskStates, taskCategories); + } + + @Override + public List getTasksByCategories(List taskCategories) { + return taskRepository.getTasksByCategories(taskCategories); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java b/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java index d6e43e4..e721419 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java @@ -11,23 +11,23 @@ @Service public class TaskStateService implements ITaskStateService { - @Autowired - private TaskStateRepository taskStateRepository; - - @Override - public TaskStateEntity getById(Long id) { - return taskStateRepository.findById(id).orElse(null); - } - - @Override - public Long getAllCount() { - return taskStateRepository.count(); - } - - @Override - @Transactional - public TaskStateEntity createTaskState(TaskStateEntity taskEntity) { - return taskStateRepository.save(taskEntity); - } + @Autowired + private TaskStateRepository taskStateRepository; + + @Override + public TaskStateEntity getById(Long id) { + return taskStateRepository.findById(id).orElse(null); + } + + @Override + public Long getAllCount() { + return taskStateRepository.count(); + } + + @Override + @Transactional + public TaskStateEntity createTaskState(TaskStateEntity taskEntity) { + return taskStateRepository.save(taskEntity); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java b/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java index 23f7327..dd4fa3f 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java @@ -11,23 +11,23 @@ @Service public class TaskTypeStepService implements ITaskTypeStepService { - @Autowired - private TaskTypeStepRepository typeStepRepository; - - @Override - public Long getCount() { - return typeStepRepository.count(); - } - - @Override - @Transactional - public TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity) { - return typeStepRepository.save(typeStepEntity); - } - - @Override - public TaskTypeStepEntity getTypeStepById(Long id) { - return typeStepRepository.findById(id).orElse(null); - } + @Autowired + private TaskTypeStepRepository typeStepRepository; + + @Override + public Long getCount() { + return typeStepRepository.count(); + } + + @Override + @Transactional + public TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity) { + return typeStepRepository.save(typeStepEntity); + } + + @Override + public TaskTypeStepEntity getTypeStepById(Long id) { + return typeStepRepository.findById(id).orElse(null); + } } diff --git a/src/main/java/com/ai/st/microservice/tasks/services/tracing/SCMTracing.java b/src/main/java/com/ai/st/microservice/tasks/services/tracing/SCMTracing.java new file mode 100644 index 0000000..eb6b9a2 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/services/tracing/SCMTracing.java @@ -0,0 +1,27 @@ +package com.ai.st.microservice.tasks.services.tracing; + +import com.newrelic.api.agent.NewRelic; + +public class SCMTracing { + + public static void setTransactionName(String transactionName) { + NewRelic.setTransactionName("SCM", transactionName); + } + + public static void sendError(String message) { + NewRelic.noticeError(message); + } + + public static void addCustomParameter(TracingKeyword key, Number value) { + NewRelic.addCustomParameter(key.getValue(), value); + } + + public static void addCustomParameter(TracingKeyword key, String value) { + NewRelic.addCustomParameter(key.getValue(), value); + } + + public static void addCustomParameter(TracingKeyword key, boolean value) { + NewRelic.addCustomParameter(key.getValue(), value); + } + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java b/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java new file mode 100644 index 0000000..cb64bd6 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java @@ -0,0 +1,17 @@ +package com.ai.st.microservice.tasks.services.tracing; + +public enum TracingKeyword { + BODY_REQUEST("bodyRequest"), AUTHORIZATION_HEADER("authorizationHeader"), USER_ID("userId"), USER_NAME("username"), + USER_EMAIL("userEmail"), MANAGER_ID("managerId"), MANAGER_NAME("managerName"); + + private final String value; + + TracingKeyword(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/swagger/SwaggerConfig.java b/src/main/java/com/ai/st/microservice/tasks/swagger/SwaggerConfig.java index 1fbdfad..86befd5 100644 --- a/src/main/java/com/ai/st/microservice/tasks/swagger/SwaggerConfig.java +++ b/src/main/java/com/ai/st/microservice/tasks/swagger/SwaggerConfig.java @@ -18,19 +18,19 @@ @Configuration public class SwaggerConfig { - @Bean - public Docket usersApi() { - return new Docket(DocumentationType.SWAGGER_2).apiInfo(usersApiInfo()).select().paths(userPaths()) - .apis(RequestHandlerSelectors.any()).build().useDefaultResponseMessages(false); - } - - private ApiInfo usersApiInfo() { - return new ApiInfoBuilder().title("Microservice Tasks").version("1.0") - .license("GNU AFFERO GENERAL PUBLIC LICENSE - Version 3").build(); - } - - private Predicate userPaths() { - return regex("/api.*"); - } + @Bean + public Docket usersApi() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(usersApiInfo()).select().paths(userPaths()) + .apis(RequestHandlerSelectors.any()).build().useDefaultResponseMessages(false); + } + + private ApiInfo usersApiInfo() { + return new ApiInfoBuilder().title("Microservice Tasks").version("1.0") + .license("GNU AFFERO GENERAL PUBLIC LICENSE - Version 3").build(); + } + + private Predicate userPaths() { + return regex("/api.*"); + } } diff --git a/src/main/resources/db/migration/V1_0_0__database_definition.sql b/src/main/resources/db/migration/V1_0_0__database_definition.sql new file mode 100644 index 0000000..8ebf907 --- /dev/null +++ b/src/main/resources/db/migration/V1_0_0__database_definition.sql @@ -0,0 +1,219 @@ +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +CREATE SCHEMA IF NOT EXISTS tasks; + +SET default_tablespace = ''; + +CREATE TABLE tasks.tasks ( + id bigint NOT NULL, + closing_date timestamp without time zone, + created_at timestamp without time zone NOT NULL, + deadline timestamp without time zone, + description character varying(500), + name character varying(255) NOT NULL, + reason character varying(500), + task_state_id bigint NOT NULL +); + +CREATE TABLE tasks.tasks_categories ( + id bigint NOT NULL, + name character varying(255) NOT NULL +); + +ALTER TABLE tasks.tasks_categories ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_categories_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +ALTER TABLE tasks.tasks ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_members ( + id bigint NOT NULL, + created_at timestamp without time zone NOT NULL, + member_code bigint NOT NULL, + task_id bigint NOT NULL +); + +ALTER TABLE tasks.tasks_members ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_members_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_metadata ( + id bigint NOT NULL, + key character varying(255) NOT NULL, + task_id bigint NOT NULL +); + +ALTER TABLE tasks.tasks_metadata ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_metadata_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_metadata_properties ( + id bigint NOT NULL, + key character varying(255) NOT NULL, + value character varying(255) NOT NULL, + metadata_id bigint NOT NULL +); + +ALTER TABLE tasks.tasks_metadata_properties ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_metadata_properties_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_states ( + id bigint NOT NULL, + name character varying(255) NOT NULL +); + +ALTER TABLE tasks.tasks_states ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_states_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_steps ( + id bigint NOT NULL, + code character varying(20) NOT NULL, + description character varying(1000) NOT NULL, + status boolean NOT NULL, + step_id bigint, + task_id bigint NOT NULL, + task_type_step_id bigint NOT NULL +); + +ALTER TABLE tasks.tasks_steps ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_steps_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_types_steps ( + id bigint NOT NULL, + name character varying(255) NOT NULL +); + +ALTER TABLE tasks.tasks_types_steps ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( + SEQUENCE NAME tasks.tasks_types_steps_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1 +); + +CREATE TABLE tasks.tasks_x_categories ( + task_id bigint NOT NULL, + category_id bigint NOT NULL +); + +INSERT INTO tasks.tasks_categories VALUES (1, 'INTEGRACIÓN DE INSUMOS'); +INSERT INTO tasks.tasks_categories VALUES (2, 'GENERACIÓN INSUMO CATASTRAL'); +INSERT INTO tasks.tasks_categories VALUES (3, 'CONTROL DE CALIDAD XTF'); + +INSERT INTO tasks.tasks_states VALUES (1, 'ASIGNADA'); +INSERT INTO tasks.tasks_states VALUES (2, 'CERRADA'); +INSERT INTO tasks.tasks_states VALUES (3, 'CANCELADA'); +INSERT INTO tasks.tasks_states VALUES (4, 'INICIADA'); + +INSERT INTO tasks.tasks_types_steps VALUES (1, 'ÚNICA VEZ'); +INSERT INTO tasks.tasks_types_steps VALUES (2, 'SIEMPRE'); + +SELECT pg_catalog.setval('tasks.tasks_categories_id_seq', 3, true); +SELECT pg_catalog.setval('tasks.tasks_id_seq', 1, false); +SELECT pg_catalog.setval('tasks.tasks_members_id_seq', 1, false); +SELECT pg_catalog.setval('tasks.tasks_metadata_id_seq', 1, false); +SELECT pg_catalog.setval('tasks.tasks_metadata_properties_id_seq', 1, false); +SELECT pg_catalog.setval('tasks.tasks_states_id_seq', 4, true); +SELECT pg_catalog.setval('tasks.tasks_steps_id_seq', 1, false); +SELECT pg_catalog.setval('tasks.tasks_types_steps_id_seq', 2, true); + +ALTER TABLE ONLY tasks.tasks_categories + ADD CONSTRAINT tasks_categories_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_members + ADD CONSTRAINT tasks_members_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_metadata + ADD CONSTRAINT tasks_metadata_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_metadata_properties + ADD CONSTRAINT tasks_metadata_properties_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks + ADD CONSTRAINT tasks_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_states + ADD CONSTRAINT tasks_states_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_steps + ADD CONSTRAINT tasks_steps_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_types_steps + ADD CONSTRAINT tasks_types_steps_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY tasks.tasks_members + ADD CONSTRAINT fk2ffgbngedy5k8g9jphuemkx0i FOREIGN KEY (task_id) REFERENCES tasks.tasks(id); + +ALTER TABLE ONLY tasks.tasks_steps + ADD CONSTRAINT fk91eqoe255e72lsmpkxo6psvmx FOREIGN KEY (task_id) REFERENCES tasks.tasks(id); + +ALTER TABLE ONLY tasks.tasks_x_categories + ADD CONSTRAINT fkb4cb0gqnvfbf5ocarsrl06pub FOREIGN KEY (category_id) REFERENCES tasks.tasks_categories(id); + +ALTER TABLE ONLY tasks.tasks_metadata + ADD CONSTRAINT fki3ykfnubwe9x93mtfvbg1sdko FOREIGN KEY (task_id) REFERENCES tasks.tasks(id); + +ALTER TABLE ONLY tasks.tasks_steps + ADD CONSTRAINT fkmh1uts5s7p5i78ya704i9dvx3 FOREIGN KEY (task_type_step_id) REFERENCES tasks.tasks_types_steps(id); + +ALTER TABLE ONLY tasks.tasks_steps + ADD CONSTRAINT fkmn0ex8gysk22vtt0anfy271jw FOREIGN KEY (step_id) REFERENCES tasks.tasks_steps(id); + +ALTER TABLE ONLY tasks.tasks_metadata_properties + ADD CONSTRAINT fkn41ds9u9mdvobrd8sxiw9as6p FOREIGN KEY (metadata_id) REFERENCES tasks.tasks_metadata(id); + +ALTER TABLE ONLY tasks.tasks + ADD CONSTRAINT fkpw2opc7ay9q1wua1kkbmwg7qc FOREIGN KEY (task_state_id) REFERENCES tasks.tasks_states(id); + +ALTER TABLE ONLY tasks.tasks_x_categories + ADD CONSTRAINT fkrltxlgup2ma7fp2jxy26gpqvs FOREIGN KEY (task_id) REFERENCES tasks.tasks(id); \ No newline at end of file diff --git a/src/test/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplicationTests.java b/src/test/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplicationTests.java index bd86318..90c1e9b 100644 --- a/src/test/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplicationTests.java +++ b/src/test/java/com/ai/st/microservice/tasks/StMicroserviceTasksApplicationTests.java @@ -6,8 +6,8 @@ @SpringBootTest class StMicroserviceTasksApplicationTests { - @Test - void contextLoads() { - } + @Test + void contextLoads() { + } } From 07ec425991d5c7fc0c7555ebb609b44ea110f35f Mon Sep 17 00:00:00 2001 From: Jhon Rondon Date: Fri, 8 Apr 2022 17:51:15 -0500 Subject: [PATCH 2/4] feat: Refactor services layer --- .../tasks/business/TaskBusiness.java | 8 ++--- .../tasks/business/TaskStateBusiness.java | 4 +-- .../tasks/clients/UserFeignClient.java | 19 ----------- .../repositories/TaskCategoryRepository.java | 2 +- .../repositories/TaskMemberRepository.java | 2 +- .../repositories/TaskRepository.java | 2 +- .../repositories/TaskStateRepository.java | 2 +- .../repositories/TaskTypeStepRepository.java | 2 +- .../models/services/ITaskCategoryService.java | 13 +++++++ .../models/services/ITaskMemberService.java | 13 +++++++ .../tasks/models/services/ITaskService.java | 34 +++++++++++++++++++ .../models/services/ITaskStateService.java | 13 +++++++ .../models/services/ITaskTypeStepService.java | 13 +++++++ .../services/TaskCategoryService.java | 4 +-- .../services/TaskMemberService.java | 4 +-- .../{ => models}/services/TaskService.java | 4 +-- .../services/TaskStateService.java | 4 +-- .../services/TaskTypeStepService.java | 4 +-- .../tasks/services/ITaskCategoryService.java | 13 ------- .../tasks/services/ITaskMemberService.java | 13 ------- .../tasks/services/ITaskService.java | 34 ------------------- .../tasks/services/ITaskStateService.java | 13 ------- .../tasks/services/ITaskTypeStepService.java | 13 ------- 23 files changed, 107 insertions(+), 126 deletions(-) delete mode 100644 src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java rename src/main/java/com/ai/st/microservice/tasks/{ => models}/repositories/TaskCategoryRepository.java (79%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/repositories/TaskMemberRepository.java (81%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/repositories/TaskRepository.java (97%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/repositories/TaskStateRepository.java (78%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/repositories/TaskTypeStepRepository.java (79%) create mode 100644 src/main/java/com/ai/st/microservice/tasks/models/services/ITaskCategoryService.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/models/services/ITaskMemberService.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/models/services/ITaskService.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/models/services/ITaskStateService.java create mode 100644 src/main/java/com/ai/st/microservice/tasks/models/services/ITaskTypeStepService.java rename src/main/java/com/ai/st/microservice/tasks/{ => models}/services/TaskCategoryService.java (85%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/services/TaskMemberService.java (86%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/services/TaskService.java (94%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/services/TaskStateService.java (85%) rename src/main/java/com/ai/st/microservice/tasks/{ => models}/services/TaskTypeStepService.java (85%) delete mode 100644 src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java delete mode 100644 src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java index 463980a..33ec2c3 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskBusiness.java @@ -31,10 +31,10 @@ import com.ai.st.microservice.tasks.entities.TaskStepEntity; import com.ai.st.microservice.tasks.entities.TaskTypeStepEntity; import com.ai.st.microservice.tasks.exceptions.BusinessException; -import com.ai.st.microservice.tasks.services.ITaskMemberService; -import com.ai.st.microservice.tasks.services.ITaskService; -import com.ai.st.microservice.tasks.services.TaskCategoryService; -import com.ai.st.microservice.tasks.services.TaskTypeStepService; +import com.ai.st.microservice.tasks.models.services.ITaskMemberService; +import com.ai.st.microservice.tasks.models.services.ITaskService; +import com.ai.st.microservice.tasks.models.services.TaskCategoryService; +import com.ai.st.microservice.tasks.models.services.TaskTypeStepService; @Component public class TaskBusiness { diff --git a/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java b/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java index e876a2c..5886b67 100644 --- a/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java +++ b/src/main/java/com/ai/st/microservice/tasks/business/TaskStateBusiness.java @@ -5,7 +5,7 @@ import com.ai.st.microservice.tasks.dto.TaskStateDto; import com.ai.st.microservice.tasks.entities.TaskStateEntity; -import com.ai.st.microservice.tasks.services.ITaskStateService; +import com.ai.st.microservice.tasks.models.services.ITaskStateService; @Component public class TaskStateBusiness { @@ -23,7 +23,7 @@ public TaskStateDto getById(Long id) { TaskStateDto taskStateDto = null; TaskStateEntity taskStateEntity = taskStateService.getById(id); - if (taskStateEntity instanceof TaskStateEntity) { + if (taskStateEntity != null) { taskStateDto = new TaskStateDto(taskStateEntity.getId(), taskStateEntity.getName()); } diff --git a/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java b/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java deleted file mode 100644 index a8b647f..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/clients/UserFeignClient.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.ai.st.microservice.tasks.clients; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; - -import com.ai.st.microservice.tasks.dto.UserDto; - -@FeignClient(name = "st-microservice-administration") -public interface UserFeignClient { - - @GetMapping("/api/administration/users/{id}") - public UserDto findById(@PathVariable Long id); - - @GetMapping("/api/administration/users/token") - public UserDto findByToken(@RequestParam(name = "token") String token); - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskCategoryRepository.java b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskCategoryRepository.java similarity index 79% rename from src/main/java/com/ai/st/microservice/tasks/repositories/TaskCategoryRepository.java rename to src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskCategoryRepository.java index 2aa5ed1..e8739f3 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskCategoryRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskCategoryRepository.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.repositories; +package com.ai.st.microservice.tasks.models.repositories; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskMemberRepository.java similarity index 81% rename from src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java rename to src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskMemberRepository.java index 5183120..de81d4b 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskMemberRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskMemberRepository.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.repositories; +package com.ai.st.microservice.tasks.models.repositories; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskRepository.java similarity index 97% rename from src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java rename to src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskRepository.java index 6d26542..fbd7770 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskRepository.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.repositories; +package com.ai.st.microservice.tasks.models.repositories; import java.util.List; diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskStateRepository.java b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskStateRepository.java similarity index 78% rename from src/main/java/com/ai/st/microservice/tasks/repositories/TaskStateRepository.java rename to src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskStateRepository.java index 51eb4e4..6abc565 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskStateRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskStateRepository.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.repositories; +package com.ai.st.microservice.tasks.models.repositories; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskTypeStepRepository.java b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskTypeStepRepository.java similarity index 79% rename from src/main/java/com/ai/st/microservice/tasks/repositories/TaskTypeStepRepository.java rename to src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskTypeStepRepository.java index d27f56e..abf8344 100644 --- a/src/main/java/com/ai/st/microservice/tasks/repositories/TaskTypeStepRepository.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/repositories/TaskTypeStepRepository.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.repositories; +package com.ai.st.microservice.tasks.models.repositories; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskCategoryService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskCategoryService.java new file mode 100644 index 0000000..7bbd2d4 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskCategoryService.java @@ -0,0 +1,13 @@ +package com.ai.st.microservice.tasks.models.services; + +import com.ai.st.microservice.tasks.entities.TaskCategoryEntity; + +public interface ITaskCategoryService { + + TaskCategoryEntity getCategoryById(Long id); + + Long getCount(); + + TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity); + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskMemberService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskMemberService.java new file mode 100644 index 0000000..e860a3e --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskMemberService.java @@ -0,0 +1,13 @@ +package com.ai.st.microservice.tasks.models.services; + +import com.ai.st.microservice.tasks.entities.TaskMemberEntity; + +public interface ITaskMemberService { + + void removeMemberById(Long memberId); + + void removeMemberByCode(Long memberCode); + + TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity); + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskService.java new file mode 100644 index 0000000..a52ed49 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskService.java @@ -0,0 +1,34 @@ +package com.ai.st.microservice.tasks.models.services; + +import java.util.List; + +import com.ai.st.microservice.tasks.entities.TaskEntity; + +public interface ITaskService { + + List getAllTasks(); + + TaskEntity createTask(TaskEntity task); + + TaskEntity getById(Long id); + + List getTasksByStatesAndMember(List taskStates, Long memberCode); + + List getTasksByStates(List taskStates); + + List getTasksByMember(Long memberCode); + + TaskEntity updateTask(TaskEntity task); + + Long getCount(); + + List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, + Long memberCode); + + List getTasksByMemberAndCategories(List taskCategories, Long memberCode); + + List getTasksByStatesAndCategories(List taskCategories, List taskStates); + + List getTasksByCategories(List taskCategories); + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskStateService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskStateService.java new file mode 100644 index 0000000..e1d1fd4 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskStateService.java @@ -0,0 +1,13 @@ +package com.ai.st.microservice.tasks.models.services; + +import com.ai.st.microservice.tasks.entities.TaskStateEntity; + +public interface ITaskStateService { + + TaskStateEntity getById(Long id); + + Long getAllCount(); + + TaskStateEntity createTaskState(TaskStateEntity taskEntity); + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskTypeStepService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskTypeStepService.java new file mode 100644 index 0000000..efc5093 --- /dev/null +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/ITaskTypeStepService.java @@ -0,0 +1,13 @@ +package com.ai.st.microservice.tasks.models.services; + +import com.ai.st.microservice.tasks.entities.TaskTypeStepEntity; + +public interface ITaskTypeStepService { + + Long getCount(); + + TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity); + + TaskTypeStepEntity getTypeStepById(Long id); + +} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskCategoryService.java similarity index 85% rename from src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java rename to src/main/java/com/ai/st/microservice/tasks/models/services/TaskCategoryService.java index 8f4c061..c27d3a0 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskCategoryService.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskCategoryService.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.services; +package com.ai.st.microservice.tasks.models.services; import javax.transaction.Transactional; @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import com.ai.st.microservice.tasks.entities.TaskCategoryEntity; -import com.ai.st.microservice.tasks.repositories.TaskCategoryRepository; +import com.ai.st.microservice.tasks.models.repositories.TaskCategoryRepository; @Service public class TaskCategoryService implements ITaskCategoryService { diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskMemberService.java similarity index 86% rename from src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java rename to src/main/java/com/ai/st/microservice/tasks/models/services/TaskMemberService.java index 83732eb..039684b 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskMemberService.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskMemberService.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.services; +package com.ai.st.microservice.tasks.models.services; import javax.transaction.Transactional; @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import com.ai.st.microservice.tasks.entities.TaskMemberEntity; -import com.ai.st.microservice.tasks.repositories.TaskMemberRepository; +import com.ai.st.microservice.tasks.models.repositories.TaskMemberRepository; @Service public class TaskMemberService implements ITaskMemberService { diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskService.java similarity index 94% rename from src/main/java/com/ai/st/microservice/tasks/services/TaskService.java rename to src/main/java/com/ai/st/microservice/tasks/models/services/TaskService.java index 91ba968..bc8e9e1 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskService.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskService.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.services; +package com.ai.st.microservice.tasks.models.services; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service; import com.ai.st.microservice.tasks.entities.TaskEntity; -import com.ai.st.microservice.tasks.repositories.TaskRepository; +import com.ai.st.microservice.tasks.models.repositories.TaskRepository; @Service public class TaskService implements ITaskService { diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskStateService.java similarity index 85% rename from src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java rename to src/main/java/com/ai/st/microservice/tasks/models/services/TaskStateService.java index e721419..ce9340e 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskStateService.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskStateService.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.services; +package com.ai.st.microservice.tasks.models.services; import javax.transaction.Transactional; @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import com.ai.st.microservice.tasks.entities.TaskStateEntity; -import com.ai.st.microservice.tasks.repositories.TaskStateRepository; +import com.ai.st.microservice.tasks.models.repositories.TaskStateRepository; @Service public class TaskStateService implements ITaskStateService { diff --git a/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskTypeStepService.java similarity index 85% rename from src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java rename to src/main/java/com/ai/st/microservice/tasks/models/services/TaskTypeStepService.java index dd4fa3f..6233da2 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/TaskTypeStepService.java +++ b/src/main/java/com/ai/st/microservice/tasks/models/services/TaskTypeStepService.java @@ -1,4 +1,4 @@ -package com.ai.st.microservice.tasks.services; +package com.ai.st.microservice.tasks.models.services; import javax.transaction.Transactional; @@ -6,7 +6,7 @@ import org.springframework.stereotype.Service; import com.ai.st.microservice.tasks.entities.TaskTypeStepEntity; -import com.ai.st.microservice.tasks.repositories.TaskTypeStepRepository; +import com.ai.st.microservice.tasks.models.repositories.TaskTypeStepRepository; @Service public class TaskTypeStepService implements ITaskTypeStepService { diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java deleted file mode 100644 index 7decd84..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskCategoryService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ai.st.microservice.tasks.services; - -import com.ai.st.microservice.tasks.entities.TaskCategoryEntity; - -public interface ITaskCategoryService { - - public TaskCategoryEntity getCategoryById(Long id); - - public Long getCount(); - - public TaskCategoryEntity createTaskCategory(TaskCategoryEntity categoryEntity); - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java deleted file mode 100644 index ec2eca0..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskMemberService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ai.st.microservice.tasks.services; - -import com.ai.st.microservice.tasks.entities.TaskMemberEntity; - -public interface ITaskMemberService { - - public void removeMemberById(Long memberId); - - public void removeMemberByCode(Long memberCode); - - public TaskMemberEntity addMemberToTask(TaskMemberEntity memberEntity); - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java deleted file mode 100644 index bf1786b..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskService.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.ai.st.microservice.tasks.services; - -import java.util.List; - -import com.ai.st.microservice.tasks.entities.TaskEntity; - -public interface ITaskService { - - public List getAllTasks(); - - public TaskEntity createTask(TaskEntity task); - - public TaskEntity getById(Long id); - - public List getTasksByStatesAndMember(List taskStates, Long memberCode); - - public List getTasksByStates(List taskStates); - - public List getTasksByMember(Long memberCode); - - public TaskEntity updateTask(TaskEntity task); - - public Long getCount(); - - public List getTasksByStatesAndMemberAndCategories(List taskStates, List taskCategories, - Long memberCode); - - public List getTasksByMemberAndCategories(List taskCategories, Long memberCode); - - public List getTasksByStatesAndCategories(List taskCategories, List taskStates); - - public List getTasksByCategories(List taskCategories); - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java deleted file mode 100644 index e90da21..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskStateService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ai.st.microservice.tasks.services; - -import com.ai.st.microservice.tasks.entities.TaskStateEntity; - -public interface ITaskStateService { - - public TaskStateEntity getById(Long id); - - public Long getAllCount(); - - public TaskStateEntity createTaskState(TaskStateEntity taskEntity); - -} diff --git a/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java b/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java deleted file mode 100644 index 2c59f43..0000000 --- a/src/main/java/com/ai/st/microservice/tasks/services/ITaskTypeStepService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ai.st.microservice.tasks.services; - -import com.ai.st.microservice.tasks.entities.TaskTypeStepEntity; - -public interface ITaskTypeStepService { - - public Long getCount(); - - public TaskTypeStepEntity createTypeStep(TaskTypeStepEntity typeStepEntity); - - public TaskTypeStepEntity getTypeStepById(Long id); - -} From 906dd00b433a9623ab4634ca122001e5978ebd21 Mon Sep 17 00:00:00 2001 From: Jhon Rondon Date: Fri, 8 Apr 2022 17:55:55 -0500 Subject: [PATCH 3/4] feat: Update keywords --- .../st/microservice/tasks/services/tracing/TracingKeyword.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java b/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java index cb64bd6..b60b754 100644 --- a/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java +++ b/src/main/java/com/ai/st/microservice/tasks/services/tracing/TracingKeyword.java @@ -1,8 +1,7 @@ package com.ai.st.microservice.tasks.services.tracing; public enum TracingKeyword { - BODY_REQUEST("bodyRequest"), AUTHORIZATION_HEADER("authorizationHeader"), USER_ID("userId"), USER_NAME("username"), - USER_EMAIL("userEmail"), MANAGER_ID("managerId"), MANAGER_NAME("managerName"); + BODY_REQUEST("bodyRequest"); private final String value; From 27b40cea3ad45c4e7d1bdd6476f923ef0fbdc409 Mon Sep 17 00:00:00 2001 From: Jhon Rondon Date: Wed, 13 Apr 2022 17:37:25 -0500 Subject: [PATCH 4/4] chore: Set version --- pom.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cb31745..f242a88 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.ai.st.microservice.tasks st-microservice-tasks - 1.0.9 + 1.2.0 st-microservice-tasks Microservice Tasks @@ -108,6 +108,14 @@ com.newrelic.agent.java newrelic-api 7.5.0 + compile + + + + com.newrelic.agent.java + newrelic-agent + 7.5.0 + provided