Review-fixed (Classification). Domain berücksichtigt, Status im Controller inzugefügt, ValidUntil berücksichtigt.

This commit is contained in:
Marcel Lengl 2017-11-27 09:44:13 +01:00 committed by BerndBreier
parent dc02e33233
commit c1188a561d
4 changed files with 36 additions and 17 deletions

View File

@ -147,7 +147,6 @@ public class ClassificationServiceImpl implements ClassificationService {
taskanaEngineImpl.openConnection();
Classification result = null;
Classification classification = classificationMapper.findByIdAndDomain(id, domain, CURRENT_CLASSIFICATIONS_VALID_UNTIL);
if (classification == null) {
return classificationMapper.findByIdAndDomain(id, "", CURRENT_CLASSIFICATIONS_VALID_UNTIL);
} else {
@ -156,6 +155,7 @@ public class ClassificationServiceImpl implements ClassificationService {
} finally {
taskanaEngineImpl.returnConnection();
}
}
@Override

View File

@ -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"),

View File

@ -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)

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, '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);