no message
This commit is contained in:
parent
c36fa5e6f8
commit
e437ae354e
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.dao.entities;
|
package eu.eudat.dao.entities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import eu.eudat.dao.DatabaseAccess;
|
import eu.eudat.dao.DatabaseAccess;
|
||||||
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.entities.*;
|
import eu.eudat.entities.*;
|
||||||
|
@ -21,21 +22,26 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
|
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
|
||||||
QueryableList<Project> query = getDatabaseService().getQueryable(Project.class);
|
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.getLike() != null && !criteria.getLike().isEmpty())
|
||||||
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("enddate"),criteria.getPeriodEnd()));
|
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
|
||||||
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("startdate"),criteria.getPeriodStart()));
|
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()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Project createOrUpdate(Project item) {
|
public Project createOrUpdate(Project item) {
|
||||||
return getDatabaseService().createOrUpdate(item,Project.class);
|
return getDatabaseService().createOrUpdate(item, Project.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Project find(UUID id) {
|
public Project find(UUID id) {
|
||||||
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")),id)).getSingle();
|
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -258,6 +258,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
this.created = entity.created;
|
this.created = entity.created;
|
||||||
|
this.project = entity.getProject();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.researchers = entity.getResearchers();
|
this.researchers = entity.getResearchers();
|
||||||
this.organisations = entity.getOrganisations();
|
this.organisations = entity.getOrganisations();
|
||||||
|
|
|
@ -106,9 +106,9 @@ public class DataManagementPlanManager {
|
||||||
if (newDmp.getProject() != null) {
|
if (newDmp.getProject() != null) {
|
||||||
Project project = newDmp.getProject();
|
Project project = newDmp.getProject();
|
||||||
ProjectCriteria criteria = new ProjectCriteria();
|
ProjectCriteria criteria = new ProjectCriteria();
|
||||||
criteria.setLike(project.getReference());
|
criteria.setReference(project.getReference());
|
||||||
List<eu.eudat.entities.Project> entries = projectDao.getWithCriteria(criteria).toList();
|
eu.eudat.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault();
|
||||||
if (entries != null && !entries.isEmpty()) project.setId(entries.get(0).getId());
|
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||||
else {
|
else {
|
||||||
project.setCreationUser(userInfo);
|
project.setCreationUser(userInfo);
|
||||||
projectDao.createOrUpdate(project);
|
projectDao.createOrUpdate(project);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Date;
|
||||||
public class ProjectCriteria extends Criteria<Project>{
|
public class ProjectCriteria extends Criteria<Project>{
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
|
private String reference;
|
||||||
public Date getPeriodStart() {
|
public Date getPeriodStart() {
|
||||||
return periodStart;
|
return periodStart;
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,12 @@ public class ProjectCriteria extends Criteria<Project>{
|
||||||
public void setPeriodEnd(Date periodEnd) {
|
public void setPeriodEnd(Date periodEnd) {
|
||||||
this.periodEnd = periodEnd;
|
this.periodEnd = periodEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(String reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@ import eu.eudat.models.dmp.DataManagementPlan;
|
||||||
|
|
||||||
public class Project implements DataModel<eu.eudat.entities.Project> {
|
public class Project implements DataModel<eu.eudat.entities.Project> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
private List<DataManagementPlan> dmps;
|
private List<DataManagementPlan> dmps;
|
||||||
|
@ -170,7 +167,6 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -179,7 +175,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
|
||||||
entity.setId(this.id);
|
entity.setId(this.id);
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setReference(this.reference);
|
entity.setReference(this.reference == null ? "dmp:"+this.label : this.reference);
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
entity.setDefinition(this.definition);
|
entity.setDefinition(this.definition);
|
||||||
entity.setStartdate(this.startDate);
|
entity.setStartdate(this.startDate);
|
||||||
|
|
Loading…
Reference in New Issue