TSK-747 Remove spring-boot-web from taskana-history-rest since doesn't allow to register history-controller for other spring applications

This commit is contained in:
Martin Rojas Miguel Angel 2019-02-20 15:15:58 +01:00 committed by Holger Hagen
parent 90f3b0b485
commit a9d3ef5d39
52 changed files with 121 additions and 1567 deletions

View File

@ -56,6 +56,7 @@ jobs:
&& ci/release.sh lib/taskana-cdi $TRAVIS_TAG && ci/release.sh lib/taskana-cdi $TRAVIS_TAG
&& ci/release.sh web/ $TRAVIS_TAG && ci/release.sh web/ $TRAVIS_TAG
&& ci/release.sh rest/taskana-rest-spring $TRAVIS_TAG && ci/release.sh rest/taskana-rest-spring $TRAVIS_TAG
&& ci/release.sh rest/taskana-rest-spring-base $TRAVIS_TAG
if: repo = env(DEPLOY_REPO) AND (tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ OR branch = master) AND type != pull_request if: repo = env(DEPLOY_REPO) AND (tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ OR branch = master) AND type != pull_request
- stage: "Release / Deploy" - stage: "Release / Deploy"
name: "Update Pom's stage" name: "Update Pom's stage"

View File

@ -31,8 +31,9 @@ function main {
mvn clean verify -q -f $REL/../lib/ -B mvn clean verify -q -f $REL/../lib/ -B
mvn clean install -q -f $REL/../rest/ -B -P history.plugin mvn clean install -q -f $REL/../rest/ -B -P history.plugin
elif [[ "$1" == "POSTGRES_10_4" ]]; then elif [[ "$1" == "POSTGRES_10_4" ]]; then
mvn clean verify -q -f $REL/../lib/taskana-core -B mvn clean install -q -f $REL/../lib/ -B -DskipTests=true -Dmaven.javadoc.skip=true
mvn clean install -q -f $REL/../rest/ -B -P postgres mvn clean install -q -f $REL/../rest/ -B -DskipTests=true -pl !taskana-rest-spring-wildfly-example -Dmaven.javadoc.skip=true
mvn clean install -q -f $REL/../rest/ -B -pl taskana-rest-spring-wildfly-example -Dmaven.javadoc.skip=true -P postgres
else else
mvn clean verify -q -f $REL/../lib/taskana-core -B mvn clean verify -q -f $REL/../lib/taskana-core -B
fi fi

View File

@ -15,8 +15,7 @@
<modules> <modules>
<module>taskana-rest-spring</module> <module>taskana-rest-spring</module>
<module>../web</module> <module>../web</module>
<module>taskana-history-rest-spring</module> <module>taskana-rest-spring-base</module>
<module>taskana-rest-spring-setup</module>
<module>taskana-rest-spring-example</module> <module>taskana-rest-spring-example</module>
<module>taskana-rest-spring-wildfly-example</module> <module>taskana-rest-spring-wildfly-example</module>
</modules> </modules>

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pro.taskana</groupId>
<artifactId>taskana-history-rest-spring</artifactId>
<version>1.0.8-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/*Documentation.java</include>
</includes>
<!-- Travis build workaround to prevent error that VM is closed due to an error. -->
<argLine>-Xms1024m -Xmx2048m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html</backend>
<doctype>book</doctype>
<attributes>
<snippets>target/generated-snippets</snippets>
<docinfo>shared</docinfo>
</attributes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-simplehistory-provider</artifactId>
<version>0.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
</dependency>
<!-- Tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.24.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>pro.taskana</groupId>
<artifactId>taskana-spring</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>pro.taskana</groupId>
<artifactId>taskana-rest-spring</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,64 +0,0 @@
<!-- Sourcecode at https://stackoverflow.com/questions/34481638/how-to-use-tocify-with-asciidoctor-for-a-dynamic-toc -->
<script src="./jquery-1.11.3.min.js"></script>
<script src="./jquery-ui.min.js"></script>
<script src="./jquery.tocify.min.js"></script>
<style>
.tocify-header {
font-style: italic;
}
.tocify-subheader {
font-style: normal;
font-size: 100%;
}
.tocify ul {
margin: 0;
}
.tocify-focus {
color: #7a2518;
background-color: rgba(0, 0, 0, 0.1);
}
.tocify-focus > a {
color: #7a2518;
}
</style>
<script type="text/javascript">
$(function () {
$("#toc").append("<div id='generated-toc'></div>");
$("#generated-toc").tocify({
extendPage: true,
context: "#content",
highlightOnScroll: true,
hideEffect: "slideUp",
hashGenerator: function(text, element) {
return $(element).attr("id");
},
smoothScroll: false,
theme: "none",
selectors: $( "#content" ).has( "h1" ).size() > 0 ? "h1,h2,h3,h4,h5" : "h2,h3,h4,h5",
ignoreSelector: ".discrete"
});
var handleTocOnResize = function() {
if ($(document).width() < 768) {
$("#generated-toc").hide();
$(".sectlevel0").show();
$(".sectlevel1").show();
}
else {
$("#generated-toc").show();
$(".sectlevel0").hide();
$(".sectlevel1").hide();
}
}
$(window).resize(handleTocOnResize);
handleTocOnResize();
});
</script>

View File

@ -1,97 +0,0 @@
= Taskana RESTful API Documentation
taskana.pro;
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 4
:sectlinks:
= Overview
[big]#*This Documentation is still under development and probably incomplete and/or flawed in certain areas.*#
== HTTP verbs
The Taskana RESTful API tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP verbs.
|===
| Verb | Usage
| `GET`
| Used to retrieve a resource
| `POST`
| Used to create a new resource
| `PUT`
| Used to update a resource
| `DELETE`
| Used to delete a existing resource
|===
== HTTP status codes
The Taskana RESTful API tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP status codes.
|===
| Status code | Usage
| `200 OK`
| The request completed successfully.
| `201 Created`
| The request completed successfully und create the new resource.
| `204 No Content`
| The request completed successfully and there is no content to send in the response payload.
| `400 Bad Request`
| The request was not performed because of a client error like a invalid parameter.
| `401 Unauthorized`
| The request has not been applied because it lacks valid authentication credentials for the target resource.
| `403 FORBIDDEN`
| The current user <user> has no read permission for <Resource Type> <Resource>.
| `404 Not Found`
| The requested resource did not exist.
| `405 Method not allowed`
| The method used in this request is can not be used on this resource.
| `406` Not acceptable
| Wrong content-type in request header.
| `409 Conflict`
| The resource could not be updatet or created because of a conflict with an existing one.
| `415 Unsupported Media Type`
| The content of the request can't be understood due to being in an unsupported media-type.
|===
== History event
=== Get all task history event
==== Example request
include::../../../{snippets}/GetAllTaskHistoryEventDocTest/http-request.adoc[]
==== Example response
include::../../../{snippets}/GetAllTaskHistoryEventDocTest/response-body.adoc[]
=== Get a specific task history event
==== Example request
include::../../../{snippets}/GetSpecificTaskHistoryEventDocTest/http-request.adoc[]
==== Example response
include::../../../{snippets}/GetSpecificTaskHistoryEventDocTest/response-body.adoc[]

View File

@ -1,72 +0,0 @@
package pro.taskana.rest;
import java.sql.SQLException;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
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.ComponentScan;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import pro.taskana.rest.sampledata.SampleDataGenerator;
/**
* Example Application showing the implementation of taskana-rest-spring.
*/
@SpringBootApplication
@ComponentScan(basePackages = "pro.taskana")
@Import({RestConfiguration.class})
public class ExampleRestApplication {
@Value("${taskana.schemaName:TASKANA}")
public String schemaName;
@Autowired
private SampleDataGenerator sampleDataGenerator;
public static void main(String[] 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
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
sampleDataGenerator = new SampleDataGenerator(dataSource);
return sampleDataGenerator;
}
@PostConstruct
private void init() {
sampleDataGenerator.generateSampleData(schemaName);
}
}

View File

@ -1,413 +0,0 @@
package pro.taskana.rest;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pro.taskana.BaseQuery;
import pro.taskana.TimeInterval;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.rest.resource.TaskHistoryEventResource;
import pro.taskana.rest.resource.TaskHistoryEventListAssembler;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.query.HistoryQuery;
/**
* Controller for all TaskHistoryEvent related endpoints.
*/
@RestController
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@RequestMapping(path = "/v1/task-history-event", produces = "application/hal+json")
public class TaskHistoryEventController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskHistoryEventController.class);
private static final String LIKE = "%";
private static final String BUSINESS_PROCESS_ID = "business-process-id";
private static final String BUSINESS_PROCESS_ID_LIKE = "business-process-id-like";
private static final String PARENT_BUSINESS_PROCESS_ID = "parent-business-process-id";
private static final String PARENT_BUSINESS_PROCESS_ID_LIKE = "parent-business-process-id-like";
private static final String TASK_ID = "task-id";
private static final String TASK_ID_LIKE = "task-id-like";
private static final String EVENT_TYPE = "event-type";
private static final String EVENT_TYPE_LIKE = "event-type-like";
private static final String CREATED = "created";
private static final String USER_ID = "user-id";
private static final String USER_ID_LIKE = "user-id-like";
private static final String DOMAIN = "domain";
private static final String WORKBASKET_KEY = "workbasket-key";
private static final String WORKBASKET_KEY_LIKE = "workbasket-key-like";
private static final String POR_COMPANY = "por-company";
private static final String POR_COMPANY_LIKE = "por-company-like";
private static final String POR_SYSTEM = "por-system";
private static final String POR_SYSTEM_LIKE = "por-system-like";
private static final String POR_INSTANCE = "por-instance";
private static final String POR_INSTANCE_LIKE = "por-instance-like";
private static final String POR_TYPE = "por-type";
private static final String POR_TYPE_LIKE = "por-type-like";
private static final String POR_VALUE = "por-value";
private static final String POR_VALUE_LIKE = "por-value-like";
private static final String TASK_CLASSIFICATION_KEY = "task-classification-key";
private static final String TASK_CLASSIFICATION_KEY_LIKE = "task-classification-key-like";
private static final String TASK_CLASSIFICATION_CATEGORY = "task-classification-category";
private static final String TASK_CLASSIFICATION_CATEGORY_LIKE = "task-classification-category-like";
private static final String ATTACHMENT_CLASSIFICATION_KEY = "attachment-classification-key";
private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE = "attachment-classification-key-like";
private static final String CUSTOM_1 = "custom-1";
private static final String CUSTOM_1_LIKE = "custom-1-like";
private static final String CUSTOM_2 = "custom-2";
private static final String CUSTOM_2_LIKE = "custom-2-like";
private static final String CUSTOM_3 = "custom-3";
private static final String CUSTOM_3_LIKE = "custom-3-like";
private static final String CUSTOM_4 = "custom-4";
private static final String CUSTOM_4_LIKE = "custom-4-like";
private static final String SORT_BY = "sort-by";
private static final String SORT_DIRECTION = "order";
private static final String PAGING_PAGE = "page";
private static final String PAGING_PAGE_SIZE = "page-size";
private SimpleHistoryServiceImpl simpleHistoryService;
@Autowired
private TaskanaEngineConfiguration taskanaEngineConfiguration;
public TaskHistoryEventController(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
simpleHistoryService = new SimpleHistoryServiceImpl();
simpleHistoryService.initialize(taskanaEngineConfiguration);
}
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<TaskHistoryEventResource>> getTaskHistoryEvent(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params));
}
HistoryQuery query = simpleHistoryService.createHistoryQuery();
query = applySortingParams(query, params);
query = applyFilterParams(query, params);
PageMetadata pageMetadata = null;
List<HistoryEventImpl> historyEvents = null;
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) {
long totalElements = query.count();
pageMetadata = initPageMetadata(pageSize, page, totalElements);
historyEvents = query.listPage((int) pageMetadata.getNumber(),
(int) pageMetadata.getSize());
} else if (page == null && pageSize == null) {
historyEvents = query.list();
} else {
throw new InvalidArgumentException("Paging information is incomplete.");
}
TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler();
PagedResources<TaskHistoryEventResource> pagedResources = assembler.toResources(historyEvents, pageMetadata);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTaskHistoryEvent(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK));
}
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
}
private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap<String, String> params)
throws IllegalArgumentException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", LoggerUtils.mapToString(params));
}
String sortBy = params.getFirst(SORT_BY);
if (sortBy != null) {
BaseQuery.SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null && "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = BaseQuery.SortDirection.DESCENDING;
} else {
sortDirection = BaseQuery.SortDirection.ASCENDING;
}
switch (sortBy) {
case (BUSINESS_PROCESS_ID):
query = query.orderByBusinessProcessId(sortDirection);
break;
case (PARENT_BUSINESS_PROCESS_ID):
query = query.orderByParentBusinessProcessId(sortDirection);
break;
case (TASK_ID):
query = query.orderByTaskId(sortDirection);
break;
case (EVENT_TYPE):
query = query.orderByEventType(sortDirection);
break;
case (CREATED):
query = query.orderByCreated(sortDirection);
break;
case (USER_ID):
query = query.orderByUserId(sortDirection);
break;
case (DOMAIN):
query = query.orderByDomain(sortDirection);
break;
case (WORKBASKET_KEY):
query = query.orderByWorkbasketKey(sortDirection);
break;
case (POR_COMPANY):
query = query.orderByPorCompany(sortDirection);
break;
case (POR_SYSTEM):
query = query.orderByPorSystem(sortDirection);
break;
case (POR_INSTANCE):
query = query.orderByPorInstance(sortDirection);
break;
case (POR_TYPE):
query = query.orderByPorType(sortDirection);
break;
case (POR_VALUE):
query = query.orderByPorValue(sortDirection);
break;
case (TASK_CLASSIFICATION_KEY):
query = query.orderByTaskClassificationKey(sortDirection);
break;
case (TASK_CLASSIFICATION_CATEGORY):
query = query.orderByTaskClassificationCategory(sortDirection);
break;
case (ATTACHMENT_CLASSIFICATION_KEY):
query = query.orderByAttachmentClassificationKey(sortDirection);
break;
case (CUSTOM_1):
query = query.orderByCustomAttribute(1, sortDirection);
break;
case (CUSTOM_2):
query = query.orderByCustomAttribute(2, sortDirection);
break;
case (CUSTOM_3):
query = query.orderByCustomAttribute(3, sortDirection);
break;
case (CUSTOM_4):
query = query.orderByCustomAttribute(4, sortDirection);
break;
default:
throw new IllegalArgumentException("Unknown order '" + sortBy + "'");
}
}
params.remove(SORT_BY);
params.remove(SORT_DIRECTION);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query);
}
return query;
}
private HistoryQuery applyFilterParams(HistoryQuery query,
MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
}
if (params.containsKey(BUSINESS_PROCESS_ID)) {
String[] businessProcessId = extractCommaSeparatedFields(params.get(BUSINESS_PROCESS_ID));
query.businessProcessIdIn(businessProcessId);
params.remove(BUSINESS_PROCESS_ID);
}
if (params.containsKey(BUSINESS_PROCESS_ID_LIKE)) {
query.businessProcessIdLike(LIKE + params.get(BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID)) {
String[] parentBusinessProcessId = extractCommaSeparatedFields(params.get(PARENT_BUSINESS_PROCESS_ID));
query.parentBusinessProcessIdIn(parentBusinessProcessId);
params.remove(PARENT_BUSINESS_PROCESS_ID);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID_LIKE)) {
query.parentBusinessProcessIdLike(LIKE + params.get(PARENT_BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(PARENT_BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(TASK_ID)) {
String[] taskId = extractCommaSeparatedFields(params.get(TASK_ID));
query.taskIdIn(taskId);
params.remove(TASK_ID);
}
if (params.containsKey(TASK_ID_LIKE)) {
query.taskIdLike(LIKE + params.get(TASK_ID_LIKE).get(0) + LIKE);
params.remove(TASK_ID_LIKE);
}
if (params.containsKey(EVENT_TYPE)) {
String[] eventType = extractCommaSeparatedFields(params.get(EVENT_TYPE));
query.eventTypeIn(eventType);
params.remove(EVENT_TYPE);
}
if (params.containsKey(EVENT_TYPE_LIKE)) {
query.eventTypeLike(LIKE + params.get(EVENT_TYPE_LIKE).get(0) + LIKE);
params.remove(EVENT_TYPE_LIKE);
}
if (params.containsKey(CREATED)) {
String[] created = extractCommaSeparatedFields(params.get(CREATED));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
Instant date = Instant.from(formatter.parse(created[0]));
TimeInterval timeInterval = new TimeInterval(date, date);
query.createdWithin(timeInterval);
params.remove(CREATED);
}
if (params.containsKey(USER_ID)) {
String[] userId = extractCommaSeparatedFields(params.get(USER_ID));
query.userIdIn(userId);
params.remove(USER_ID);
}
if (params.containsKey(USER_ID_LIKE)) {
query.userIdLike(LIKE + params.get(USER_ID_LIKE).get(0) + LIKE);
params.remove(USER_ID_LIKE);
}
if (params.containsKey(DOMAIN)) {
query.domainIn(extractCommaSeparatedFields(params.get(DOMAIN)));
params.remove(DOMAIN);
}
if (params.containsKey(WORKBASKET_KEY)) {
String[] workbasketKey = extractCommaSeparatedFields(params.get(WORKBASKET_KEY));
query.workbasketKeyIn(workbasketKey);
params.remove(WORKBASKET_KEY);
}
if (params.containsKey(WORKBASKET_KEY_LIKE)) {
query.workbasketKeyLike(LIKE + params.get(WORKBASKET_KEY_LIKE).get(0) + LIKE);
params.remove(WORKBASKET_KEY_LIKE);
}
if (params.containsKey(POR_COMPANY)) {
String[] porCompany = extractCommaSeparatedFields(params.get(POR_COMPANY));
query.porCompanyIn(porCompany);
params.remove(POR_COMPANY);
}
if (params.containsKey(POR_COMPANY_LIKE)) {
query.porCompanyLike(LIKE + params.get(POR_COMPANY_LIKE).get(0) + LIKE);
params.remove(POR_COMPANY_LIKE);
}
if (params.containsKey(POR_SYSTEM)) {
String[] porSystem = extractCommaSeparatedFields(params.get(POR_SYSTEM));
query.porSystemIn(porSystem);
params.remove(POR_SYSTEM);
}
if (params.containsKey(POR_SYSTEM_LIKE)) {
query.porSystemLike(LIKE + params.get(POR_SYSTEM_LIKE).get(0) + LIKE);
params.remove(POR_SYSTEM_LIKE);
}
if (params.containsKey(POR_INSTANCE)) {
String[] porInstance = extractCommaSeparatedFields(params.get(POR_INSTANCE));
query.porInstanceIn(porInstance);
params.remove(POR_INSTANCE);
}
if (params.containsKey(POR_INSTANCE_LIKE)) {
query.porInstanceLike(LIKE + params.get(POR_INSTANCE_LIKE).get(0) + LIKE);
params.remove(POR_INSTANCE_LIKE);
}
if (params.containsKey(POR_TYPE)) {
String[] porType = extractCommaSeparatedFields(params.get(POR_TYPE));
query.porTypeIn(porType);
params.remove(POR_TYPE);
}
if (params.containsKey(POR_TYPE_LIKE)) {
query.porTypeLike(LIKE + params.get(POR_TYPE_LIKE).get(0) + LIKE);
params.remove(POR_TYPE_LIKE);
}
if (params.containsKey(POR_VALUE)) {
String[] porValue = extractCommaSeparatedFields(params.get(POR_VALUE));
query.porValueIn(porValue);
params.remove(POR_VALUE);
}
if (params.containsKey(POR_VALUE_LIKE)) {
query.porValueLike(LIKE + params.get(POR_VALUE_LIKE).get(0) + LIKE);
params.remove(POR_VALUE_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY)) {
String[] taskClassificationKey = extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_KEY));
query.taskClassificationKeyIn(taskClassificationKey);
params.remove(TASK_CLASSIFICATION_KEY);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY_LIKE)) {
query.taskClassificationKeyLike(LIKE + params.get(TASK_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY)) {
String[] taskClassificationCategory = extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_CATEGORY));
query.taskClassificationCategoryIn(taskClassificationCategory);
params.remove(TASK_CLASSIFICATION_CATEGORY);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY_LIKE)) {
query.taskClassificationCategoryLike(LIKE + params.get(TASK_CLASSIFICATION_CATEGORY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_CATEGORY_LIKE);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY)) {
String[] attachmentClassificationKey = extractCommaSeparatedFields(params.get(ATTACHMENT_CLASSIFICATION_KEY));
query.attachmentClassificationKeyIn(attachmentClassificationKey);
params.remove(ATTACHMENT_CLASSIFICATION_KEY);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY_LIKE)) {
query.attachmentClassificationKeyLike(LIKE + params.get(ATTACHMENT_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(CUSTOM_1)) {
String[] custom1 = extractCommaSeparatedFields(params.get(CUSTOM_1));
query.custom1In(custom1);
params.remove(CUSTOM_1);
}
if (params.containsKey(CUSTOM_1_LIKE)) {
query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE);
params.remove(CUSTOM_1_LIKE);
}
if (params.containsKey(CUSTOM_2)) {
String[] custom2 = extractCommaSeparatedFields(params.get(CUSTOM_2));
query.custom2In(custom2);
params.remove(CUSTOM_2);
}
if (params.containsKey(CUSTOM_2_LIKE)) {
query.custom2Like(LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE);
params.remove(CUSTOM_2_LIKE);
}
if (params.containsKey(CUSTOM_3)) {
String[] custom3 = extractCommaSeparatedFields(params.get(CUSTOM_3));
query.custom3In(custom3);
params.remove(CUSTOM_3);
}
if (params.containsKey(CUSTOM_3_LIKE)) {
query.custom3Like(LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE);
params.remove(CUSTOM_3_LIKE);
}
if (params.containsKey(CUSTOM_4)) {
String[] custom4 = extractCommaSeparatedFields(params.get(CUSTOM_4));
query.custom4In(custom4);
params.remove(CUSTOM_4);
}
if (params.containsKey(CUSTOM_4_LIKE)) {
query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
}
return query;
}
}

View File

@ -1,29 +0,0 @@
package pro.taskana.rest.resource;
import org.springframework.beans.BeanUtils;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import pro.taskana.history.api.TaskanaHistoryEvent;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
/**
* Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventResource}.
*/
public class TaskHistoryEventAssembler extends ResourceAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
public TaskHistoryEventAssembler() {
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
}
@Override
public TaskHistoryEventResource toResource(TaskanaHistoryEvent historyEvent) {
TaskHistoryEventResource resource = createResourceWithId(historyEvent.getId(), historyEvent);
BeanUtils.copyProperties(historyEvent, resource);
if (historyEvent.getCreated() != null) {
resource.setCreated(historyEvent.getCreated().toString());
}
resource.setTaskHistoryId(String.valueOf(historyEvent.getId()));
resource.removeLinks();
return resource;
}
}

View File

@ -1,53 +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.web.util.UriComponentsBuilder;
import pro.taskana.rest.TaskHistoryEventController;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
/**
* Mapper to convert from a list of HistoryEventImpl to a TaskHistoryEventResource.
*/
public class TaskHistoryEventListAssembler {
public TaskHistoryEventListAssembler() {
}
public PagedResources<TaskHistoryEventResource> toResources(List<HistoryEventImpl> historyEvents,
PagedResources.PageMetadata pageMetadata) {
TaskHistoryEventAssembler assembler = new TaskHistoryEventAssembler();
List<TaskHistoryEventResource> resources = assembler.toResources(historyEvents);
PagedResources<TaskHistoryEventResource> pagedResources = new PagedResources<TaskHistoryEventResource>(
resources,
pageMetadata);
UriComponentsBuilder original = getBuilderForOriginalUri();
pagedResources.add(new Link(original.toUriString()).withSelfRel());
if (pageMetadata != null) {
pagedResources.add(linkTo(TaskHistoryEventController.class).withRel("allTaskHistoryEvent"));
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;
}
}

View File

@ -1,266 +0,0 @@
package pro.taskana.rest.resource;
import org.springframework.hateoas.ResourceSupport;
import javax.validation.constraints.NotNull;
/**
* Resource class for {@link pro.taskana.history.api.TaskanaHistoryEvent}.
*/
public class TaskHistoryEventResource extends ResourceSupport {
@NotNull
private String taskHistoryEventId;
private String businessProcessId;
private String parentBusinessProcessId;
private String taskId;
private String eventType;
private String created;
private String userId;
private String domain;
private String workbasketKey;
private String porCompany;
private String porType;
private String porSystem;
private String porInstance;
private String porValue;
private String taskClassificationKey;
private String taskClassificationCategory;
private String attachmentClassificationKey;
private String comment;
private String oldValue;
private String newValue;
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String oldData;
private String newData;
public String getTaskHistoryId() {
return taskHistoryEventId;
}
public void setTaskHistoryId(String taskHistoryId) {
this.taskHistoryEventId = taskHistoryId;
}
public String getBusinessProcessId() {
return businessProcessId;
}
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getWorkbasketKey() {
return workbasketKey;
}
public void setWorkbasketKey(String workbasketKey) {
this.workbasketKey = workbasketKey;
}
public String getPorCompany() {
return porCompany;
}
public void setPorCompany(String porCompany) {
this.porCompany = porCompany;
}
public String getPorType() {
return porType;
}
public void setPorType(String porType) {
this.porType = porType;
}
public String getPorSystem() {
return porSystem;
}
public void setPorSystem(String porSystem) {
this.porSystem = porSystem;
}
public String getPorInstance() {
return porInstance;
}
public void setPorInstance(String porInstance) {
this.porInstance = porInstance;
}
public String getPorValue() {
return porValue;
}
public void setPorValue(String porValue) {
this.porValue = porValue;
}
public String getTaskClassificationKey() {
return taskClassificationKey;
}
public void setTaskClassificationKey(String taskClassificationKey) {
this.taskClassificationKey = taskClassificationKey;
}
public String getTaskClassificationCategory() {
return taskClassificationCategory;
}
public void setTaskClassificationCategory(String taskClassificationCategory) {
this.taskClassificationCategory = taskClassificationCategory;
}
public String getAttachmentClassificationKey() {
return attachmentClassificationKey;
}
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
this.attachmentClassificationKey = attachmentClassificationKey;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getOldValue() {
return oldValue;
}
public void setOldValue(String oldValue) {
this.oldValue = oldValue;
}
public String getNewValue() {
return newValue;
}
public void setNewValue(String newValue) {
this.newValue = newValue;
}
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getOldData() {
return oldData;
}
public void setOldData(String oldData) {
this.oldData = oldData;
}
public String getNewData() {
return newData;
}
public void setNewData(String newData) {
this.newData = newData;
}
@Override
public String toString() {
return "TaskHistoryEventResource ["
+ "taskHistoryEventId= " + this.taskHistoryEventId
+ "businessProcessId= " + this.businessProcessId
+ "parentBusinessProcessId= " + this.parentBusinessProcessId
+ "taskId= " + this.taskId
+ "eventType= " + this.eventType
+ "created= " + this.created
+ "userId= " + this.userId
+ "domain= " + this.domain
+ "workbasketKey= " + this.workbasketKey
+ "oldValue= " + this.oldValue
+ "newValue= " + this.newValue
+ "oldData= " + this.oldData
+ "newData= " + this.newData
+ "]";
}
}

View File

@ -1,75 +0,0 @@
package pro.taskana.rest.sampledata;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class generates sample data for manual testing purposes.
*/
public class SampleDataGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleDataGenerator.class);
private static final String TEST_DATA = "/sql.sample-data";
private static final String CLEAR = TEST_DATA + "/clear-db.sql";
private static final String HISTORY_EVENT = TEST_DATA + "/history-event.sql";
private ScriptRunner runner;
DataSource dataSource;
public SampleDataGenerator(DataSource dataSource) throws SQLException {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(dataSource.getConnection().getMetaData().toString());
}
this.dataSource = dataSource;
runner = new ScriptRunner(dataSource.getConnection());
}
public void generateSampleData(String schemaName) {
StringWriter outWriter = new StringWriter();
PrintWriter logWriter = new PrintWriter(outWriter);
StringWriter errorWriter = new StringWriter();
PrintWriter errorLogWriter = new PrintWriter(errorWriter);
try {
runner.runScript(selectSchemaScript(dataSource.getConnection().getMetaData().getDatabaseProductName(), schemaName));
runner.setStopOnError(false);
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
} catch (Exception e) {
LOGGER.error("caught Exception {}", e);
}
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(HISTORY_EVENT), StandardCharsets.UTF_8)));
runner.closeConnection();
LOGGER.trace(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
private StringReader selectSchemaScript(String dbProductName, String schemaName) {
return new StringReader("PostgreSQL".equals(dbProductName)
? "SET search_path TO " + schemaName + ";"
: "SET SCHEMA " + schemaName + ";");
}
}

View File

@ -1,2 +0,0 @@
logging.level.pro.taskana=INFO
taskana.schemaName=TASKANA

View File

@ -1,3 +0,0 @@
-- the order is important!
DELETE FROM HISTORY_EVENTS;
COMMIT;

View File

@ -1,4 +0,0 @@
DROP TABLE TASKANA_SCHEMA_VERSION;
DROP TABLE HISTORY_EVENTS;
COMMIT;

View File

@ -1,7 +0,0 @@
SET SCHEMA TASKANA;
INSERT INTO HISTORY_EVENTS (BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID, EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY, ATTACHMENT_CLASSIFICATION_KEY, COMMENT, OLD_VALUE, NEW_VALUE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, OLD_DATA, NEW_DATA) VALUES
-- BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID, EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, POR_COMPANY , POR_SYSTEM, POR_INSTANCE , POR_TYPE , POR_VALUE , TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY , ATTACHMENT_CLASSIFICATION_KEY , COMMENT , OLD_VALUE , NEW_VALUE , CUSTOM_1 , CUSTOM_2 , CUSTOM_3 , CUSTOM_4 , OLD_DATA , NEW_DATA
('BPI:01' ,'' ,'TKI:000000000000000000000000000000000000', 'CREATE', CURRENT_TIMESTAMP , 'USER_2_2', 'DOMAIN_B', 'WBI:100000000000000000000000000000000001', '00' , 'PASystem', '00' , 'VNR' , '11223344', 'L140101' , 'TASK' ,'' , 'this task has been created' ,'old_val' ,'new_val' ,'custom1' ,'custom2' , 'custom3' ,'custom4' ,'123' ,'456'),
('BPI:02' ,'' ,'TKI:000000000000000000000000000000000000', 'CREATE', DATEADD('DAY', -2, CURRENT_TIMESTAMP),'USER_1_1', 'DOMAIN_A', 'WBI:100000000000000000000000000000000001', '00' , 'PASystem', '00' , 'VNR' , '11223344', '' , '' ,'' , 'created by Peter' ,'2old_val' ,'new_val2' ,'custom1' ,'' , 'custom2' ,'' ,'234' ,'456'),
('BPI:03' ,'BPI:01','TKI:000000000000000000000000000000000001', 'CREATE', CURRENT_TIMESTAMP , 'USER_2_1', 'DOMAIN_A', 'WBI:100000000000000000000000000000000002', '11' , '' , '22' , '' , '' , 'L140101' , 'TASK' ,'DOCTYPE_DEFAULT' , 'created a bug' ,'' ,'' ,'custom1' ,'' , 'custom3' ,'' ,'123' ,'456');

View File

@ -1,23 +0,0 @@
package pro.taskana.historyPlugin.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
/**
* Configuration for Taskana history REST service.
*/
@Configuration
@ComponentScan
@EnableTransactionManagement
public class TaskHistoryRestConfiguration {
@Bean
public SimpleHistoryServiceImpl getSimpleHistoryService() {
return new SimpleHistoryServiceImpl();
}
}

View File

@ -1,160 +0,0 @@
package pro.taskana.historyPlugin.doc.api;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import java.util.HashMap;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration;
import pro.taskana.rest.RestConfiguration;
/**
* Controller for Rest documentation.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TaskHistoryEventControllerRestDocumentation {
@LocalServerPort
int port;
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired
private WebApplicationContext context;
private MockMvc mockMvc;
private HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<String, String>();
private FieldDescriptor[] allTaskHistoryEventFieldDescriptors;
private FieldDescriptor[] taskHistoryEventFieldDescriptors;
@Before
public void setUp() {
document("{methodName}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint()))
.build();
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskHistoryId", "Unique ID");
taskHistoryEventFieldDescriptionsMap.put("_embedded.businessProcessId", "The id of the business process");
taskHistoryEventFieldDescriptionsMap.put("_embedded.parentBusinessProcessId", "The id of the parent business process");
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskId", "The id of the task");
taskHistoryEventFieldDescriptionsMap.put("_embedded.eventType", "The type of the event");
taskHistoryEventFieldDescriptionsMap.put("_embedded.created", "The time was created");
taskHistoryEventFieldDescriptionsMap.put("_embedded.userId", "The id of the user");
taskHistoryEventFieldDescriptionsMap.put("_embedded.domain", "Domain");
taskHistoryEventFieldDescriptionsMap.put("_embedded.workbasketKey", "The key of workbasket");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porCompany", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porSystem", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porInstance", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porValue", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porType", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationKey", "The key of classification task");
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationCategory", "The category of classification");
taskHistoryEventFieldDescriptionsMap.put("_embedded.attachmentClassificationKey", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.comment", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.oldValue", "The old value");
taskHistoryEventFieldDescriptionsMap.put("_embedded.newValue", "The new value");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom1", "A custom property with name \"1\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom2", "A custom property with name \"2\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom3", "A custom property with name \"3\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom4", "A custom property with name \"4\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.oldData", "The old data");
taskHistoryEventFieldDescriptionsMap.put("_embedded.newData", "The new data");
taskHistoryEventFieldDescriptionsMap.put("_links.self.href", "The links of this task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.allTaskHistoryEvent.href", "Link to all task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.first.href", "Link to the first result");
taskHistoryEventFieldDescriptionsMap.put("_links.last.href", "Link to the last result");
allTaskHistoryEventFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.taskHistoryEventResourceList").description("An array of Task history event"),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
};
taskHistoryEventFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("_embedded.taskHistoryEventResourceList[].taskHistoryId").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.taskHistoryId")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].businessProcessId").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.businessProcessId")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].parentBusinessProcessId").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.parentBusinessProcessId")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].taskId").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.taskId")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].eventType").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.eventType")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].created").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.created")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].userId").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.userId")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].domain").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.domain")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].workbasketKey").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.workbasketKey")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].porCompany").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.porCompany")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].porSystem").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.porSystem")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].porInstance").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.porInstance")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].porValue").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.porValue")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].porType").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.porType")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].taskClassificationKey").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.taskClassificationKey")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].taskClassificationCategory").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.taskClassificationCategory")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].attachmentClassificationKey").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.attachmentClassificationKey")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].comment").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.comment")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].oldValue").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.oldValue")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].newValue").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.newValue")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].custom1").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.custom1")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].custom2").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.custom2")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].custom3").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.custom3")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].custom4").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.custom4")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].oldData").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.oldData")),
fieldWithPath("_embedded.taskHistoryEventResourceList[].newData").description(taskHistoryEventFieldDescriptionsMap.get("_embedded.newData")),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
};
}
@Test
public void getAllTaskHistoryEventDocTest() throws Exception {
this.mockMvc.perform(
RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/task-history-event")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllTaskHistoryEventDocTest",
responseFields(allTaskHistoryEventFieldDescriptors)));
}
@Test
public void getSpecificTaskHistoryEventDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/v1/task-history-event?business-process-id=BPI:02")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificTaskHistoryEventDocTest",
responseFields(taskHistoryEventFieldDescriptors)));
}
}

View File

@ -1,161 +0,0 @@
package pro.taskana.historyPlugin.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration;
import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.TaskHistoryEventResource;
/**
* Controller for integration test.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
@ActiveProfiles(profiles = "history.plugin")
public class TaskHistoryEventControllerIntTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskHistoryEventControllerIntTest.class);
String server = "http://127.0.0.1:";
RestTemplate template;
HttpEntity<String> request;
@LocalServerPort
int port;
@Before
public void before() {
template = getRestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
request = new HttpEntity<String>(headers);
}
@Test
public void testGetAllHistoryEvent() {
ResponseEntity<PagedResources<TaskHistoryEventResource>> response = template.exchange(
server + port + "/v1/task-history-event", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskHistoryEventResource>>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(3, response.getBody().getContent().size());
}
@Test
public void testGetAllHistoryEventDescendingOrder() {
String parameters = "/v1/task-history-event?sort-by=business-process-id&order=desc&page-size=3&page=1";
ResponseEntity<PagedResources<TaskHistoryEventResource>> response = template.exchange(
server + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskHistoryEventResource>>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(3, response.getBody().getContent().size());
assertTrue(response.getBody()
.getLink(Link.REL_SELF)
.getHref()
.endsWith(parameters));
}
@Test
public void testGetSpecificTaskHistoryEvent() {
ResponseEntity<PagedResources<TaskHistoryEventResource>> response = template.exchange(
server + port
+ "/v1/task-history-event?business-process-id=BPI:01&sort-by=business-process-id&order=asc&page-size=6&page=1",
HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskHistoryEventResource>>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertNotNull(response.getBody().getLinks());
assertNotNull(response.getBody().getMetadata());
assertEquals(1, response.getBody().getContent().size());
}
@Test
public void testThrowsExceptionIfInvalidFilterIsUsed() {
try {
template.exchange(
server + port + "/v1/task-history-event?invalid=BPI:01", HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskHistoryEventResource>>() {
});
fail();
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains("[invalid]"));
}
}
@Test
public void testGetSecondPageSortedByKey() {
String parameters = "/v1/task-history-event?sort-by=workbasket-key&order=desc&page=2&page-size=2";
ResponseEntity<PagedResources<TaskHistoryEventResource>> response = template.exchange(
server + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<PagedResources<TaskHistoryEventResource>>() {
});
assertEquals(1, response.getBody().getContent().size());
assertEquals("WBI:100000000000000000000000000000000001",
response.getBody().getContent().iterator().next().getWorkbasketKey());
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody()
.getLink(Link.REL_SELF)
.getHref()
.endsWith(parameters));
assertNotNull(response.getBody().getLink("allTaskHistoryEvent"));
assertTrue(response.getBody()
.getLink("allTaskHistoryEvent")
.getHref()
.endsWith("/v1/task-history-event"));
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST));
}
/**
* Return a REST template which is capable of dealing with responses in HAL format.
*
* @return RestTemplate
*/
private RestTemplate getRestTemplate() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
return template;
}
}

View File

@ -1 +0,0 @@
logging.level.pro.taskana=INFO

View File

@ -2,14 +2,120 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>taskana-rest-spring-base</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<description>The taskana rest spring base configuration for a spring based web application.</description>
<url>http://taskana.pro</url>
<parent> <parent>
<artifactId>taskana-rest-parent</artifactId> <artifactId>taskana-rest-parent</artifactId>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<version>1.0.8-SNAPSHOT</version> <version>1.0.8-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>taskana-rest-spring-setup</artifactId> <licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>Holger Hagen</name>
<email>holger.hagen@novatec-gmbh.de</email>
<organization>NovaTec Consulting GmbH</organization>
<organizationUrl>https://www.novatec-gmbh.de</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/taskana/taskana.git</connection>
<developerConnection>scm:git:ssh://github.com:taskana/taskana.git</developerConnection>
<url>http://github.com/taskana/taskana/tree/master</url>
</scm>
<profiles>
<profile>
<id>snapshot</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

View File

@ -74,8 +74,6 @@ public class SampleDataGenerator {
runner.setStopOnError(false); runner.setStopOnError(false);
runner.runScript(new BufferedReader( runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8))); new InputStreamReader(this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR_HISTORY_EVENTS), StandardCharsets.UTF_8)));
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("caught Exception {}", e); LOGGER.error("caught Exception {}", e);
} }
@ -156,9 +154,11 @@ public class SampleDataGenerator {
runner.runScript(new BufferedReader( runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CHECK_HISTORY_EVENT_EXIST), new InputStreamReader(this.getClass().getResourceAsStream(CHECK_HISTORY_EVENT_EXIST),
StandardCharsets.UTF_8))); StandardCharsets.UTF_8)));
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR_HISTORY_EVENTS), StandardCharsets.UTF_8)));
scriptsList.add(HISTORY_EVENT); scriptsList.add(HISTORY_EVENT);
} catch (Exception e) { } catch (Exception e) {
LOGGER.info("The HISTORY_EVENTS table is not created"); LOGGER.error("The HISTORY_EVENTS table is not created");
} }
return scriptsList.toArray(new String[0]); return scriptsList.toArray(new String[0]);
} }

View File

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 145 KiB

View File

@ -36,9 +36,9 @@
</activation> </activation>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>pro.taskana</groupId> <groupId>pro.taskana.simplehistory</groupId>
<artifactId>taskana-history-rest-spring</artifactId> <artifactId>taskana-simplehistory-rest-spring</artifactId>
<version>${project.version}</version> <version>0.0.9</version>
</dependency> </dependency>
</dependencies> </dependencies>
</profile> </profile>
@ -150,7 +150,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-rest-spring-setup</artifactId> <artifactId>taskana-rest-spring-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -40,7 +40,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>pro.taskana</groupId> <groupId>pro.taskana</groupId>
<artifactId>taskana-rest-spring-setup</artifactId> <artifactId>taskana-rest-spring-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>