no message

This commit is contained in:
Ioannis Kalyvas 2018-02-02 18:21:46 +02:00
parent c36fa5e6f8
commit e437ae354e
5 changed files with 57 additions and 46 deletions

View File

@ -1,6 +1,7 @@
package eu.eudat.dao.entities;
import java.util.UUID;
import eu.eudat.dao.DatabaseAccess;
import eu.eudat.dao.databaselayer.service.DatabaseService;
import eu.eudat.entities.*;
@ -21,9 +22,14 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
@Override
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("enddate"),criteria.getPeriodEnd()));
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("startdate"),criteria.getPeriodStart()));
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
if (criteria.getPeriodEnd() != null)
query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd()));
if (criteria.getPeriodStart() != null)
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
if (criteria.getReference() != null)
query.where((builder, root) -> builder.equal(root.get("reference"), criteria.getReference()));
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query;
}

View File

@ -258,6 +258,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
this.label = entity.getLabel();
this.status = entity.getStatus();
this.created = entity.created;
this.project = entity.getProject();
this.description = entity.getDescription();
this.researchers = entity.getResearchers();
this.organisations = entity.getOrganisations();

View File

@ -106,9 +106,9 @@ public class DataManagementPlanManager {
if (newDmp.getProject() != null) {
Project project = newDmp.getProject();
ProjectCriteria criteria = new ProjectCriteria();
criteria.setLike(project.getReference());
List<eu.eudat.entities.Project> entries = projectDao.getWithCriteria(criteria).toList();
if (entries != null && !entries.isEmpty()) project.setId(entries.get(0).getId());
criteria.setReference(project.getReference());
eu.eudat.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault();
if (projectEntity != null) project.setId(projectEntity.getId());
else {
project.setCreationUser(userInfo);
projectDao.createOrUpdate(project);

View File

@ -7,7 +7,7 @@ import java.util.Date;
public class ProjectCriteria extends Criteria<Project>{
private Date periodStart;
private Date periodEnd;
private String reference;
public Date getPeriodStart() {
return periodStart;
}
@ -23,4 +23,12 @@ public class ProjectCriteria extends Criteria<Project>{
public void setPeriodEnd(Date periodEnd) {
this.periodEnd = periodEnd;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
}

View File

@ -12,9 +12,6 @@ import eu.eudat.models.dmp.DataManagementPlan;
public class Project implements DataModel<eu.eudat.entities.Project> {
private UUID id;
private List<DataManagementPlan> dmps;
@ -170,7 +167,6 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
this.created = entity.getCreated();
this.modified = entity.getModified();
this.description = entity.getDescription();
}
@Override
@ -179,7 +175,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
entity.setId(this.id);
entity.setAbbreviation(this.abbreviation);
entity.setLabel(this.label);
entity.setReference(this.reference);
entity.setReference(this.reference == null ? "dmp:"+this.label : this.reference);
entity.setUri(this.uri);
entity.setDefinition(this.definition);
entity.setStartdate(this.startDate);