66 lines
4.4 KiB
Java
66 lines
4.4 KiB
Java
package eu.eudat.logic.managers;
|
|
|
|
import eu.eudat.commons.enums.DescriptionStatus;
|
|
import eu.eudat.commons.enums.DmpStatus;
|
|
import eu.eudat.commons.enums.IsActive;
|
|
import eu.eudat.commons.scope.user.UserScope;
|
|
import eu.eudat.data.DescriptionEntity;
|
|
import eu.eudat.data.DmpEntity;
|
|
import eu.eudat.data.UserEntity;
|
|
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
|
|
import eu.eudat.logic.services.ApiContext;
|
|
import eu.eudat.queryable.QueryableList;
|
|
import gr.cite.tools.data.query.QueryFactory;
|
|
|
|
import javax.management.InvalidApplicationException;
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
|
|
public class DatasetWizardManager {
|
|
|
|
// public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserScope userScope) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
|
// UserEntity userInfo = new UserEntity();
|
|
// userInfo.setId(userScope.getUserId());
|
|
// QueryableList<DmpEntity> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest.getCriteria(), userInfo);
|
|
// List<DataManagentPlanListingModel> dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item));
|
|
// return dataManagementPlans;
|
|
// }
|
|
|
|
// public static List<AssociatedProfile> getAvailableProfiles(DMPDao dmpRepository, DatasetProfileDao profileDao, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
|
// DataManagementPlan dataManagementPlan = new DataManagementPlan().fromDataModel(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()));
|
|
// if (dataManagementPlan.getProfiles() == null || dataManagementPlan.getProfiles().isEmpty()) {
|
|
// return new LinkedList<>();
|
|
// }
|
|
// DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
|
// criteria.setIds(dataManagementPlan.getProfiles().stream().map(AssociatedProfile::getDescriptionTemplateId).collect(Collectors.toList()));
|
|
// List<DescriptionTemplateEntity> descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
|
// criteria.setIds(null);
|
|
// criteria.setGroupIds(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getGroupId).collect(Collectors.toList()));
|
|
// descriptionTemplateEntities = profileDao.getWithCriteria(criteria).toList();
|
|
// List<AssociatedProfile> profiles = descriptionTemplateEntities.stream().map(profile -> new AssociatedProfile().fromData(profile)).collect(Collectors.toList());
|
|
// return profiles;
|
|
// }
|
|
|
|
// public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
|
// DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
|
// DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDescriptionTemplateId());
|
|
// if(dmp.getStatus().equals(DmpStatus.Finalized)) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
|
// descriptionEntity.setStatus(DescriptionStatus.Draft);
|
|
// apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
|
// return;
|
|
// }
|
|
|
|
public void delete(ApiContext apiContext, UUID uuid) throws IOException, InvalidApplicationException {
|
|
DescriptionEntity oldDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
|
// eu.eudat.elastic.entities.Dataset oldDatasetElasitc = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(uuid.toString()); //TODO
|
|
oldDescriptionEntity.setIsActive(IsActive.Inactive);
|
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(oldDescriptionEntity);
|
|
// if (oldDatasetElasitc != null && uuid != null && oldDatasetElasitc.getId()!= null) {
|
|
// oldDatasetElasitc.setStatus(oldDescriptionEntity.getStatus().getValue());
|
|
// apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(oldDatasetElasitc);
|
|
// }
|
|
}
|
|
}
|