make grant funder not mandatory for the creation/new version/clone of dmp

This commit is contained in:
Bernaldo Mihasi 2023-09-18 17:48:54 +03:00
parent bfa310a074
commit 93c5918251
16 changed files with 294 additions and 130 deletions

View File

@ -46,9 +46,9 @@ public class QuickWizardController extends BaseController {
Funder funderEntity;
//Create Funder
if (quickWizard.getFunder() == null) {
throw new Exception("Funder is a mandatory entity");
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
throw new Exception("Funder is a mandatory entity");
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
} else {
@ -58,9 +58,9 @@ public class QuickWizardController extends BaseController {
eu.eudat.data.entities.Grant grantEntity;
//Create Grant
if (quickWizard.getGrant() == null) {
throw new Exception("Grant is a mandatory entity");
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
throw new Exception("Grant is a mandatory entity");
grantEntity = null;
} else if (quickWizard.getGrant().getExistGrant() == null) {
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
} else {

View File

@ -91,7 +91,9 @@ public class DashBoardManager {
for (DMP dmp : dmps) {
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
grants.add(dmp.getGrant());
if (dmp.getGrant() != null) {
grants.add(dmp.getGrant());
}
}
statistics.setTotalDataManagementPlanCount((long) dmps.size());

View File

@ -53,6 +53,7 @@ import eu.eudat.models.data.doi.Doi;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
import eu.eudat.models.data.funder.FunderDMPEditorModel;
import eu.eudat.models.data.grant.GrantDMPEditorModel;
import eu.eudat.models.data.helpermodels.Tuple;
@ -110,6 +111,7 @@ public class DataManagementPlanManager {
private ApiContext apiContext;
private DatasetManager datasetManager;
private DataManagementProfileManager dataManagementProfileManager;
private DatabaseRepository databaseRepository;
private Environment environment;
private RDAManager rdaManager;
@ -119,10 +121,11 @@ public class DataManagementPlanManager {
private List<RepositoryDeposit> repositoriesDeposit;
@Autowired
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager,
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, DataManagementProfileManager dataManagementProfileManager, Environment environment, RDAManager rdaManager, UserManager userManager,
MetricsManager metricsManager, ConfigLoader configLoader, List<RepositoryDeposit> repositoriesDeposit) {
this.apiContext = apiContext;
this.datasetManager = datasetManager;
this.dataManagementProfileManager = dataManagementProfileManager;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.environment = environment;
this.rdaManager = rdaManager;
@ -486,14 +489,24 @@ public class DataManagementPlanManager {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
newDmp.setCreator(user);
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
if (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty()) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS, principal)) {
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS, principal)) {
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
}
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao());
}
}
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao());
DMP dmp;
if (dataManagementPlan.getId() != null) {
@ -513,12 +526,18 @@ public class DataManagementPlanManager {
}
}
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
assignFunderUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
assignProjectUserIfInternal(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
assignFunderUserIfInternal(newDmp, user);
assignProjectUserIfInternal(newDmp, user);
if(newDmp.getId() != null){
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
@ -526,7 +545,9 @@ public class DataManagementPlanManager {
}
}
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
}
newDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
for(DMPDatasetProfile dmpDatasetProfile : newDmp.getAssociatedDmps()){
@ -622,10 +643,18 @@ public class DataManagementPlanManager {
checkDmpValidationRules(tempDMP);
}
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.ORGANIZATIONS, principal)) {
createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.RESEARCHERS, principal)) {
createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.FUNDER, principal)) {
createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.GRANT, principal)) {
createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao());
}
DMP result = createOrUpdate(dataManagementPlan, principal);
@ -660,31 +689,50 @@ public class DataManagementPlanManager {
DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
newDmp.setCreator(user);
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
if (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty()) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS, principal)) {
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS, principal)) {
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
}
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
}
}
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
newDmp.setGroupId(oldDmp.getGroupId());
newDmp.setVersion(oldDmp.getVersion() + 1);
newDmp.setId(null);
checkIfUserCanEditGrant(newDmp, user);
assignGrandUserIfInternal(newDmp, user);
assignFunderUserIfInternal(newDmp, user);
assignProjectUserIfInternal(newDmp, user);
if (newDmp.getGrant().getStartdate() == null) {
newDmp.getGrant().setStartdate(new Date());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
}
if (newDmp.getGrant().getEnddate() == null) {
newDmp.getGrant().setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
assignFunderUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
assignProjectUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getStartdate() == null) {
newDmp.getGrant().setStartdate(new Date());
}
if (newDmp.getGrant().getEnddate() == null) {
newDmp.getGrant().setEnddate(Date.from(Instant.now().plus(365, ChronoUnit.DAYS)));
}
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
}
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
newDmp.setId(tempDmp.getId());
@ -721,25 +769,44 @@ public class DataManagementPlanManager {
UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
newDmp.setCreator(user);
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
if (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty()) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS, principal)) {
createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS, principal)) {
createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao());
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
}
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
}
}
createProjectIfItDoesntExist(newDmp, databaseRepository.getProjectDao());
newDmp.setGroupId(UUID.randomUUID());
newDmp.setVersion(0);
newDmp.setId(null);
checkIfUserCanEditGrant(newDmp, user);
assignGrandUserIfInternal(newDmp, user);
assignFunderUserIfInternal(newDmp, user);
assignProjectUserIfInternal(newDmp, user);
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) {
checkIfUserCanEditGrant(newDmp, user);
}
assignGrandUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER, principal)) {
assignFunderUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT, principal)) {
assignProjectUserIfInternal(newDmp, user);
}
if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT, principal)) {
databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant());
}
DMP tempDmp = databaseRepository.getDmpDao().createOrUpdate(newDmp);
newDmp.setId(tempDmp.getId());
@ -882,7 +949,7 @@ public class DataManagementPlanManager {
}
private void createFunderIfItDoesntExist(DMP newDmp, FunderDao funderDao) {
if (newDmp.getGrant().getFunder() != null) {
if (newDmp.getGrant() != null && newDmp.getGrant().getFunder() != null) {
Funder funder = newDmp.getGrant().getFunder();
FunderCriteria criteria = new FunderCriteria();
if (funder.getReference() != null) {
@ -1005,7 +1072,9 @@ public class DataManagementPlanManager {
datasetElastic.setStatus(dataset1.getStatus());
datasetElastic.setDmp(dataset1.getDmp().getId());
datasetElastic.setGroup(dataset1.getDmp().getGroupId());
datasetElastic.setGrant(dataset1.getDmp().getGrant().getId());
if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), SystemFieldType.GRANT, null)) {
datasetElastic.setGrant(dataset1.getDmp().getGrant().getId());
}
if (dataset1.getDmp().getUsers() != null) {
datasetElastic.setCollaborators(dataset1.getDmp().getUsers().stream().map(user -> {
Collaborator collaborator = new Collaborator();
@ -1026,7 +1095,9 @@ public class DataManagementPlanManager {
}).collect(Collectors.toList()));
}
datasetElastic.setPublic(dataset1.getDmp().isPublic());
datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus());
if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), SystemFieldType.GRANT, null)) {
datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus());
}
try {
eu.eudat.elastic.entities.Dataset oldDatasetElastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
@ -1660,53 +1731,59 @@ public class DataManagementPlanManager {
// Funder.
Element funder = xmlDoc.createElement("funder");
Element funderLabel = xmlDoc.createElement("label");
Element funderId = xmlDoc.createElement("id");
funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel());
funderId.setTextContent(dmp.getGrant().getFunder().getId().toString());
funder.appendChild(funderLabel);
funder.appendChild(funderId);
if(dmp.getGrant().getFunder().getReference() != null){
String referencePrefix = dmp.getGrant().getFunder().getReference().split(":")[0];
String shortReference = dmp.getGrant().getFunder().getReference().substring(referencePrefix.length() + 1);
Element funderReference = xmlDoc.createElement("reference");
funderReference.setTextContent(shortReference);
funder.appendChild(funderReference);
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER, principal)) {
Element funderLabel = xmlDoc.createElement("label");
Element funderId = xmlDoc.createElement("id");
funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel());
funderId.setTextContent(dmp.getGrant().getFunder().getId().toString());
funder.appendChild(funderLabel);
funder.appendChild(funderId);
if (dmp.getGrant().getFunder().getReference() != null) {
String referencePrefix = dmp.getGrant().getFunder().getReference().split(":")[0];
String shortReference = dmp.getGrant().getFunder().getReference().substring(referencePrefix.length() + 1);
Element funderReference = xmlDoc.createElement("reference");
funderReference.setTextContent(shortReference);
funder.appendChild(funderReference);
}
}
dmpElement.appendChild(funder);
// Grant.
Element grant = xmlDoc.createElement("grant");
Element grantLabel = xmlDoc.createElement("label");
Element grantId = xmlDoc.createElement("id");
grantLabel.setTextContent(dmp.getGrant().getLabel());
grantId.setTextContent(dmp.getGrant().getId().toString());
grant.appendChild(grantLabel);
grant.appendChild(grantId);
if(dmp.getGrant().getReference() != null) {
String referencePrefix = dmp.getGrant().getReference().split(":")[0];
String shortReference = dmp.getGrant().getReference().substring(referencePrefix.length() + 1);
Element grantReference = xmlDoc.createElement("reference");
grantReference.setTextContent(shortReference);
grant.appendChild(grantReference);
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal)) {
Element grantLabel = xmlDoc.createElement("label");
Element grantId = xmlDoc.createElement("id");
grantLabel.setTextContent(dmp.getGrant().getLabel());
grantId.setTextContent(dmp.getGrant().getId().toString());
grant.appendChild(grantLabel);
grant.appendChild(grantId);
if (dmp.getGrant().getReference() != null) {
String referencePrefix = dmp.getGrant().getReference().split(":")[0];
String shortReference = dmp.getGrant().getReference().substring(referencePrefix.length() + 1);
Element grantReference = xmlDoc.createElement("reference");
grantReference.setTextContent(shortReference);
grant.appendChild(grantReference);
}
}
dmpElement.appendChild(grant);
// Project.
Element project = xmlDoc.createElement("project");
Element projectId = xmlDoc.createElement("id");
Element projectLabel = xmlDoc.createElement("label");
Element projectDescription = xmlDoc.createElement("description");
Element projectStartDate = xmlDoc.createElement("start");
Element projectEndDate = xmlDoc.createElement("end");
projectId.setTextContent(dmp.getProject().getId().toString());
projectLabel.setTextContent(dmp.getProject().getLabel());
projectDescription.setTextContent(dmp.getProject().getDescription());
projectStartDate.setTextContent(dmp.getProject().getStartdate().toString());
projectEndDate.setTextContent(dmp.getProject().getEnddate().toString());
project.appendChild(projectId);
project.appendChild(projectLabel);
project.appendChild(projectDescription);
project.appendChild(projectStartDate);
project.appendChild(projectEndDate);
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT, principal)) {
Element projectId = xmlDoc.createElement("id");
Element projectLabel = xmlDoc.createElement("label");
Element projectDescription = xmlDoc.createElement("description");
Element projectStartDate = xmlDoc.createElement("start");
Element projectEndDate = xmlDoc.createElement("end");
projectId.setTextContent(dmp.getProject().getId().toString());
projectLabel.setTextContent(dmp.getProject().getLabel());
projectDescription.setTextContent(dmp.getProject().getDescription());
projectStartDate.setTextContent(dmp.getProject().getStartdate().toString());
projectEndDate.setTextContent(dmp.getProject().getEnddate().toString());
project.appendChild(projectId);
project.appendChild(projectLabel);
project.appendChild(projectDescription);
project.appendChild(projectStartDate);
project.appendChild(projectEndDate);
}
dmpElement.appendChild(project);
Element organisationsElement = xmlDoc.createElement("organisations");

View File

@ -13,8 +13,9 @@ import eu.eudat.logic.utilities.builders.XmlBuilder;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile;
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DmpProfileExternalAutoComplete;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory;
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
import eu.eudat.models.data.helpers.common.DataTableData;
@ -101,13 +102,29 @@ public class DataManagementProfileManager {
return dataManagementPlanProfileListingModel;
}
public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id, Principal principal) throws InstantiationException, IllegalAccessException {
public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id, Principal principal) {
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = new DataManagementPlanBlueprintListingModel();
dataManagementPlanBlueprintListingModel.fromDataModel(dmpProfile);
return dataManagementPlanBlueprintListingModel;
}
public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type, Principal principal) {
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
dmpBlueprint.fromDataModel(dmpProfile);
for(Section section: dmpBlueprint.getDefinition().getSections()){
for(FieldModel field: section.getFields()){
if(field.getCategory().equals(FieldCategory.SYSTEM)){
SystemField systemField = field.toSystemField();
if(systemField.getType().equals(type)){
return true;
}
}
}
}
return false;
}
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));

View File

@ -50,7 +50,9 @@ public class DatasetMapper {
elastic.setStatus(dataset.getStatus());
elastic.setDmp(dataset.getDmp().getId());
elastic.setGroup(dataset.getDmp().getGroupId());
elastic.setGrant(dataset.getDmp().getGrant().getId());
if (dataset.getDmp().getGrant() != null) {
elastic.setGrant(dataset.getDmp().getGrant().getId());
}
elastic.setCreated(dataset.getCreated());
elastic.setModified(dataset.getModified());
elastic.setFinalizedAt(dataset.getFinalizedAt());
@ -74,7 +76,9 @@ public class DatasetMapper {
elastic.setOrganizations(dataset.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
}
elastic.setPublic(dataset.getDmp().isPublic());
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
if (dataset.getDmp().getGrant() != null) {
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
}
elastic.setFormData(datasetManager.getWordDocumentText(dataset));
return elastic;

View File

@ -37,7 +37,9 @@ public class DmpMapper {
elastic.setCollaborators(dmp.getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
}
elastic.setDescription(dmp.getDescription());
elastic.setGrant(dmp.getGrant().getId());
if (dmp.getGrant() != null) {
elastic.setGrant(dmp.getGrant().getId());
}
elastic.setLabel(dmp.getLabel());
elastic.setPublic(dmp.isPublic());
elastic.setStatus(dmp.getStatus());

View File

@ -37,7 +37,9 @@ public class DMPToDepositMapper {
deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
deposit.setGrant(fromGrant(entity.getGrant()));
if (entity.getGrant() != null) {
deposit.setGrant(fromGrant(entity.getGrant()));
}
deposit.setPdfFile(pdfFile);
deposit.setRdaJsonFile(jsonFile);

View File

@ -242,9 +242,14 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.version = entity.getVersion();
this.groupId = this.groupId == null ? null : entity.getGroupId();
this.label = entity.getLabel();
this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
this.grant.fromDataModel(entity.getGrant());
if(entity.getGrant() != null) {
this.grant = new Grant();
this.grant.fromDataModel(entity.getGrant());
}
else {
this.grant = null;
}
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId();
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
@ -296,7 +301,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.project = new Project().fromDataModel(entity.getProject());
}
if (entity.getGrant().getFunder() != null) {
if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
this.funder = new Funder();
this.funder.fromDataModel(entity.getGrant().getFunder());
}
@ -362,7 +367,6 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.version = entity.getVersion();
this.label = entity.getLabel();
this.grant = new Grant();
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
this.groupId = entity.getGroupId();
@ -398,13 +402,19 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
this.grant.fromDataModel(entity.getGrant());
if(entity.getGrant() != null) {
this.grant = new Grant();
this.grant.fromDataModel(entity.getGrant());
}
else {
this.grant = null;
}
if (entity.getProject() != null) {
this.project = new Project();
this.project = new Project().fromDataModel(entity.getProject());
}
if (entity.getGrant().getFunder() != null) {
if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
this.funder = new Funder();
this.funder.fromDataModel(entity.getGrant().getFunder());
}

View File

@ -314,13 +314,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
}
}
if (this.funder == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else if (this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else {
if (this.funder != null) {
if (this.funder.getLabel() != null) {
Funder funder = new Funder();
funder.setId(UUID.randomUUID());

View File

@ -214,13 +214,7 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
}
}
if (this.funder == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else if (this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else {
if (this.funder != null) {
if (this.funder.getLabel() != null) {
Funder funder = new Funder();
funder.setId(UUID.randomUUID());

View File

@ -147,7 +147,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.fromDataModel(entity);
this.status = entity.getStatus();
this.version = entity.getVersion();
this.grant = entity.getGrant().getLabel();
this.grant = (entity.getGrant() != null) ? entity.getGrant().getLabel() : null;
this.creationTime = entity.getCreated();
this.modifiedTime = entity.getModified();
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());

View File

@ -104,7 +104,9 @@ public class DmpRDAMapper {
}
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
if (dmp.getProject() != null) {
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
}
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
return rda;
}

View File

@ -94,7 +94,7 @@ CREATE TABLE public."DMP" (
"GroupId" uuid,
"Label" character varying(250) NOT NULL,
"Version" integer NOT NULL,
"Grant" uuid NOT NULL,
"Grant" uuid,
"AssociatedDmps" xml,
"Profile" uuid,
"Status" smallint DEFAULT 0 NOT NULL,
@ -130,7 +130,7 @@ CREATE TABLE public."DMPDatasetProfile" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
dmp uuid NOT NULL,
datasetprofile uuid NOT NULL,
"data" text
"data" text NOT NULL
);
@ -236,7 +236,7 @@ CREATE TABLE public."Dataset" (
"ID" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"DMP" uuid,
"DmpSectionIndex" integer,
"DmpSectionIndex" integer NOT NULL,
"Uri" character varying(250),
"Properties" text,
"Profile" uuid,

View File

@ -0,0 +1,12 @@
DO $$DECLARE
this_version CONSTANT varchar := '00.00.017';
BEGIN
PERFORM * FROM "DBVersion" WHERE version = this_version;
IF FOUND THEN RETURN; END IF;
ALTER TABLE public."DMP"
ALTER COLUMN "Grant" DROP NOT NULL;
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.017', '2023-09-18 12:00:00.000000+02', now(), 'Make grant column of dmp table not null.');
END$$;

View File

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
import { DmpBlueprintDefinition, SystemFieldType } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
import { DmpBlueprintDefinition, FieldCategory, SystemFieldType } from '@app/core/model/dmp/dmp-blueprint/dmp-blueprint';
import { DmpBlueprintCriteria } from '@app/core/query/dmp/dmp-blueprint-criteria';
import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
@ -178,6 +178,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
this.selectedDmpBlueprintDefinition = result.definition;
this.checkForGrant();
this.checkForFunder();
this.checkForProject();
this.formGroup.get('profile').setValue(result);
this.maxStep = this.selectedDmpBlueprintDefinition.sections.length;
this.step = 1;
@ -784,6 +787,9 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
.subscribe(Option => {
if (Option instanceof Object) {
this.selectedDmpBlueprintDefinition = Option.definition;
this.checkForGrant();
this.checkForFunder();
this.checkForProject();
this.addProfiles();
}
else {
@ -792,6 +798,48 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
})
}
private checkForGrant() {
let hasGrant = false;
this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach(
field => {
if (field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.GRANT) {
hasGrant = true;
}
}
));
if (!hasGrant) {
this.formGroup.removeControl('grant');
}
}
private checkForFunder() {
let hasFunder = false;
this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach(
field => {
if (field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.FUNDER) {
hasFunder = true;
}
}
));
if (!hasFunder) {
this.formGroup.removeControl('funder');
}
}
private checkForProject() {
let hasProject = false;
this.selectedDmpBlueprintDefinition.sections.forEach(section => section.fields.forEach(
field => {
if (field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.PROJECT) {
hasProject = true;
}
}
));
if (!hasProject) {
this.formGroup.removeControl('project');
}
}
private addProfiles(profiles?: DmpDatasetProfile[]) {
for(let i = 0; i < this.selectedDmpBlueprintDefinition.sections.length; i++){
this.sectionTemplates.push(new Array<DatasetProfileModel>());

View File

@ -134,9 +134,9 @@ export class DmpEditorModel {
baseContext.validation.push({ key: 'version', validators: [BackendErrorValidator(this.validationErrorModel, 'version')] });
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'grant', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'grant')] });
baseContext.validation.push({ key: 'grant', validators: [BackendErrorValidator(this.validationErrorModel, 'grant')] });
baseContext.validation.push({ key: 'project', validators: [BackendErrorValidator(this.validationErrorModel, 'project')] });
baseContext.validation.push({ key: 'funder', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'funder')] });
baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] });
baseContext.validation.push({ key: 'organisations', validators: [BackendErrorValidator(this.validationErrorModel, 'organisations')] });
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.validationErrorModel, 'researchers')] });
baseContext.validation.push({ key: 'profiles', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profiles')] });