Fixes bug with QuickWizard Profile name on backend model

This commit is contained in:
ikalyvas 2019-03-05 18:08:38 +02:00
parent 5ae18beb5d
commit 90aace8e68
3 changed files with 71 additions and 78 deletions

View File

@ -51,7 +51,6 @@ public class QuickWizardController extends BaseController {
//Create Dmp
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
principal);
@ -60,7 +59,6 @@ public class QuickWizardController extends BaseController {
quickWizard.getDmp().setId(dmpEntity.getId());
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
this.datasetManager.createOrUpdate(dataset.toDataModel(quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
quickWizard.getDmp().getDatasetProfile().getId()),

View File

@ -56,6 +56,7 @@ public class DatasetManager {
private DatasetRepository datasetRepository;
private BuilderFactory builderFactory;
private UserManager userManager;
@Autowired
public DatasetManager(ApiContext apiContext, UserManager userManager) {
this.apiContext = apiContext;

View File

@ -1,6 +1,5 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.Project;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
@ -13,98 +12,93 @@ import java.util.UUID;
public class DmpQuickWizardModel {
private UUID id;
private String label;
private int status;
private AssociatedProfile profile;
private String description;
private eu.eudat.models.data.project.Project project;
private UUID id;
private String label;
private int status;
private AssociatedProfile datasetProfile;
private String description;
private eu.eudat.models.data.project.Project project;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public int getStatus() {
return status;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public void setStatus(int status) {
this.status = status;
}
public AssociatedProfile getProfile() {
return profile;
}
public void setDatasetProfile(AssociatedProfile datasetProfile) {
this.datasetProfile = datasetProfile;
}
public void setProfile(AssociatedProfile profile) {
this.profile = profile;
}
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
public eu.eudat.models.data.project.Project getProject() {
return project;
}
public eu.eudat.models.data.project.Project getProject() {
return project;
}
public void setProject(eu.eudat.models.data.project.Project project) {
this.project = project;
}
public void setProject(eu.eudat.models.data.project.Project project) {
this.project = project;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(UserInfoDao userInfoRepository ,Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
dataManagementPlanEntity.setId(this.id);
dataManagementPlanEntity.setVersion(0);
dataManagementPlanEntity.setId(this.id);
dataManagementPlanEntity.setVersion(0);
dataManagementPlanEntity.setLabel(this.label);
if (project != null) {
eu.eudat.models.data.project.Project importProject = new eu.eudat.models.data.project.Project();
dataManagementPlanEntity.setProject(importProject.fromDataModel(project));
}
if(this.profile!=null) {
List<AssociatedProfile> assProfile = new LinkedList<>();
assProfile.add(this.profile);
dataManagementPlanEntity.setProfiles(assProfile);
}
dataManagementPlanEntity.setStatus((short) this.status);
dataManagementPlanEntity.setDescription(this.description);
dataManagementPlanEntity.setProperties(null);
dataManagementPlanEntity.setCreated(new Date());
List<UserInfo> user = new LinkedList<UserInfo>();
eu.eudat.models.data.userinfo.UserInfo usetInfo = new eu.eudat.models.data.userinfo.UserInfo();
usetInfo.fromDataModel(userInfoRepository.find(principal.getId()));
user.add(usetInfo);
dataManagementPlanEntity.setAssociatedUsers(user);
return dataManagementPlanEntity;
}
dataManagementPlanEntity.setLabel(this.label);
if (project != null) {
eu.eudat.models.data.project.Project importProject = new eu.eudat.models.data.project.Project();
dataManagementPlanEntity.setProject(importProject.fromDataModel(project));
}
if (this.datasetProfile != null) {
List<AssociatedProfile> assProfile = new LinkedList<>();
assProfile.add(this.datasetProfile);
dataManagementPlanEntity.setProfiles(assProfile);
}
dataManagementPlanEntity.setStatus((short) this.status);
dataManagementPlanEntity.setDescription(this.description);
dataManagementPlanEntity.setProperties(null);
dataManagementPlanEntity.setCreated(new Date());
List<UserInfo> user = new LinkedList<UserInfo>();
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
userInfo.setId(principal.getId());
dataManagementPlanEntity.setAssociatedUsers(user);
return dataManagementPlanEntity;
}
public eu.eudat.data.entities.DatasetProfile getDatasetProfile(){
eu.eudat.data.entities.DatasetProfile datasetProfile = new eu.eudat.data.entities.DatasetProfile();
datasetProfile.setDefinition(this.profile.getLabel());
datasetProfile.setLabel(this.profile.getLabel());
datasetProfile.setId(this.profile.getId());
return datasetProfile;
}
public eu.eudat.data.entities.DatasetProfile getDatasetProfile() {
eu.eudat.data.entities.DatasetProfile datasetProfile = new eu.eudat.data.entities.DatasetProfile();
datasetProfile.setDefinition(this.datasetProfile.getLabel());
datasetProfile.setLabel(this.datasetProfile.getLabel());
datasetProfile.setId(this.datasetProfile.getId());
return datasetProfile;
}
}