Merge pull request #37 from MLengl/TSK-52

Tsk 52 - Illigal ArgumentException
This commit is contained in:
Holger Hagen 2017-11-27 12:19:28 +01:00 committed by GitHub
commit 2d5ca63c67
27 changed files with 144 additions and 104 deletions

View File

@ -66,7 +66,6 @@ public class TaskanaProducersTest {
} }
Assert.assertEquals(1, resultCount); Assert.assertEquals(1, resultCount);
} }
@ -86,7 +85,5 @@ public class TaskanaProducersTest {
} }
Assert.assertEquals(0, resultCount); Assert.assertEquals(0, resultCount);
} }
} }

View File

@ -20,9 +20,7 @@ import java.util.List;
public class ClassificationServiceImpl implements ClassificationService { public class ClassificationServiceImpl implements ClassificationService {
private static final String ID_PREFIX_CLASSIFICATION = "CLI"; private static final String ID_PREFIX_CLASSIFICATION = "CLI";
public static final Date CURRENT_CLASSIFICATIONS_VALID_UNTIL = Date.valueOf("9999-12-31"); public static final Date CURRENT_CLASSIFICATIONS_VALID_UNTIL = Date.valueOf("9999-12-31");
private ClassificationMapper classificationMapper; private ClassificationMapper classificationMapper;
private TaskanaEngine taskanaEngine; private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl; private TaskanaEngineImpl taskanaEngineImpl;
@ -61,8 +59,6 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
} }
@Override @Override
public void addClassification(Classification classification) { public void addClassification(Classification classification) {
try { try {
@ -134,7 +130,6 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
@Override @Override
public List<Classification> getAllClassificationsWithId(String id, String domain) { public List<Classification> getAllClassificationsWithId(String id, String domain) {
try { try {
@ -148,24 +143,22 @@ public class ClassificationServiceImpl implements ClassificationService {
@Override @Override
public Classification getClassification(String id, String domain) { public Classification getClassification(String id, String domain) {
Classification classification = null;
try { try {
taskanaEngineImpl.openConnection(); taskanaEngineImpl.openConnection();
Classification result = null; if (domain == null) {
Classification classification = classificationMapper.findByIdAndDomain(id, domain, CURRENT_CLASSIFICATIONS_VALID_UNTIL); classification = classificationMapper.findByIdAndDomain(id, "", CURRENT_CLASSIFICATIONS_VALID_UNTIL);
if (classification == null) {
return classificationMapper.findByIdAndDomain(id, "", CURRENT_CLASSIFICATIONS_VALID_UNTIL);
} else { } else {
return classification; classification = classificationMapper.findByIdAndDomain(id, domain, CURRENT_CLASSIFICATIONS_VALID_UNTIL);
} }
} finally { } finally {
taskanaEngineImpl.returnConnection(); taskanaEngineImpl.returnConnection();
} }
return classification;
} }
@Override @Override
public ClassificationQuery createClassificationQuery() { public ClassificationQuery createClassificationQuery() {
return new ClassificationQueryImpl(taskanaEngine); return new ClassificationQueryImpl(taskanaEngine);
} }
} }

View File

@ -3,6 +3,7 @@ package pro.taskana.impl;
import java.util.List; import java.util.List;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.model.Task; import pro.taskana.model.Task;

View File

@ -1,16 +1,24 @@
package pro.taskana.model.mappings; package pro.taskana.model.mappings;
import org.apache.ibatis.annotations.*;
import pro.taskana.model.Classification;
import java.sql.Date; import java.sql.Date;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pro.taskana.model.Classification;
/** /**
* This class is the mybatis mapping of classifications. * This class is the mybatis mapping of classifications.
*/ */
public interface ClassificationMapper { public interface ClassificationMapper {
String VALID_UNTIL = "9999-12-31";
@Select("SELECT ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL " @Select("SELECT ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
+ "FROM CLASSIFICATION " + "FROM CLASSIFICATION "
+ "WHERE ID = #{id}" + "WHERE ID = #{id}"
@ -39,6 +47,33 @@ public interface ClassificationMapper {
@Result(property = "validUntil", column = "VALID_UNTIL")}) @Result(property = "validUntil", column = "VALID_UNTIL")})
Classification findByIdAndDomain(@Param("id") String id, @Param("domain") String domain, @Param("valid_until")Date validUntil); Classification findByIdAndDomain(@Param("id") String id, @Param("domain") String domain, @Param("valid_until")Date validUntil);
@Select("SELECT ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL "
+ "FROM CLASSIFICATION "
+ "WHERE ID = #{id} "
+ "AND VALID_UNTIL = '" + VALID_UNTIL + "'")
@Results({@Result(property = "id", column = "ID"),
@Result(property = "parentClassificationId", column = "PARENT_CLASSIFICATION_ID"),
@Result(property = "category", column = "CATEGORY"),
@Result(property = "type", column = "TYPE"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "isValidInDomain", column = "VALID_IN_DOMAIN"),
@Result(property = "created", column = "CREATED"),
@Result(property = "name", column = "NAME"),
@Result(property = "description", column = "DESCRIPTION"),
@Result(property = "priority", column = "PRIORITY"),
@Result(property = "serviceLevel", column = "SERVICE_LEVEL"),
@Result(property = "custom1", column = "CUSTOM_1"),
@Result(property = "custom2", column = "CUSTOM_2"),
@Result(property = "custom3", column = "CUSTOM_3"),
@Result(property = "custom4", column = "CUSTOM_4"),
@Result(property = "custom5", column = "CUSTOM_5"),
@Result(property = "custom6", column = "CUSTOM_6"),
@Result(property = "custom7", column = "CUSTOM_7"),
@Result(property = "custom8", column = "CUSTOM_8"),
@Result(property = "validFrom", column = "VALID_FROM"),
@Result(property = "validUntil", column = "VALID_UNTIL")})
Classification findById(@Param("id") String id);
@Insert("INSERT INTO CLASSIFICATION (ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL) VALUES (#{classification.id}, #{classification.parentClassificationId}, #{classification.category}, #{classification.type}, #{classification.domain}, #{classification.isValidInDomain}, #{classification.created}, #{classification.name}, #{classification.description}, #{classification.priority}, #{classification.serviceLevel}, #{classification.custom1}, #{classification.custom2}, #{classification.custom3}, #{classification.custom4}, #{classification.custom5}, #{classification.custom6}, #{classification.custom7}, #{classification.custom8}, #{classification.validFrom}, #{classification.validUntil})") @Insert("INSERT INTO CLASSIFICATION (ID, PARENT_CLASSIFICATION_ID, CATEGORY, TYPE, DOMAIN, VALID_IN_DOMAIN, CREATED, NAME, DESCRIPTION, PRIORITY, SERVICE_LEVEL, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, VALID_FROM, VALID_UNTIL) VALUES (#{classification.id}, #{classification.parentClassificationId}, #{classification.category}, #{classification.type}, #{classification.domain}, #{classification.isValidInDomain}, #{classification.created}, #{classification.name}, #{classification.description}, #{classification.priority}, #{classification.serviceLevel}, #{classification.custom1}, #{classification.custom2}, #{classification.custom3}, #{classification.custom4}, #{classification.custom5}, #{classification.custom6}, #{classification.custom7}, #{classification.custom8}, #{classification.validFrom}, #{classification.validUntil})")
void insert(@Param("classification") Classification classification); void insert(@Param("classification") Classification classification);
@ -74,6 +109,5 @@ public interface ClassificationMapper {
@Result(property = "validFrom", column = "VALID_FROM"), @Result(property = "validFrom", column = "VALID_FROM"),
@Result(property = "validUntil", column = "VALID_UNTIL")}) @Result(property = "validUntil", column = "VALID_UNTIL")})
List<Classification> getAllClassificationsWithId(@Param("id") String id, @Param("domain") String domain); List<Classification> getAllClassificationsWithId(@Param("id") String id, @Param("domain") String domain);
} }

View File

@ -20,7 +20,8 @@ import java.util.List;
public interface QueryMapper { public interface QueryMapper {
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById"; String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findByIdAndDomain"; String CLASSIFICATION_FINDBYIDANDDOMAIN = "pro.taskana.model.mappings.ClassificationMapper.findByIdAndDomain";
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
@Select("<script>SELECT t.ID, t.CREATED, t.CLAIMED, t.COMPLETED, t.MODIFIED, t.PLANNED, t.DUE, t.NAME, t.DESCRIPTION, t.PRIORITY, t.STATE, t.CLASSIFICATION_ID, t.WORKBASKETID, t.OWNER, t.PRIMARY_OBJ_REF_ID, t.IS_READ, t.IS_TRANSFERRED, t.CUSTOM_1, t.CUSTOM_2, t.CUSTOM_3, t.CUSTOM_4, t.CUSTOM_5, t.CUSTOM_6, t.CUSTOM_7, t.CUSTOM_8, t.CUSTOM_9, t.CUSTOM_10 " @Select("<script>SELECT t.ID, t.CREATED, t.CLAIMED, t.COMPLETED, t.MODIFIED, t.PLANNED, t.DUE, t.NAME, t.DESCRIPTION, t.PRIORITY, t.STATE, t.CLASSIFICATION_ID, t.WORKBASKETID, t.OWNER, t.PRIMARY_OBJ_REF_ID, t.IS_READ, t.IS_TRANSFERRED, t.CUSTOM_1, t.CUSTOM_2, t.CUSTOM_3, t.CUSTOM_4, t.CUSTOM_5, t.CUSTOM_6, t.CUSTOM_7, t.CUSTOM_8, t.CUSTOM_9, t.CUSTOM_10 "
+ "FROM TASK t " + "FROM TASK t "

View File

@ -15,7 +15,7 @@ import java.util.Map;
public interface TaskMapper { public interface TaskMapper {
String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById"; String OBJECTREFERENCEMAPPER_FINDBYID = "pro.taskana.model.mappings.ObjectReferenceMapper.findById";
String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findByIdAndDomain"; String CLASSIFICATION_FINDBYID = "pro.taskana.model.mappings.ClassificationMapper.findById";
@Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 " @Select("SELECT ID, CREATED, CLAIMED, COMPLETED, MODIFIED, PLANNED, DUE, NAME, DESCRIPTION, PRIORITY, STATE, CLASSIFICATION_ID, WORKBASKETID, OWNER, PRIMARY_OBJ_REF_ID, IS_READ, IS_TRANSFERRED, CUSTOM_ATTRIBUTES, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, CUSTOM_10 "
+ "FROM TASK " + "FROM TASK "

View File

@ -42,7 +42,6 @@ public class ClassificationServiceImplTest {
@Mock @Mock
TaskanaEngineImpl taskanaEngineImpl; TaskanaEngineImpl taskanaEngineImpl;
@Test @Test
public void testAddClassification() { public void testAddClassification() {
doNothing().when(classificationMapper).insert(any()); doNothing().when(classificationMapper).insert(any());

View File

@ -54,6 +54,4 @@ public class DBCleaner {
LOGGER.error(errorWriter.toString()); LOGGER.error(errorWriter.toString());
} }
} }
} }

View File

@ -20,23 +20,34 @@ public class ClassificationController {
@Autowired @Autowired
private ClassificationService classificationService; private ClassificationService classificationService;
@RequestMapping @RequestMapping(method = RequestMethod.GET)
public ResponseEntity<List<Classification>> getClassifications() { public ResponseEntity<List<Classification>> getClassifications() {
try { try {
List<Classification> classificationTree = classificationService.getClassificationTree(); List<Classification> classificationTree = classificationService.getClassificationTree();
return ResponseEntity.status(HttpStatus.CREATED).body(classificationTree); return ResponseEntity.status(HttpStatus.OK).body(classificationTree);
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
} }
} }
@RequestMapping(value = "/{classificationId}")
public Classification getClassification(@PathVariable String classificationId) { @RequestMapping(value = "/{classificationId}", method = RequestMethod.GET)
return classificationService.getClassification(classificationId, ""); public ResponseEntity<Classification> getClassification(@PathVariable String classificationId) {
try {
Classification classification = classificationService.getClassification(classificationId, "");
return ResponseEntity.status(HttpStatus.OK).body(classification);
} catch(Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} }
@RequestMapping(value = "/{classificationId}/{domain}") @RequestMapping(value = "/{classificationId}/{domain}", method = RequestMethod.GET)
public Classification getClassification(@PathVariable String classificationId, @PathVariable String domain) { public ResponseEntity<Classification> getClassification(@PathVariable String classificationId, @PathVariable String domain) {
return classificationService.getClassification(classificationId, domain); try {
Classification classification = classificationService.getClassification(classificationId, domain);
return ResponseEntity.status(HttpStatus.OK).body(classification);
} catch(Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
@ -58,5 +69,4 @@ public class ClassificationController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
} }
} }
} }

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskNotFoundException; import pro.taskana.exceptions.TaskNotFoundException;
@ -42,7 +43,6 @@ public class TaskController {
// get all // get all
return ResponseEntity.status(HttpStatus.OK).body(taskLogic.getAll()); return ResponseEntity.status(HttpStatus.OK).body(taskLogic.getAll());
} }
return ResponseEntity.status(HttpStatus.OK).body(taskLogic.inspectPrams(params)); return ResponseEntity.status(HttpStatus.OK).body(taskLogic.inspectPrams(params));
} catch (NotAuthorizedException e) { } catch (NotAuthorizedException e) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();

View File

@ -59,7 +59,6 @@ public class WorkbasketController {
} else { } else {
return workbasketService.getWorkbaskets(); return workbasketService.getWorkbaskets();
} }
} }
@RequestMapping(value = "/{workbasketid}") @RequestMapping(value = "/{workbasketid}")

View File

@ -1,9 +1,9 @@
INSERT INTO CLASSIFICATION VALUES ('1', '', 'EXTERN', 'BRIEF','nova-domain', TRUE, CURRENT_TIMESTAMP, 'ROOT', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES ('1', '', 'EXTERN', 'BRIEF','nova-domain', TRUE, CURRENT_TIMESTAMP, 'ROOT', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
INSERT INTO CLASSIFICATION VALUES ('2', '1','MANUELL', 'BRIEF', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'CHILD', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES ('2', '1','MANUELL', 'BRIEF', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'CHILD', 'DESC', 1, 'P1D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
INSERT INTO CLASSIFICATION VALUES ('3', '1','MASCHINELL', 'BRIEF', 'nova-domain', FALSE, CURRENT_TIMESTAMP, 'ANOTHER CHILD', 'DESC', 1, 'P2D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES ('3', '1','MASCHINELL', 'BRIEF', '', FALSE, CURRENT_TIMESTAMP, 'ANOTHER CHILD', 'DESC', 1, 'P2D', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
INSERT INTO CLASSIFICATION VALUES ('4', '2','PROZESS', 'EXCEL-SHEET', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'GRANDCHILD', 'DESC', 1, 'P1DT4H12S', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES ('4', '2','PROZESS', 'EXCEL-SHEET', '', TRUE, CURRENT_TIMESTAMP, 'GRANDCHILD', 'DESC', 1, 'P1DT4H12S', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, '9999-12-31');
INSERT INTO CLASSIFICATION VALUES('13', '3', 'MANUELL', '', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'ANOTHER GRANDCHILD', 'DESC', 3, 'P3DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES('13', '3', 'MANUELL', '', '', TRUE, CURRENT_TIMESTAMP, 'ANOTHER GRANDCHILD', 'DESC', 3, 'P3DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
INSERT INTO CLASSIFICATION VALUES('14', '4', 'MANUELL', '', 'nova-domain', FALSE, CURRENT_TIMESTAMP, 'BIG GRANDCHILD', 'DESC', 2, 'P2DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES('14', '4', 'MANUELL', '', '', FALSE, CURRENT_TIMESTAMP, 'BIG GRANDCHILD', 'DESC', 2, 'P2DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
INSERT INTO CLASSIFICATION VALUES('15', '3', 'PROZESS', 'MINDMAP', 'nova-domain', FALSE, CURRENT_TIMESTAMP, 'SMALL GRANDCHILD', 'DESC', 4, 'P5DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES('15', '3', 'PROZESS', 'MINDMAP', 'nova-domain', FALSE, CURRENT_TIMESTAMP, 'SMALL GRANDCHILD', 'DESC', 4, 'P5DT12H', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
INSERT INTO CLASSIFICATION VALUES('16', '4', 'MANUELL', '', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'NO GRANDCHILD', 'DESC', 3, 'P3DT', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO CLASSIFICATION VALUES('16', '4', 'MANUELL', '', 'nova-domain', TRUE, CURRENT_TIMESTAMP, 'NO GRANDCHILD', 'DESC', 3, 'P3DT', 'custom 1', 'custom 2', 'custom 3', 'custom 4', 'custom 5', 'custom 6', 'custom 7', 'custom 8', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

View File

@ -1,19 +1,19 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { TaskComponent } from './task/task.component'; import { TaskComponent } from './task/task.component';
import { TasksComponent } from './tasks/tasks.component'; import { TasksComponent } from './tasks/tasks.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
{ {
path: 'tasks', path: 'tasks',
component: TasksComponent component: TasksComponent
}, },
{ {
path: 'tasks/:id', path: 'tasks/:id',
component: TaskComponent component: TaskComponent
}, },
{ {
path: '', path: '',
redirectTo: 'tasks', redirectTo: 'tasks',
pathMatch: 'full' pathMatch: 'full'
@ -29,4 +29,4 @@
RouterModule RouterModule
] ]
}) })
export class AppRoutingModule {} export class AppRoutingModule {}

View File

@ -1,5 +1,5 @@
export class Task { export class Task {
id: string; id: string;
created: any; created: any;
claimed: any; claimed: any;
@ -14,12 +14,12 @@ export class Task {
type: string; type: string;
workbasket: string; workbasket: string;
owner: string; owner: string;
static create(data){ static create(data) {
return new Task(data); return new Task(data);
} }
constructor(data){ constructor(data) {
this.id = data.id; this.id = data.id;
this.created = data.created; this.created = data.created;
this.claimed = data.claimed; this.claimed = data.claimed;
@ -35,4 +35,4 @@ export class Task {
this.workbasket = data.workbasket; this.workbasket = data.workbasket;
this.owner = data.owner; this.owner = data.owner;
} }
} }

View File

@ -1,9 +1,8 @@
export class Workbasket { export class Workbasket {
id: string; id: string;
tenant_id: string;
created: string; created: string;
modified: string; modified: string;
name: string; name: string;
description: string; description: string;
owner: string; owner: string;
} }

View File

@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
@Injectable() @Injectable()
export class DataService { export class DataService {
workbasketId: string; workbasketId: string;
workbasketName: string; workbasketName: string;
} }

View File

@ -12,38 +12,40 @@ export class RestConnectorService {
constructor(private http: Http) { } constructor(private http: Http) { }
getAllWorkBaskets(): Observable<Workbasket[]> { getAllWorkBaskets(): Observable<Workbasket[]> {
return this.http.get(environment.taskanaRestUrl + "/v1/workbaskets?requiredPermission=OPEN", this.createAuthorizationHeader()) return this.http.get(environment.taskanaRestUrl + '/v1/workbaskets?requiredPermission=OPEN', this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
findTaskWithWorkbaskets(basketName: string): Observable<Task[]> { findTaskWithWorkbaskets(basketName: string): Observable<Task[]> {
return this.http.get(environment.taskanaRestUrl + "/v1/tasks?workbasketid=" + basketName + "&state=READY&state=CLAIMED", this.createAuthorizationHeader()) return this.http.get(environment.taskanaRestUrl + '/v1/tasks?workbasketid='
+ basketName + '&state=READY&state=CLAIMED', this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
getTask(id: string): Observable<Task> { getTask(id: string): Observable<Task> {
return this.http.get(environment.taskanaRestUrl + "/v1/tasks/" + id, this.createAuthorizationHeader()) return this.http.get(environment.taskanaRestUrl + '/v1/tasks/' + id, this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
completeTask(id: string): Observable<Task> { completeTask(id: string): Observable<Task> {
return this.http.post(environment.taskanaRestUrl + "/v1/tasks/" + id + "/complete", "", this.createAuthorizationHeader()) return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + id + '/complete', '', this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
claimTask(id: string): Observable<Task> { claimTask(id: string): Observable<Task> {
return this.http.post(environment.taskanaRestUrl + "/v1/tasks/" + id + "/claim", "test", this.createAuthorizationHeader()) return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + id + '/claim', 'test', this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
transferTask(taskId: string, workbasketId: string) { transferTask(taskId: string, workbasketId: string) {
return this.http.post(environment.taskanaRestUrl + "/v1/tasks/" + taskId + "/transfer/" + workbasketId, "", this.createAuthorizationHeader()) return this.http.post(environment.taskanaRestUrl + '/v1/tasks/' + taskId
+ '/transfer/' + workbasketId, '', this.createAuthorizationHeader())
.map(res => res.json()); .map(res => res.json());
} }
private createAuthorizationHeader() { private createAuthorizationHeader() {
let headers: Headers = new Headers(); const headers: Headers = new Headers();
headers.append("Authorization", "Basic TWF4OnRlc3Q="); headers.append('Authorization', 'Basic TWF4OnRlc3Q=');
return new RequestOptions({ headers: headers }); return new RequestOptions({ headers: headers });
} }

View File

@ -1,9 +1,11 @@
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-brand" href="#"> <p>
<p>{{ task?.name }}</p> <a class="navbar-brand" href="#">
</a> {{ task?.name }}
</a>
</p>
</div> </div>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li><input class="form-control" auto-complete [(ngModel)]="workbasket" [source]="autoCompleteData" placeholder="Transfer ..." style="margin-top:10px;"/></li> <li><input class="form-control" auto-complete [(ngModel)]="workbasket" [source]="autoCompleteData" placeholder="Transfer ..." style="margin-top:10px;"/></li>

View File

@ -14,7 +14,7 @@ import { SafeResourceUrl, DomSanitizer} from '@angular/platform-browser';
export class TaskComponent implements OnInit { export class TaskComponent implements OnInit {
task: Task = null; task: Task = null;
link: SafeResourceUrl = this.sanitizer.bypassSecurityTrustResourceUrl("https://duckduckgo.com/?q="); link: SafeResourceUrl = this.sanitizer.bypassSecurityTrustResourceUrl('https://duckduckgo.com/?q=');
autoCompleteData: string[] = new Array; autoCompleteData: string[] = new Array;
workbasket: string = null; workbasket: string = null;
workbasketId: string; workbasketId: string;
@ -22,18 +22,20 @@ export class TaskComponent implements OnInit {
private sub: any; private sub: any;
constructor(private restConnectorService:RestConnectorService, private route:ActivatedRoute, private router:Router, private sanitizer: DomSanitizer) { } constructor(private restConnectorService: RestConnectorService,
private route: ActivatedRoute, private router: Router,
private sanitizer: DomSanitizer) { }
ngOnInit() { ngOnInit() {
let id = this.route.snapshot.params['id']; const id = this.route.snapshot.params['id'];
this.restConnectorService.getTask(id).subscribe( this.restConnectorService.getTask(id).subscribe(
t => { t => {
this.task = t; this.task = t;
this.link = this.sanitizer.bypassSecurityTrustResourceUrl("https://duckduckgo.com/?q=" + this.task.name ); this.link = this.sanitizer.bypassSecurityTrustResourceUrl('https://duckduckgo.com/?q=' + this.task.name );
this.restConnectorService.getAllWorkBaskets().subscribe( w => { this.restConnectorService.getAllWorkBaskets().subscribe( w => {
this.workbaskets = w; this.workbaskets = w;
this.workbaskets.forEach(workbasket => { this.workbaskets.forEach(workbasket => {
if(workbasket.id != this.task.workbasket) { if (workbasket.id !== this.task.workbasket) {
this.autoCompleteData.push(workbasket.name); this.autoCompleteData.push(workbasket.name);
} }
}); });
@ -42,9 +44,9 @@ export class TaskComponent implements OnInit {
} }
transferTask() { transferTask() {
if(this.workbasket) { if (this.workbasket) {
this.workbaskets.forEach(workbasket => { this.workbaskets.forEach(workbasket => {
if (workbasket.name == this.workbasket) { if (workbasket.name === this.workbasket) {
this.workbasketId = workbasket.id; this.workbasketId = workbasket.id;
} }
}); });

View File

@ -16,4 +16,4 @@
<p><b>Type:</b> {{ task.type }}</p> <p><b>Type:</b> {{ task.type }}</p>
<p><b>Workbasket:</b> {{ task.workbasket }}</p> <p><b>Workbasket:</b> {{ task.workbasket }}</p>
</div> </div>
<div> </div>

View File

@ -11,10 +11,9 @@ export class TaskdetailsComponent implements OnInit {
@Input() @Input()
task: Task = null; task: Task = null;
constructor() { constructor() {
} }
ngOnInit() { ngOnInit() {
} }
} }

View File

@ -1,11 +1,13 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<th class="clickable" (click)="orderTasks('id')">ID</th> <tr>
<th class="clickable" (click)="orderTasks('name')">Name</th> <th class="clickable" (click)="orderTasks('id')">ID</th>
<th class="clickable" (click)="orderTasks('due')">Due Date</th> <th class="clickable" (click)="orderTasks('name')">Name</th>
<th class="clickable" (click)="orderTasks('priority')">Priority</th> <th class="clickable" (click)="orderTasks('due')">Due Date</th>
<th class="clickable" (click)="orderTasks('state')">State</th> <th class="clickable" (click)="orderTasks('priority')">Priority</th>
<th>Actions</th> <th class="clickable" (click)="orderTasks('state')">State</th>
<th>Actions</th>
</tr>
</thead> </thead>
<tr *ngFor="let task of tasks"> <tr *ngFor="let task of tasks">
<td>{{ task.id }}</td> <td>{{ task.id }}</td>

View File

@ -17,18 +17,18 @@ export class TasklistComponent implements OnInit {
@Input() tasks: Task[]; @Input() tasks: Task[];
constructor(private restConnectorService:RestConnectorService, private router:Router) { constructor(private restConnectorService: RestConnectorService, private router: Router) {
this.columnForOrdering = 'id'; // default: order tasks by id this.columnForOrdering = 'id'; // default: order tasks by id
} }
ngOnInit() { ngOnInit() {
} }
selectTask(task: Task) { selectTask(task: Task) {
this.task.next(task); this.task.next(task);
} }
orderTasks(column:string) { orderTasks(column: string) {
this.columnForOrdering = column; this.columnForOrdering = column;
} }

View File

@ -1,9 +1,9 @@
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-brand" href="#"> <p>
<p>Taskana Workplace</p> <a class="navbar-brand" href="#">Taskana Workplace</a>
</a> </p>
</div> </div>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li><a [href]="adminUrl">Admin</a></li> <li><a [href]="adminUrl">Admin</a></li>

View File

@ -18,11 +18,11 @@ export class TasksComponent {
@Input() @Input()
task: Task; task: Task;
loadTasks(tasks: Task[]){ loadTasks(tasks: Task[]) {
this.tasks = tasks; this.tasks = tasks;
} }
selectTask(task: Task){ selectTask(task: Task) {
this.task = task; this.task = task;
} }

View File

@ -7,15 +7,18 @@ import { Task } from '../model/task';
}) })
export class OrderTasksByPipe implements PipeTransform { export class OrderTasksByPipe implements PipeTransform {
transform(value:Task[], column:string) { transform(value: Task[], column: string) {
if(value === null) return null; if (value === null) { return null; }
value.sort((a, b) => { value.sort((a, b) => {
if(typeof a[column] === 'string') return _compareString(a[column], b[column]); if (typeof a[column] === 'string') {
else return _compareNumber(a[column], b[column]); return _compareString(a[column], b[column]);
} else {
return _compareNumber(a[column], b[column]);
}
}); });
return value; return value;
function _compareString(a:string, b:string): number { function _compareString(a: string, b: string): number {
if (a.toLowerCase() < b.toLowerCase()) { if (a.toLowerCase() < b.toLowerCase()) {
return -1; return -1;
} else if (a.toLowerCase() > b.toLowerCase()) { } else if (a.toLowerCase() > b.toLowerCase()) {
@ -24,9 +27,9 @@ export class OrderTasksByPipe implements PipeTransform {
return 0; return 0;
} }
} }
function _compareNumber(a:number, b:number): number { function _compareNumber(a: number, b: number): number {
return _compareString(a.toString(), b.toString()); return _compareString(a.toString(), b.toString());
} }
} }
} }

View File

@ -27,23 +27,23 @@ export class SelectorComponent implements OnInit {
this.autoCompleteData.push(workbasket.name); this.autoCompleteData.push(workbasket.name);
}); });
}); });
if(this.dataService.workbasketId) { if (this.dataService.workbasketId) {
this.getTasks(this.dataService.workbasketId); this.getTasks(this.dataService.workbasketId);
this.result = this.dataService.workbasketName; this.result = this.dataService.workbasketName;
} }
} }
searchBasket() { searchBasket() {
if(this.workbaskets) { if (this.workbaskets) {
this.workbaskets.forEach(workbasket => { this.workbaskets.forEach(workbasket => {
if (workbasket.name == this.result) { if (workbasket.name === this.result) {
this.resultId = workbasket.id; this.resultId = workbasket.id;
} }
}); });
this.getTasks(this.resultId); this.getTasks(this.resultId);
this.dataService.workbasketId = this.resultId; this.dataService.workbasketId = this.resultId;
this.dataService.workbasketName = this.result; this.dataService.workbasketName = this.result;
} }
} }
getTasks(id: string) { getTasks(id: string) {