Fix Delete DMP If hasn't Dataset

This commit is contained in:
Diamantis Tziotzios 2019-02-15 17:11:38 +02:00
parent 3f97ab9f41
commit f6ef760e99
1 changed files with 6 additions and 6 deletions

View File

@ -2,10 +2,7 @@ package eu.eudat.logic.managers;
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
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.criteria.*;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.entities.*;
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 {
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
if (oldDmp.getDataset().size() > 0)
DatasetCriteria criteria = new DatasetCriteria();
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");
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
oldDmp.setStatus(DMP.DMPStatus.DELETED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(oldDmp);
}