Review-fixed (Classification). Domain berücksichtigt, Status im Controller inzugefügt, ValidUntil berücksichtigt.
This commit is contained in:
parent
6b885ab0ec
commit
f0b8e6742a
|
@ -114,13 +114,13 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
@Override
|
||||
public Classification getClassification(String id, String domain) {
|
||||
Classification classification = classificationMapper.findByIdAndDomain(id, domain, CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
|
||||
if (classification == null) {
|
||||
return classificationMapper.findByIdAndDomain(id, "", CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
Classification classification;
|
||||
if (domain == null) {
|
||||
classification = classificationMapper.findByIdAndDomain(id, "", CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
} else {
|
||||
return classification;
|
||||
classification = classificationMapper.findByIdAndDomain(id, domain, CURRENT_CLASSIFICATIONS_VALID_UNTIL);
|
||||
}
|
||||
return classification;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
package pro.taskana.model.mappings;
|
||||
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import pro.taskana.model.Classification;
|
||||
|
||||
import java.sql.Date;
|
||||
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.
|
||||
*/
|
||||
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 "
|
||||
+ "FROM CLASSIFICATION "
|
||||
+ "WHERE ID = #{id}"
|
||||
|
@ -41,7 +49,8 @@ public interface ClassificationMapper {
|
|||
|
||||
@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}")
|
||||
+ "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"),
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
package pro.taskana.impl;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -7,19 +20,12 @@ import org.mockito.InjectMocks;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.persistence.TestClassificationQuery;
|
||||
import pro.taskana.model.Classification;
|
||||
import pro.taskana.model.mappings.ClassificationMapper;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Unit Test for ClassificationServiceImpl.
|
||||
* @author EH
|
||||
|
|
|
@ -20,24 +20,34 @@ public class ClassificationController {
|
|||
@Autowired
|
||||
private ClassificationService classificationService;
|
||||
|
||||
@RequestMapping
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public ResponseEntity<List<Classification>> getClassifications() {
|
||||
try {
|
||||
List<Classification> classificationTree = classificationService.getClassificationTree();
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(classificationTree);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(classificationTree);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{classificationId}")
|
||||
public Classification getClassification(@PathVariable String classificationId) {
|
||||
return classificationService.getClassification(classificationId, "nova-domain");
|
||||
@RequestMapping(value = "/{classificationId}", method = RequestMethod.GET)
|
||||
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}")
|
||||
public Classification getClassification(@PathVariable String classificationId, @PathVariable String domain) {
|
||||
return classificationService.getClassification(classificationId, domain);
|
||||
@RequestMapping(value = "/{classificationId}/{domain}", method = RequestMethod.GET)
|
||||
public ResponseEntity<Classification> getClassification(@PathVariable String classificationId, @PathVariable String 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)
|
||||
|
|
|
@ -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, '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, '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 ('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 ('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', '', 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('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('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', '', '', 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('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);
|
||||
|
|
Loading…
Reference in New Issue