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

View File

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

View File

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