feature/810 Add querying by planned date in monitor screen
This commit is contained in:
parent
ab4458a2c7
commit
aea64975db
|
@ -18,15 +18,21 @@
|
||||||
<version>2.0.2.RELEASE</version>
|
<version>2.0.2.RELEASE</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<!-- Repository for postgresql V. 9.4.1212 driver.
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<!-- Repository for postgresql V. 9.4.1212 driver.
|
||||||
<repository>
|
<repository>
|
||||||
<id>postgresql</id>
|
<id>postgresql</id>
|
||||||
<name>postgresql repository</name>
|
<name>postgresql repository</name>
|
||||||
<url>https://mvnrepository.com/artifact/postgresql/postgresql</url>
|
<url>https://mvnrepository.com/artifact/postgresql/postgresql</url>
|
||||||
|
</repository>-->
|
||||||
|
<!-- this repository is needed to fetch com.ibm.db2.jcc -->
|
||||||
|
<repository>
|
||||||
|
<id>novatec public</id>
|
||||||
|
<name>novatec-repository</name>
|
||||||
|
<url>https://repository.novatec-gmbh.de/content/repositories/novatec/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
-->
|
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -84,14 +90,12 @@
|
||||||
<version>11.1.1.1</version>
|
<version>11.1.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
||||||
<!-- Postgresql driver dependency
|
<!-- Postgresql driver dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>9.4.1212</version>
|
<version>9.4.1212</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
@ -159,15 +163,4 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<!--
|
|
||||||
this repository is needed to fetch com.ibm.db2.jcc
|
|
||||||
-->
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>novatec public</id>
|
|
||||||
<name>novatec-repository</name>
|
|
||||||
<url>https://repository.novatec-gmbh.de/content/repositories/novatec/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -9,13 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
@ -53,20 +50,6 @@ public class ExampleRestApplication {
|
||||||
SpringApplication.run(ExampleRestApplication.class, args);
|
SpringApplication.run(ExampleRestApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "datasource")
|
|
||||||
public DataSourceProperties dataSourceProperties() {
|
|
||||||
DataSourceProperties props = new DataSourceProperties();
|
|
||||||
props.setUrl("jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS " + schemaName);
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DataSource dataSource(DataSourceProperties properties) {
|
|
||||||
return properties.initializeDataSourceBuilder().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PlatformTransactionManager txManager(DataSource dataSource) {
|
public PlatformTransactionManager txManager(DataSource dataSource) {
|
||||||
return new DataSourceTransactionManager(dataSource);
|
return new DataSourceTransactionManager(dataSource);
|
||||||
|
|
|
@ -2,23 +2,25 @@ logging.level.pro.taskana=INFO
|
||||||
### logging.level.org.springframework=DEBUG
|
### logging.level.org.springframework=DEBUG
|
||||||
######## Taskana DB #######
|
######## Taskana DB #######
|
||||||
######## h2 configuration ########
|
######## h2 configuration ########
|
||||||
datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0
|
spring.datasource.url=jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0
|
||||||
datasource.driverClassName=org.h2.Driver
|
spring.datasource.driverClassName=org.h2.Driver
|
||||||
datasource.username=sa
|
spring.datasource.username=sa
|
||||||
datasource.password=sa
|
spring.datasource.password=sa
|
||||||
taskana.schemaName=TASKANA
|
taskana.schemaName=TASKANA
|
||||||
######## h2 console configuration ########
|
######## h2 console configuration ########
|
||||||
######## spring.h2.console.enabled=true ########
|
########spring.h2.console.enabled=true
|
||||||
######## spring.h2.console.path=/h2-console ########
|
########spring.h2.console.path=/h2-console
|
||||||
|
|
||||||
######## Postgres configuration ########
|
######## Postgres configuration ########
|
||||||
######## datasource.url=jdbc:postgresql://localhost/taskana ########
|
########spring.datasource.url=jdbc:postgresql://localhost/taskana
|
||||||
######## datasource.driverClassName=org.postgresql.Driver ########
|
########spring.datasource.driverClassName=org.postgresql.Driver
|
||||||
######## datasource.username=postgres ########
|
########spring.datasource.username=postgres
|
||||||
######## datasource.password=1234 ########
|
########spring.datasource.password=1234
|
||||||
|
########spring.jpa.generate-ddl=true
|
||||||
|
########spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||||
####### property that control rest api security deploy use true for no security.
|
####### property that control rest api security deploy use true for no security.
|
||||||
devMode=false
|
devMode=false
|
||||||
|
|
||||||
####### property that control if the database is cleaned and sample data is generated
|
####### property that control if the database is cleaned and sample data is generated
|
||||||
generateSampleData=true
|
generateSampleData=true
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class AbstractPagingControllerRestDocumentation {
|
||||||
pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items");
|
pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items");
|
||||||
pagingFieldDescriptionsMap.put("page.totalPages", "Number of pages");
|
pagingFieldDescriptionsMap.put("page.totalPages", "Number of pages");
|
||||||
pagingFieldDescriptionsMap.put("page.number", "Current page number");
|
pagingFieldDescriptionsMap.put("page.number", "Current page number");
|
||||||
pagingFieldDescriptionsMap.put("_links.allClassifications.href", "Link to the main Summary-Resourc");
|
|
||||||
pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page");
|
pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page");
|
||||||
pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page");
|
pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page");
|
||||||
pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page");
|
pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page");
|
||||||
|
@ -87,7 +86,6 @@ public class AbstractPagingControllerRestDocumentation {
|
||||||
fieldWithPath("page.totalElements").description(pagingFieldDescriptionsMap.get("page.totalElements")),
|
fieldWithPath("page.totalElements").description(pagingFieldDescriptionsMap.get("page.totalElements")),
|
||||||
fieldWithPath("page.totalPages").description(pagingFieldDescriptionsMap.get("page.totalPages")),
|
fieldWithPath("page.totalPages").description(pagingFieldDescriptionsMap.get("page.totalPages")),
|
||||||
fieldWithPath("page.number").description(pagingFieldDescriptionsMap.get("page.number")),
|
fieldWithPath("page.number").description(pagingFieldDescriptionsMap.get("page.number")),
|
||||||
fieldWithPath("_links.allClassifications.href").description(pagingFieldDescriptionsMap.get("_links.allClassifications.href")),
|
|
||||||
fieldWithPath("_links.first.href").description(pagingFieldDescriptionsMap.get("_links.first.href")),
|
fieldWithPath("_links.first.href").description(pagingFieldDescriptionsMap.get("_links.first.href")),
|
||||||
fieldWithPath("_links.last.href").description(pagingFieldDescriptionsMap.get("_links.last.href")),
|
fieldWithPath("_links.last.href").description(pagingFieldDescriptionsMap.get("_links.last.href")),
|
||||||
fieldWithPath("_links.prev.href").description(pagingFieldDescriptionsMap.get("_links.prev.href")),
|
fieldWithPath("_links.prev.href").description(pagingFieldDescriptionsMap.get("_links.prev.href")),
|
||||||
|
|
|
@ -247,23 +247,21 @@ public class WorkbasketControllerRestDocumentation {
|
||||||
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
|
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")),
|
||||||
fieldWithPath("_embedded.accessItems[].permCustom12").description(
|
fieldWithPath("_embedded.accessItems[].permCustom12").description(
|
||||||
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
|
accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")),
|
||||||
fieldWithPath("_embedded.accessItems[]._links.workbasket.href").description(
|
|
||||||
accessItemFieldDescriptionsMap.get("_embedded.accessItems._links.workbasket.href")),
|
|
||||||
fieldWithPath("_links.self.href").ignored(),
|
fieldWithPath("_links.self.href").ignored(),
|
||||||
fieldWithPath("_links.workbasket.href").ignored()
|
fieldWithPath("_links.workbasket.href").ignored()
|
||||||
};
|
};
|
||||||
|
|
||||||
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] {
|
allWorkbasketAccessItemsFieldDescriptors = new FieldDescriptor[] {
|
||||||
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
|
subsectionWithPath("_embedded.accessItems").description("An array of <<access-item, Access Items>>"),
|
||||||
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
|
fieldWithPath("_links.self.href").ignored(),
|
||||||
fieldWithPath("_links.self.href").ignored()
|
fieldWithPath("_links.workbasket.href").ignored()
|
||||||
};
|
};
|
||||||
|
|
||||||
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
|
allDistributionTargetsFieldDescriptors = new FieldDescriptor[] {
|
||||||
subsectionWithPath("_embedded.distributionTargets").description(
|
subsectionWithPath("_embedded.distributionTargets").description(
|
||||||
"An array of <<workbasket-subset, workbasket subsets>>"),
|
"An array of <<workbasket-subset, workbasket subsets>>"),
|
||||||
fieldWithPath("_links.workbasket.href").description("Link to the workbasket"),
|
fieldWithPath("_links.self.href").ignored(),
|
||||||
fieldWithPath("_links.self.href").ignored()
|
fieldWithPath("_links.workbasket.href").ignored()
|
||||||
};
|
};
|
||||||
|
|
||||||
createWorkbasketFieldDescriptors = new FieldDescriptor[] {
|
createWorkbasketFieldDescriptors = new FieldDescriptor[] {
|
||||||
|
|
|
@ -130,11 +130,6 @@ public class ClassificationControllerIntTest {
|
||||||
.getLink(Link.REL_SELF)
|
.getLink(Link.REL_SELF)
|
||||||
.getHref()
|
.getHref()
|
||||||
.endsWith("/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"));
|
.endsWith("/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"));
|
||||||
assertNotNull(response.getBody().getLink("allClassifications"));
|
|
||||||
assertTrue(response.getBody()
|
|
||||||
.getLink("allClassifications")
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/v1/classifications"));
|
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
|
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
|
||||||
|
|
|
@ -221,11 +221,6 @@ public class TaskControllerIntTest {
|
||||||
.getLink(Link.REL_SELF)
|
.getLink(Link.REL_SELF)
|
||||||
.getHref()
|
.getHref()
|
||||||
.endsWith("/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5"));
|
.endsWith("/v1/tasks?state=READY,CLAIMED&sort-by=por.value&order=desc&page=15&page-size=5"));
|
||||||
assertNotNull(response.getBody().getLink("allTasks"));
|
|
||||||
assertTrue(response.getBody()
|
|
||||||
.getLink("allTasks")
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/v1/tasks"));
|
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||||
|
@ -263,11 +258,6 @@ public class TaskControllerIntTest {
|
||||||
.getLink(Link.REL_SELF)
|
.getLink(Link.REL_SELF)
|
||||||
.getHref()
|
.getHref()
|
||||||
.endsWith("/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"));
|
.endsWith("/v1/tasks?sort-by=due&order=desc&page=5&page-size=5"));
|
||||||
assertNotNull(response.getBody().getLink("allTasks"));
|
|
||||||
assertTrue(response.getBody()
|
|
||||||
.getLink("allTasks")
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/v1/tasks"));
|
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||||
|
@ -298,11 +288,6 @@ public class TaskControllerIntTest {
|
||||||
.getHref()
|
.getHref()
|
||||||
.endsWith(
|
.endsWith(
|
||||||
"/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5"));
|
"/v1/tasks?por.company=00&por.system=PASystem&por.instance=00&por.type=VNR&por.value=22334455&sort-by=por.type&order=asc&page=2&page-size=5"));
|
||||||
assertNotNull(response.getBody().getLink("allTasks"));
|
|
||||||
assertTrue(response.getBody()
|
|
||||||
.getLink("allTasks")
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/v1/tasks"));
|
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWorkbasketAccessItemsKeepingFilters() {
|
public void testGetWorkbasketAccessItemsKeepingFilters() {
|
||||||
String parameters = "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
String parameters = "/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=1&page-size=9&access-ids=user_1_1";
|
||||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
||||||
url + port + parameters, HttpMethod.GET, request,
|
url + port + parameters, HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||||
|
@ -100,7 +100,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSecondPageSortedByWorkbasketKey() {
|
public void testGetSecondPageSortedByWorkbasketKey() {
|
||||||
String parameters = "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
String parameters = "/v1/workbasket-access-items?sort-by=workbasket-key&order=asc&page=2&page-size=9&access-ids=user_1_1";
|
||||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = template.exchange(
|
||||||
url + port + parameters, HttpMethod.GET, request,
|
url + port + parameters, HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketAccessItemResource>>() {
|
||||||
|
@ -134,7 +134,7 @@ public class WorkbasketAccessItemControllerIntTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
public void testGetBadRequestIfTryingToDeleteAccessItemsForGroup() {
|
||||||
String parameters = "/v1/workbasket-access-items/?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
String parameters = "/v1/workbasket-access-items?access-id=cn=DevelopersGroup,ou=groups,o=TaskanaTest";
|
||||||
try {
|
try {
|
||||||
ResponseEntity<Void> response = template.exchange(
|
ResponseEntity<Void> response = template.exchange(
|
||||||
url + port + parameters, HttpMethod.DELETE, request,
|
url + port + parameters, HttpMethod.DELETE, request,
|
||||||
|
|
|
@ -117,17 +117,12 @@ public class WorkbasketControllerIntTest {
|
||||||
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
new ParameterizedTypeReference<PagedResources<WorkbasketSummaryResource>>() {
|
||||||
});
|
});
|
||||||
assertEquals(5, response.getBody().getContent().size());
|
assertEquals(5, response.getBody().getContent().size());
|
||||||
assertEquals("USER_1_1", response.getBody().getContent().iterator().next().key);
|
assertEquals("USER_1_1", response.getBody().getContent().iterator().next().getKey());
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
assertNotNull(response.getBody().getLink(Link.REL_SELF));
|
||||||
assertTrue(response.getBody()
|
assertTrue(response.getBody()
|
||||||
.getLink(Link.REL_SELF)
|
.getLink(Link.REL_SELF)
|
||||||
.getHref()
|
.getHref()
|
||||||
.endsWith(parameters));
|
.endsWith(parameters));
|
||||||
assertNotNull(response.getBody().getLink("allWorkbaskets"));
|
|
||||||
assertTrue(response.getBody()
|
|
||||||
.getLink("allWorkbaskets")
|
|
||||||
.getHref()
|
|
||||||
.endsWith("/v1/workbaskets"));
|
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
assertNotNull(response.getBody().getLink(Link.REL_LAST));
|
||||||
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
|
assertNotNull(response.getBody().getLink(Link.REL_NEXT));
|
||||||
|
@ -150,7 +145,7 @@ public class WorkbasketControllerIntTest {
|
||||||
assertEquals(HttpStatus.OK, response2.getStatusCode());
|
assertEquals(HttpStatus.OK, response2.getStatusCode());
|
||||||
Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator();
|
Iterator<DistributionTargetResource> iterator = response2.getBody().getContent().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
assertNotEquals("WBI:100000000000000000000000000000000007", iterator.next().workbasketId);
|
assertNotEquals("WBI:100000000000000000000000000000000007", iterator.next().getWorkbasketId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import pro.taskana.rest.resource.WorkbasketDefinitionResource;
|
import pro.taskana.rest.resource.WorkbasketDefinitionResource;
|
||||||
|
/**
|
||||||
|
* Integration tests for WorkbasketDefinitionController.
|
||||||
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||||
public class WorkbasketDefinitionControllerIntTest {
|
public class WorkbasketDefinitionControllerIntTest {
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
package pro.taskana;
|
package pro.taskana;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -19,14 +10,12 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
|
|
||||||
import pro.taskana.jobs.TransactionalJobsConfiguration;
|
import pro.taskana.jobs.TransactionalJobsConfiguration;
|
||||||
import pro.taskana.ldap.LdapCacheTestImpl;
|
import pro.taskana.ldap.LdapCacheTestImpl;
|
||||||
import pro.taskana.ldap.LdapClient;
|
import pro.taskana.ldap.LdapClient;
|
||||||
|
@ -36,6 +25,14 @@ import pro.taskana.rest.RestConfiguration;
|
||||||
import pro.taskana.rest.WebMvcConfig;
|
import pro.taskana.rest.WebMvcConfig;
|
||||||
import pro.taskana.sampledata.SampleDataGenerator;
|
import pro.taskana.sampledata.SampleDataGenerator;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example Application showing the implementation of taskana-rest-spring for jboss application server.
|
* Example Application showing the implementation of taskana-rest-spring for jboss application server.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,8 +30,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
import pro.taskana.rest.resource.TaskanaUserInfoResource;
|
||||||
|
|
||||||
// This test class is configured to run with postgres DB if you want to run it with h2 it is needed
|
/**
|
||||||
// to change data source configuration at project-defaults.yml
|
* This test class is configured to run with postgres DB if you want to run it with h2 it is needed.
|
||||||
|
* to change data source configuration at project-defaults.yml.
|
||||||
|
*/
|
||||||
@RunWith(Arquillian.class)
|
@RunWith(Arquillian.class)
|
||||||
public class TaskanaWildflyTest {
|
public class TaskanaWildflyTest {
|
||||||
|
|
||||||
|
@ -61,6 +63,7 @@ public class TaskanaWildflyTest {
|
||||||
ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange(
|
ResponseEntity<TaskanaUserInfoResource> response = getRestTemplate().exchange(
|
||||||
"http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request,
|
"http://127.0.0.1:" + "8090" + "/v1/current-user-info", HttpMethod.GET, request,
|
||||||
new ParameterizedTypeReference<TaskanaUserInfoResource>() {
|
new ParameterizedTypeReference<TaskanaUserInfoResource>() {
|
||||||
|
|
||||||
});
|
});
|
||||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,19 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-aop</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.aspectj</groupId>
|
||||||
|
<artifactId>aspectjweaver</artifactId>
|
||||||
|
<version>1.9.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!---->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface LdapCache {
|
||||||
* Find the groups belong to a user.
|
* Find the groups belong to a user.
|
||||||
* @param searchFor the search string. The search is performed over names and ids of group .
|
* @param searchFor the search string. The search is performed over names and ids of group .
|
||||||
* @param maxNumberOfReturnedAccessIds the maximum number of results to return.
|
* @param maxNumberOfReturnedAccessIds the maximum number of results to return.
|
||||||
* @return
|
* @return a List of access ids for groups of users.
|
||||||
*/
|
*/
|
||||||
List<AccessIdResource> findGroupsOfUser(String searchFor, int maxNumberOfReturnedAccessIds);
|
List<AccessIdResource> findGroupsOfUser(String searchFor, int maxNumberOfReturnedAccessIds);
|
||||||
|
|
||||||
|
|
|
@ -7,30 +7,16 @@ import java.util.List;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
|
import pro.taskana.BaseQuery;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract superclass for taskana REST controller with pagable resources.
|
* Abstract superclass for taskana REST controller with pageable resources.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPagingController {
|
public abstract class AbstractPagingController {
|
||||||
|
|
||||||
protected PageMetadata initPageMetadata(String pagesizeParam, String pageParam, long totalElements)
|
private static final String PAGING_PAGE = "page";
|
||||||
throws InvalidArgumentException {
|
private static final String PAGING_PAGE_SIZE = "page-size";
|
||||||
long pagesize;
|
|
||||||
long page;
|
|
||||||
try {
|
|
||||||
pagesize = Long.valueOf(pagesizeParam);
|
|
||||||
page = Long.valueOf(pageParam);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new InvalidArgumentException("page and pagesize must be a integer value.", e.getCause());
|
|
||||||
}
|
|
||||||
PageMetadata pageMetadata = new PageMetadata(pagesize, page, totalElements);
|
|
||||||
if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) {
|
|
||||||
// unfortunately no setter for number
|
|
||||||
pageMetadata = new PageMetadata(pagesize, pageMetadata.getTotalPages(), totalElements);
|
|
||||||
}
|
|
||||||
return pageMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String[] extractCommaSeparatedFields(List<String> list) {
|
protected String[] extractCommaSeparatedFields(List<String> list) {
|
||||||
List<String> values = new ArrayList<>();
|
List<String> values = new ArrayList<>();
|
||||||
|
@ -47,4 +33,89 @@ public abstract class AbstractPagingController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected PageMetadata getPageMetadata(MultiValueMap<String, String> params, BaseQuery<?, ?> query)
|
||||||
|
throws InvalidArgumentException {
|
||||||
|
PageMetadata pageMetadata = null;
|
||||||
|
if (hasPagingInformationInParams(params)) {
|
||||||
|
// paging
|
||||||
|
long totalElements = query.count();
|
||||||
|
pageMetadata = initPageMetadata(params, totalElements);
|
||||||
|
validateNoInvalidParameterIsLeft(params);
|
||||||
|
} else {
|
||||||
|
// not paging
|
||||||
|
validateNoInvalidParameterIsLeft(params);
|
||||||
|
}
|
||||||
|
return pageMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<?> getQueryList(BaseQuery<?, ?> query, PageMetadata pageMetadata) {
|
||||||
|
List<?> resultList;
|
||||||
|
if (pageMetadata != null) {
|
||||||
|
resultList = query.listPage((int) pageMetadata.getNumber(), (int) pageMetadata.getSize());
|
||||||
|
} else {
|
||||||
|
resultList = query.list();
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasPagingInformationInParams(MultiValueMap<String, String> params) {
|
||||||
|
return params.getFirst(PAGING_PAGE) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PageMetadata initPageMetadata(MultiValueMap<String, String> param, long totalElements)
|
||||||
|
throws InvalidArgumentException {
|
||||||
|
long pageSize = getPageSize(param);
|
||||||
|
long page = getPage(param);
|
||||||
|
|
||||||
|
PageMetadata pageMetadata = new PageMetadata(pageSize, page,
|
||||||
|
totalElements != 0 ? totalElements : Integer.MAX_VALUE);
|
||||||
|
if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) {
|
||||||
|
// unfortunately no setter for number
|
||||||
|
pageMetadata = new PageMetadata(pageSize, pageMetadata.getTotalPages(), totalElements);
|
||||||
|
}
|
||||||
|
return pageMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is deprecated please remove it after updating taskana-simple-history reference to it.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
protected PageMetadata initPageMetadata(String pagesizeParam, String pageParam, long totalElements)
|
||||||
|
throws InvalidArgumentException {
|
||||||
|
long pageSize;
|
||||||
|
long page;
|
||||||
|
try {
|
||||||
|
pageSize = Long.valueOf(pagesizeParam);
|
||||||
|
page = Long.valueOf(pageParam);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidArgumentException("page and pageSize must be a integer value.", e.getCause());
|
||||||
|
}
|
||||||
|
PageMetadata pageMetadata = new PageMetadata(pageSize, page, totalElements);
|
||||||
|
if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) {
|
||||||
|
// unfortunately no setter for number
|
||||||
|
pageMetadata = new PageMetadata(pageSize, pageMetadata.getTotalPages(), totalElements);
|
||||||
|
}
|
||||||
|
return pageMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getPage(MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||||
|
String param = params.getFirst(PAGING_PAGE);
|
||||||
|
params.remove(PAGING_PAGE);
|
||||||
|
try {
|
||||||
|
return Long.valueOf(param != null ? param : "1");
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidArgumentException("page must be a integer value.", e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getPageSize(MultiValueMap<String, String> params) throws InvalidArgumentException {
|
||||||
|
String param = params.getFirst(PAGING_PAGE_SIZE);
|
||||||
|
params.remove(PAGING_PAGE_SIZE);
|
||||||
|
try {
|
||||||
|
return param != null ? Long.valueOf(param) : Integer.MAX_VALUE;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidArgumentException("page-size must be a integer value.", e.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||||
|
@ -38,7 +37,7 @@ import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.rest.resource.ClassificationResource;
|
import pro.taskana.rest.resource.ClassificationResource;
|
||||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||||
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
import pro.taskana.rest.resource.ClassificationSummaryResource;
|
||||||
import pro.taskana.rest.resource.ClassificationSummaryResourcesAssembler;
|
import pro.taskana.rest.resource.ClassificationSummaryResourceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for all {@link Classification} related endpoints.
|
* Controller for all {@link Classification} related endpoints.
|
||||||
|
@ -65,19 +64,25 @@ public class ClassificationController extends AbstractPagingController {
|
||||||
private static final String CUSTOM_6_LIKE = "custom-6-like";
|
private static final String CUSTOM_6_LIKE = "custom-6-like";
|
||||||
private static final String CUSTOM_7_LIKE = "custom-7-like";
|
private static final String CUSTOM_7_LIKE = "custom-7-like";
|
||||||
private static final String CUSTOM_8_LIKE = "custom-8-like";
|
private static final String CUSTOM_8_LIKE = "custom-8-like";
|
||||||
|
|
||||||
private static final String SORT_BY = "sort-by";
|
private static final String SORT_BY = "sort-by";
|
||||||
private static final String SORT_DIRECTION = "order";
|
private static final String SORT_DIRECTION = "order";
|
||||||
|
|
||||||
private static final String PAGING_PAGE = "page";
|
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClassificationService classificationService;
|
private ClassificationService classificationService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClassificationResourceAssembler classificationResourceAssembler;
|
private ClassificationResourceAssembler classificationResourceAssembler;
|
||||||
|
|
||||||
|
private ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler;
|
||||||
|
|
||||||
|
ClassificationController(
|
||||||
|
ClassificationService classificationService,
|
||||||
|
ClassificationResourceAssembler classificationResourceAssembler,
|
||||||
|
ClassificationSummaryResourceAssembler classificationSummaryResourceAssembler
|
||||||
|
) {
|
||||||
|
this.classificationService = classificationService;
|
||||||
|
this.classificationResourceAssembler = classificationResourceAssembler;
|
||||||
|
this.classificationSummaryResourceAssembler = classificationSummaryResourceAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<PagedResources<ClassificationSummaryResource>> getClassifications(
|
public ResponseEntity<PagedResources<ClassificationSummaryResource>> getClassifications(
|
||||||
|
@ -90,34 +95,17 @@ public class ClassificationController extends AbstractPagingController {
|
||||||
query = applySortingParams(query, params);
|
query = applySortingParams(query, params);
|
||||||
query = applyFilterParams(query, params);
|
query = applyFilterParams(query, params);
|
||||||
|
|
||||||
PageMetadata pageMetadata = null;
|
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||||
List<ClassificationSummary> classificationSummaries = null;
|
List<ClassificationSummary> classificationSummaries = (List<ClassificationSummary>) getQueryList(query,
|
||||||
String page = params.getFirst(PAGING_PAGE);
|
|
||||||
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
|
||||||
params.remove(PAGING_PAGE);
|
|
||||||
params.remove(PAGING_PAGE_SIZE);
|
|
||||||
validateNoInvalidParameterIsLeft(params);
|
|
||||||
if (page != null && pageSize != null) {
|
|
||||||
// paging
|
|
||||||
long totalElements = query.count();
|
|
||||||
pageMetadata = initPageMetadata(pageSize, page, totalElements);
|
|
||||||
classificationSummaries = query.listPage((int) pageMetadata.getNumber(),
|
|
||||||
(int) pageMetadata.getSize());
|
|
||||||
} else if (page == null && pageSize == null) {
|
|
||||||
// not paging
|
|
||||||
classificationSummaries = query.list();
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException("Paging information is incomplete.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassificationSummaryResourcesAssembler assembler = new ClassificationSummaryResourcesAssembler();
|
|
||||||
PagedResources<ClassificationSummaryResource> pagedResources = assembler.toResources(classificationSummaries,
|
|
||||||
pageMetadata);
|
pageMetadata);
|
||||||
|
|
||||||
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>(pagedResources,
|
ResponseEntity<PagedResources<ClassificationSummaryResource>> response = new ResponseEntity<>(
|
||||||
HttpStatus.OK);
|
classificationSummaryResourceAssembler.toResources(
|
||||||
|
classificationSummaries,
|
||||||
|
pageMetadata), HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getClassifications(), returning {}", response);
|
LOGGER.debug("Exit from getClassifications(), returning {}",
|
||||||
|
new ResponseEntity<>(response, HttpStatus.OK));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -126,14 +114,17 @@ public class ClassificationController extends AbstractPagingController {
|
||||||
@GetMapping(path = "/{classificationId}")
|
@GetMapping(path = "/{classificationId}")
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<ClassificationResource> getClassification(@PathVariable String classificationId)
|
public ResponseEntity<ClassificationResource> getClassification(@PathVariable String classificationId)
|
||||||
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException,
|
throws ClassificationNotFoundException {
|
||||||
ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId);
|
LOGGER.debug("Entry to getClassification(classificationId= {})", classificationId);
|
||||||
|
}
|
||||||
|
|
||||||
Classification classification = classificationService.getClassification(classificationId);
|
Classification classification = classificationService.getClassification(classificationId);
|
||||||
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
|
ResponseEntity<ClassificationResource> response = new ResponseEntity<>(
|
||||||
classificationResourceAssembler.toResource(classification), HttpStatus.OK);
|
classificationResourceAssembler.toResource(classification), HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getClassification(), returning {}", response);
|
LOGGER.debug("Exit from getClassification(), returning {}",
|
||||||
|
ResponseEntity.status(HttpStatus.OK).body(classificationResourceAssembler.toResource(classification)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -148,7 +139,6 @@ public class ClassificationController extends AbstractPagingController {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Entry to createClassification(resource= {})", resource);
|
LOGGER.debug("Entry to createClassification(resource= {})", resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
Classification classification = classificationResourceAssembler.toModel(resource);
|
Classification classification = classificationResourceAssembler.toModel(resource);
|
||||||
classification = classificationService.createClassification(classification);
|
classification = classificationService.createClassification(classification);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package pro.taskana.rest;
|
package pro.taskana.rest;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -19,6 +22,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import pro.taskana.Classification;
|
import pro.taskana.Classification;
|
||||||
import pro.taskana.ClassificationQuery;
|
import pro.taskana.ClassificationQuery;
|
||||||
import pro.taskana.ClassificationService;
|
import pro.taskana.ClassificationService;
|
||||||
|
@ -33,15 +40,6 @@ import pro.taskana.impl.util.LoggerUtils;
|
||||||
import pro.taskana.rest.resource.ClassificationResource;
|
import pro.taskana.rest.resource.ClassificationResource;
|
||||||
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
import pro.taskana.rest.resource.ClassificationResourceAssembler;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for Importing / Exporting classifications.
|
* Controller for Importing / Exporting classifications.
|
||||||
*/
|
*/
|
||||||
|
@ -51,12 +49,18 @@ public class ClassificationDefinitionController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationDefinitionController.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClassificationService classificationService;
|
private ClassificationService classificationService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClassificationResourceAssembler classificationResourceAssembler;
|
private ClassificationResourceAssembler classificationResourceAssembler;
|
||||||
|
|
||||||
|
ClassificationDefinitionController(
|
||||||
|
ClassificationService classificationService,
|
||||||
|
ClassificationResourceAssembler classificationResourceAssembler
|
||||||
|
) {
|
||||||
|
this.classificationService = classificationService;
|
||||||
|
this.classificationResourceAssembler = classificationResourceAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<List<ClassificationResource>> exportClassifications(
|
public ResponseEntity<List<ClassificationResource>> exportClassifications(
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -22,8 +21,8 @@ import pro.taskana.TaskState;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.impl.report.header.TimeIntervalColumnHeader;
|
import pro.taskana.impl.report.header.TimeIntervalColumnHeader;
|
||||||
import pro.taskana.rest.resource.ReportAssembler;
|
|
||||||
import pro.taskana.rest.resource.ReportResource;
|
import pro.taskana.rest.resource.ReportResource;
|
||||||
|
import pro.taskana.rest.resource.ReportResourceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for all monitoring endpoints.
|
* Controller for all monitoring endpoints.
|
||||||
|
@ -34,11 +33,14 @@ public class MonitorController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MonitorController.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskMonitorService taskMonitorService;
|
private TaskMonitorService taskMonitorService;
|
||||||
|
|
||||||
@Autowired
|
private ReportResourceAssembler reportResourceAssembler;
|
||||||
private ReportAssembler reportAssembler;
|
|
||||||
|
MonitorController(TaskMonitorService taskMonitorService, ReportResourceAssembler reportResourceAssembler) {
|
||||||
|
this.taskMonitorService = taskMonitorService;
|
||||||
|
this.reportResourceAssembler = reportResourceAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/tasks-status-report")
|
@GetMapping(path = "/tasks-status-report")
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
|
@ -46,18 +48,14 @@ public class MonitorController {
|
||||||
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException,
|
@RequestParam(required = false) List<TaskState> states) throws NotAuthorizedException,
|
||||||
InvalidArgumentException {
|
InvalidArgumentException {
|
||||||
LOGGER.debug("Entry to getTasksStatusReport()");
|
LOGGER.debug("Entry to getTasksStatusReport()");
|
||||||
ReportResource report = reportAssembler.toResource(
|
ResponseEntity<ReportResource> response = new ResponseEntity<>(reportResourceAssembler.toResource(
|
||||||
taskMonitorService.createTaskStatusReportBuilder()
|
taskMonitorService.createTaskStatusReportBuilder().stateIn(states).domainIn(domains).buildReport(),
|
||||||
.stateIn(states)
|
domains, states), HttpStatus.OK);
|
||||||
.domainIn(domains)
|
|
||||||
.buildReport(),
|
|
||||||
domains, states);
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", report);
|
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return response;
|
||||||
.body(report);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/tasks-workbasket-report")
|
@GetMapping(path = "/tasks-workbasket-report")
|
||||||
|
@ -67,7 +65,7 @@ public class MonitorController {
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
LOGGER.debug("Entry to getTasksWorkbasketReport()");
|
LOGGER.debug("Entry to getTasksWorkbasketReport()");
|
||||||
|
|
||||||
ReportResource report = reportAssembler.toResource(
|
ReportResource report = reportResourceAssembler.toResource(
|
||||||
taskMonitorService.createWorkbasketReportBuilder()
|
taskMonitorService.createWorkbasketReportBuilder()
|
||||||
.withColumnHeaders(getRangeTimeInterval())
|
.withColumnHeaders(getRangeTimeInterval())
|
||||||
.buildReport(), states);
|
.buildReport(), states);
|
||||||
|
@ -89,7 +87,7 @@ public class MonitorController {
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()");
|
LOGGER.debug("Entry to getTasksWorkbasketPlannedDateReport()");
|
||||||
|
|
||||||
ReportResource report = reportAssembler.toResource(
|
ReportResource report = reportResourceAssembler.toResource(
|
||||||
taskMonitorService.createWorkbasketReportBuilder()
|
taskMonitorService.createWorkbasketReportBuilder()
|
||||||
.stateIn(states)
|
.stateIn(states)
|
||||||
.withColumnHeaders(getDateTimeInterval(daysInPast)).buildPlannedDateBasedReport(),
|
.withColumnHeaders(getDateTimeInterval(daysInPast)).buildPlannedDateBasedReport(),
|
||||||
|
@ -103,13 +101,14 @@ public class MonitorController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(path = "/tasks-classification-report")
|
@GetMapping(path = "/tasks-classification-report")
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<ReportResource> getTasksClassificationReport()
|
public ResponseEntity<ReportResource> getTasksClassificationReport()
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
||||||
LOGGER.debug("Entry to getTasksClassificationReport()");
|
LOGGER.debug("Entry to getTasksClassificationReport()");
|
||||||
|
|
||||||
ReportResource report = reportAssembler.toResource(
|
ReportResource report = reportResourceAssembler.toResource(
|
||||||
taskMonitorService.createClassificationReportBuilder()
|
taskMonitorService.createClassificationReportBuilder()
|
||||||
.withColumnHeaders(getRangeTimeInterval())
|
.withColumnHeaders(getRangeTimeInterval())
|
||||||
.buildReport());
|
.buildReport());
|
||||||
|
@ -130,7 +129,7 @@ public class MonitorController {
|
||||||
.mapToObj(TimeIntervalColumnHeader.Date::new)
|
.mapToObj(TimeIntervalColumnHeader.Date::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(reportAssembler.toResource(
|
.body(reportResourceAssembler.toResource(
|
||||||
taskMonitorService.createTimestampReportBuilder()
|
taskMonitorService.createTimestampReportBuilder()
|
||||||
.withColumnHeaders(columnHeaders)
|
.withColumnHeaders(columnHeaders)
|
||||||
.buildReport()));
|
.buildReport()));
|
||||||
|
|
|
@ -7,10 +7,7 @@ import javax.sql.DataSource;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.*;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||||
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
import org.springframework.hateoas.config.EnableHypermediaSupport;
|
||||||
|
@ -44,7 +43,7 @@ import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.rest.resource.TaskResource;
|
import pro.taskana.rest.resource.TaskResource;
|
||||||
import pro.taskana.rest.resource.TaskResourceAssembler;
|
import pro.taskana.rest.resource.TaskResourceAssembler;
|
||||||
import pro.taskana.rest.resource.TaskSummaryResource;
|
import pro.taskana.rest.resource.TaskSummaryResource;
|
||||||
import pro.taskana.rest.resource.TaskSummaryResourcesAssembler;
|
import pro.taskana.rest.resource.TaskSummaryResourceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for all {@link Task} related endpoints.
|
* Controller for all {@link Task} related endpoints.
|
||||||
|
@ -81,15 +80,22 @@ public class TaskController extends AbstractPagingController {
|
||||||
private static final String SORT_BY = "sort-by";
|
private static final String SORT_BY = "sort-by";
|
||||||
private static final String SORT_DIRECTION = "order";
|
private static final String SORT_DIRECTION = "order";
|
||||||
|
|
||||||
private static final String PAGING_PAGE = "page";
|
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskResourceAssembler taskResourceAssembler;
|
private TaskResourceAssembler taskResourceAssembler;
|
||||||
|
|
||||||
|
private TaskSummaryResourceAssembler taskSummaryResourceAssembler;
|
||||||
|
|
||||||
|
TaskController(
|
||||||
|
TaskService taskService,
|
||||||
|
TaskResourceAssembler taskResourceAssembler,
|
||||||
|
TaskSummaryResourceAssembler taskSummaryResourceAssembler
|
||||||
|
) {
|
||||||
|
this.taskService = taskService;
|
||||||
|
this.taskResourceAssembler = taskResourceAssembler;
|
||||||
|
this.taskSummaryResourceAssembler = taskSummaryResourceAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
|
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
|
||||||
|
@ -102,29 +108,10 @@ public class TaskController extends AbstractPagingController {
|
||||||
query = applyFilterParams(query, params);
|
query = applyFilterParams(query, params);
|
||||||
query = applySortingParams(query, params);
|
query = applySortingParams(query, params);
|
||||||
|
|
||||||
PageMetadata pageMetadata = null;
|
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||||
List<TaskSummary> taskSummaries = null;
|
List<TaskSummary> taskSummaries = (List<TaskSummary>) getQueryList(query, pageMetadata);
|
||||||
String page = params.getFirst(PAGING_PAGE);
|
|
||||||
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
|
||||||
params.remove(PAGING_PAGE);
|
|
||||||
params.remove(PAGING_PAGE_SIZE);
|
|
||||||
validateNoInvalidParameterIsLeft(params);
|
|
||||||
if (page != null && pageSize != null) {
|
|
||||||
// paging
|
|
||||||
long totalElements = query.count();
|
|
||||||
pageMetadata = initPageMetadata(pageSize, page,
|
|
||||||
totalElements);
|
|
||||||
taskSummaries = query.listPage((int) pageMetadata.getNumber(),
|
|
||||||
(int) pageMetadata.getSize());
|
|
||||||
} else if (page == null && pageSize == null) {
|
|
||||||
// not paging
|
|
||||||
taskSummaries = query.list();
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException("Paging information is incomplete.");
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskSummaryResourcesAssembler taskSummaryResourcesAssembler = new TaskSummaryResourcesAssembler();
|
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourceAssembler.toResources(taskSummaries,
|
||||||
PagedResources<TaskSummaryResource> pagedResources = taskSummaryResourcesAssembler.toResources(taskSummaries,
|
|
||||||
pageMetadata);
|
pageMetadata);
|
||||||
ResponseEntity<PagedResources<TaskSummaryResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
ResponseEntity<PagedResources<TaskSummaryResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana.rest;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -29,11 +30,16 @@ public class TaskanaEngineController {
|
||||||
|
|
||||||
TaskanaEngine taskanaEngine;
|
TaskanaEngine taskanaEngine;
|
||||||
|
|
||||||
TaskanaEngineController(TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine taskanaEngine) {
|
TaskanaEngineController(
|
||||||
|
TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine taskanaEngine) {
|
||||||
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
|
||||||
this.taskanaEngine = taskanaEngine;
|
this.taskanaEngine = taskanaEngine;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Value("${version:Local build}")
|
||||||
|
private String version;
|
||||||
|
|
||||||
@GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE})
|
@GetMapping(path = "/v1/domains", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
public ResponseEntity<List<String>> getDomains() {
|
public ResponseEntity<List<String>> getDomains() {
|
||||||
ResponseEntity<List<String>> response = new ResponseEntity<>(taskanaEngineConfiguration.getDomains(),
|
ResponseEntity<List<String>> response = new ResponseEntity<>(taskanaEngineConfiguration.getDomains(),
|
||||||
|
|
|
@ -25,8 +25,8 @@ import pro.taskana.WorkbasketService;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.ldap.LdapClient;
|
import pro.taskana.ldap.LdapClient;
|
||||||
|
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||||
import pro.taskana.rest.resource.WorkbasketAccessItemAssembler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for Workbasket access.
|
* Controller for Workbasket access.
|
||||||
|
@ -48,15 +48,15 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||||
private static final String SORT_BY = "sort-by";
|
private static final String SORT_BY = "sort-by";
|
||||||
private static final String SORT_DIRECTION = "order";
|
private static final String SORT_DIRECTION = "order";
|
||||||
|
|
||||||
private static final String PAGING_PAGE = "page";
|
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
LdapClient ldapClient;
|
LdapClient ldapClient;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This GET method return all workbasketAccessItems that correspond the given data.
|
* This GET method return all workbasketAccessItems that correspond the given data.
|
||||||
*
|
*
|
||||||
|
@ -78,31 +78,15 @@ public class WorkbasketAccessItemController extends AbstractPagingController {
|
||||||
query = applyFilterParams(query, params);
|
query = applyFilterParams(query, params);
|
||||||
query = applySortingParams(query, params);
|
query = applySortingParams(query, params);
|
||||||
|
|
||||||
PagedResources.PageMetadata pageMetadata = null;
|
PagedResources.PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||||
List<WorkbasketAccessItem> workbasketAccessItems;
|
List<WorkbasketAccessItem> workbasketAccessItems = (List<WorkbasketAccessItem>) getQueryList(query,
|
||||||
String page = params.getFirst(PAGING_PAGE);
|
|
||||||
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
|
||||||
params.remove(PAGING_PAGE);
|
|
||||||
params.remove(PAGING_PAGE_SIZE);
|
|
||||||
validateNoInvalidParameterIsLeft(params);
|
|
||||||
if (page != null && pageSize != null) {
|
|
||||||
// paging
|
|
||||||
long totalElements = query.count();
|
|
||||||
pageMetadata = initPageMetadata(pageSize, page, totalElements);
|
|
||||||
workbasketAccessItems = query.listPage((int) pageMetadata.getNumber(),
|
|
||||||
(int) pageMetadata.getSize());
|
|
||||||
} else if (page == null && pageSize == null) {
|
|
||||||
// not paging
|
|
||||||
workbasketAccessItems = query.list();
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException("Paging information is incomplete.");
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkbasketAccessItemAssembler assembler = new WorkbasketAccessItemAssembler();
|
|
||||||
PagedResources<WorkbasketAccessItemResource> pagedResources = assembler.toResources(
|
|
||||||
workbasketAccessItems,
|
|
||||||
pageMetadata);
|
pageMetadata);
|
||||||
|
|
||||||
|
PagedResources pagedResources = workbasketAccessItemResourceAssembler.toResources(
|
||||||
|
workbasketAccessItems,
|
||||||
|
pageMetadata
|
||||||
|
);
|
||||||
|
|
||||||
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
ResponseEntity<PagedResources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(pagedResources, HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
|
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", response);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
import org.springframework.hateoas.PagedResources.PageMetadata;
|
||||||
import org.springframework.hateoas.Resources;
|
import org.springframework.hateoas.Resources;
|
||||||
|
@ -27,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import pro.taskana.BaseQuery.SortDirection;
|
import pro.taskana.BaseQuery.SortDirection;
|
||||||
import pro.taskana.TaskService;
|
|
||||||
import pro.taskana.Workbasket;
|
import pro.taskana.Workbasket;
|
||||||
import pro.taskana.WorkbasketAccessItem;
|
import pro.taskana.WorkbasketAccessItem;
|
||||||
import pro.taskana.WorkbasketPermission;
|
import pro.taskana.WorkbasketPermission;
|
||||||
|
@ -43,15 +41,14 @@ import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||||
import pro.taskana.exceptions.WorkbasketInUseException;
|
import pro.taskana.exceptions.WorkbasketInUseException;
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
import pro.taskana.impl.util.LoggerUtils;
|
import pro.taskana.impl.util.LoggerUtils;
|
||||||
import pro.taskana.rest.resource.DistributionTargetListAssembler;
|
|
||||||
import pro.taskana.rest.resource.DistributionTargetResource;
|
import pro.taskana.rest.resource.DistributionTargetResource;
|
||||||
import pro.taskana.rest.resource.WorkbasketAccessItemAssembler;
|
import pro.taskana.rest.resource.DistributionTargetResourceAssembler;
|
||||||
import pro.taskana.rest.resource.WorkbasketAccessItemListAssembler;
|
|
||||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||||
|
import pro.taskana.rest.resource.WorkbasketAccessItemResourceAssembler;
|
||||||
import pro.taskana.rest.resource.WorkbasketResource;
|
import pro.taskana.rest.resource.WorkbasketResource;
|
||||||
import pro.taskana.rest.resource.WorkbasketResourceAssembler;
|
import pro.taskana.rest.resource.WorkbasketResourceAssembler;
|
||||||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||||
import pro.taskana.rest.resource.WorkbasketSummaryResourcesAssembler;
|
import pro.taskana.rest.resource.WorkbasketSummaryResourceAssembler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for all {@link Workbasket} related endpoints.
|
* Controller for all {@link Workbasket} related endpoints.
|
||||||
|
@ -79,26 +76,27 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
private static final String SORT_BY = "sort-by";
|
private static final String SORT_BY = "sort-by";
|
||||||
private static final String SORT_DIRECTION = "order";
|
private static final String SORT_DIRECTION = "order";
|
||||||
|
|
||||||
private static final String PAGING_PAGE = "page";
|
|
||||||
private static final String PAGING_PAGE_SIZE = "page-size";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskService taskService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketResourceAssembler workbasketResourceAssembler;
|
private WorkbasketResourceAssembler workbasketResourceAssembler;
|
||||||
|
|
||||||
@Autowired
|
private WorkbasketSummaryResourceAssembler workbasketSummaryResourceAssembler;
|
||||||
private DistributionTargetListAssembler distributionTargetListAssembler;
|
|
||||||
|
|
||||||
@Autowired
|
private DistributionTargetResourceAssembler distributionTargetResourceAssembler;
|
||||||
private WorkbasketAccessItemListAssembler accessItemListAssembler;
|
|
||||||
|
|
||||||
@Autowired
|
private WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler;
|
||||||
private WorkbasketAccessItemAssembler workbasketAccessItemAssembler;
|
|
||||||
|
WorkbasketController(WorkbasketService workbasketService,
|
||||||
|
WorkbasketResourceAssembler workbasketResourceAssembler,
|
||||||
|
WorkbasketSummaryResourceAssembler workbasketSummaryResourceAssembler,
|
||||||
|
DistributionTargetResourceAssembler distributionTargetResourceAssembler,
|
||||||
|
WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler) {
|
||||||
|
this.workbasketService = workbasketService;
|
||||||
|
this.workbasketResourceAssembler = workbasketResourceAssembler;
|
||||||
|
this.workbasketSummaryResourceAssembler = workbasketSummaryResourceAssembler;
|
||||||
|
this.distributionTargetResourceAssembler = distributionTargetResourceAssembler;
|
||||||
|
this.workbasketAccessItemResourceAssembler = workbasketAccessItemResourceAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
|
@ -112,28 +110,9 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
query = applySortingParams(query, params);
|
query = applySortingParams(query, params);
|
||||||
query = applyFilterParams(query, params);
|
query = applyFilterParams(query, params);
|
||||||
|
|
||||||
PageMetadata pageMetadata = null;
|
PageMetadata pageMetadata = getPageMetadata(params, query);
|
||||||
List<WorkbasketSummary> workbasketSummaries = null;
|
List<WorkbasketSummary> workbasketSummaries = (List<WorkbasketSummary>) getQueryList(query, pageMetadata);
|
||||||
String page = params.getFirst(PAGING_PAGE);
|
PagedResources pagedResources = workbasketSummaryResourceAssembler.toResources(workbasketSummaries,
|
||||||
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
|
|
||||||
params.remove(PAGING_PAGE);
|
|
||||||
params.remove(PAGING_PAGE_SIZE);
|
|
||||||
validateNoInvalidParameterIsLeft(params);
|
|
||||||
if (page != null && pageSize != null) {
|
|
||||||
// paging
|
|
||||||
long totalElements = query.count();
|
|
||||||
pageMetadata = initPageMetadata(pageSize, page, totalElements);
|
|
||||||
workbasketSummaries = query.listPage((int) pageMetadata.getNumber(),
|
|
||||||
(int) pageMetadata.getSize());
|
|
||||||
} else if (page == null && pageSize == null) {
|
|
||||||
// not paging
|
|
||||||
workbasketSummaries = query.list();
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException("Paging information is incomplete.");
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkbasketSummaryResourcesAssembler assembler = new WorkbasketSummaryResourcesAssembler();
|
|
||||||
PagedResources<WorkbasketSummaryResource> pagedResources = assembler.toResources(workbasketSummaries,
|
|
||||||
pageMetadata);
|
pageMetadata);
|
||||||
|
|
||||||
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = new ResponseEntity<>(pagedResources,
|
ResponseEntity<PagedResources<WorkbasketSummaryResource>> response = new ResponseEntity<>(pagedResources,
|
||||||
|
@ -166,7 +145,8 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
throws NotAuthorizedException, InvalidArgumentException,
|
throws NotAuthorizedException, InvalidArgumentException,
|
||||||
WorkbasketNotFoundException, WorkbasketInUseException {
|
WorkbasketNotFoundException, WorkbasketInUseException {
|
||||||
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
|
LOGGER.debug("Entry to markWorkbasketForDeletion(workbasketId= {})", workbasketId);
|
||||||
ResponseEntity<?> response = new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId), HttpStatus.ACCEPTED);
|
ResponseEntity<?> response = new ResponseEntity<>(workbasketService.deleteWorkbasket(workbasketId),
|
||||||
|
HttpStatus.ACCEPTED);
|
||||||
LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}",
|
LOGGER.debug("Exit from markWorkbasketForDeletion(), returning {}",
|
||||||
response);
|
response);
|
||||||
return response;
|
return response;
|
||||||
|
@ -183,7 +163,8 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
|
|
||||||
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
|
Workbasket workbasket = workbasketResourceAssembler.toModel(workbasketResource);
|
||||||
workbasket = workbasketService.createWorkbasket(workbasket);
|
workbasket = workbasketService.createWorkbasket(workbasket);
|
||||||
ResponseEntity<WorkbasketResource> response = new ResponseEntity<>(workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED);
|
ResponseEntity<WorkbasketResource> response = new ResponseEntity<>(
|
||||||
|
workbasketResourceAssembler.toResource(workbasket), HttpStatus.CREATED);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
|
LOGGER.debug("Exit from createWorkbasket(), returning {}", response);
|
||||||
}
|
}
|
||||||
|
@ -226,9 +207,8 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
ResponseEntity<Resources<WorkbasketAccessItemResource>> result;
|
ResponseEntity<Resources<WorkbasketAccessItemResource>> result;
|
||||||
|
|
||||||
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||||
Resources<WorkbasketAccessItemResource> accessItemListResource = accessItemListAssembler
|
result = new ResponseEntity<>(workbasketAccessItemResourceAssembler
|
||||||
.toResource(workbasketId, accessItems);
|
.toResources(workbasketId, accessItems), HttpStatus.OK);
|
||||||
result = new ResponseEntity<>(accessItemListResource, HttpStatus.OK);
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
|
LOGGER.debug("Exit from getWorkbasketAccessItems(), returning {}", result);
|
||||||
}
|
}
|
||||||
|
@ -248,14 +228,14 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>();
|
List<WorkbasketAccessItem> wbAccessItems = new ArrayList<>();
|
||||||
workbasketAccessResourceItems.forEach(item -> wbAccessItems.add(workbasketAccessItemAssembler.toModel(item)));
|
workbasketAccessResourceItems.forEach(
|
||||||
|
item -> wbAccessItems.add(workbasketAccessItemResourceAssembler.toModel(item)));
|
||||||
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
|
workbasketService.setWorkbasketAccessItems(workbasketId, wbAccessItems);
|
||||||
|
|
||||||
List<WorkbasketAccessItem> updatedWbAccessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
List<WorkbasketAccessItem> updatedWbAccessItems = workbasketService.getWorkbasketAccessItems(workbasketId);
|
||||||
Resources<WorkbasketAccessItemResource> accessItemListResource = accessItemListAssembler
|
|
||||||
.toResource(workbasketId, updatedWbAccessItems);
|
|
||||||
|
|
||||||
ResponseEntity<Resources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(accessItemListResource, HttpStatus.OK);
|
ResponseEntity<Resources<WorkbasketAccessItemResource>> response = new ResponseEntity<>(
|
||||||
|
workbasketAccessItemResourceAssembler
|
||||||
|
.toResources(workbasketId, updatedWbAccessItems), HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
|
LOGGER.debug("Exit from setWorkbasketAccessItems(), returning {}", response);
|
||||||
}
|
}
|
||||||
|
@ -268,11 +248,12 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
public ResponseEntity<Resources<DistributionTargetResource>> getDistributionTargets(
|
public ResponseEntity<Resources<DistributionTargetResource>> getDistributionTargets(
|
||||||
@PathVariable(value = "workbasketId") String workbasketId)
|
@PathVariable(value = "workbasketId") String workbasketId)
|
||||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||||
|
|
||||||
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
|
LOGGER.debug("Entry to getDistributionTargets(workbasketId= {})", workbasketId);
|
||||||
ResponseEntity<Resources<DistributionTargetResource>> result;
|
ResponseEntity<Resources<DistributionTargetResource>> result;
|
||||||
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasketId);
|
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasketId);
|
||||||
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetListAssembler
|
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetResourceAssembler
|
||||||
.toResource(workbasketId, distributionTargets);
|
.toResources(workbasketId, distributionTargets);
|
||||||
result = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK);
|
result = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
|
LOGGER.debug("Exit from getDistributionTargets(), returning {}", result);
|
||||||
|
@ -295,10 +276,9 @@ public class WorkbasketController extends AbstractPagingController {
|
||||||
workbasketService.setDistributionTargets(sourceWorkbasketId, targetWorkbasketIds);
|
workbasketService.setDistributionTargets(sourceWorkbasketId, targetWorkbasketIds);
|
||||||
|
|
||||||
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(sourceWorkbasketId);
|
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(sourceWorkbasketId);
|
||||||
Resources<DistributionTargetResource> distributionTargetListResource = distributionTargetListAssembler
|
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(
|
||||||
.toResource(sourceWorkbasketId, distributionTargets);
|
distributionTargetResourceAssembler
|
||||||
|
.toResources(sourceWorkbasketId, distributionTargets), HttpStatus.OK);
|
||||||
ResponseEntity<Resources<DistributionTargetResource>> response = new ResponseEntity<>(distributionTargetListResource, HttpStatus.OK);
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
LOGGER.debug("Exit from getTasksStatusReport(), returning {}", response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -49,12 +48,18 @@ public class WorkbasketDefinitionController {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketDefinitionController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(WorkbasketDefinitionController.class);
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler;
|
private WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler;
|
||||||
|
|
||||||
|
WorkbasketDefinitionController(
|
||||||
|
WorkbasketService workbasketService,
|
||||||
|
WorkbasketDefinitionResourceAssembler workbasketDefinitionAssembler
|
||||||
|
) {
|
||||||
|
this.workbasketService = workbasketService;
|
||||||
|
this.workbasketDefinitionAssembler = workbasketDefinitionAssembler;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
@Transactional(readOnly = true, rollbackFor = Exception.class)
|
||||||
public ResponseEntity<List<WorkbasketDefinitionResource>> exportWorkbaskets(@RequestParam(required = false) String domain)
|
public ResponseEntity<List<WorkbasketDefinitionResource>> exportWorkbaskets(@RequestParam(required = false) String domain)
|
||||||
|
@ -86,6 +91,13 @@ public class WorkbasketDefinitionController {
|
||||||
* @param file the list of workbasket definitions which will be imported to the current system.
|
* @param file the list of workbasket definitions which will be imported to the current system.
|
||||||
* @return Return answer is determined by the status code: 200 - all good 400 - list state error (referring to non
|
* @return Return answer is determined by the status code: 200 - all good 400 - list state error (referring to non
|
||||||
* existing id's) 401 - not authorized
|
* existing id's) 401 - not authorized
|
||||||
|
* @throws IOException if multipart file cannot be parsed.
|
||||||
|
* @throws NotAuthorizedException if the user is not authorized.
|
||||||
|
* @throws DomainNotFoundException if domain information is incorrect.
|
||||||
|
* @throws InvalidWorkbasketException if workbasket has invalid information.
|
||||||
|
* @throws WorkbasketAlreadyExistException if workbasket already exists when trying to create a new one.
|
||||||
|
* @throws WorkbasketNotFoundException if do not exists a workbasket in the system with the used id.
|
||||||
|
* @throws InvalidArgumentException if authorization information in workbaskets definitions is incorrect.
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
|
@ -1,175 +0,0 @@
|
||||||
package pro.taskana.rest.query;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.MultiValueMap;
|
|
||||||
|
|
||||||
import pro.taskana.TaskQuery;
|
|
||||||
import pro.taskana.TaskService;
|
|
||||||
import pro.taskana.TaskState;
|
|
||||||
import pro.taskana.TaskSummary;
|
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
|
||||||
import pro.taskana.impl.util.LoggerUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class TaskFilter {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskFilter.class);
|
|
||||||
|
|
||||||
private static final String CLASSIFICATION = "classification";
|
|
||||||
private static final String POR = "por";
|
|
||||||
private static final String DOT = ".";
|
|
||||||
|
|
||||||
private static final String STATE = "state";
|
|
||||||
private static final String PRIORITY = "priority";
|
|
||||||
private static final String DESCRIPTION = "description";
|
|
||||||
private static final String NAME = "name";
|
|
||||||
private static final String OWNER = "owner";
|
|
||||||
private static final String WORKBASKET_ID = "workbasketId";
|
|
||||||
private static final String CUSTOM = "custom";
|
|
||||||
private static final String IS_TRANSFERRED = "isTransferred";
|
|
||||||
private static final String IS_READ = "isRead";
|
|
||||||
|
|
||||||
private static final String CLASSIFICATION_KEY = CLASSIFICATION + DOT + "key";
|
|
||||||
|
|
||||||
private static final String POR_VALUE = POR + DOT + "value";
|
|
||||||
private static final String POR_TYPE = POR + DOT + "type";
|
|
||||||
private static final String POR_SYSTEM_INSTANCE = POR + DOT + "systemInstance";
|
|
||||||
private static final String POR_SYSTEM = POR + DOT + "system";
|
|
||||||
private static final String POR_COMPANY = POR + DOT + "company";
|
|
||||||
|
|
||||||
private static final String CLAIMED = "CLAIMED";
|
|
||||||
private static final String COMPLETED = "COMPLETED";
|
|
||||||
private static final String READY = "READY";
|
|
||||||
private static final String COMMA = ",";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskService taskService;
|
|
||||||
|
|
||||||
public List<TaskSummary> getAll() {
|
|
||||||
return taskService.createTaskQuery().list();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TaskSummary> inspectParams(MultiValueMap<String, String> params)
|
|
||||||
throws InvalidArgumentException {
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug("Entry to inspectParams(params= {})", params);
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
|
||||||
|
|
||||||
// apply filters
|
|
||||||
if (params.containsKey(NAME)) {
|
|
||||||
String[] names = extractCommaSeperatedFields(params.get(NAME));
|
|
||||||
taskQuery.nameIn(names);
|
|
||||||
}
|
|
||||||
if (params.containsKey(DESCRIPTION)) {
|
|
||||||
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
|
|
||||||
}
|
|
||||||
if (params.containsKey(PRIORITY)) {
|
|
||||||
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
|
|
||||||
int[] priorites = extractPriorities(prioritesInString);
|
|
||||||
taskQuery.priorityIn(priorites);
|
|
||||||
}
|
|
||||||
if (params.containsKey(STATE)) {
|
|
||||||
TaskState[] states = extractStates(params);
|
|
||||||
taskQuery.stateIn(states);
|
|
||||||
}
|
|
||||||
if (params.containsKey(CLASSIFICATION_KEY)) {
|
|
||||||
String[] classificationKeys = extractCommaSeperatedFields(params.get(CLASSIFICATION_KEY));
|
|
||||||
taskQuery.classificationKeyIn(classificationKeys);
|
|
||||||
}
|
|
||||||
if (params.containsKey(WORKBASKET_ID)) {
|
|
||||||
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_ID));
|
|
||||||
taskQuery.workbasketIdIn(workbaskets);
|
|
||||||
}
|
|
||||||
if (params.containsKey(OWNER)) {
|
|
||||||
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
|
|
||||||
taskQuery.ownerIn(owners);
|
|
||||||
}
|
|
||||||
// objectReference
|
|
||||||
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
|
|
||||||
if (params.containsKey(POR_COMPANY)) {
|
|
||||||
String[] companies = extractCommaSeperatedFields(params.get(POR_COMPANY));
|
|
||||||
taskQuery.primaryObjectReferenceCompanyIn(companies);
|
|
||||||
}
|
|
||||||
if (params.containsKey(POR_SYSTEM)) {
|
|
||||||
String[] systems = extractCommaSeperatedFields(params.get(POR_SYSTEM));
|
|
||||||
taskQuery.primaryObjectReferenceSystemIn(systems);
|
|
||||||
}
|
|
||||||
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
|
|
||||||
String[] systemInstances = extractCommaSeperatedFields(params.get(POR_SYSTEM_INSTANCE));
|
|
||||||
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
|
|
||||||
}
|
|
||||||
if (params.containsKey(POR_TYPE)) {
|
|
||||||
String[] types = extractCommaSeperatedFields(params.get(POR_TYPE));
|
|
||||||
taskQuery.primaryObjectReferenceTypeIn(types);
|
|
||||||
}
|
|
||||||
if (params.containsKey(POR_VALUE)) {
|
|
||||||
String[] values = extractCommaSeperatedFields(params.get(POR_VALUE));
|
|
||||||
taskQuery.primaryObjectReferenceValueIn(values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (params.containsKey(IS_READ)) {
|
|
||||||
taskQuery.readEquals(Boolean.getBoolean(params.get(IS_READ).get(0)));
|
|
||||||
}
|
|
||||||
if (params.containsKey(IS_TRANSFERRED)) {
|
|
||||||
taskQuery.transferredEquals(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug("Exit from inspectParams(), returning {}", LoggerUtils.listToString(taskQuery.list()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return taskQuery.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int[] extractPriorities(String[] prioritesInString) {
|
|
||||||
int[] priorites = new int[prioritesInString.length];
|
|
||||||
for (int i = 0; i < prioritesInString.length; i++) {
|
|
||||||
priorites[i] = Integer.getInteger(prioritesInString[i]);
|
|
||||||
}
|
|
||||||
return priorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] extractCommaSeperatedFields(List<String> list) {
|
|
||||||
List<String> values = new ArrayList<>();
|
|
||||||
list.forEach(item -> values.addAll(Arrays.asList(item.split(COMMA))));
|
|
||||||
return values.toArray(new String[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TaskState[] extractStates(MultiValueMap<String, String> params) throws InvalidArgumentException {
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug("Entry to extractStates(params= {})", params);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TaskState> states = new ArrayList<>();
|
|
||||||
for (String item : params.get(STATE)) {
|
|
||||||
for (String state : item.split(COMMA)) {
|
|
||||||
switch (state) {
|
|
||||||
case READY:
|
|
||||||
states.add(TaskState.READY);
|
|
||||||
break;
|
|
||||||
case COMPLETED:
|
|
||||||
states.add(TaskState.COMPLETED);
|
|
||||||
break;
|
|
||||||
case CLAIMED:
|
|
||||||
states.add(TaskState.CLAIMED);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidArgumentException("Unknown status '" + state + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOGGER.debug("Exit from extractStates()");
|
|
||||||
return states.toArray(new TaskState[0]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +1,69 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.Link;
|
import org.springframework.hateoas.Link;
|
||||||
import org.springframework.hateoas.PagedResources;
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base assembler for paged list resources.
|
* Abstract resources assembler for taskana REST controller with pageable resources.
|
||||||
|
* This method is deprecated, it can be removed after fixing taskana-simple-history references
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public abstract class AbstractRessourcesAssembler {
|
public abstract class AbstractRessourcesAssembler {
|
||||||
|
|
||||||
UriComponentsBuilder original;
|
UriComponentsBuilder original = getBuilderForOriginalUri();
|
||||||
|
|
||||||
public AbstractRessourcesAssembler() {
|
public AbstractRessourcesAssembler() {
|
||||||
original = getBuilderForOriginalUri();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static UriComponentsBuilder getBuilderForOriginalUri() {
|
protected static UriComponentsBuilder getBuilderForOriginalUri() {
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
.getRequest();
|
|
||||||
UriComponentsBuilder baseUri = ServletUriComponentsBuilder.fromServletMapping(request)
|
UriComponentsBuilder baseUri = ServletUriComponentsBuilder.fromServletMapping(request)
|
||||||
.path(request.getRequestURI());
|
.path(request.getRequestURI());
|
||||||
for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
|
Iterator var2 = request.getParameterMap().entrySet().iterator();
|
||||||
for (String value : entry.getValue()) {
|
|
||||||
baseUri.queryParam(entry.getKey(), value);
|
while (var2.hasNext()) {
|
||||||
|
Map.Entry<String, String[]> entry = (Map.Entry) var2.next();
|
||||||
|
String[] var4 = (String[]) entry.getValue();
|
||||||
|
int var5 = var4.length;
|
||||||
|
|
||||||
|
for (int var6 = 0; var6 < var5; ++var6) {
|
||||||
|
String value = var4[var6];
|
||||||
|
baseUri.queryParam((String) entry.getKey(), new Object[] {value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UriComponentsBuilder original = baseUri;
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PagedResources<?> addPageLinks(PagedResources<?> pagedResources, PageMetadata pageMetadata) {
|
return baseUri;
|
||||||
UriComponentsBuilder original = getBuilderForOriginalUri();
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
|
|
||||||
.withRel(Link.REL_LAST));
|
|
||||||
if (pageMetadata.getNumber() > 1) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
|
|
||||||
.withRel(Link.REL_PREVIOUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected PagedResources<?> addPageLinks(PagedResources<?> pagedResources,
|
||||||
|
PagedResources.PageMetadata pageMetadata) {
|
||||||
|
UriComponentsBuilder original = getBuilderForOriginalUri();
|
||||||
|
pagedResources.add(
|
||||||
|
(new Link(original.replaceQueryParam("page", new Object[] {1}).toUriString())).withRel("first"));
|
||||||
|
pagedResources.add((new Link(
|
||||||
|
original.replaceQueryParam("page", new Object[] {pageMetadata.getTotalPages()}).toUriString())).withRel(
|
||||||
|
"last"));
|
||||||
|
if (pageMetadata.getNumber() > 1L) {
|
||||||
|
pagedResources.add((new Link(
|
||||||
|
original.replaceQueryParam("page", new Object[] {pageMetadata.getNumber() - 1L})
|
||||||
|
.toUriString())).withRel("prev"));
|
||||||
|
}
|
||||||
|
|
||||||
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
||||||
pagedResources
|
pagedResources.add((new Link(
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
|
original.replaceQueryParam("page", new Object[] {pageMetadata.getNumber() + 1L})
|
||||||
.withRel(Link.REL_NEXT));
|
.toUriString())).withRel("next"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pagedResources;
|
return pagedResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
|
import pro.taskana.Attachment;
|
||||||
import pro.taskana.ObjectReference;
|
import pro.taskana.ObjectReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.Attachment}.
|
* Resource class for {@link pro.taskana.Attachment}.
|
||||||
*/
|
*/
|
||||||
public class AttachmentResource extends ResourceSupport {
|
public class AttachmentResource extends ResourceSupport {
|
||||||
|
|
||||||
private String attachmentId;
|
private String attachmentId;
|
||||||
private String taskId;
|
private String taskId;
|
||||||
private String created;
|
private String created;
|
||||||
|
@ -20,6 +22,21 @@ public class AttachmentResource extends ResourceSupport {
|
||||||
private String channel;
|
private String channel;
|
||||||
private String received;
|
private String received;
|
||||||
|
|
||||||
|
public AttachmentResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachmentResource(Attachment attachment) {
|
||||||
|
this.attachmentId = attachment.getId();
|
||||||
|
this.taskId = attachment.getTaskId();
|
||||||
|
this.created = attachment.getCreated() != null ? attachment.getCreated().toString() : null;
|
||||||
|
this.modified = attachment.getModified() != null ? attachment.getModified().toString() : null;
|
||||||
|
this.classificationSummaryResource = new ClassificationSummaryResource(attachment.getClassificationSummary());
|
||||||
|
this.objectReference = attachment.getObjectReference();
|
||||||
|
this.channel = attachment.getChannel();
|
||||||
|
this.received = attachment.getReceived() != null ? attachment.getReceived().toString() : null;
|
||||||
|
this.customAttributes = attachment.getCustomAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
public String getCreated() {
|
public String getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import pro.taskana.Attachment;
|
||||||
|
import pro.taskana.TaskService;
|
||||||
|
import pro.taskana.impl.AttachmentImpl;
|
||||||
|
import pro.taskana.rest.AttachmentController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resource assembler for {@link AttachmentResource}.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AttachmentResourceAssembler extends ResourceAssemblerSupport<Attachment, AttachmentResource> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ClassificationSummaryResourceAssembler classificationAssembler;
|
||||||
|
|
||||||
|
public AttachmentResourceAssembler() {
|
||||||
|
super(AttachmentController.class, AttachmentResource.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AttachmentResource toResource(Attachment attachment) {
|
||||||
|
AttachmentResource resource = new AttachmentResource(attachment);
|
||||||
|
resource.add(linkTo(AttachmentController.class).slash(attachment.getId()).withSelfRel());
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attachment> toModel(List<AttachmentResource> resources) {
|
||||||
|
return resources.stream().map(attachmentResource -> {
|
||||||
|
AttachmentImpl attachment = (AttachmentImpl) taskService.newAttachment();
|
||||||
|
BeanUtils.copyProperties(attachmentResource, attachment);
|
||||||
|
attachment.setId(attachmentResource.getAttachmentId());
|
||||||
|
attachment.setClassificationSummary(
|
||||||
|
classificationAssembler.toModel(attachmentResource.getClassificationSummary()));
|
||||||
|
return attachment;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import pro.taskana.Attachment;
|
|
||||||
import pro.taskana.TaskService;
|
|
||||||
import pro.taskana.impl.AttachmentImpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resource assembler for {@link AttachmentResource}.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class AttachmentResourcesAssembler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TaskService taskService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClassificationSummaryResourceAssembler classificationAssembler;
|
|
||||||
|
|
||||||
public List<AttachmentResource> toResources(List<Attachment> attachments) {
|
|
||||||
List<AttachmentResource> resourceList = new ArrayList<>();
|
|
||||||
for (Attachment a : attachments) {
|
|
||||||
AttachmentResource resource = new AttachmentResource();
|
|
||||||
BeanUtils.copyProperties(a, resource);
|
|
||||||
if (a.getCreated() != null) {
|
|
||||||
resource.setCreated(a.getCreated().toString());
|
|
||||||
}
|
|
||||||
if (a.getModified() != null) {
|
|
||||||
resource.setModified(a.getModified().toString());
|
|
||||||
}
|
|
||||||
if (a.getReceived() != null) {
|
|
||||||
resource.setReceived(a.getReceived().toString());
|
|
||||||
}
|
|
||||||
resource.setAttachmentId(a.getId());
|
|
||||||
resource.setClassificationSummary(
|
|
||||||
classificationAssembler.toResource(a.getClassificationSummary()));
|
|
||||||
resourceList.add(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Attachment> toModel(List<AttachmentResource> resources) {
|
|
||||||
|
|
||||||
List<Attachment> attachmentList = new ArrayList<>();
|
|
||||||
for (AttachmentResource ar : resources) {
|
|
||||||
AttachmentImpl attachment = (AttachmentImpl) taskService.newAttachment();
|
|
||||||
BeanUtils.copyProperties(ar, attachment);
|
|
||||||
attachment.setId(ar.getAttachmentId());
|
|
||||||
attachment.setClassificationSummary(
|
|
||||||
classificationAssembler.toModel(ar.getClassificationSummary()));
|
|
||||||
attachmentList.add(attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
return attachmentList;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
|
import pro.taskana.AttachmentSummary;
|
||||||
import pro.taskana.ObjectReference;
|
import pro.taskana.ObjectReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +19,21 @@ public class AttachmentSummaryResource extends ResourceSupport {
|
||||||
private String channel;
|
private String channel;
|
||||||
private String received;
|
private String received;
|
||||||
|
|
||||||
|
AttachmentSummaryResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachmentSummaryResource(AttachmentSummary attachmentSummary) {
|
||||||
|
this.attachmentId = attachmentSummary.getId();
|
||||||
|
this.taskId = attachmentSummary.getTaskId();
|
||||||
|
this.created = attachmentSummary.getCreated() != null ? attachmentSummary.getCreated().toString() : null;
|
||||||
|
this.modified = attachmentSummary.getModified() != null ? attachmentSummary.getModified().toString() : null;
|
||||||
|
this.classificationSummaryResource = new ClassificationSummaryResource(
|
||||||
|
attachmentSummary.getClassificationSummary());
|
||||||
|
this.objectReference = attachmentSummary.getObjectReference();
|
||||||
|
this.channel = attachmentSummary.getChannel();
|
||||||
|
this.received = attachmentSummary.getReceived() != null ? attachmentSummary.getReceived().toString() : null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAttachmentId() {
|
public String getAttachmentId() {
|
||||||
return attachmentId;
|
return attachmentId;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +57,7 @@ public class AttachmentSummaryResource extends ResourceSupport {
|
||||||
public void setCreated(String created) {
|
public void setCreated(String created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModified() {
|
public String getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -20,19 +21,12 @@ public class AttachmentSummaryResourceAssembler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttachmentSummaryResource toResource(AttachmentSummary attachmentSummary) {
|
public AttachmentSummaryResource toResource(AttachmentSummary attachmentSummary) {
|
||||||
AttachmentSummaryResource resource = createResourceWithId(attachmentSummary.getId(),
|
return new AttachmentSummaryResource(attachmentSummary);
|
||||||
attachmentSummary);
|
|
||||||
BeanUtils.copyProperties(attachmentSummary, resource);
|
|
||||||
if (attachmentSummary.getCreated() != null) {
|
|
||||||
resource.setCreated(attachmentSummary.getCreated().toString());
|
|
||||||
}
|
}
|
||||||
if (attachmentSummary.getModified() != null) {
|
|
||||||
resource.setModified(attachmentSummary.getModified().toString());
|
public List<AttachmentSummaryResource> toResources(
|
||||||
}
|
List<AttachmentSummary> attachmentSummaries) {
|
||||||
if (attachmentSummary.getReceived() != null) {
|
List<AttachmentSummaryResource> resources = super.toResources(attachmentSummaries);
|
||||||
resource.setReceived(attachmentSummary.getReceived().toString());
|
return resources;
|
||||||
}
|
|
||||||
resource.setAttachmentId(attachmentSummary.getId());
|
|
||||||
return resource;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import pro.taskana.AttachmentSummary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resources assembler for {@link AttachmentSummaryResource}.
|
|
||||||
*/
|
|
||||||
public class AttachmentSummaryResourcesAssembler {
|
|
||||||
|
|
||||||
public List<AttachmentSummaryResource> toResources(
|
|
||||||
List<AttachmentSummary> attachmentSummaries) {
|
|
||||||
AttachmentSummaryResourceAssembler assembler = new AttachmentSummaryResourceAssembler();
|
|
||||||
List<AttachmentSummaryResource> resources = assembler.toResources(attachmentSummaries);
|
|
||||||
return resources;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +1,19 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
|
import pro.taskana.Classification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.Classification}.
|
* Resource class for {@link pro.taskana.Classification}.
|
||||||
*/
|
*/
|
||||||
public class ClassificationResource extends ResourceSupport {
|
public class ClassificationResource extends ResourceSupport {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public String classificationId;
|
public String classificationId;
|
||||||
|
@NotNull
|
||||||
public String key;
|
public String key;
|
||||||
public String parentId;
|
public String parentId;
|
||||||
public String parentKey;
|
public String parentKey;
|
||||||
|
@ -31,12 +37,33 @@ public class ClassificationResource extends ResourceSupport {
|
||||||
public String custom7;
|
public String custom7;
|
||||||
public String custom8;
|
public String custom8;
|
||||||
|
|
||||||
public Boolean getIsValidInDomain() {
|
public ClassificationResource() {
|
||||||
return isValidInDomain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsValidInDomain(Boolean isValidInDomain) {
|
public ClassificationResource(Classification classification) {
|
||||||
this.isValidInDomain = isValidInDomain;
|
this.classificationId = classification.getId();
|
||||||
|
this.key = classification.getKey();
|
||||||
|
this.parentId = classification.getParentId();
|
||||||
|
this.parentKey = classification.getParentKey();
|
||||||
|
this.category = classification.getCategory();
|
||||||
|
this.type = classification.getType();
|
||||||
|
this.domain = classification.getDomain();
|
||||||
|
this.isValidInDomain = classification.getIsValidInDomain();
|
||||||
|
this.created = classification.getCreated() != null ? classification.getCreated().toString() : null;
|
||||||
|
this.modified = classification.getModified() != null ? classification.getModified().toString() : null;
|
||||||
|
this.name = classification.getName();
|
||||||
|
this.description = classification.getDescription();
|
||||||
|
this.priority = classification.getPriority();
|
||||||
|
this.serviceLevel = classification.getServiceLevel();
|
||||||
|
this.applicationEntryPoint = classification.getApplicationEntryPoint();
|
||||||
|
this.custom1 = classification.getCustom1();
|
||||||
|
this.custom2 = classification.getCustom2();
|
||||||
|
this.custom3 = classification.getCustom3();
|
||||||
|
this.custom4 = classification.getCustom4();
|
||||||
|
this.custom5 = classification.getCustom5();
|
||||||
|
this.custom6 = classification.getCustom6();
|
||||||
|
this.custom7 = classification.getCustom7();
|
||||||
|
this.custom8 = classification.getCustom8();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassificationId() {
|
public String getClassificationId() {
|
||||||
|
@ -95,6 +122,14 @@ public class ClassificationResource extends ResourceSupport {
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getIsValidInDomain() {
|
||||||
|
return isValidInDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValidInDomain(Boolean validInDomain) {
|
||||||
|
isValidInDomain = validInDomain;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCreated() {
|
public String getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import pro.taskana.Classification;
|
import pro.taskana.Classification;
|
||||||
import pro.taskana.ClassificationService;
|
import pro.taskana.ClassificationService;
|
||||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
|
||||||
import pro.taskana.exceptions.ConcurrencyException;
|
|
||||||
import pro.taskana.exceptions.DomainNotFoundException;
|
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.impl.ClassificationImpl;
|
import pro.taskana.impl.ClassificationImpl;
|
||||||
import pro.taskana.rest.ClassificationController;
|
import pro.taskana.rest.ClassificationController;
|
||||||
|
|
||||||
|
@ -24,22 +18,24 @@ import pro.taskana.rest.ClassificationController;
|
||||||
* Transforms {@link Classification} to its resource counterpart {@link ClassificationResource} and vice versa.
|
* Transforms {@link Classification} to its resource counterpart {@link ClassificationResource} and vice versa.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ClassificationResourceAssembler {
|
public class ClassificationResourceAssembler extends ResourceAssemblerSupport<Classification, ClassificationResource> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ClassificationService classificationService;
|
ClassificationService classificationService;
|
||||||
|
|
||||||
public ClassificationResource toResource(Classification classification)
|
public ClassificationResourceAssembler() {
|
||||||
throws InvalidArgumentException, ConcurrencyException, ClassificationNotFoundException, DomainNotFoundException,
|
super(ClassificationController.class, ClassificationResource.class);
|
||||||
ClassificationAlreadyExistException, NotAuthorizedException {
|
|
||||||
return this.createResource(classification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassificationResource toDefinition(Classification classification)
|
public ClassificationResource toResource(Classification classification) {
|
||||||
throws InvalidArgumentException, ConcurrencyException, ClassificationNotFoundException, DomainNotFoundException,
|
ClassificationResource resource = new ClassificationResource(classification);
|
||||||
ClassificationAlreadyExistException, NotAuthorizedException {
|
resource.add(linkTo(ClassificationController.class).slash(classification.getId()).withSelfRel());
|
||||||
ClassificationResource resource = this.createResource(classification);
|
return resource;
|
||||||
resource.removeLinks();
|
}
|
||||||
|
|
||||||
|
public ClassificationResource toDefinition(Classification classification) {
|
||||||
|
ClassificationResource resource = new ClassificationResource(classification);
|
||||||
|
resource.add(linkTo(ClassificationController.class).slash(classification.getId()).withSelfRel());
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,28 +54,4 @@ public class ClassificationResourceAssembler {
|
||||||
return classification;
|
return classification;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassificationResource createResource(Classification classification)
|
|
||||||
throws NotAuthorizedException, ConcurrencyException, InvalidArgumentException, DomainNotFoundException,
|
|
||||||
ClassificationAlreadyExistException, ClassificationNotFoundException {
|
|
||||||
ClassificationResource resource = new ClassificationResource();
|
|
||||||
BeanUtils.copyProperties(classification, resource);
|
|
||||||
// need to be set by hand, because they are named different, or have different types
|
|
||||||
resource.setClassificationId(classification.getId());
|
|
||||||
if (classification.getCreated() != null) {
|
|
||||||
resource.setCreated(classification.getCreated().toString());
|
|
||||||
}
|
|
||||||
if (classification.getModified() != null) {
|
|
||||||
resource.setModified(classification.getModified().toString());
|
|
||||||
}
|
|
||||||
return addLinks(resource, classification);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClassificationResource addLinks(ClassificationResource resource, Classification classification)
|
|
||||||
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException,
|
|
||||||
ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
|
|
||||||
resource.add(
|
|
||||||
linkTo(methodOn(ClassificationController.class).getClassification(classification.getId()))
|
|
||||||
.withSelfRel());
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
|
import pro.taskana.ClassificationSummary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.Classification}.
|
* Resource class for {@link pro.taskana.ClassificationSummary}.
|
||||||
*/
|
*/
|
||||||
public class ClassificationSummaryResource extends ResourceSupport {
|
public class ClassificationSummaryResource extends ResourceSupport {
|
||||||
|
|
||||||
|
@ -25,6 +27,29 @@ public class ClassificationSummaryResource extends ResourceSupport {
|
||||||
public String custom7;
|
public String custom7;
|
||||||
public String custom8;
|
public String custom8;
|
||||||
|
|
||||||
|
ClassificationSummaryResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassificationSummaryResource(ClassificationSummary classification) {
|
||||||
|
classificationId = classification.getId();
|
||||||
|
key = classification.getKey();
|
||||||
|
parentId = classification.getParentId();
|
||||||
|
parentKey = classification.getParentKey();
|
||||||
|
category = classification.getCategory();
|
||||||
|
type = classification.getType();
|
||||||
|
domain = classification.getDomain();
|
||||||
|
name = classification.getName();
|
||||||
|
priority = classification.getPriority();
|
||||||
|
custom1 = classification.getCustom1();
|
||||||
|
custom2 = classification.getCustom2();
|
||||||
|
custom3 = classification.getCustom3();
|
||||||
|
custom4 = classification.getCustom4();
|
||||||
|
custom5 = classification.getCustom5();
|
||||||
|
custom6 = classification.getCustom6();
|
||||||
|
custom7 = classification.getCustom7();
|
||||||
|
custom8 = classification.getCustom8();
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassificationId() {
|
public String getClassificationId() {
|
||||||
return classificationId;
|
return classificationId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -9,6 +12,7 @@ import pro.taskana.ClassificationService;
|
||||||
import pro.taskana.ClassificationSummary;
|
import pro.taskana.ClassificationSummary;
|
||||||
import pro.taskana.impl.ClassificationImpl;
|
import pro.taskana.impl.ClassificationImpl;
|
||||||
import pro.taskana.rest.ClassificationController;
|
import pro.taskana.rest.ClassificationController;
|
||||||
|
import pro.taskana.rest.resource.links.PageLinks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource assembler for {@link ClassificationSummaryResource}.
|
* Resource assembler for {@link ClassificationSummaryResource}.
|
||||||
|
@ -26,12 +30,7 @@ public class ClassificationSummaryResourceAssembler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassificationSummaryResource toResource(ClassificationSummary classificationSummary) {
|
public ClassificationSummaryResource toResource(ClassificationSummary classificationSummary) {
|
||||||
ClassificationSummaryResource resource = createResourceWithId(classificationSummary.getId(),
|
return new ClassificationSummaryResource(classificationSummary);
|
||||||
classificationSummary);
|
|
||||||
BeanUtils.copyProperties(classificationSummary, resource);
|
|
||||||
// named different so needs to be set by hand
|
|
||||||
resource.setClassificationId(classificationSummary.getId());
|
|
||||||
return resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassificationSummary toModel(ClassificationSummaryResource resource) {
|
public ClassificationSummary toModel(ClassificationSummaryResource resource) {
|
||||||
|
@ -44,4 +43,9 @@ public class ClassificationSummaryResourceAssembler
|
||||||
return classification.asSummary();
|
return classification.asSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PageLinks(ClassificationController.class)
|
||||||
|
public PagedResources<ClassificationSummaryResource> toResources(Collection<ClassificationSummary> entities,
|
||||||
|
PagedResources.PageMetadata pageMetadata) {
|
||||||
|
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
import static pro.taskana.rest.resource.AbstractRessourcesAssembler.getBuilderForOriginalUri;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.Link;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import pro.taskana.ClassificationSummary;
|
|
||||||
import pro.taskana.rest.ClassificationController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HH
|
|
||||||
*/
|
|
||||||
public class ClassificationSummaryResourcesAssembler {
|
|
||||||
|
|
||||||
public ClassificationSummaryResourcesAssembler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public PagedResources<ClassificationSummaryResource> toResources(
|
|
||||||
List<ClassificationSummary> classificationSummaries,
|
|
||||||
PageMetadata pageMetadata) {
|
|
||||||
|
|
||||||
ClassificationSummaryResourceAssembler assembler = new ClassificationSummaryResourceAssembler();
|
|
||||||
List<ClassificationSummaryResource> resources = assembler.toResources(classificationSummaries);
|
|
||||||
PagedResources<ClassificationSummaryResource> pagedResources = new PagedResources<ClassificationSummaryResource>(
|
|
||||||
resources,
|
|
||||||
pageMetadata);
|
|
||||||
|
|
||||||
UriComponentsBuilder original = getBuilderForOriginalUri();
|
|
||||||
pagedResources.add(new Link(original.toUriString()).withSelfRel());
|
|
||||||
if (pageMetadata != null) {
|
|
||||||
pagedResources.add(linkTo(ClassificationController.class).withRel("allClassifications"));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
|
|
||||||
.withRel(Link.REL_LAST));
|
|
||||||
if (pageMetadata.getNumber() > 1) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
|
|
||||||
.withRel(Link.REL_PREVIOUS));
|
|
||||||
}
|
|
||||||
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
|
|
||||||
.withRel(Link.REL_NEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagedResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.Resources;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import pro.taskana.WorkbasketSummary;
|
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|
||||||
import pro.taskana.rest.WorkbasketController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapper to convert from a list of WorkbasketSummary to a workbasket list resource.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class DistributionTargetListAssembler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DistributionTargetResourceAssembler distributionTargetResourceAssembler;
|
|
||||||
|
|
||||||
public Resources<DistributionTargetResource> toResource(String workbasketId,
|
|
||||||
Collection<WorkbasketSummary> distributionTargets) throws WorkbasketNotFoundException, NotAuthorizedException {
|
|
||||||
List<DistributionTargetResource> resourceList = new ArrayList<>();
|
|
||||||
for (WorkbasketSummary wb : distributionTargets) {
|
|
||||||
resourceList.add(distributionTargetResourceAssembler.toResource(wb));
|
|
||||||
}
|
|
||||||
Resources<DistributionTargetResource> distributionTargetListResource = new Resources<>(resourceList);
|
|
||||||
|
|
||||||
distributionTargetListResource
|
|
||||||
.add(linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
|
|
||||||
.withSelfRel());
|
|
||||||
distributionTargetListResource
|
|
||||||
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
|
|
||||||
.withRel("workbasket"));
|
|
||||||
|
|
||||||
return distributionTargetListResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,10 +2,18 @@ package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import org.springframework.hateoas.core.Relation;
|
import org.springframework.hateoas.core.Relation;
|
||||||
|
|
||||||
|
import pro.taskana.WorkbasketSummary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for a distribution target based on {@link pro.taskana.WorkbasketSummary}.
|
* Resource class for a distribution target based on {@link pro.taskana.WorkbasketSummary}.
|
||||||
*/
|
*/
|
||||||
@Relation(collectionRelation = "distributionTargets")
|
@Relation(collectionRelation = "distributionTargets")
|
||||||
public class DistributionTargetResource extends WorkbasketSummaryResource {
|
public class DistributionTargetResource extends WorkbasketSummaryResource {
|
||||||
|
|
||||||
|
DistributionTargetResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
DistributionTargetResource(WorkbasketSummary workbasketSummary) {
|
||||||
|
super(workbasketSummary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,10 @@ package pro.taskana.rest.resource;
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.hateoas.Resources;
|
||||||
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import pro.taskana.WorkbasketSummary;
|
import pro.taskana.WorkbasketSummary;
|
||||||
|
@ -15,21 +18,28 @@ import pro.taskana.rest.WorkbasketController;
|
||||||
* Transforms WorkbasketSummary to its resource counterpart DistributionTargerResource and vice versa.
|
* Transforms WorkbasketSummary to its resource counterpart DistributionTargerResource and vice versa.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class DistributionTargetResourceAssembler {
|
public class DistributionTargetResourceAssembler extends
|
||||||
|
ResourceAssemblerSupport<WorkbasketSummary, DistributionTargetResource> {
|
||||||
|
|
||||||
public DistributionTargetResource toResource(WorkbasketSummary summary)
|
public DistributionTargetResourceAssembler() {
|
||||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
super(WorkbasketController.class, DistributionTargetResource.class);
|
||||||
DistributionTargetResource resource = new DistributionTargetResource();
|
|
||||||
BeanUtils.copyProperties(summary, resource);
|
|
||||||
// named different so needs to be set by hand
|
|
||||||
resource.setWorkbasketId(summary.getId());
|
|
||||||
|
|
||||||
return addLinks(resource, summary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionTargetResource addLinks(DistributionTargetResource resource, WorkbasketSummary summary)
|
public DistributionTargetResource toResource(WorkbasketSummary summary) {
|
||||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
return new DistributionTargetResource(summary);
|
||||||
resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(summary.getId())).withSelfRel());
|
|
||||||
return resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Resources<DistributionTargetResource> toResources(String workbasketId,
|
||||||
|
List<WorkbasketSummary> distributionTargets) throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||||
|
Resources<DistributionTargetResource> distributionTargetListResource = new Resources<>(super.toResources(distributionTargets));
|
||||||
|
distributionTargetListResource
|
||||||
|
.add(linkTo(methodOn(WorkbasketController.class).getDistributionTargets(workbasketId))
|
||||||
|
.withSelfRel());
|
||||||
|
distributionTargetListResource
|
||||||
|
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
|
||||||
|
.withRel("workbasket"));
|
||||||
|
|
||||||
|
return distributionTargetListResource;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import pro.taskana.rest.MonitorController;
|
||||||
* Transforms any {@link Report} into its {@link ReportResource}.
|
* Transforms any {@link Report} into its {@link ReportResource}.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ReportAssembler {
|
public class ReportResourceAssembler {
|
||||||
|
|
||||||
public ReportResource toResource(TaskStatusReport report, List<String> domains, List<TaskState> states)
|
public ReportResource toResource(TaskStatusReport report, List<String> domains, List<TaskState> states)
|
||||||
throws NotAuthorizedException, InvalidArgumentException {
|
throws NotAuthorizedException, InvalidArgumentException {
|
|
@ -3,11 +3,14 @@ package pro.taskana.rest.resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
import pro.taskana.ObjectReference;
|
import pro.taskana.ObjectReference;
|
||||||
|
import pro.taskana.Task;
|
||||||
import pro.taskana.TaskState;
|
import pro.taskana.TaskState;
|
||||||
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.Task}.
|
* Resource class for {@link pro.taskana.Task}.
|
||||||
|
@ -57,6 +60,64 @@ public class TaskResource extends ResourceSupport {
|
||||||
private String custom15;
|
private String custom15;
|
||||||
private String custom16;
|
private String custom16;
|
||||||
|
|
||||||
|
public TaskResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskResource(Task task) throws InvalidArgumentException {
|
||||||
|
|
||||||
|
taskId = task.getId();
|
||||||
|
externalId = task.getExternalId();
|
||||||
|
created = task.getCreated() != null ? task.getCreated().toString() : null;
|
||||||
|
claimed = task.getClaimed() != null ? task.getClaimed().toString() : null;
|
||||||
|
completed = task.getCompleted() != null ? task.getCompleted().toString() : null;
|
||||||
|
modified = task.getModified() != null ? task.getModified().toString() : null;
|
||||||
|
planned = task.getPlanned() != null ? task.getPlanned().toString() : null;
|
||||||
|
due = task.getDue() != null ? task.getDue().toString() : null;
|
||||||
|
name = task.getName();
|
||||||
|
creator = task.getCreator();
|
||||||
|
description = task.getDescription();
|
||||||
|
note = task.getNote();
|
||||||
|
priority = task.getPriority();
|
||||||
|
state = task.getState();
|
||||||
|
classificationSummaryResource = new ClassificationSummaryResource(task.getClassificationSummary());
|
||||||
|
workbasketSummaryResource = new WorkbasketSummaryResource(task.getWorkbasketSummary());
|
||||||
|
businessProcessId = task.getBusinessProcessId();
|
||||||
|
parentBusinessProcessId = task.getParentBusinessProcessId();
|
||||||
|
owner = task.getOwner();
|
||||||
|
primaryObjRef = task.getPrimaryObjRef();
|
||||||
|
isRead = task.isRead();
|
||||||
|
isTransferred = task.isTransferred();
|
||||||
|
customAttributes = task.getCustomAttributes().entrySet().stream()
|
||||||
|
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
callbackInfo = task.getCallbackInfo().entrySet().stream()
|
||||||
|
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
attachments =
|
||||||
|
task.getAttachments()
|
||||||
|
.stream()
|
||||||
|
.map(attachment -> new AttachmentResource(attachment))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
custom1 = task.getCustomAttribute("1");
|
||||||
|
custom2 = task.getCustomAttribute("2");
|
||||||
|
custom3 = task.getCustomAttribute("3");
|
||||||
|
custom4 = task.getCustomAttribute("4");
|
||||||
|
custom5 = task.getCustomAttribute("5");
|
||||||
|
custom6 = task.getCustomAttribute("6");
|
||||||
|
custom7 = task.getCustomAttribute("7");
|
||||||
|
custom8 = task.getCustomAttribute("8");
|
||||||
|
custom9 = task.getCustomAttribute("9");
|
||||||
|
custom10 = task.getCustomAttribute("10");
|
||||||
|
custom11 = task.getCustomAttribute("11");
|
||||||
|
custom12 = task.getCustomAttribute("12");
|
||||||
|
custom13 = task.getCustomAttribute("13");
|
||||||
|
custom14 = task.getCustomAttribute("14");
|
||||||
|
custom15 = task.getCustomAttribute("15");
|
||||||
|
custom16 = task.getCustomAttribute("16");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public String getTaskId() {
|
public String getTaskId() {
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -33,7 +35,7 @@ public class TaskResourceAssembler
|
||||||
private WorkbasketSummaryResourceAssembler workbasketAssembler;
|
private WorkbasketSummaryResourceAssembler workbasketAssembler;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttachmentResourcesAssembler attachmentAssembler;
|
private AttachmentResourceAssembler attachmentAssembler;
|
||||||
|
|
||||||
public TaskResourceAssembler() {
|
public TaskResourceAssembler() {
|
||||||
super(TaskController.class, TaskResource.class);
|
super(TaskController.class, TaskResource.class);
|
||||||
|
@ -41,88 +43,13 @@ public class TaskResourceAssembler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskResource toResource(Task task) {
|
public TaskResource toResource(Task task) {
|
||||||
TaskResource resource = createResourceWithId(task.getId(), task);
|
TaskResource resource;
|
||||||
BeanUtils.copyProperties(task, resource);
|
|
||||||
resource.setTaskId(task.getId());
|
|
||||||
resource.setExternalId(task.getExternalId());
|
|
||||||
if (task.getCreated() != null) {
|
|
||||||
resource.setCreated(task.getCreated().toString());
|
|
||||||
}
|
|
||||||
if (task.getModified() != null) {
|
|
||||||
resource.setModified(task.getModified().toString());
|
|
||||||
}
|
|
||||||
if (task.getClaimed() != null) {
|
|
||||||
resource.setClaimed(task.getClaimed().toString());
|
|
||||||
}
|
|
||||||
if (task.getCompleted() != null) {
|
|
||||||
resource.setCompleted(task.getCompleted().toString());
|
|
||||||
}
|
|
||||||
if (task.getDue() != null) {
|
|
||||||
resource.setDue(task.getDue().toString());
|
|
||||||
}
|
|
||||||
resource.setClassificationSummaryResource(
|
|
||||||
classificationAssembler.toResource(task.getClassificationSummary()));
|
|
||||||
resource.setWorkbasketSummaryResource(workbasketAssembler.toResource(task.getWorkbasketSummary()));
|
|
||||||
resource.setAttachments(attachmentAssembler.toResources(task.getAttachments()));
|
|
||||||
resource.setCustomAttributes(task.getCustomAttributes().entrySet().stream()
|
|
||||||
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
resource.setCallbackInfo(task.getCallbackInfo().entrySet().stream()
|
|
||||||
.map(e -> new TaskResource.CustomAttribute(e.getKey(), e.getValue()))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
try {
|
try {
|
||||||
if (task.getCustomAttribute("1") != null) {
|
resource = new TaskResource(task);
|
||||||
resource.setCustom1(task.getCustomAttribute("1"));
|
resource.add(linkTo(TaskController.class).slash(task.getId()).withSelfRel());
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("2") != null) {
|
|
||||||
resource.setCustom2(task.getCustomAttribute("2"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("3") != null) {
|
|
||||||
resource.setCustom3(task.getCustomAttribute("3"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("4") != null) {
|
|
||||||
resource.setCustom4(task.getCustomAttribute("4"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("5") != null) {
|
|
||||||
resource.setCustom5(task.getCustomAttribute("5"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("6") != null) {
|
|
||||||
resource.setCustom6(task.getCustomAttribute("6"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("7") != null) {
|
|
||||||
resource.setCustom7(task.getCustomAttribute("7"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("8") != null) {
|
|
||||||
resource.setCustom8(task.getCustomAttribute("8"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("8") != null) {
|
|
||||||
resource.setCustom9(task.getCustomAttribute("9"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("10") != null) {
|
|
||||||
resource.setCustom10(task.getCustomAttribute("10"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("11") != null) {
|
|
||||||
resource.setCustom11(task.getCustomAttribute("11"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("12") != null) {
|
|
||||||
resource.setCustom12(task.getCustomAttribute("12"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("13") != null) {
|
|
||||||
resource.setCustom13(task.getCustomAttribute("13"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("14") != null) {
|
|
||||||
resource.setCustom14(task.getCustomAttribute("14"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("15") != null) {
|
|
||||||
resource.setCustom15(task.getCustomAttribute("15"));
|
|
||||||
}
|
|
||||||
if (task.getCustomAttribute("16") != null) {
|
|
||||||
resource.setCustom16(task.getCustomAttribute("16"));
|
|
||||||
}
|
|
||||||
} catch (InvalidArgumentException e) {
|
} catch (InvalidArgumentException e) {
|
||||||
throw new SystemException("caught unexpected Exception.", e.getCause());
|
throw new SystemException("caught unexpected Exception.", e.getCause());
|
||||||
}
|
}
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,54 +83,6 @@ public class TaskResourceAssembler
|
||||||
task.setCallbackInfo(resource.getCallbackInfo().stream()
|
task.setCallbackInfo(resource.getCallbackInfo().stream()
|
||||||
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
|
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
|
||||||
.collect(Collectors.toMap(TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
|
.collect(Collectors.toMap(TaskResource.CustomAttribute::getKey, TaskResource.CustomAttribute::getValue)));
|
||||||
if (resource.getCustom1() != null) {
|
|
||||||
task.setCustom1(resource.getCustom1());
|
|
||||||
}
|
|
||||||
if (resource.getCustom2() != null) {
|
|
||||||
task.setCustom2(resource.getCustom2());
|
|
||||||
}
|
|
||||||
if (resource.getCustom3() != null) {
|
|
||||||
task.setCustom3(resource.getCustom3());
|
|
||||||
}
|
|
||||||
if (resource.getCustom4() != null) {
|
|
||||||
task.setCustom4(resource.getCustom4());
|
|
||||||
}
|
|
||||||
if (resource.getCustom5() != null) {
|
|
||||||
task.setCustom5(resource.getCustom5());
|
|
||||||
}
|
|
||||||
if (resource.getCustom6() != null) {
|
|
||||||
task.setCustom6(resource.getCustom6());
|
|
||||||
}
|
|
||||||
if (resource.getCustom7() != null) {
|
|
||||||
task.setCustom7(resource.getCustom7());
|
|
||||||
}
|
|
||||||
if (resource.getCustom8() != null) {
|
|
||||||
task.setCustom8(resource.getCustom8());
|
|
||||||
}
|
|
||||||
if (resource.getCustom9() != null) {
|
|
||||||
task.setCustom9(resource.getCustom9());
|
|
||||||
}
|
|
||||||
if (resource.getCustom10() != null) {
|
|
||||||
task.setCustom10(resource.getCustom10());
|
|
||||||
}
|
|
||||||
if (resource.getCustom11() != null) {
|
|
||||||
task.setCustom11(resource.getCustom11());
|
|
||||||
}
|
|
||||||
if (resource.getCustom12() != null) {
|
|
||||||
task.setCustom12(resource.getCustom12());
|
|
||||||
}
|
|
||||||
if (resource.getCustom13() != null) {
|
|
||||||
task.setCustom13(resource.getCustom13());
|
|
||||||
}
|
|
||||||
if (resource.getCustom14() != null) {
|
|
||||||
task.setCustom14(resource.getCustom14());
|
|
||||||
}
|
|
||||||
if (resource.getCustom15() != null) {
|
|
||||||
task.setCustom15(resource.getCustom15());
|
|
||||||
}
|
|
||||||
if (resource.getCustom16() != null) {
|
|
||||||
task.setCustom16(resource.getCustom16());
|
|
||||||
}
|
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
import org.springframework.hateoas.core.Relation;
|
import org.springframework.hateoas.core.Relation;
|
||||||
|
|
||||||
import pro.taskana.ObjectReference;
|
import pro.taskana.ObjectReference;
|
||||||
import pro.taskana.TaskState;
|
import pro.taskana.TaskState;
|
||||||
|
import pro.taskana.TaskSummary;
|
||||||
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.WorkbasketSummary}.
|
* Resource class for {@link pro.taskana.WorkbasketSummary}.
|
||||||
|
@ -27,7 +28,6 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
private String due; // ISO-8601
|
private String due; // ISO-8601
|
||||||
private String name;
|
private String name;
|
||||||
private String creator;
|
private String creator;
|
||||||
private String description;
|
|
||||||
private String note;
|
private String note;
|
||||||
private int priority;
|
private int priority;
|
||||||
private TaskState state;
|
private TaskState state;
|
||||||
|
@ -39,8 +39,6 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
private ObjectReference primaryObjRef;
|
private ObjectReference primaryObjRef;
|
||||||
private boolean isRead;
|
private boolean isRead;
|
||||||
private boolean isTransferred;
|
private boolean isTransferred;
|
||||||
// All objects have to be serializable
|
|
||||||
private Map<String, String> customAttributes = Collections.emptyMap();
|
|
||||||
private List<AttachmentSummaryResource> attachmentSummaryResources = new ArrayList<>();
|
private List<AttachmentSummaryResource> attachmentSummaryResources = new ArrayList<>();
|
||||||
private String custom1;
|
private String custom1;
|
||||||
private String custom2;
|
private String custom2;
|
||||||
|
@ -59,6 +57,53 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
private String custom15;
|
private String custom15;
|
||||||
private String custom16;
|
private String custom16;
|
||||||
|
|
||||||
|
TaskSummaryResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskSummaryResource(TaskSummary taskSummary) throws InvalidArgumentException {
|
||||||
|
this.taskId = taskSummary.getTaskId();
|
||||||
|
this.externalId = taskSummary.getExternalId();
|
||||||
|
created = taskSummary.getCreated() != null ? taskSummary.getCreated().toString() : null;
|
||||||
|
claimed = taskSummary.getClaimed() != null ? taskSummary.getClaimed().toString() : null;
|
||||||
|
completed = taskSummary.getCompleted() != null ? taskSummary.getCompleted().toString() : null;
|
||||||
|
modified = taskSummary.getModified() != null ? taskSummary.getModified().toString() : null;
|
||||||
|
planned = taskSummary.getPlanned() != null ? taskSummary.getPlanned().toString() : null;
|
||||||
|
due = taskSummary.getDue() != null ? taskSummary.getDue().toString() : null;
|
||||||
|
this.name = taskSummary.getName();
|
||||||
|
this.creator = taskSummary.getCreator();
|
||||||
|
this.note = taskSummary.getNote();
|
||||||
|
this.priority = taskSummary.getPriority();
|
||||||
|
this.state = taskSummary.getState();
|
||||||
|
this.classificationSummaryResource = new ClassificationSummaryResource(taskSummary.getClassificationSummary());
|
||||||
|
this.workbasketSummaryResource = new WorkbasketSummaryResource(taskSummary.getWorkbasketSummary());
|
||||||
|
this.businessProcessId = taskSummary.getBusinessProcessId();
|
||||||
|
this.parentBusinessProcessId = taskSummary.getParentBusinessProcessId();
|
||||||
|
this.owner = taskSummary.getOwner();
|
||||||
|
this.primaryObjRef = taskSummary.getPrimaryObjRef();
|
||||||
|
this.isRead = taskSummary.isRead();
|
||||||
|
this.isTransferred = taskSummary.isTransferred();
|
||||||
|
this.attachmentSummaryResources = taskSummary.getAttachmentSummaries()
|
||||||
|
.stream()
|
||||||
|
.map(attachment -> new AttachmentSummaryResource(attachment))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
this.custom1 = taskSummary.getCustomAttribute("1");
|
||||||
|
this.custom2 = taskSummary.getCustomAttribute("2");
|
||||||
|
this.custom3 = taskSummary.getCustomAttribute("3");
|
||||||
|
this.custom4 = taskSummary.getCustomAttribute("4");
|
||||||
|
this.custom5 = taskSummary.getCustomAttribute("5");
|
||||||
|
this.custom6 = taskSummary.getCustomAttribute("6");
|
||||||
|
this.custom7 = taskSummary.getCustomAttribute("7");
|
||||||
|
this.custom8 = taskSummary.getCustomAttribute("8");
|
||||||
|
this.custom9 = taskSummary.getCustomAttribute("9");
|
||||||
|
this.custom10 = taskSummary.getCustomAttribute("10");
|
||||||
|
this.custom11 = taskSummary.getCustomAttribute("11");
|
||||||
|
this.custom12 = taskSummary.getCustomAttribute("12");
|
||||||
|
this.custom13 = taskSummary.getCustomAttribute("13");
|
||||||
|
this.custom14 = taskSummary.getCustomAttribute("14");
|
||||||
|
this.custom15 = taskSummary.getCustomAttribute("15");
|
||||||
|
this.custom16 = taskSummary.getCustomAttribute("16");
|
||||||
|
}
|
||||||
|
|
||||||
public String getTaskId() {
|
public String getTaskId() {
|
||||||
return taskId;
|
return taskId;
|
||||||
}
|
}
|
||||||
|
@ -139,14 +184,6 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNote() {
|
public String getNote() {
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
|
@ -235,14 +272,6 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
this.isTransferred = isTransferred;
|
this.isTransferred = isTransferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getCustomAttributes() {
|
|
||||||
return customAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomAttributes(Map<String, String> customAttributes) {
|
|
||||||
this.customAttributes = customAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AttachmentSummaryResource> getAttachmentSummaries() {
|
public List<AttachmentSummaryResource> getAttachmentSummaries() {
|
||||||
return attachmentSummaryResources;
|
return attachmentSummaryResources;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +421,6 @@ public class TaskSummaryResource extends ResourceSupport {
|
||||||
+ "due= " + this.due
|
+ "due= " + this.due
|
||||||
+ "name= " + this.name
|
+ "name= " + this.name
|
||||||
+ "creator= " + this.creator
|
+ "creator= " + this.creator
|
||||||
+ "description= " + this.description
|
|
||||||
+ "priority= " + this.priority
|
+ "priority= " + this.priority
|
||||||
+ "owner= " + this.owner
|
+ "owner= " + this.owner
|
||||||
+ "]";
|
+ "]";
|
||||||
|
|
|
@ -1,104 +1,44 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import pro.taskana.TaskSummary;
|
import pro.taskana.TaskSummary;
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
import pro.taskana.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.exceptions.SystemException;
|
import pro.taskana.exceptions.SystemException;
|
||||||
import pro.taskana.rest.TaskController;
|
import pro.taskana.rest.TaskController;
|
||||||
|
import pro.taskana.rest.resource.links.PageLinks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource assembler for {@link TaskSummaryResource}.
|
* Resource assembler for {@link TaskSummaryResource}.
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class TaskSummaryResourceAssembler
|
public class TaskSummaryResourceAssembler
|
||||||
extends ResourceAssemblerSupport<TaskSummary, TaskSummaryResource> {
|
extends ResourceAssemblerSupport<TaskSummary, TaskSummaryResource> {
|
||||||
|
|
||||||
private WorkbasketSummaryResourceAssembler workbasketAssembler = new WorkbasketSummaryResourceAssembler();
|
|
||||||
private ClassificationSummaryResourceAssembler classificationAssembler = new ClassificationSummaryResourceAssembler();
|
|
||||||
private AttachmentSummaryResourcesAssembler attachmentsAssembler = new AttachmentSummaryResourcesAssembler();
|
|
||||||
|
|
||||||
public TaskSummaryResourceAssembler() {
|
public TaskSummaryResourceAssembler() {
|
||||||
super(TaskController.class, TaskSummaryResource.class);
|
super(TaskController.class, TaskSummaryResource.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskSummaryResource toResource(TaskSummary taskSummary) {
|
public TaskSummaryResource toResource(TaskSummary taskSummary) {
|
||||||
TaskSummaryResource resource = createResourceWithId(taskSummary.getTaskId(), taskSummary);
|
TaskSummaryResource resource = null;
|
||||||
BeanUtils.copyProperties(taskSummary, resource);
|
|
||||||
if (taskSummary.getCreated() != null) {
|
|
||||||
resource.setCreated(taskSummary.getCreated().toString());
|
|
||||||
}
|
|
||||||
if (taskSummary.getModified() != null) {
|
|
||||||
resource.setModified(taskSummary.getModified().toString());
|
|
||||||
}
|
|
||||||
if (taskSummary.getClaimed() != null) {
|
|
||||||
resource.setClaimed(taskSummary.getClaimed().toString());
|
|
||||||
}
|
|
||||||
if (taskSummary.getCompleted() != null) {
|
|
||||||
resource.setCompleted(taskSummary.getCompleted().toString());
|
|
||||||
}
|
|
||||||
if (taskSummary.getDue() != null) {
|
|
||||||
resource.setDue(taskSummary.getDue().toString());
|
|
||||||
}
|
|
||||||
resource.setClassificationSummaryResource(
|
|
||||||
classificationAssembler.toResource(taskSummary.getClassificationSummary()));
|
|
||||||
resource.setWorkbasketSummaryResource(workbasketAssembler.toResource(taskSummary.getWorkbasketSummary()));
|
|
||||||
resource.setAttachmentSummaries(attachmentsAssembler.toResources(taskSummary.getAttachmentSummaries()));
|
|
||||||
try {
|
try {
|
||||||
if (taskSummary.getCustomAttribute("1") != null) {
|
resource = new TaskSummaryResource(taskSummary);
|
||||||
resource.setCustom1(taskSummary.getCustomAttribute("1"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("2") != null) {
|
|
||||||
resource.setCustom2(taskSummary.getCustomAttribute("2"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("3") != null) {
|
|
||||||
resource.setCustom3(taskSummary.getCustomAttribute("3"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("4") != null) {
|
|
||||||
resource.setCustom4(taskSummary.getCustomAttribute("4"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("5") != null) {
|
|
||||||
resource.setCustom5(taskSummary.getCustomAttribute("5"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("6") != null) {
|
|
||||||
resource.setCustom6(taskSummary.getCustomAttribute("6"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("7") != null) {
|
|
||||||
resource.setCustom7(taskSummary.getCustomAttribute("7"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("8") != null) {
|
|
||||||
resource.setCustom8(taskSummary.getCustomAttribute("8"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("8") != null) {
|
|
||||||
resource.setCustom9(taskSummary.getCustomAttribute("9"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("10") != null) {
|
|
||||||
resource.setCustom10(taskSummary.getCustomAttribute("10"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("11") != null) {
|
|
||||||
resource.setCustom11(taskSummary.getCustomAttribute("11"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("12") != null) {
|
|
||||||
resource.setCustom12(taskSummary.getCustomAttribute("12"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("13") != null) {
|
|
||||||
resource.setCustom13(taskSummary.getCustomAttribute("13"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("14") != null) {
|
|
||||||
resource.setCustom14(taskSummary.getCustomAttribute("14"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("15") != null) {
|
|
||||||
resource.setCustom15(taskSummary.getCustomAttribute("15"));
|
|
||||||
}
|
|
||||||
if (taskSummary.getCustomAttribute("16") != null) {
|
|
||||||
resource.setCustom16(taskSummary.getCustomAttribute("16"));
|
|
||||||
}
|
|
||||||
} catch (InvalidArgumentException e) {
|
} catch (InvalidArgumentException e) {
|
||||||
throw new SystemException("caught unexpected Exception.", e.getCause());
|
throw new SystemException("caught unexpected Exception.", e.getCause());
|
||||||
}
|
} finally {
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PageLinks(TaskController.class)
|
||||||
|
public PagedResources<TaskSummaryResource> toResources(List<TaskSummary> taskSummaries,
|
||||||
|
PagedResources.PageMetadata pageMetadata) {
|
||||||
|
return new PagedResources<>(toResources(taskSummaries), pageMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.Link;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
|
||||||
|
|
||||||
import pro.taskana.TaskSummary;
|
|
||||||
import pro.taskana.rest.TaskController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resources assembler for {@link TaskSummaryResource}.
|
|
||||||
*/
|
|
||||||
public class TaskSummaryResourcesAssembler extends AbstractRessourcesAssembler {
|
|
||||||
|
|
||||||
public TaskSummaryResourcesAssembler() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PagedResources<TaskSummaryResource> toResources(List<TaskSummary> taskSummaries,
|
|
||||||
PageMetadata pageMetadata) {
|
|
||||||
|
|
||||||
TaskSummaryResourceAssembler assembler = new TaskSummaryResourceAssembler();
|
|
||||||
List<TaskSummaryResource> resources = assembler.toResources(taskSummaries);
|
|
||||||
PagedResources<TaskSummaryResource> pagedResources = new PagedResources<TaskSummaryResource>(
|
|
||||||
resources,
|
|
||||||
pageMetadata);
|
|
||||||
|
|
||||||
pagedResources.add(new Link(original.toUriString()).withSelfRel());
|
|
||||||
if (pageMetadata != null) {
|
|
||||||
pagedResources.add(linkTo(TaskController.class).withRel("allTasks"));
|
|
||||||
addPageLinks(pagedResources, pageMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagedResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|
||||||
import static pro.taskana.rest.resource.AbstractRessourcesAssembler.getBuilderForOriginalUri;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.Link;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import pro.taskana.WorkbasketAccessItem;
|
|
||||||
import pro.taskana.WorkbasketService;
|
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|
||||||
import pro.taskana.impl.WorkbasketAccessItemImpl;
|
|
||||||
import pro.taskana.rest.WorkbasketController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transforms {@link WorkbasketAccessItem} to its resource counterpart {@link WorkbasketAccessItemResource} and vice
|
|
||||||
* versa.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class WorkbasketAccessItemAssembler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketService workbasketService;
|
|
||||||
|
|
||||||
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem)
|
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
||||||
WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource();
|
|
||||||
BeanUtils.copyProperties(wbAccItem, resource);
|
|
||||||
// property is named different, so it needs to be set by hand
|
|
||||||
resource.setAccessItemId(wbAccItem.getId());
|
|
||||||
|
|
||||||
return addLinks(resource, wbAccItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkbasketAccessItem toModel(WorkbasketAccessItemResource wbAccItemRecource) {
|
|
||||||
WorkbasketAccessItemImpl wbAccItemModel = (WorkbasketAccessItemImpl) workbasketService.newWorkbasketAccessItem(
|
|
||||||
wbAccItemRecource.workbasketId, wbAccItemRecource.accessId);
|
|
||||||
BeanUtils.copyProperties(wbAccItemRecource, wbAccItemModel);
|
|
||||||
|
|
||||||
wbAccItemModel.setId(wbAccItemRecource.accessItemId);
|
|
||||||
return wbAccItemModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private WorkbasketAccessItemResource addLinks(WorkbasketAccessItemResource resource, WorkbasketAccessItem wbAccItem)
|
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
||||||
|
|
||||||
resource.add(
|
|
||||||
linkTo(methodOn(WorkbasketController.class).getWorkbasket(wbAccItem.getWorkbasketId()))
|
|
||||||
.withRel("workbasket"));
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PagedResources<WorkbasketAccessItemResource> toResources(List<WorkbasketAccessItem> workbasketAccessItems,
|
|
||||||
PagedResources.PageMetadata pageMetadata) {
|
|
||||||
WorkbasketAccessItemsAssembler assembler = new WorkbasketAccessItemsAssembler();
|
|
||||||
List<WorkbasketAccessItemResource> resources = assembler.toResources(workbasketAccessItems);
|
|
||||||
|
|
||||||
PagedResources<WorkbasketAccessItemResource> pagedResources = new PagedResources<WorkbasketAccessItemResource>(
|
|
||||||
resources,
|
|
||||||
pageMetadata);
|
|
||||||
|
|
||||||
UriComponentsBuilder original = getBuilderForOriginalUri();
|
|
||||||
pagedResources.add(new Link(original.toUriString()).withSelfRel());
|
|
||||||
if (pageMetadata != null) {
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
|
|
||||||
.withRel(Link.REL_LAST));
|
|
||||||
if (pageMetadata.getNumber() > 1) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
|
|
||||||
.withRel(Link.REL_PREVIOUS));
|
|
||||||
}
|
|
||||||
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
|
|
||||||
.withRel(Link.REL_NEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagedResources;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.Resources;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import pro.taskana.WorkbasketAccessItem;
|
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|
||||||
import pro.taskana.rest.WorkbasketController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapper to convert from a list of WorkbasketAccessItem to a WorkbasketAccessItemResource.
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class WorkbasketAccessItemListAssembler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WorkbasketAccessItemAssembler workbasketAccessItemAssembler;
|
|
||||||
|
|
||||||
public Resources<WorkbasketAccessItemResource> toResource(String workbasketId,
|
|
||||||
Collection<WorkbasketAccessItem> accessItems) throws NotAuthorizedException, WorkbasketNotFoundException {
|
|
||||||
List<WorkbasketAccessItemResource> resourceList = new ArrayList<>();
|
|
||||||
for (WorkbasketAccessItem accessItem : accessItems) {
|
|
||||||
resourceList.add(workbasketAccessItemAssembler.toResource(accessItem));
|
|
||||||
}
|
|
||||||
|
|
||||||
Resources<WorkbasketAccessItemResource> accessItemListResource = new Resources<>(resourceList);
|
|
||||||
|
|
||||||
accessItemListResource
|
|
||||||
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
|
|
||||||
.withSelfRel());
|
|
||||||
accessItemListResource
|
|
||||||
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
|
|
||||||
.withRel("workbasket"));
|
|
||||||
|
|
||||||
return accessItemListResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -5,6 +5,8 @@ import javax.validation.constraints.NotNull;
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
import org.springframework.hateoas.core.Relation;
|
import org.springframework.hateoas.core.Relation;
|
||||||
|
|
||||||
|
import pro.taskana.WorkbasketAccessItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.WorkbasketAccessItem}.
|
* Resource class for {@link pro.taskana.WorkbasketAccessItem}.
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +44,34 @@ public class WorkbasketAccessItemResource extends ResourceSupport {
|
||||||
public boolean permCustom11;
|
public boolean permCustom11;
|
||||||
public boolean permCustom12;
|
public boolean permCustom12;
|
||||||
|
|
||||||
|
public WorkbasketAccessItemResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkbasketAccessItemResource(WorkbasketAccessItem workbasketAccessItem) {
|
||||||
|
this.accessItemId = workbasketAccessItem.getId();
|
||||||
|
this.workbasketId = workbasketAccessItem.getWorkbasketId();
|
||||||
|
this.workbasketKey = workbasketAccessItem.getWorkbasketKey();
|
||||||
|
this.accessId = workbasketAccessItem.getAccessId();
|
||||||
|
this.accessName = workbasketAccessItem.getAccessName();
|
||||||
|
this.permRead = workbasketAccessItem.isPermRead();
|
||||||
|
this.permOpen = workbasketAccessItem.isPermOpen();
|
||||||
|
this.permAppend = workbasketAccessItem.isPermAppend();
|
||||||
|
this.permTransfer = workbasketAccessItem.isPermTransfer();
|
||||||
|
this.permDistribute = workbasketAccessItem.isPermDistribute();
|
||||||
|
this.permCustom1 = workbasketAccessItem.isPermCustom1();
|
||||||
|
this.permCustom2 = workbasketAccessItem.isPermCustom2();
|
||||||
|
this.permCustom3 = workbasketAccessItem.isPermCustom3();
|
||||||
|
this.permCustom4 = workbasketAccessItem.isPermCustom4();
|
||||||
|
this.permCustom5 = workbasketAccessItem.isPermCustom5();
|
||||||
|
this.permCustom6 = workbasketAccessItem.isPermCustom6();
|
||||||
|
this.permCustom7 = workbasketAccessItem.isPermCustom7();
|
||||||
|
this.permCustom8 = workbasketAccessItem.isPermCustom8();
|
||||||
|
this.permCustom9 = workbasketAccessItem.isPermCustom9();
|
||||||
|
this.permCustom10 = workbasketAccessItem.isPermCustom10();
|
||||||
|
this.permCustom11 = workbasketAccessItem.isPermCustom11();
|
||||||
|
this.permCustom12 = workbasketAccessItem.isPermCustom12();
|
||||||
|
}
|
||||||
|
|
||||||
public String getAccessItemId() {
|
public String getAccessItemId() {
|
||||||
return accessItemId;
|
return accessItemId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.hateoas.PagedResources;
|
||||||
|
import org.springframework.hateoas.Resources;
|
||||||
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import pro.taskana.WorkbasketAccessItem;
|
||||||
|
import pro.taskana.WorkbasketService;
|
||||||
|
import pro.taskana.exceptions.NotAuthorizedException;
|
||||||
|
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||||
|
import pro.taskana.impl.WorkbasketAccessItemImpl;
|
||||||
|
import pro.taskana.rest.WorkbasketAccessItemController;
|
||||||
|
import pro.taskana.rest.WorkbasketController;
|
||||||
|
import pro.taskana.rest.resource.links.PageLinks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms {@link WorkbasketAccessItem} to its resource counterpart {@link WorkbasketAccessItemResource} and vice
|
||||||
|
* versa.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class WorkbasketAccessItemResourceAssembler extends
|
||||||
|
ResourceAssemblerSupport<WorkbasketAccessItem, WorkbasketAccessItemResource> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkbasketService workbasketService;
|
||||||
|
public WorkbasketAccessItemResourceAssembler() {
|
||||||
|
super(WorkbasketController.class, WorkbasketAccessItemResource.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) {
|
||||||
|
return new WorkbasketAccessItemResource(wbAccItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkbasketAccessItem toModel(WorkbasketAccessItemResource wbAccItemResource) {
|
||||||
|
WorkbasketAccessItemImpl wbAccItemModel = (WorkbasketAccessItemImpl) workbasketService.newWorkbasketAccessItem(
|
||||||
|
wbAccItemResource.workbasketId, wbAccItemResource.accessId);
|
||||||
|
BeanUtils.copyProperties(wbAccItemResource, wbAccItemModel);
|
||||||
|
|
||||||
|
wbAccItemModel.setId(wbAccItemResource.accessItemId);
|
||||||
|
return wbAccItemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PageLinks(WorkbasketAccessItemController.class)
|
||||||
|
public PagedResources<WorkbasketAccessItemResource> toResources(List<WorkbasketAccessItem> entities,
|
||||||
|
PagedResources.PageMetadata pageMetadata) {
|
||||||
|
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resources<WorkbasketAccessItemResource> toResources(String workbasketId, List<WorkbasketAccessItem> entities)
|
||||||
|
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||||
|
Resources<WorkbasketAccessItemResource> accessItemListResource = new Resources<>(super.toResources(entities));
|
||||||
|
accessItemListResource
|
||||||
|
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(workbasketId))
|
||||||
|
.withSelfRel());
|
||||||
|
accessItemListResource
|
||||||
|
.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(workbasketId))
|
||||||
|
.withRel("workbasket"));
|
||||||
|
return accessItemListResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
|
||||||
|
|
||||||
import pro.taskana.WorkbasketAccessItem;
|
|
||||||
import pro.taskana.rest.WorkbasketAccessItemController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapper to convert from a list of WorkbasketAccessItem to a WorkbasketAccessItemResource.
|
|
||||||
*/
|
|
||||||
public class WorkbasketAccessItemsAssembler
|
|
||||||
extends ResourceAssemblerSupport<WorkbasketAccessItem, WorkbasketAccessItemResource> {
|
|
||||||
|
|
||||||
public WorkbasketAccessItemsAssembler() {
|
|
||||||
super(WorkbasketAccessItemController.class, WorkbasketAccessItemResource.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem workbasketAccessItem) {
|
|
||||||
WorkbasketAccessItemResource resource = createResourceWithId(workbasketAccessItem.getId(),
|
|
||||||
workbasketAccessItem);
|
|
||||||
resource.removeLinks();
|
|
||||||
BeanUtils.copyProperties(workbasketAccessItem, resource);
|
|
||||||
resource.setAccessItemId(workbasketAccessItem.getId());
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -44,11 +44,7 @@ public class WorkbasketDefinitionResourceAssembler {
|
||||||
public WorkbasketDefinitionResource toResource(Workbasket workbasket)
|
public WorkbasketDefinitionResource toResource(Workbasket workbasket)
|
||||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||||
|
|
||||||
WorkbasketResourceWithoutLinks basket = new WorkbasketResourceWithoutLinks();
|
WorkbasketResourceWithoutLinks basket = new WorkbasketResourceWithoutLinks(workbasket);
|
||||||
BeanUtils.copyProperties(workbasket, basket);
|
|
||||||
basket.setWorkbasketId(workbasket.getId());
|
|
||||||
basket.setModified(workbasket.getModified().toString());
|
|
||||||
basket.setCreated(workbasket.getCreated().toString());
|
|
||||||
|
|
||||||
List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>();
|
List<WorkbasketAccessItemImpl> authorizations = new ArrayList<>();
|
||||||
for (WorkbasketAccessItem accessItem : workbasketService.getWorkbasketAccessItems(basket.getWorkbasketId())) {
|
for (WorkbasketAccessItem accessItem : workbasketService.getWorkbasketAccessItems(basket.getWorkbasketId())) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
||||||
|
import pro.taskana.Workbasket;
|
||||||
import pro.taskana.WorkbasketType;
|
import pro.taskana.WorkbasketType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,19 +13,14 @@ import pro.taskana.WorkbasketType;
|
||||||
public class WorkbasketResource extends ResourceSupport {
|
public class WorkbasketResource extends ResourceSupport {
|
||||||
|
|
||||||
public String workbasketId;
|
public String workbasketId;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String key;
|
public String key;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String domain;
|
public String domain;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public WorkbasketType type;
|
public WorkbasketType type;
|
||||||
|
|
||||||
public String created; // ISO-8601
|
public String created; // ISO-8601
|
||||||
public String modified; // ISO-8601
|
public String modified; // ISO-8601
|
||||||
public String description;
|
public String description;
|
||||||
|
@ -38,6 +34,29 @@ public class WorkbasketResource extends ResourceSupport {
|
||||||
public String orgLevel3;
|
public String orgLevel3;
|
||||||
public String orgLevel4;
|
public String orgLevel4;
|
||||||
|
|
||||||
|
public WorkbasketResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkbasketResource(Workbasket workbasket) {
|
||||||
|
this.workbasketId = workbasket.getId();
|
||||||
|
this.key = workbasket.getKey();
|
||||||
|
this.name = workbasket.getName();
|
||||||
|
this.domain = workbasket.getDomain();
|
||||||
|
this.type = workbasket.getType();
|
||||||
|
this.created = workbasket.getCreated() != null ? workbasket.getCreated().toString() : null;
|
||||||
|
this.modified = workbasket.getModified() != null ? workbasket.getModified().toString() : null;
|
||||||
|
this.description = workbasket.getDescription();
|
||||||
|
this.owner = workbasket.getOwner();
|
||||||
|
this.custom1 = workbasket.getCustom1();
|
||||||
|
this.custom2 = workbasket.getCustom2();
|
||||||
|
this.custom3 = workbasket.getCustom3();
|
||||||
|
this.custom4 = workbasket.getCustom4();
|
||||||
|
this.orgLevel1 = workbasket.getOrgLevel1();
|
||||||
|
this.orgLevel2 = workbasket.getOrgLevel2();
|
||||||
|
this.orgLevel3 = workbasket.getOrgLevel3();
|
||||||
|
this.orgLevel4 = workbasket.getOrgLevel4();
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorkbasketId() {
|
public String getWorkbasketId() {
|
||||||
return workbasketId;
|
return workbasketId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,7 @@ public class WorkbasketResourceAssembler {
|
||||||
private WorkbasketService workbasketService;
|
private WorkbasketService workbasketService;
|
||||||
|
|
||||||
public WorkbasketResource toResource(Workbasket wb) throws NotAuthorizedException, WorkbasketNotFoundException {
|
public WorkbasketResource toResource(Workbasket wb) throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||||
WorkbasketResource resource = new WorkbasketResource();
|
WorkbasketResource resource = new WorkbasketResource(wb);
|
||||||
BeanUtils.copyProperties(wb, resource);
|
|
||||||
// need to be set by hand, since name or type is different
|
|
||||||
resource.setWorkbasketId(wb.getId());
|
|
||||||
resource.setModified(wb.getModified().toString());
|
|
||||||
resource.setCreated(wb.getCreated().toString());
|
|
||||||
|
|
||||||
return addLinks(resource, wb);
|
return addLinks(resource, wb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,18 @@ package pro.taskana.rest.resource;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
import pro.taskana.Workbasket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource class for {@link pro.taskana.Workbasket} but without links property.
|
* Resource class for {@link pro.taskana.Workbasket} but without links property.
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(value = {"links"})
|
@JsonIgnoreProperties(value = {"links"})
|
||||||
public class WorkbasketResourceWithoutLinks extends WorkbasketResource {
|
public class WorkbasketResourceWithoutLinks extends WorkbasketResource {
|
||||||
|
|
||||||
|
WorkbasketResourceWithoutLinks() {
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkbasketResourceWithoutLinks(Workbasket workbasket) {
|
||||||
|
super(workbasket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import javax.validation.constraints.NotNull;
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
import org.springframework.hateoas.core.Relation;
|
import org.springframework.hateoas.core.Relation;
|
||||||
|
|
||||||
|
import pro.taskana.WorkbasketSummary;
|
||||||
import pro.taskana.WorkbasketType;
|
import pro.taskana.WorkbasketType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,32 +14,54 @@ import pro.taskana.WorkbasketType;
|
||||||
@Relation(collectionRelation = "workbaskets")
|
@Relation(collectionRelation = "workbaskets")
|
||||||
public class WorkbasketSummaryResource extends ResourceSupport {
|
public class WorkbasketSummaryResource extends ResourceSupport {
|
||||||
|
|
||||||
public String workbasketId;
|
private String workbasketId;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String key;
|
private String key;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String name;
|
private String name;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String domain;
|
private String domain;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public WorkbasketType type;
|
private WorkbasketType type;
|
||||||
|
|
||||||
public String description;
|
private String description;
|
||||||
public String owner;
|
private String owner;
|
||||||
public String custom1;
|
private String custom1;
|
||||||
public String custom2;
|
private String custom2;
|
||||||
public String custom3;
|
private String custom3;
|
||||||
public String custom4;
|
private String custom4;
|
||||||
public String orgLevel1;
|
private String orgLevel1;
|
||||||
public String orgLevel2;
|
private String orgLevel2;
|
||||||
public String orgLevel3;
|
private String orgLevel3;
|
||||||
public String orgLevel4;
|
private String orgLevel4;
|
||||||
private boolean markedForDeletion;
|
private boolean markedForDeletion;
|
||||||
|
|
||||||
|
public WorkbasketSummaryResource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkbasketSummaryResource(WorkbasketSummary workbasketSummary) {
|
||||||
|
this.workbasketId = workbasketSummary.getId();
|
||||||
|
this.key = workbasketSummary.getKey();
|
||||||
|
this.name = workbasketSummary.getName();
|
||||||
|
this.domain = workbasketSummary.getDomain();
|
||||||
|
this.type = workbasketSummary.getType();
|
||||||
|
this.description = workbasketSummary.getDescription();
|
||||||
|
this.owner = workbasketSummary.getOwner();
|
||||||
|
this.markedForDeletion = workbasketSummary.isMarkedForDeletion();
|
||||||
|
this.custom1 = workbasketSummary.getCustom1();
|
||||||
|
this.custom2 = workbasketSummary.getCustom2();
|
||||||
|
this.custom3 = workbasketSummary.getCustom3();
|
||||||
|
this.custom4 = workbasketSummary.getCustom4();
|
||||||
|
this.orgLevel1 = workbasketSummary.getOrgLevel1();
|
||||||
|
this.orgLevel2 = workbasketSummary.getOrgLevel2();
|
||||||
|
this.orgLevel3 = workbasketSummary.getOrgLevel3();
|
||||||
|
this.orgLevel4 = workbasketSummary.getOrgLevel4();
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorkbasketId() {
|
public String getWorkbasketId() {
|
||||||
return workbasketId;
|
return workbasketId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package pro.taskana.rest.resource;
|
package pro.taskana.rest.resource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.hateoas.PagedResources;
|
||||||
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -9,6 +12,7 @@ import pro.taskana.WorkbasketService;
|
||||||
import pro.taskana.WorkbasketSummary;
|
import pro.taskana.WorkbasketSummary;
|
||||||
import pro.taskana.impl.WorkbasketImpl;
|
import pro.taskana.impl.WorkbasketImpl;
|
||||||
import pro.taskana.rest.WorkbasketController;
|
import pro.taskana.rest.WorkbasketController;
|
||||||
|
import pro.taskana.rest.resource.links.PageLinks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HH
|
* @author HH
|
||||||
|
@ -26,11 +30,13 @@ public class WorkbasketSummaryResourceAssembler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkbasketSummaryResource toResource(WorkbasketSummary workbasketSummary) {
|
public WorkbasketSummaryResource toResource(WorkbasketSummary workbasketSummary) {
|
||||||
WorkbasketSummaryResource resource = createResourceWithId(workbasketSummary.getId(), workbasketSummary);
|
return new WorkbasketSummaryResource(workbasketSummary);
|
||||||
BeanUtils.copyProperties(workbasketSummary, resource);
|
}
|
||||||
// named different so needs to be set by hand
|
|
||||||
resource.setWorkbasketId(workbasketSummary.getId());
|
@PageLinks(WorkbasketController.class)
|
||||||
return resource;
|
public PagedResources<WorkbasketSummaryResource> toResources(List<WorkbasketSummary> entities,
|
||||||
|
PagedResources.PageMetadata pageMetadata) {
|
||||||
|
return new PagedResources<>(toResources(entities), pageMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {
|
public WorkbasketSummary toModel(WorkbasketSummaryResource resource) {
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
package pro.taskana.rest.resource;
|
|
||||||
|
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.hateoas.Link;
|
|
||||||
import org.springframework.hateoas.PagedResources;
|
|
||||||
import org.springframework.hateoas.PagedResources.PageMetadata;
|
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
|
||||||
|
|
||||||
import pro.taskana.WorkbasketSummary;
|
|
||||||
import pro.taskana.rest.WorkbasketController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HH
|
|
||||||
*/
|
|
||||||
public class WorkbasketSummaryResourcesAssembler {
|
|
||||||
|
|
||||||
public WorkbasketSummaryResourcesAssembler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public PagedResources<WorkbasketSummaryResource> toResources(List<WorkbasketSummary> workbasketSummaries,
|
|
||||||
PageMetadata pageMetadata) {
|
|
||||||
|
|
||||||
WorkbasketSummaryResourceAssembler assembler = new WorkbasketSummaryResourceAssembler();
|
|
||||||
List<WorkbasketSummaryResource> resources = assembler.toResources(workbasketSummaries);
|
|
||||||
PagedResources<WorkbasketSummaryResource> pagedResources = new PagedResources<WorkbasketSummaryResource>(
|
|
||||||
resources,
|
|
||||||
pageMetadata);
|
|
||||||
|
|
||||||
UriComponentsBuilder original = AbstractRessourcesAssembler.getBuilderForOriginalUri();
|
|
||||||
pagedResources.add(new Link(original.toUriString()).withSelfRel());
|
|
||||||
if (pageMetadata != null) {
|
|
||||||
pagedResources.add(linkTo(WorkbasketController.class).withRel("allWorkbaskets"));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
|
||||||
pagedResources.add(new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
|
|
||||||
.withRel(Link.REL_LAST));
|
|
||||||
if (pageMetadata.getNumber() > 1) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
|
|
||||||
.withRel(Link.REL_PREVIOUS));
|
|
||||||
}
|
|
||||||
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
|
|
||||||
pagedResources
|
|
||||||
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
|
|
||||||
.withRel(Link.REL_NEXT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pagedResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package pro.taskana.rest.resource.links;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to generate HATEOAS Links for paged list resources.
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface PageLinks {
|
||||||
|
Class<?> value();
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package pro.taskana.rest.resource.links;
|
||||||
|
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.hateoas.Link;
|
||||||
|
import org.springframework.hateoas.PagedResources;
|
||||||
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of the PageLinks annotation to generate HATEOAS Links for paged list resources.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@Aspect
|
||||||
|
public class PageLinksAspect {
|
||||||
|
|
||||||
|
@Around("@annotation(pro.taskana.rest.resource.links.PageLinks) && args(data, page, ..)")
|
||||||
|
public ResourceSupport addLinksToPageResource(ProceedingJoinPoint joinPoint, List<?> data, PagedResources.PageMetadata page)
|
||||||
|
throws Throwable {
|
||||||
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
PageLinks pageLinks = method.getAnnotation(PageLinks.class);
|
||||||
|
Class<?> controller = pageLinks.value();
|
||||||
|
UriComponentsBuilder original = originalUri(controller, request);
|
||||||
|
ResourceSupport resourceSupport = (ResourceSupport) joinPoint.proceed();
|
||||||
|
resourceSupport.add(new Link(original.toUriString()).withSelfRel());
|
||||||
|
if (page != null) {
|
||||||
|
resourceSupport.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
|
||||||
|
resourceSupport.add(new Link(original.replaceQueryParam("page", page.getTotalPages()).toUriString())
|
||||||
|
.withRel(Link.REL_LAST));
|
||||||
|
if (page.getNumber() > 1) {
|
||||||
|
resourceSupport
|
||||||
|
.add(new Link(original.replaceQueryParam("page", page.getNumber() - 1).toUriString())
|
||||||
|
.withRel(Link.REL_PREVIOUS));
|
||||||
|
}
|
||||||
|
if (page.getNumber() < page.getTotalPages()) {
|
||||||
|
resourceSupport
|
||||||
|
.add(new Link(original.replaceQueryParam("page", page.getNumber() + 1).toUriString())
|
||||||
|
.withRel(Link.REL_NEXT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resourceSupport;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UriComponentsBuilder originalUri(Class<?> controller, HttpServletRequest request) {
|
||||||
|
UriComponentsBuilder baseUri = linkTo(controller).toUriComponentsBuilder();
|
||||||
|
for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
|
||||||
|
for (String value : entry.getValue()) {
|
||||||
|
baseUri.queryParam(entry.getKey(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baseUri;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,12 +12,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
import pro.taskana.Classification;
|
import pro.taskana.Classification;
|
||||||
import pro.taskana.ClassificationService;
|
import pro.taskana.ClassificationService;
|
||||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
|
||||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
|
||||||
import pro.taskana.exceptions.ConcurrencyException;
|
|
||||||
import pro.taskana.exceptions.DomainNotFoundException;
|
|
||||||
import pro.taskana.exceptions.InvalidArgumentException;
|
|
||||||
import pro.taskana.exceptions.NotAuthorizedException;
|
|
||||||
import pro.taskana.impl.ClassificationImpl;
|
import pro.taskana.impl.ClassificationImpl;
|
||||||
import pro.taskana.rest.TestConfiguration;
|
import pro.taskana.rest.TestConfiguration;
|
||||||
|
|
||||||
|
@ -36,8 +30,7 @@ public class ClassificationAssemblerTest {
|
||||||
private ClassificationService classificationService;
|
private ClassificationService classificationService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void classificationToResource() throws ClassificationNotFoundException, NotAuthorizedException,
|
public void classificationToResource() {
|
||||||
ClassificationAlreadyExistException, ConcurrencyException, DomainNotFoundException, InvalidArgumentException {
|
|
||||||
// given
|
// given
|
||||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("DOMAIN_A",
|
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("DOMAIN_A",
|
||||||
"1", "A");
|
"1", "A");
|
||||||
|
@ -68,34 +61,37 @@ public class ClassificationAssemblerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resourceToClassification() {
|
public void resourceToClassification() {
|
||||||
|
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("12",
|
||||||
|
"DOMAIN_B", "AB");
|
||||||
|
|
||||||
// given
|
// given
|
||||||
ClassificationResource classificationResource = new ClassificationResource();
|
classification.setId("1");
|
||||||
classificationResource.setClassificationId("1");
|
classification.setType("AB");
|
||||||
classificationResource.setKey("12");
|
classification.setDomain("DOMAIN_B");
|
||||||
classificationResource.setName("TestB");
|
classification.setApplicationEntryPoint("Test");
|
||||||
classificationResource.setType("AB");
|
classification.setCategory("ABC");
|
||||||
classificationResource.setDomain("DOMAIN_B");
|
classification.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||||
classificationResource.setApplicationEntryPoint("Test");
|
classification.setModified(Instant.parse("2011-11-11T11:00:00Z"));
|
||||||
classificationResource.setCategory("ABC");
|
classification.setCustom1("Custom");
|
||||||
classificationResource.setCreated("2010-01-01T12:00:00Z");
|
classification.setCustom2("Custom2");
|
||||||
classificationResource.setModified("2011-11-11T11:00:00Z");
|
classification.setCustom1("Custom1");
|
||||||
classificationResource.setCustom1("Custom");
|
classification.setCustom3("Custom3");
|
||||||
classificationResource.setCustom2("Custom2");
|
classification.setCustom4("Custom4");
|
||||||
classificationResource.setCustom1("Custom1");
|
classification.setCustom5("Custom5");
|
||||||
classificationResource.setCustom3("Custom3");
|
classification.setCustom6("Custom6");
|
||||||
classificationResource.setCustom4("Custom4");
|
classification.setCustom7("Custom7");
|
||||||
classificationResource.setCustom5("Custom5");
|
classification.setCustom8("Custom8");
|
||||||
classificationResource.setCustom6("Custom6");
|
classification.setParentId("2");
|
||||||
classificationResource.setCustom7("Custom7");
|
classification.setPriority(2);
|
||||||
classificationResource.setCustom8("Custom8");
|
classification.setApplicationEntryPoint("12");
|
||||||
classificationResource.setParentId("2");
|
classification.setServiceLevel("P1D");
|
||||||
classificationResource.setPriority(2);
|
classification.setDescription("Test");
|
||||||
classificationResource.setApplicationEntryPoint("12");
|
classification.setIsValidInDomain(true);
|
||||||
classificationResource.setServiceLevel("P1D");
|
|
||||||
classificationResource.setDescription("Test");
|
ClassificationResource classificationResource = new ClassificationResource(classification);
|
||||||
classificationResource.setIsValidInDomain(true);
|
|
||||||
// when
|
// when
|
||||||
ClassificationImpl classification = (ClassificationImpl) classificationResourceAssembler
|
classification = (ClassificationImpl) classificationResourceAssembler
|
||||||
.toModel(classificationResource);
|
.toModel(classificationResource);
|
||||||
// then
|
// then
|
||||||
testEquality(classification, classificationResource);
|
testEquality(classification, classificationResource);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import pro.taskana.report.WorkbasketReport;
|
||||||
import pro.taskana.rest.TestConfiguration;
|
import pro.taskana.rest.TestConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ReportAssembler}.
|
* Test for {@link ReportResourceAssembler}.
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||||
|
@ -37,7 +37,7 @@ import pro.taskana.rest.TestConfiguration;
|
||||||
public class ReportResourceTest {
|
public class ReportResourceTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ReportAssembler reportAssembler;
|
private ReportResourceAssembler reportResourceAssembler;
|
||||||
|
|
||||||
private int daysDiff;
|
private int daysDiff;
|
||||||
private LocalDateTime now;
|
private LocalDateTime now;
|
||||||
|
@ -58,7 +58,7 @@ public class ReportResourceTest {
|
||||||
// given
|
// given
|
||||||
WorkbasketReport report = new WorkbasketReport(headers);
|
WorkbasketReport report = new WorkbasketReport(headers);
|
||||||
// when
|
// when
|
||||||
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
ReportResource resource = reportResourceAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
||||||
// then
|
// then
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
|
@ -92,7 +92,7 @@ public class ReportResourceTest {
|
||||||
item.setKey("key");
|
item.setKey("key");
|
||||||
report.addItem(item);
|
report.addItem(item);
|
||||||
// when
|
// when
|
||||||
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
ReportResource resource = reportResourceAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
||||||
// then
|
// then
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
|
@ -137,7 +137,7 @@ public class ReportResourceTest {
|
||||||
item.setKey("key2");
|
item.setKey("key2");
|
||||||
report.addItem(item);
|
report.addItem(item);
|
||||||
// when
|
// when
|
||||||
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
ReportResource resource = reportResourceAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
||||||
// then
|
// then
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
|
@ -190,7 +190,7 @@ public class ReportResourceTest {
|
||||||
item.setAttachmentKey(null);
|
item.setAttachmentKey(null);
|
||||||
report.addItem(item);
|
report.addItem(item);
|
||||||
// when
|
// when
|
||||||
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
ReportResource resource = reportResourceAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
||||||
// then
|
// then
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
|
@ -268,7 +268,7 @@ public class ReportResourceTest {
|
||||||
item.setKey("key2");
|
item.setKey("key2");
|
||||||
report.addItem(item);
|
report.addItem(item);
|
||||||
// when
|
// when
|
||||||
ReportResource resource = reportAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
ReportResource resource = reportResourceAssembler.toReportResource(report, now.toInstant(ZoneOffset.UTC));
|
||||||
// then
|
// then
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
|
|
|
@ -16,15 +16,15 @@ import pro.taskana.impl.WorkbasketAccessItemImpl;
|
||||||
import pro.taskana.rest.TestConfiguration;
|
import pro.taskana.rest.TestConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link WorkbasketAccessItemAssembler}.
|
* Test for {@link WorkbasketAccessItemResourceAssembler}.
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = {TestConfiguration.class})
|
@ContextConfiguration(classes = {TestConfiguration.class})
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class WorkbasketAccessItemAssemblerTest {
|
public class WorkbasketAccessItemResourceAssemblerTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
WorkbasketAccessItemAssembler workbasketAccessItemAssembler;
|
WorkbasketAccessItemResourceAssembler workbasketAccessItemResourceAssembler;
|
||||||
@Autowired
|
@Autowired
|
||||||
WorkbasketService workbasketService;
|
WorkbasketService workbasketService;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class WorkbasketAccessItemAssemblerTest {
|
||||||
accessItem.setPermCustom11(true);
|
accessItem.setPermCustom11(true);
|
||||||
accessItem.setPermCustom12(true);
|
accessItem.setPermCustom12(true);
|
||||||
// when
|
// when
|
||||||
WorkbasketAccessItemResource resource = workbasketAccessItemAssembler.toResource(
|
WorkbasketAccessItemResource resource = workbasketAccessItemResourceAssembler.toResource(
|
||||||
accessItem);
|
accessItem);
|
||||||
// then
|
// then
|
||||||
testEquality(accessItem, resource);
|
testEquality(accessItem, resource);
|
||||||
|
@ -84,7 +84,7 @@ public class WorkbasketAccessItemAssemblerTest {
|
||||||
resource.setPermCustom11(true);
|
resource.setPermCustom11(true);
|
||||||
resource.setPermCustom12(false);
|
resource.setPermCustom12(false);
|
||||||
// when
|
// when
|
||||||
WorkbasketAccessItem accessItem = workbasketAccessItemAssembler.toModel(resource);
|
WorkbasketAccessItem accessItem = workbasketAccessItemResourceAssembler.toModel(resource);
|
||||||
// then
|
// then
|
||||||
testEquality(accessItem, resource);
|
testEquality(accessItem, resource);
|
||||||
}
|
}
|
|
@ -47,20 +47,20 @@ public class WorkbasketSummaryAssemblerTest {
|
||||||
// when
|
// when
|
||||||
WorkbasketSummaryResource workbasketSummaryResource = workbasketSummaryAssembler.toResource(workbasketSummary);
|
WorkbasketSummaryResource workbasketSummaryResource = workbasketSummaryAssembler.toResource(workbasketSummary);
|
||||||
// then
|
// then
|
||||||
Assert.assertEquals(workbasketSummary.getDescription(), workbasketSummaryResource.description);
|
Assert.assertEquals(workbasketSummary.getDescription(), workbasketSummaryResource.getDescription());
|
||||||
Assert.assertEquals(workbasketSummary.getDomain(), workbasketSummaryResource.domain);
|
Assert.assertEquals(workbasketSummary.getDomain(), workbasketSummaryResource.getDomain());
|
||||||
Assert.assertEquals(workbasketSummary.getId(), workbasketSummaryResource.workbasketId);
|
Assert.assertEquals(workbasketSummary.getId(), workbasketSummaryResource.getWorkbasketId());
|
||||||
Assert.assertEquals(workbasketSummary.getKey(), workbasketSummaryResource.key);
|
Assert.assertEquals(workbasketSummary.getKey(), workbasketSummaryResource.getKey());
|
||||||
Assert.assertEquals(workbasketSummary.getName(), workbasketSummaryResource.name);
|
Assert.assertEquals(workbasketSummary.getName(), workbasketSummaryResource.getName());
|
||||||
Assert.assertEquals(workbasketSummary.getCustom1(), workbasketSummaryResource.custom1);
|
Assert.assertEquals(workbasketSummary.getCustom1(), workbasketSummaryResource.getCustom1());
|
||||||
Assert.assertEquals(workbasketSummary.getCustom2(), workbasketSummaryResource.custom2);
|
Assert.assertEquals(workbasketSummary.getCustom2(), workbasketSummaryResource.getCustom2());
|
||||||
Assert.assertEquals(workbasketSummary.getCustom3(), workbasketSummaryResource.custom3);
|
Assert.assertEquals(workbasketSummary.getCustom3(), workbasketSummaryResource.getCustom3());
|
||||||
Assert.assertEquals(workbasketSummary.getCustom4(), workbasketSummaryResource.custom4);
|
Assert.assertEquals(workbasketSummary.getCustom4(), workbasketSummaryResource.getCustom4());
|
||||||
Assert.assertEquals(workbasketSummary.getOrgLevel1(), workbasketSummaryResource.orgLevel1);
|
Assert.assertEquals(workbasketSummary.getOrgLevel1(), workbasketSummaryResource.getOrgLevel1());
|
||||||
Assert.assertEquals(workbasketSummary.getOrgLevel2(), workbasketSummaryResource.orgLevel2);
|
Assert.assertEquals(workbasketSummary.getOrgLevel2(), workbasketSummaryResource.getOrgLevel2());
|
||||||
Assert.assertEquals(workbasketSummary.getOrgLevel3(), workbasketSummaryResource.orgLevel3);
|
Assert.assertEquals(workbasketSummary.getOrgLevel3(), workbasketSummaryResource.getOrgLevel3());
|
||||||
Assert.assertEquals(workbasketSummary.getOrgLevel4(), workbasketSummaryResource.orgLevel4);
|
Assert.assertEquals(workbasketSummary.getOrgLevel4(), workbasketSummaryResource.getOrgLevel4());
|
||||||
Assert.assertEquals(workbasketSummary.getOwner(), workbasketSummaryResource.owner);
|
Assert.assertEquals(workbasketSummary.getOwner(), workbasketSummaryResource.getOwner());
|
||||||
Assert.assertEquals(workbasketSummary.getType(), workbasketSummaryResource.type);
|
Assert.assertEquals(workbasketSummary.getType(), workbasketSummaryResource.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue