change taskForClassification-request
This commit is contained in:
parent
2d45297acd
commit
9f86a5ef94
|
@ -12,6 +12,7 @@ import pro.taskana.Classification;
|
|||
import pro.taskana.ClassificationQuery;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.ClassificationSummary;
|
||||
import pro.taskana.TaskSummary;
|
||||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationInUseException;
|
||||
|
@ -311,9 +312,14 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
|
||||
TaskServiceImpl taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService();
|
||||
int countTasks = taskService.countTasksByClassificationAndDomain(classificationKey, domain);
|
||||
if (countTasks > 0) {
|
||||
throw new ClassificationInUseException("There are " + countTasks + " Tasks which belong to this classification or a child classification. Please complete them and try again.");
|
||||
try {
|
||||
List<TaskSummary> classificationTasks = taskService.createTaskQuery().classificationKeyIn(classificationKey).domainIn(domain).list();
|
||||
if (!classificationTasks.isEmpty()) {
|
||||
throw new ClassificationInUseException("There are " + classificationTasks.size() + " Tasks which belong to this classification or a child classification. Please complete them and try again.");
|
||||
}
|
||||
} catch (NotAuthorizedException e) {
|
||||
LOGGER.error("ClassificationQuery unexpectedly returned NotauthorizedException. Throwing SystemException ");
|
||||
throw new SystemException("ClassificationQuery unexpectedly returned NotauthorizedException.");
|
||||
}
|
||||
|
||||
List<String> childKeys = this.classificationMapper.getChildrenOfClassification(classificationKey, domain);
|
||||
|
|
|
@ -835,9 +835,9 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
}
|
||||
|
||||
public int countTasksByClassificationAndDomain(String classificationKey, String domain) {
|
||||
return taskMapper.countTasksByClassificationAndDomain(classificationKey, domain);
|
||||
}
|
||||
private void initAttachment(AttachmentImpl attachment, Task newTask) {
|
||||
if (attachment.getId() == null) {
|
||||
attachment.setId(IdGenerator.generateWithPrefix(ID_PREFIX_ATTACHMENT));
|
||||
}
|
||||
if (attachment.getCreated() == null) {
|
||||
attachment.setCreated(Instant.now());
|
||||
|
|
|
@ -170,10 +170,4 @@ public interface TaskMapper {
|
|||
@Result(property = "custom9", column = "CUSTOM_9"),
|
||||
@Result(property = "custom10", column = "CUSTOM_10") })
|
||||
List<TaskSummaryImpl> findTaskSummariesByWorkbasketKey(@Param("workbasketKey") String workbasketKey);
|
||||
|
||||
@Select("SELECT COUNT(ID) "
|
||||
+ "FROM TASK "
|
||||
+ "WHERE CLASSIFICATION_KEY = #{classificationKey} "
|
||||
+ "AND DOMAIN = #{domain}")
|
||||
int countTasksByClassificationAndDomain(@Param("classificationKey") String classificationKey, @Param("domain") String domain);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package acceptance.classification;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -78,8 +79,9 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
} catch (ClassificationInUseException e) {
|
||||
classificationInUse = true;
|
||||
}
|
||||
Classification rollback = classificationService.getClassification("L11010", "DOMAIN_A");
|
||||
assertTrue(classificationInUse);
|
||||
classificationService.getClassification("L11010", "DOMAIN_A");
|
||||
assertEquals("DOMAIN_A", rollback.getDomain());
|
||||
|
||||
classificationInUse = false;
|
||||
try {
|
||||
|
@ -87,9 +89,11 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
} catch (ClassificationInUseException e) {
|
||||
classificationInUse = true;
|
||||
}
|
||||
Classification rollbackMaster = classificationService.getClassification("L11010", "");
|
||||
Classification rollbackA = classificationService.getClassification("L11010", "DOMAIN_A");
|
||||
assertTrue(classificationInUse);
|
||||
classificationService.getClassification("L11010", "");
|
||||
classificationService.getClassification("L11010", "DOMAIN_A");
|
||||
assertEquals(rollbackMaster.getKey(), rollbackA.getKey());
|
||||
assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain());
|
||||
}
|
||||
|
||||
@Test(expected = ClassificationNotFoundException.class)
|
||||
|
|
|
@ -24,7 +24,7 @@ INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000008', 'L
|
|||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000009', 'L140101', '', 'EXTERN', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'Zustimmungserklärung', 'Zustimmungserklärung', 2, 'P2D', '', 'VNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000010', 'T2100', '', 'MANUAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'T-Vertragstermin VERA', 'T-Vertragstermin VERA', 2, 'P2D', '', 'VNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000011', 'T6310', '', 'AUTOMATIC', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'T-GUK Honorarrechnung erstellen', 'Generali Unterstützungskasse Honorar wird fällig', 2, 'P2D', '', 'VNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000013', 'DOKTYP_DEFAULT', '', 'EXTERN', 'DOCUMENT', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'EP allgemein', 'EP allgemein', 99, 'P2000D', '', 'VNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000013', 'DOCTYPE_DEFAULT', '', 'EXTERN', 'DOCUMENT', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'EP allgemein', 'EP allgemein', 99, 'P2000D', '', 'VNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000014', 'L10000', '', 'EXTERN', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'BUZ-Leistungsfall', 'BUZ-Leistungsfall', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
|
||||
INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000016', 'T2000', '', 'MANUAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, 'T-Vertragstermin', 'T-Vertragstermin', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', '');
|
||||
|
||||
|
|
Loading…
Reference in New Issue