diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java index cd2ccde5b..10fada41e 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationServiceImpl.java @@ -4,8 +4,6 @@ import java.sql.SQLException; import java.sql.SQLIntegrityConstraintViolationException; import java.time.Duration; import java.time.Instant; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -295,47 +293,23 @@ public class ClassificationServiceImpl implements ClassificationService { } } - private void validateServiceLevel(String serviceLevel) throws InvalidArgumentException { - Duration duration; + private static void validateServiceLevel(String serviceLevel) throws InvalidArgumentException { try { - duration = Duration.parse(serviceLevel); + Duration.parse(serviceLevel); } catch (Exception e) { throw new InvalidArgumentException("Invalid service level " + serviceLevel - + ". The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. " - + "For example: \"P2D\" represents a period of \"two days.\" ", + + ". The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. " + + "For example: \"P2D\" represents a period of \"two days.\" ", e.getCause()); } - // check that the duration contains only whole days and no remaining hours, minutes or seconds - LocalDateTime ref = LocalDateTime.now(); // reference timestamp - LocalDateTime end = ref.plus(duration); - // find the years part - LocalDateTime ldt = ref; - long years = ChronoUnit.YEARS.between(ldt, end); + // check that the duration is based on format PnD, i.e. it must start with a P, end with a D + String serviceLevelLower = serviceLevel.toLowerCase(); + if (!('p' == serviceLevelLower.charAt(0)) + || !('d' == serviceLevelLower.charAt(serviceLevel.length() - 1))) { - // find the months part - ldt = ldt.plus(years, ChronoUnit.YEARS); - long months = ChronoUnit.MONTHS.between(ldt, end); - - // find the days part - ldt = ldt.plus(months, ChronoUnit.MONTHS); - long days = ChronoUnit.DAYS.between(ldt, end); - - // find the hours part - ldt = ldt.plus(days, ChronoUnit.DAYS); - long hours = ChronoUnit.HOURS.between(ldt, end); - - // find the minutes part - ldt = ldt.plus(hours, ChronoUnit.HOURS); - long minutes = ChronoUnit.MINUTES.between(ldt, end); - - // find the seconds part - ldt = ldt.plus(minutes, ChronoUnit.MINUTES); - long seconds = ChronoUnit.SECONDS.between(ldt, end); - - if (hours != 0 || minutes != 0 || seconds != 0) { throw new InvalidArgumentException("Invalid service level " + serviceLevel + ". Taskana only supports service levels that" - + " contain a number of whole days without additional hours, minutes or seconds."); + + " contain a number of whole days specified according to the format 'PnD' where n is the number of days"); } } diff --git a/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java b/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java index ac48a971a..d7dcb10d4 100644 --- a/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java +++ b/lib/taskana-core/src/test/java/acceptance/classification/QueryClassificationAccTest.java @@ -306,7 +306,7 @@ public class QueryClassificationAccTest extends AbstractAccTest { List results = classificationService.createClassificationQuery() .serviceLevelLike("PT%") .list(); - assertEquals(2, results.size()); + assertEquals(0, results.size()); } @Test @@ -523,7 +523,7 @@ public class QueryClassificationAccTest extends AbstractAccTest { List results = classificationService.createClassificationQuery() .orderByServiceLevel(desc) .list(); - assertEquals("PT24H", results.get(0).getServiceLevel()); + assertEquals("P8D", results.get(0).getServiceLevel()); } @Test diff --git a/lib/taskana-core/src/test/java/acceptance/classification/UpdateClassificationAccTest.java b/lib/taskana-core/src/test/java/acceptance/classification/UpdateClassificationAccTest.java index 02b9f6e48..28d55ad19 100644 --- a/lib/taskana-core/src/test/java/acceptance/classification/UpdateClassificationAccTest.java +++ b/lib/taskana-core/src/test/java/acceptance/classification/UpdateClassificationAccTest.java @@ -74,7 +74,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest { classification.setParentId("CLI:100000000000000000000000000000000004"); classification.setParentKey("L11010"); classification.setPriority(1000); - classification.setServiceLevel("P2DT24H"); + classification.setServiceLevel("P3D"); classificationService.updateClassification(classification); diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java index 91a5251e5..82186048f 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntAutoCommitTest.java @@ -328,7 +328,7 @@ public class ClassificationServiceImplIntAutoCommitTest { classificationService.createClassification(classification); all++; Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK"); - classification1.setServiceLevel("P1DT24H"); + classification1.setServiceLevel("P2D"); classification1.setName("name1"); classification1.setDescription("desc"); classificationService.createClassification(classification1); @@ -349,7 +349,7 @@ public class ClassificationServiceImplIntAutoCommitTest { Assert.assertEquals(1, list.size()); list = classificationService.createClassificationQuery().serviceLevelIn("P1D").descriptionLike("desc").list(); Assert.assertEquals(2, list.size()); - list = classificationService.createClassificationQuery().serviceLevelIn("P1DT24H").nameIn("name").list(); + list = classificationService.createClassificationQuery().serviceLevelIn("P2D").nameIn("name").list(); Assert.assertEquals(0, list.size()); list = classificationService.createClassificationQuery().descriptionLike("desc%").list(); Assert.assertEquals(all, list.size()); diff --git a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java index 667aa08d3..9ba584873 100644 --- a/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java +++ b/lib/taskana-core/src/test/java/pro/taskana/impl/integration/ClassificationServiceImplIntExplicitTest.java @@ -366,7 +366,7 @@ public class ClassificationServiceImplIntExplicitTest { classificationService.createClassification(classification); all++; Classification classification1 = this.createNewClassificationWithUniqueKey("", "TASK"); - classification1.setServiceLevel("P1DT24H"); + classification1.setServiceLevel("P2D"); classification1.setName("name1"); classification1.setDescription("desc"); classificationService.createClassification(classification1); @@ -387,7 +387,7 @@ public class ClassificationServiceImplIntExplicitTest { Assert.assertEquals(1, list.size()); list = classificationService.createClassificationQuery().serviceLevelIn("P1D").descriptionLike("desc").list(); Assert.assertEquals(2, list.size()); - list = classificationService.createClassificationQuery().serviceLevelIn("P1DT24H").nameIn("name").list(); + list = classificationService.createClassificationQuery().serviceLevelIn("P2D").nameIn("name").list(); Assert.assertEquals(0, list.size()); list = classificationService.createClassificationQuery().descriptionLike("desc%").list(); Assert.assertEquals(all, list.size()); diff --git a/lib/taskana-core/src/test/resources/sql/classification.sql b/lib/taskana-core/src/test/resources/sql/classification.sql index 0c0b07710..02e11ed84 100644 --- a/lib/taskana-core/src/test/resources/sql/classification.sql +++ b/lib/taskana-core/src/test/resources/sql/classification.sql @@ -1,6 +1,6 @@ -- ID, KEY, PARENT_ID, PARENT_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, MODIFIED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1 - 8 -- MASTER CLASSIFICATIONS -INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 999, 'PT24H', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); +INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 999, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 1, 'P2D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000003', 'L1050', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P3D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000004', 'L11010', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamikänderung', 'Dynamikänderung', 7, 'P4D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); @@ -21,7 +21,7 @@ INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000023', 'T INSERT INTO CLASSIFICATION VALUES('CLI:300000000000000000000000000000000017', 'L3060', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf neu', 'Widerruf neu', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); -- DOMAIN_A CLASSIFICATIONS -INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 101, 'PT24H', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); +INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 101, 'P1D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000003', 'L1050', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P13D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000004', 'L11010', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamikänderung', 'Dynamikänderung', 1, 'P14D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000005', 'L110102', 'CLI:100000000000000000000000000000000004', 'L11010', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamik-Ablehnung', 'Dynamik-Ablehnung', 5, 'P15D', '', 'VNR,RVNR,KOLVNR', 'TEXT_1', '', '', '', '', '', ''); diff --git a/lib/taskana-spring-example/src/main/resources/application.properties b/lib/taskana-spring-example/src/main/resources/application.properties index 3171d4f00..4da1feb99 100644 --- a/lib/taskana-spring-example/src/main/resources/application.properties +++ b/lib/taskana-spring-example/src/main/resources/application.properties @@ -1 +1 @@ -logging.level.pro.taskana=DEBUG +logging.level.pro.taskana=INFO diff --git a/lib/taskana-spring-example/src/test/java/pro/taskana/TaskanaTransactionIntTest.java b/lib/taskana-spring-example/src/test/java/pro/taskana/TaskanaTransactionIntTest.java index 0ab53721f..7365cf650 100644 --- a/lib/taskana-spring-example/src/test/java/pro/taskana/TaskanaTransactionIntTest.java +++ b/lib/taskana-spring-example/src/test/java/pro/taskana/TaskanaTransactionIntTest.java @@ -10,6 +10,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.internal.verification.VerificationModeFactory.atLeastOnce; import java.sql.Connection; import java.sql.SQLException; @@ -246,7 +247,7 @@ public class TaskanaTransactionIntTest { WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, springTransactionProvider, null); job.run(); - verify(mockAppender, times(7)).doAppend(captorLoggingEvent.capture()); + verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture()); List allValues = captorLoggingEvent.getAllValues(); Optional result = allValues.stream().filter(event -> event.getLevel().equals( diff --git a/rest/taskana-rest-spring-example/src/main/resources/application.properties b/rest/taskana-rest-spring-example/src/main/resources/application.properties index 59940c2e2..ecaa114f3 100644 --- a/rest/taskana-rest-spring-example/src/main/resources/application.properties +++ b/rest/taskana-rest-spring-example/src/main/resources/application.properties @@ -1,4 +1,4 @@ -logging.level.pro.taskana=DEBUG +logging.level.pro.taskana=INFO ### logging.level.org.springframework=DEBUG ######## Taskana DB ####### ######## h2 configuration ######## diff --git a/rest/taskana-rest-spring-example/src/main/resources/sql/sample-data/classification.sql b/rest/taskana-rest-spring-example/src/main/resources/sql/sample-data/classification.sql index 0c0b07710..02e11ed84 100644 --- a/rest/taskana-rest-spring-example/src/main/resources/sql/sample-data/classification.sql +++ b/rest/taskana-rest-spring-example/src/main/resources/sql/sample-data/classification.sql @@ -1,6 +1,6 @@ -- ID, KEY, PARENT_ID, PARENT_KEY, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, MODIFIED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, APPLICATION_ENTRY_POINT, CUSTOM_1 - 8 -- MASTER CLASSIFICATIONS -INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 999, 'PT24H', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); +INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000001', 'L10000', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'OLD-Leistungsfall', 'OLD-Leistungsfall', 999, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 1, 'P2D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000003', 'L1050', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P3D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000004', 'L11010', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamikänderung', 'Dynamikänderung', 7, 'P4D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); @@ -21,7 +21,7 @@ INSERT INTO CLASSIFICATION VALUES('CLI:000000000000000000000000000000000023', 'T INSERT INTO CLASSIFICATION VALUES('CLI:300000000000000000000000000000000017', 'L3060', '', '', 'EXTERNAL', 'TASK', '', FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf neu', 'Widerruf neu', 1, 'P1D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); -- DOMAIN_A CLASSIFICATIONS -INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 101, 'PT24H', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); +INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000002', 'L10303', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Beratungsprotokoll', 'Beratungsprotokoll', 101, 'P1D', '', 'VNR,RVNR,KOLVNR, ANR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000003', 'L1050', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Widerruf', 'Widerruf', 1, 'P13D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000004', 'L11010', '', '', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamikänderung', 'Dynamikänderung', 1, 'P14D', '', 'VNR,RVNR,KOLVNR', '', '', '', '', '', '', ''); INSERT INTO CLASSIFICATION VALUES('CLI:100000000000000000000000000000000005', 'L110102', 'CLI:100000000000000000000000000000000004', 'L11010', 'EXTERNAL', 'TASK', 'DOMAIN_A', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Dynamik-Ablehnung', 'Dynamik-Ablehnung', 5, 'P15D', '', 'VNR,RVNR,KOLVNR', 'TEXT_1', '', '', '', '', '', ''); diff --git a/rest/taskana-rest-spring-example/src/test/resources/application.properties b/rest/taskana-rest-spring-example/src/test/resources/application.properties index 5ccbf9059..27c503833 100644 --- a/rest/taskana-rest-spring-example/src/test/resources/application.properties +++ b/rest/taskana-rest-spring-example/src/test/resources/application.properties @@ -1,4 +1,4 @@ -logging.level.pro.taskana=DEBUG +logging.level.pro.taskana=INFO ### logging.level.org.springframework=DEBUG ######## Taskana DB ####### datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0