changes regarding soft deletes
This commit is contained in:
parent
b59e8cc730
commit
69ad9164ee
|
@ -24,7 +24,7 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> listAllIDs() {
|
public List<UUID> listAllIDs() {
|
||||||
String queryString = "SELECT dmp.id FROM DMP dmp";
|
String queryString = "SELECT dmp.id FROM DMP dmp where dmp.status>=0";
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
||||||
return typedQuery.getResultList();
|
return typedQuery.getResultList();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
public List<IDLabelPair> listAllIDsLabels() {
|
||||||
String queryString = "SELECT dmp.id, dmp.label FROM DMP dmp";
|
String queryString = "SELECT dmp.id, dmp.label FROM DMP dmp where dmp.status>=0";
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
Query query = (Query) entityManager.createQuery(queryString);
|
||||||
List<Object[]> rows = query.list();
|
List<Object[]> rows = query.list();
|
||||||
return rows.stream().map(row -> {
|
return rows.stream().map(row -> {
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> listAllIDs() {
|
public List<UUID> listAllIDs() {
|
||||||
String queryString = "SELECT dataset.id FROM Dataset dataset";
|
String queryString = "SELECT dataset.id FROM Dataset dataset where dataset.status>=0";
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
||||||
return typedQuery.getResultList();
|
return typedQuery.getResultList();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
public List<IDLabelPair> listAllIDsLabels() {
|
||||||
String queryString = "SELECT dataset.id, dataset.label FROM Dataset dataset";
|
String queryString = "SELECT dataset.id, dataset.label FROM Dataset dataset where dataset.status>=0";
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
Query query = (Query) entityManager.createQuery(queryString);
|
||||||
List<Object[]> rows = query.getResultList();
|
List<Object[]> rows = query.getResultList();
|
||||||
return rows.stream().map(row -> {
|
return rows.stream().map(row -> {
|
||||||
|
@ -41,7 +41,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Dataset> getDatasetsOfDmp(UUID dmpID) {
|
public List<Dataset> getDatasetsOfDmp(UUID dmpID) {
|
||||||
String queryString = "FROM Dataset dataset where dataset.dmp.id=:dmpID";
|
String queryString = "FROM Dataset dataset where dataset.dmp.id=:dmpID and dataset.status>=0";
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
Query query = (Query) entityManager.createQuery(queryString);
|
||||||
query.setParameter("dmpID", dmpID);
|
query.setParameter("dmpID", dmpID);
|
||||||
List<Dataset> datasets = (List<Dataset>) query.getResultList();
|
List<Dataset> datasets = (List<Dataset>) query.getResultList();
|
||||||
|
|
|
@ -279,6 +279,24 @@ public class DMPs {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||||
|
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody DMP dmp) {
|
||||||
|
|
||||||
|
DMP d = dMPDao.read(dmp.getId());
|
||||||
|
d.setStatus(new Short("-1"));
|
||||||
|
try {
|
||||||
|
int code = updateDMP(dmp).getStatusCodeValue();
|
||||||
|
if(code>199 && code<300)
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
||||||
|
else
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\"");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,27 @@ public class Datasets {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||||
|
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Dataset dataset) {
|
||||||
|
|
||||||
|
Dataset d = datasetDao.read(dataset.getId());
|
||||||
|
d.setStatus(new Short("-1"));
|
||||||
|
try {
|
||||||
|
int code = updateDataset(SerializerProvider.toJson(d)).getStatusCodeValue();
|
||||||
|
if(code>199 && code<300)
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
||||||
|
else
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete dataset!\"");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete dataset!\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignDMPToDataset" })
|
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignDMPToDataset" })
|
||||||
public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {
|
public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue