package eu.eudat.managers; import eu.eudat.dao.entities.DMPDao; import eu.eudat.dao.entities.DatasetDao; import eu.eudat.entities.DMP; import eu.eudat.entities.Dataset; import eu.eudat.entities.UserInfo; import eu.eudat.models.datasetwizard.DataManagentPlanListingModel; import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest; import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest; import eu.eudat.models.dmp.AssociatedProfile; import eu.eudat.models.dmp.DataManagementPlan; import eu.eudat.models.listingmodels.DatasetListingModel; import eu.eudat.models.security.Principal; import eu.eudat.queryable.QueryableList; import eu.eudat.utilities.builders.DomainModelConverter; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; public class DatasetWizardManager { public static List getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) throws InstantiationException, IllegalAccessException { UserInfo userInfo = new UserInfo(); userInfo.setId(principal.getId()); QueryableList items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest,userInfo); List dataManagementPlans = new DomainModelConverter().fromDataModel( items.toList(), DataManagentPlanListingModel.class); return dataManagementPlans; } public static List getAvailableProfiles(DMPDao dmpRepository, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException { DataManagementPlan dataManagementPlan = new DomainModelConverter().fromDataModel(new LinkedList(Arrays.asList(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()))),DataManagementPlan.class).get(0); if(dataManagementPlan.getProfiles()==null||dataManagementPlan.getProfiles().isEmpty()){ return new LinkedList<>(); } List profiles = dataManagementPlan.getProfiles(); return profiles; } }