Fixes bug at DMP Wizard on creating new Grant, Funder and Project.
This commit is contained in:
parent
7d6790b225
commit
9dbf57be03
|
@ -3,11 +3,13 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Funder;
|
import eu.eudat.data.entities.Funder;
|
||||||
import eu.eudat.data.entities.Project;
|
import eu.eudat.data.entities.Project;
|
||||||
import eu.eudat.logic.managers.*;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
import eu.eudat.logic.managers.QuickWizardManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
|
||||||
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
|
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
|
||||||
import eu.eudat.models.data.quickwizard.QuickWizardModel;
|
import eu.eudat.models.data.quickwizard.QuickWizardModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -16,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
|
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
@ -47,7 +48,6 @@ public class QuickWizardController extends BaseController {
|
||||||
if (quickWizard.getFunder() == null) {
|
if (quickWizard.getFunder() == null) {
|
||||||
throw new Exception("Funder is a mandatory entity");
|
throw new Exception("Funder is a mandatory entity");
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
|
||||||
// funderEntity = null;
|
|
||||||
throw new Exception("Funder is a mandatory entity");
|
throw new Exception("Funder is a mandatory entity");
|
||||||
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
|
||||||
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
|
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
|
||||||
|
@ -57,7 +57,11 @@ public class QuickWizardController extends BaseController {
|
||||||
|
|
||||||
eu.eudat.data.entities.Grant grantEntity;
|
eu.eudat.data.entities.Grant grantEntity;
|
||||||
//Create Grant
|
//Create Grant
|
||||||
if (quickWizard.getGrant().getExistGrant() == null) {
|
if (quickWizard.getGrant() == null) {
|
||||||
|
throw new Exception("Grant is a mandatory entity");
|
||||||
|
} else if (quickWizard.getGrant().getExistGrant() == null && quickWizard.getGrant().getLabel() == null) {
|
||||||
|
throw new Exception("Grant is a mandatory entity");
|
||||||
|
} else if (quickWizard.getGrant().getExistGrant() == null) {
|
||||||
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
|
grantEntity = this.quickWizardManager.createOrUpdate(quickWizard.getGrant().toDataGrant(), principal);
|
||||||
} else {
|
} else {
|
||||||
grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
|
grantEntity = quickWizard.getGrant().getExistGrant().toDataModel();
|
||||||
|
@ -68,17 +72,15 @@ public class QuickWizardController extends BaseController {
|
||||||
if (quickWizard.getProject().getExistProject() == null
|
if (quickWizard.getProject().getExistProject() == null
|
||||||
&& quickWizard.getProject().getLabel() == null) {
|
&& quickWizard.getProject().getLabel() == null) {
|
||||||
projectEntity = null;
|
projectEntity = null;
|
||||||
} else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null){
|
} else if (quickWizard.getProject().getExistProject() == null && quickWizard.getProject().getLabel() != null) {
|
||||||
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject(), principal);
|
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject(), principal);
|
||||||
} else {
|
} else {
|
||||||
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create Dmp
|
//Create Dmp
|
||||||
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
|
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, principal);
|
||||||
quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, principal),
|
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan, funderEntity, principal);
|
||||||
funderEntity,
|
|
||||||
principal);
|
|
||||||
|
|
||||||
//Create Datasets
|
//Create Datasets
|
||||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class QuickWizardManager {
|
public class QuickWizardManager {
|
||||||
|
@ -109,6 +110,7 @@ public class QuickWizardManager {
|
||||||
eu.eudat.data.entities.Project projectEntity = databaseRepository.getProjectDao().getWithCritetia(criteria).getSingleOrDefault();
|
eu.eudat.data.entities.Project projectEntity = databaseRepository.getProjectDao().getWithCritetia(criteria).getSingleOrDefault();
|
||||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||||
else {
|
else {
|
||||||
|
if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
databaseRepository.getProjectDao().createOrUpdate(project);
|
databaseRepository.getProjectDao().createOrUpdate(project);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,22 +90,28 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.source = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Funder toDataModel() {
|
public eu.eudat.data.entities.Funder toDataModel() {
|
||||||
eu.eudat.data.entities.Funder entity = new eu.eudat.data.entities.Funder();
|
eu.eudat.data.entities.Funder entity = new eu.eudat.data.entities.Funder();
|
||||||
entity.setId(this.id);
|
entity.setId(UUID.randomUUID());
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
|
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
|
entity.setReference(this.reference);
|
||||||
|
}
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
|
|
|
@ -177,12 +177,14 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
||||||
if (entity.getFunder() != null)
|
if (entity.getFunder() != null)
|
||||||
this.funderId = entity.getFunder().getId();
|
this.funderId = entity.getFunder().getId();
|
||||||
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.source = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -190,11 +192,14 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Grant toDataModel() {
|
public eu.eudat.data.entities.Grant toDataModel() {
|
||||||
eu.eudat.data.entities.Grant entity = new eu.eudat.data.entities.Grant();
|
eu.eudat.data.entities.Grant entity = new eu.eudat.data.entities.Grant();
|
||||||
entity.setId(this.id);
|
entity.setId(UUID.randomUUID());
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
|
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
|
entity.setReference(this.reference);
|
||||||
|
}
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
|
|
|
@ -165,23 +165,29 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
||||||
|
if (entity.getReference() != null) {
|
||||||
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source.equals("dmp")) {
|
if (source.equals("dmp")) {
|
||||||
this.source = "Internal";
|
this.source = "Internal";
|
||||||
} else {
|
} else {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Project toDataModel() {
|
public eu.eudat.data.entities.Project toDataModel() {
|
||||||
eu.eudat.data.entities.Project entity = new eu.eudat.data.entities.Project();
|
eu.eudat.data.entities.Project entity = new eu.eudat.data.entities.Project();
|
||||||
entity.setId(this.id);
|
entity.setId(UUID.randomUUID());
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setType(this.type);
|
entity.setType(this.type);
|
||||||
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
|
if (this.source == null && this.reference != null && this.reference.startsWith("dmp:")) {
|
||||||
|
entity.setReference(this.reference);
|
||||||
|
}
|
||||||
if (this.reference != null && !this.reference.trim().isEmpty()
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
&& this.source != null && !this.source.trim().isEmpty()) {
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
|
|
|
@ -2,6 +2,8 @@ package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
import eu.eudat.models.data.funder.Funder;
|
import eu.eudat.models.data.funder.Funder;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FunderQuickWizardModel {
|
public class FunderQuickWizardModel {
|
||||||
private String label;
|
private String label;
|
||||||
private Funder existFunder;
|
private Funder existFunder;
|
||||||
|
@ -22,8 +24,9 @@ public class FunderQuickWizardModel {
|
||||||
|
|
||||||
public Funder toDataFunder() {
|
public Funder toDataFunder() {
|
||||||
Funder toFunder = new Funder();
|
Funder toFunder = new Funder();
|
||||||
|
toFunder.setId(UUID.randomUUID());
|
||||||
toFunder.setLabel(this.label);
|
toFunder.setLabel(this.label);
|
||||||
toFunder.setReference("dmp:" + this.label);
|
toFunder.setReference("dmp:" + toFunder.getId());
|
||||||
toFunder.setDefinition("");
|
toFunder.setDefinition("");
|
||||||
toFunder.setType(eu.eudat.data.entities.Funder.FunderType.INTERNAL.getValue());
|
toFunder.setType(eu.eudat.data.entities.Funder.FunderType.INTERNAL.getValue());
|
||||||
return toFunder;
|
return toFunder;
|
||||||
|
|
|
@ -3,6 +3,8 @@ package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
import eu.eudat.models.data.grant.Grant;
|
import eu.eudat.models.data.grant.Grant;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GrantQuickWizardModel {
|
public class GrantQuickWizardModel {
|
||||||
private String label;
|
private String label;
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -33,11 +35,12 @@ public class GrantQuickWizardModel {
|
||||||
this.existGrant = existGrant;
|
this.existGrant = existGrant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.grant.Grant toDataGrant(){
|
public eu.eudat.models.data.grant.Grant toDataGrant() {
|
||||||
eu.eudat.models.data.grant.Grant toGrant = new eu.eudat.models.data.grant.Grant();
|
eu.eudat.models.data.grant.Grant toGrant = new eu.eudat.models.data.grant.Grant();
|
||||||
|
toGrant.setId(UUID.randomUUID());
|
||||||
toGrant.setAbbreviation("");
|
toGrant.setAbbreviation("");
|
||||||
toGrant.setLabel(this.label);
|
toGrant.setLabel(this.label);
|
||||||
toGrant.setReference("dmp:" + this.label);
|
toGrant.setReference("dmp:" + toGrant.getId());
|
||||||
toGrant.setUri("");
|
toGrant.setUri("");
|
||||||
toGrant.setDefinition("");
|
toGrant.setDefinition("");
|
||||||
toGrant.setDescription(this.description);
|
toGrant.setDescription(this.description);
|
||||||
|
|
|
@ -2,6 +2,8 @@ package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
import eu.eudat.models.data.project.Project;
|
import eu.eudat.models.data.project.Project;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ProjectQuickWizardModel {
|
public class ProjectQuickWizardModel {
|
||||||
private String label;
|
private String label;
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -30,9 +32,10 @@ public class ProjectQuickWizardModel {
|
||||||
|
|
||||||
public Project toDataProject() {
|
public Project toDataProject() {
|
||||||
Project toProject = new Project();
|
Project toProject = new Project();
|
||||||
|
toProject.setId(UUID.randomUUID());
|
||||||
toProject.setAbbreviation("");
|
toProject.setAbbreviation("");
|
||||||
toProject.setLabel(this.label);
|
toProject.setLabel(this.label);
|
||||||
toProject.setReference("dmp:" + this.label);
|
toProject.setReference("dmp:" + toProject.getId());
|
||||||
toProject.setUri("");
|
toProject.setUri("");
|
||||||
toProject.setDefinition("");
|
toProject.setDefinition("");
|
||||||
toProject.setDescription(this.description);
|
toProject.setDescription(this.description);
|
||||||
|
|
Loading…
Reference in New Issue