Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot

This commit is contained in:
annampak 2017-11-02 19:15:07 +02:00
commit c7f1a24077
5 changed files with 45 additions and 6 deletions

View File

@ -24,7 +24,7 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
@Override
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);
return typedQuery.getResultList();
}
@ -32,7 +32,7 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
@Override
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);
List<Object[]> rows = query.list();
return rows.stream().map(row -> {

View File

@ -22,7 +22,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
@Override
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);
return typedQuery.getResultList();
}
@ -30,7 +30,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
@Override
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);
List<Object[]> rows = query.getResultList();
return rows.stream().map(row -> {
@ -41,7 +41,7 @@ public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao
@Override
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.setParameter("dmpID", dmpID);
List<Dataset> datasets = (List<Dataset>) query.getResultList();

View File

@ -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!\"");
}
}

View File

@ -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" })
public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {

View File

@ -52,10 +52,10 @@
<tr *ngFor="let dataset of mf.data" class="hover">
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{dataset.id}}</td>
<td>{{dataset?.label}}</td>
<td>{{dataset?.status}}</td>
<td>{{dataset?.uri}}</td>
<td>{{dataset?.profile?.label}}</td>
<td>{{dataset?.description}}</td>
<td>{{dataset?.status}}</td>
<td><a class="editGridColumn" (click)="editRow(dataset, $event)"><i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit Properties" id="editDataset"></i>
<i class="fa fa-eraser fa-fw" data-toggle="tooltip" title="delete Dataset"></i>
<i class="fa fa-list-alt fa-fw" data-toggle="tooltip" title="describe dataset" id="describeDataset"></i></a></td>