no message

This commit is contained in:
annabakouli 2017-12-20 16:52:09 +02:00
parent d05b2ba5e2
commit 06f1086ceb
31 changed files with 440 additions and 83 deletions

View File

@ -18,6 +18,7 @@ import eu.eudat.models.dmp.DataManagementPlanTableRequest;
import eu.eudat.models.helpers.DataTableData;
import eu.eudat.models.helpers.responses.*;
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -96,10 +97,17 @@ public class DMPs {
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/add" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<eu.eudat.entities.DMP> addDmp(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan) {
eu.eudat.entities.DMP createdProject = dMPDao.createOrUpdate(dataManagementPlan.toDataModel());
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/createOrUpdate" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<DMP> createOrUpdate(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
try{
DataManagementPlanManager.createOrUpdate(dMPDao,researcherDao,userInfoDao,organisationDao,dataManagementPlan,principal);
return new ResponseItem<DMP>().status(HttpStatus.CREATED);
}catch (Exception ex){
ex.printStackTrace();
return new ResponseItem<DMP>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.controllers;
import eu.eudat.dao.entities.DMPDao;
import eu.eudat.managers.DatasetManager;
import eu.eudat.managers.DatasetWizardManager;
import eu.eudat.models.dataset.DatasetTableRequest;
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.models.helpers.DataTableData;
import eu.eudat.models.helpers.responses.ResponseItem;
import eu.eudat.models.listingmodels.DatasetListingModel;
import eu.eudat.models.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Created by ikalyvas on 12/20/2017.
*/
@RestController
@CrossOrigin
@RequestMapping( value = { "/datasetwizard" })
public class DatasetWizardController {
@Autowired
private DMPDao dMPDao;
@RequestMapping(method = RequestMethod.POST, value = { "/userDmps" }, produces="application/json")
public @ResponseBody
ResponseItem<List<DataManagentPlanListingModel>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
try {
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(dMPDao,datasetWizardAutocompleteRequest,principal);
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans);
} catch (Exception ex) {
ex.printStackTrace();
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
}
}

View File

@ -13,6 +13,7 @@ import eu.eudat.models.external.ProjectsExternalSourcesModel;
import eu.eudat.models.external.RegistriesExternalSourcesModel;
import eu.eudat.models.helpers.responses.*;
import eu.eudat.models.project.ProjectCriteriaRequest;
import eu.eudat.models.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -102,9 +103,9 @@ public class Projects {
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/projects/createOrUpdate" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project) {
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project, Principal principal) {
try {
Project createdProject = projectDao.createOrUpdate(project.toDataModel());
ProjectManager.createOrUpdate(projectDao,userInfoDao,project,principal);
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
}catch (Exception ex){
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());

View File

@ -5,15 +5,20 @@ import java.util.UUID;
import eu.eudat.dao.Dao;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Dataset;
import eu.eudat.entities.UserInfo;
import eu.eudat.entities.responses.IDLabelPair;
import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
import eu.eudat.queryable.QueryableList;
import org.springframework.stereotype.Service;
public interface DMPDao {
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria);
QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria);
QueryableList<DMP> getUserDmps(DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserInfo userInfo);
DMP createOrUpdate(DMP item);

View File

@ -11,8 +11,11 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import eu.eudat.dao.databaselayer.service.DatabaseService;
import eu.eudat.entities.Dataset;
import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
import eu.eudat.queryable.QueryableList;
import org.hibernate.query.Query;
@ -53,4 +56,13 @@ public class DMPDaoImpl implements DMPDao {
public Long count(){
return this.databaseService.count(DMP.class);
}
@Override
public QueryableList<DMP> getUserDmps(DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserInfo userInfo) {
QueryableList<DMP> query = databaseService.getQueryable(DMP.class).where((builder, root) -> builder.equal(root.get("creator"),userInfo));
if(datasetWizardAutocompleteRequest.getCriteria().getLike()!=null&&!datasetWizardAutocompleteRequest.getCriteria().getLike().isEmpty()){
query.where((builder, root) -> builder.like(root.get("label"),"%"+datasetWizardAutocompleteRequest.getCriteria().getLike()+"%"));
}
return query;
}
}

View File

@ -6,18 +6,20 @@ import java.util.UUID;
import eu.eudat.dao.Dao;
import eu.eudat.entities.Dataset;
import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo;
import eu.eudat.entities.responses.IDLabelPair;
import eu.eudat.models.criteria.DatasetCriteria;
import eu.eudat.models.criteria.ProjectCriteria;
import eu.eudat.models.dataset.DatasetTableRequest;
import eu.eudat.models.project.ProjectTableRequest;
import eu.eudat.models.security.Principal;
import eu.eudat.queryable.QueryableList;
import org.springframework.stereotype.Service;
public interface DatasetDao {
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
Dataset createOrUpdate(Dataset item);

View File

@ -15,9 +15,11 @@ import eu.eudat.dao.JpaDao;
import eu.eudat.dao.databaselayer.service.DatabaseService;
import eu.eudat.entities.Dataset;
import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo;
import eu.eudat.entities.responses.IDLabelPair;
import eu.eudat.models.criteria.DatasetCriteria;
import eu.eudat.models.dataset.DatasetTableRequest;
import eu.eudat.models.security.Principal;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -51,4 +53,6 @@ public class DatasetDaoImpl implements DatasetDao {
public Long count(){
return this.databaseService.count(Dataset.class);
}
}

View File

@ -59,8 +59,8 @@ public class DMP implements Serializable,DataEntity<DMP> {
@Type(type="eu.eudat.typedefinition.XMLType")
@Column(name = "\"ProfileData\"", columnDefinition = "xml", nullable = true)
private String profileData;
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
private String associatedDmps;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Profile\"")
@ -211,12 +211,12 @@ public class DMP implements Serializable,DataEntity<DMP> {
this.project = project;
}
public String getProfileData() {
return profileData;
public String getAssociatedDmps() {
return associatedDmps;
}
public void setProfileData(String profileData) {
this.profileData = profileData;
public void setAssociatedDmps(String associatedDmps) {
this.associatedDmps = associatedDmps;
}
public DMPProfile getProfile() {
@ -253,7 +253,13 @@ public class DMP implements Serializable,DataEntity<DMP> {
@Override
public void update(DMP entity) {
this.setAssociatedDmps(entity.associatedDmps);
this.label = entity.getLabel();
this.status = entity.getStatus();
this.created = entity.created;
this.description = entity.getDescription();
this.researchers = entity.getResearchers();
this.organisations = entity.getOrganisations();
}
@Override

View File

@ -91,7 +91,7 @@ public class Transformers {
dmp.setPrevious(UUID.fromString(formData.getFirst("DMP.previous")));
}catch(Exception ex) {/*do nothing*/}
dmp.setProfile(profile);
dmp.setProfileData(formData.getFirst("DMP.profileData"));
dmp.setAssociatedDmps(formData.getFirst("DMP.profileData"));
dmp.setProject(project);
dmp.setVersion(Integer.parseInt(formData.getFirst("DMP.version")));
dmp.setDataset(datasets);

View File

@ -4,13 +4,19 @@ import java.util.List;
import java.util.UUID;
import eu.eudat.dao.entities.DMPDao;
import eu.eudat.dao.entities.OrganisationDao;
import eu.eudat.dao.entities.ResearcherDao;
import eu.eudat.dao.entities.UserInfoDao;
import eu.eudat.entities.DMP;
import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.criteria.OrganisationCriteria;
import eu.eudat.models.criteria.ResearcherCriteria;
import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
import eu.eudat.models.helpers.DataTableData;
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.security.Principal;
import eu.eudat.queryable.QueryableList;
import eu.eudat.utilities.builders.DomainModelConverter;
@ -37,4 +43,37 @@ public class DataManagementPlanManager {
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, eu.eudat.models.dmp.DataManagementPlan>().fromDataModel( items.toList(), eu.eudat.models.dmp.DataManagementPlan.class);
return datamanagementPlans;
}
public static void createOrUpdate(DMPDao dmpsRepository, ResearcherDao researcherRepository, UserInfoDao userInfoDao, OrganisationDao organisationRepository, DataManagementPlan dataManagementPlan, Principal principal){
DMP newDmp = dataManagementPlan.toDataModel();
createOrganisationsIfTheyDontExist(newDmp,organisationRepository);
createResearchersIfTheyDontExist(newDmp,researcherRepository);
newDmp.setCreator(userInfoDao.read(principal.getId()));
dmpsRepository.createOrUpdate(newDmp);
}
private static void createResearchersIfTheyDontExist(DMP newDmp,ResearcherDao researcherRepository){
if(newDmp.getResearchers()!=null&&!newDmp.getResearchers().isEmpty()){
for(eu.eudat.entities.Researcher researcher : newDmp.getResearchers()){
ResearcherCriteria criteria = new ResearcherCriteria();
criteria.setLike(researcher.getReference());
List<eu.eudat.entities.Researcher> entries = researcherRepository.listBy(criteria);
if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
else researcher = researcherRepository.create(researcher);
}
}
}
private static void createOrganisationsIfTheyDontExist(DMP newDmp,OrganisationDao organisationRepository){
if(newDmp.getOrganisations()!=null&&!newDmp.getOrganisations().isEmpty()){
for(eu.eudat.entities.Organisation organisation: newDmp.getOrganisations()){
OrganisationCriteria criteria = new OrganisationCriteria();
criteria.setLike(organisation.getReference());
List<eu.eudat.entities.Organisation> entries = organisationRepository.listBy(criteria);
if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
else organisation = organisationRepository.create(organisation);
}
}
}
}

View File

@ -34,4 +34,5 @@ public class DatasetManager {
dataset.fromDataModel(datatasetRepository.find(UUID.fromString(id)));
return dataset;
}
}

View File

@ -0,0 +1,30 @@
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.DatasetWizardAutocompleteRequest;
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.List;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class DatasetWizardManager {
public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) throws InstantiationException, IllegalAccessException {
UserInfo userInfo = new UserInfo();
userInfo.setId(principal.getId());
QueryableList<DMP> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest,userInfo);
List<DataManagentPlanListingModel> dataManagementPlans = new DomainModelConverter<DMP, DataManagentPlanListingModel>().fromDataModel( items.toList(), DataManagentPlanListingModel.class);
return dataManagementPlans;
}
}

View File

@ -4,11 +4,13 @@ import java.util.List;
import java.util.UUID;
import eu.eudat.dao.entities.ProjectDao;
import eu.eudat.dao.entities.UserInfoDao;
import eu.eudat.models.criteria.ProjectCriteria;
import eu.eudat.models.helpers.DataTableData;
import eu.eudat.models.project.Project;
import eu.eudat.models.project.ProjectCriteriaRequest;
import eu.eudat.models.project.ProjectTableRequest;
import eu.eudat.models.security.Principal;
import eu.eudat.queryable.QueryableList;
import eu.eudat.utilities.builders.DomainModelConverter;
@ -42,4 +44,10 @@ public class ProjectManager {
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(items.toList(), eu.eudat.models.project.Project.class);
return projects;
}
public static void createOrUpdate(ProjectDao projectRepository, UserInfoDao userInfoRepository, eu.eudat.models.project.Project project, Principal principal){
eu.eudat.entities.Project projectEntity = project.toDataModel();
projectEntity.setCreationUser(userInfoRepository.read(principal.getId()));
projectRepository.createOrUpdate(projectEntity);
}
}

View File

@ -0,0 +1,10 @@
package eu.eudat.models.criteria;
import eu.eudat.entities.DMP;
import eu.eudat.models.dmp.DataManagementPlan;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class DatasetWizardUserDmpCriteria extends Criteria<DMP>{
}

View File

@ -2,6 +2,7 @@ package eu.eudat.models.dataset;
import eu.eudat.models.DataModel;
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.dmp.AssociatedProfiles;
import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.utilities.builders.DomainModelConverter;
@ -25,7 +26,7 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
private List<Registry> registries;
private List<Service> services;
private List<DataRepository> dataRepositories;
public UUID getId() {
return id;
}

View File

@ -0,0 +1,40 @@
package eu.eudat.models.datasetwizard;
import eu.eudat.entities.DMP;
import eu.eudat.models.DataModel;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class DataManagentPlanListingModel implements DataModel<DMP>{
private String id;
private String label;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
this.id = entity.getId().toString();
this.label = entity.getLabel();
}
@Override
public DMP toDataModel() {
return null;
}
}

View File

@ -0,0 +1,10 @@
package eu.eudat.models.datasetwizard;
import eu.eudat.models.criteria.DatasetWizardUserDmpCriteria;
import eu.eudat.models.helpers.requests.RequestItem;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class DatasetWizardAutocompleteRequest extends RequestItem<DatasetWizardUserDmpCriteria> {
}

View File

@ -0,0 +1,46 @@
package eu.eudat.models.dmp;
import eu.eudat.utilities.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.UUID;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class AssociatedProfile implements XmlSerializable<AssociatedProfile>{
private UUID profileId;
private String label;
public UUID getProfileId() {
return profileId;
}
public void setProfileId(UUID profileId) {
this.profileId = profileId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public Element toXml(Document doc) {
Element profile = doc.createElement("profile");
profile.setAttribute("profileId",this.profileId.toString());
profile.setAttribute("label",this.label);
return profile;
}
@Override
public AssociatedProfile fromXml(Element item) {
this.profileId = UUID.fromString(item.getAttribute("profileId"));
this.label = item.getAttribute("label");
return this;
}
}

View File

@ -0,0 +1,49 @@
package eu.eudat.models.dmp;
import eu.eudat.utilities.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.LinkedList;
import java.util.List;
/**
* Created by ikalyvas on 12/20/2017.
*/
public class AssociatedProfiles implements XmlSerializable<AssociatedProfiles>{
List<AssociatedProfile> associatedProfiles;
public List<AssociatedProfile> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
@Override
public Element toXml(Document doc) {
Element associatedProfilesElement = doc.createElement("profiles");
for(AssociatedProfile associatedProfile:associatedProfiles){
associatedProfilesElement.appendChild(associatedProfile.toXml(doc));
}
return associatedProfilesElement;
}
@Override
public AssociatedProfiles fromXml(Element item) {
this.associatedProfiles = new LinkedList<>();
if(item!=null){
NodeList associatedProfilesElement = item.getChildNodes();
for (int temp = 0; temp < associatedProfilesElement.getLength(); temp++) {
Node associatedProfileElement = associatedProfilesElement.item(temp);
if (associatedProfileElement.getNodeType() == Node.ELEMENT_NODE) {
this.associatedProfiles.add(new AssociatedProfile().fromXml((Element)associatedProfileElement));
}
}
}
return this;
}
}

View File

@ -3,6 +3,9 @@ package eu.eudat.models.dmp;
import eu.eudat.entities.*;
import eu.eudat.models.DataModel;
import eu.eudat.utilities.builders.DomainModelConverter;
import eu.eudat.utilities.builders.XmlBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.*;
import java.util.stream.Collector;
@ -14,10 +17,13 @@ public class DataManagementPlan implements DataModel<DMP>{
private UUID previous;
private int version;
private int status;
private String description;
private AssociatedProfiles associatedProfile;
private eu.eudat.models.dmp.Project project;
private List<Organisation> organizations;
private List<Organisation> organisations;
private List<Researcher> researchers;
private UserInfo creator;
private Date created;
public UUID getId() {
return id;
}
@ -50,12 +56,12 @@ public class DataManagementPlan implements DataModel<DMP>{
this.version = version;
}
public List<Organisation> getOrganizations() {
return organizations;
public List<Organisation> getOrganisations() {
return organisations;
}
public void setOrganizations(List<Organisation> organizations) {
this.organizations = organizations;
public void setOrganisations(List<Organisation> organizations) {
this.organisations = organizations;
}
public List<Researcher> getResearchers() {
@ -90,10 +96,34 @@ public class DataManagementPlan implements DataModel<DMP>{
this.creator = creator;
}
@Override
public AssociatedProfiles getAssociatedProfile() {
return associatedProfile;
}
public void setAssociatedProfile(AssociatedProfiles associatedProfile) {
this.associatedProfile = associatedProfile;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
this.id = entity.getId();
this.organizations =new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class);
this.organisations =new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class);
this.researchers =new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class);
this.version = entity.getVersion();
this.previous = entity.getPrevious();
@ -102,18 +132,35 @@ public class DataManagementPlan implements DataModel<DMP>{
this.project.fromDataModel(entity.getProject());
this.creator = new eu.eudat.models.dmp.UserInfo();
if(entity.getCreator()!=null)this.creator.fromDataModel(entity.getCreator());
if(entity.getAssociatedDmps()!=null&&!entity.getAssociatedDmps().isEmpty()){
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
Element root = (Element)viewStyleDoc.getDocumentElement();
this.associatedProfile = new AssociatedProfiles().fromXml(root);
}
this.created = entity.getCreated();
this.description = entity.getDescription();
}
@Override
public DMP toDataModel() {
DMP dataManagementPlanEntity = new DMP();
dataManagementPlanEntity.setId(this.id);
dataManagementPlanEntity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().toDataModel(this.organizations)));
dataManagementPlanEntity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().toDataModel(this.organisations)));
dataManagementPlanEntity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().toDataModel(this.researchers)));
dataManagementPlanEntity.setVersion(this.version);
dataManagementPlanEntity.setPrevious(this.previous);
dataManagementPlanEntity.setLabel(this.label);
dataManagementPlanEntity.setProject(this.project.toDataModel());
dataManagementPlanEntity.setStatus((short)this.status);
dataManagementPlanEntity.setDescription(this.description);
if(this.associatedProfile!=null) {
Document associatedProfileDoc = XmlBuilder.getDocument();
Element associatedProfileElement = this.associatedProfile.toXml(associatedProfileDoc);
associatedProfileDoc.appendChild(associatedProfileElement);
dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));
}
dataManagementPlanEntity.setCreated(this.created!=null?this.created:new Date());
return dataManagementPlanEntity;
}
}

View File

@ -6,17 +6,17 @@ import eu.eudat.utilities.helpers.LabelGenerator;
import java.util.Date;
public class Organisation implements DataModel<eu.eudat.entities.Organisation>,LabelGenerator {
private String pid;
private String label;
private String name;
private String uri;
private String id;
private int status;
public String getPid() {
return pid;
public String getLabel() {
return label;
}
public void setPid(String pid) {
this.pid = pid;
public void setLabel(String label) {
this.label = label;
}
public String getName() {
@ -27,27 +27,35 @@ public class Organisation implements DataModel<eu.eudat.entities.Organisation>,L
this.name = name;
}
public String getUri() {
return uri;
public String getId() {
return id;
}
public void setUri(String uri) {
this.uri = uri;
public void setId(String id) {
this.id = id;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public void fromDataModel(eu.eudat.entities.Organisation entity) {
this.pid = entity.getReference();
this.id = entity.getReference();
this.name = entity.getLabel();
this.uri = entity.getUri();
this.label = entity.getUri();
}
@Override
public eu.eudat.entities.Organisation toDataModel() {
eu.eudat.entities.Organisation organisationEntity = new eu.eudat.entities.Organisation();
organisationEntity.setReference(this.pid);
organisationEntity.setReference(this.id);
organisationEntity.setLabel(this.name);
organisationEntity.setUri(this.uri);
organisationEntity.setUri(this.label);
organisationEntity.setCreated(new Date());
organisationEntity.setStatus((short)this.status);
return organisationEntity;

View File

@ -6,17 +6,17 @@ import eu.eudat.utilities.helpers.LabelGenerator;
import java.util.Date;
public class Researcher implements DataModel<eu.eudat.entities.Researcher>,LabelGenerator {
private String pid;
private String label;
private String name;
private String uri;
private String id;
private int status;
public String getPid() {
return pid;
public String getLabel() {
return label;
}
public void setPid(String pid) {
this.pid = pid;
public void setLabel(String label) {
this.label = label;
}
public String getName() {
@ -27,12 +27,12 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher>,Label
this.name = name;
}
public String getUri() {
return uri;
public String getId() {
return id;
}
public void setUri(String uri) {
this.uri = uri;
public void setId(String id) {
this.id = id;
}
public int getStatus() {
@ -45,17 +45,18 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher>,Label
@Override
public void fromDataModel(eu.eudat.entities.Researcher entity) {
this.pid = entity.getReference();
this.id = entity.getReference();
this.label = entity.getUri();
this.name = entity.getLabel();
this.status = entity.getStatus();
this.uri = entity.getUri();
}
@Override
public eu.eudat.entities.Researcher toDataModel() {
eu.eudat.entities.Researcher researcher = new eu.eudat.entities.Researcher();
researcher.setReference(this.pid);
researcher.setReference(this.id);
researcher.setLabel(this.name);
researcher.setUri(this.label);
researcher.setCreated(new Date());
researcher.setStatus((short)this.status);
return researcher;

View File

@ -1,18 +1,11 @@
package eu.eudat.models.external;
import java.util.ArrayList;
import java.util.List;
/**
* Created by ikalyvas on 12/19/2017.
*/
public abstract class ExternalListingItem<T> implements ExternalItem<T>{
private List<ExternalSourcesItemModel> data;
public abstract class ExternalListingItem<T> extends ArrayList<ExternalSourcesItemModel> implements ExternalItem<T> {
public List<ExternalSourcesItemModel> getData() {
return data;
}
public void setData(List<ExternalSourcesItemModel> data) {
this.data = data;
}
}

View File

@ -10,15 +10,13 @@ import java.util.Map;
public class OrganisationsExternalSourcesModel extends ExternalListingItem<OrganisationsExternalSourcesModel>{
@Override
public OrganisationsExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
List<ExternalSourcesItemModel> items = new LinkedList<>();
for(Map<String,String> item : values){
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("pid"));
model.setLabel(item.get("uri"));
model.setName(item.get("name"));
items.add(model);
this.add(model);
}
this.setData(items);
return this;
}
}

View File

@ -10,15 +10,13 @@ import java.util.Map;
public class ProjectsExternalSourcesModel extends ExternalListingItem<ProjectsExternalSourcesModel> {
@Override
public ProjectsExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
List<ExternalSourcesItemModel> items = new LinkedList<>();
for(Map<String,String> item : values){
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("pid"));
model.setLabel(item.get("uri"));
model.setName(item.get("name"));
items.add(model);
this.add(model);
}
this.setData(items);
return this;
}
}

View File

@ -10,15 +10,13 @@ import java.util.Map;
public class RegistriesExternalSourcesModel extends ExternalListingItem<RegistriesExternalSourcesModel> {
@Override
public RegistriesExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
List<ExternalSourcesItemModel> items = new LinkedList<>();
for(Map<String,String> item : values){
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("pid"));
model.setLabel(item.get("uri"));
model.setName(item.get("name"));
items.add(model);
this.add(model);
}
this.setData(items);
return this;
}
}

View File

@ -10,15 +10,13 @@ import java.util.Map;
public class ResearchersExternalSourcesModel extends ExternalListingItem<ResearchersExternalSourcesModel> {
@Override
public ResearchersExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
List<ExternalSourcesItemModel> items = new LinkedList<>();
for(Map<String,String> item : values){
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("pid"));
model.setLabel(item.get("uri"));
model.setName(item.get("name"));
items.add(model);
this.add(model);
}
this.setData(items);
return this;
}
}

View File

@ -10,15 +10,13 @@ import java.util.Map;
public class ServiceExternalSourcesModel extends ExternalListingItem<ServiceExternalSourcesModel> {
@Override
public ServiceExternalSourcesModel fromExternalItem(List<Map<String,String>> values) {
List<ExternalSourcesItemModel> items = new LinkedList<>();
for(Map<String,String> item : values){
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
model.setId(item.get("pid"));
model.setLabel(item.get("label"));
model.setName(item.get("name"));
items.add(model);
this.add(model);
}
this.setData(items);
return this;
}
}

View File

@ -85,7 +85,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP> {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.project = entity.getProject().getLabel();
this.profile = entity.getProfile().getLabel();
if(entity.getProfile()!=null)this.profile = entity.getProfile().getLabel();
this.organisations =LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class));
this.researchers =LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class));
this.version = ""+entity.getVersion();

View File

@ -87,7 +87,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
duration: 3000,
extraClasses: ['snackbar-success']
})
this.router.navigate(['/dataManagementPlans']);
this.router.navigate(['/dmps']);
}
onCallbackError(error: any) {
@ -102,7 +102,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
}
public cancel(): void {
this.router.navigate(['/dataManagementPlans']);
this.router.navigate(['/dmps']);
}
filterOrganisations(value: string): void {

View File

@ -40,13 +40,14 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
previous: [{ value: this.previous, disabled: disabled }, context.getValidation('previous').validators],
version: [{ value: this.version, disabled: disabled }, context.getValidation('version').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
project: [{ value: this.project, disabled: disabled }, context.getValidation('project').validators],
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('description').validators],
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
});
@ -55,14 +56,15 @@ export class DataManagementPlanModel implements Serializable<DataManagementPlanM
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'id', validators: [ BackendErrorValidator(this.errorModel, 'id')] });
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
baseContext.validation.push({ key: 'previous', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'previous')] });
baseContext.validation.push({ key: 'previous', validators: [BackendErrorValidator(this.errorModel, 'previous')] });
baseContext.validation.push({ key: 'version', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'version')] });
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'status')] });
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'project')] });
baseContext.validation.push({ key: 'organisations', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'organisations')] });
baseContext.validation.push({ key: 'researchers', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'researchers')] });
baseContext.validation.push({ key: 'organisations', validators: [BackendErrorValidator(this.errorModel, 'organisations')] });
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.errorModel, 'researchers')] });
return baseContext;
}