Fix Delete DMP If hasn't Dataset
This commit is contained in:
parent
3f97ab9f41
commit
f6ef760e99
|
@ -2,10 +2,7 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
|
||||||
import eu.eudat.configurations.dynamicproject.entities.Property;
|
import eu.eudat.configurations.dynamicproject.entities.Property;
|
||||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.ResearcherCriteria;
|
|
||||||
import eu.eudat.data.dao.entities.*;
|
import eu.eudat.data.dao.entities.*;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.*;
|
||||||
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
|
||||||
|
@ -277,9 +274,12 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsDeleteException {
|
public void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsDeleteException {
|
||||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
DatasetCriteria criteria = new DatasetCriteria();
|
||||||
if (oldDmp.getDataset().size() > 0)
|
List<UUID> dmpIds = Collections.singletonList(uuid);
|
||||||
|
criteria.setDmpIds(dmpIds);
|
||||||
|
if (apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(criteria).toList().size()>0)
|
||||||
throw new DMPWithDatasetsDeleteException("You cannot Remove Datamanagement Plan with Datasets");
|
throw new DMPWithDatasetsDeleteException("You cannot Remove Datamanagement Plan with Datasets");
|
||||||
|
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||||
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
|
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue