19 package org.turro.dossier.entity;
21 import java.io.Serializable;
22 import java.util.Collections;
23 import java.util.List;
24 import javax.persistence.Embeddable;
25 import org.turro.dossier.db.DossierPU;
26 import org.turro.elephant.db.WhereClause;
27 import org.turro.entities.Entities;
28 import org.turro.entities.EntityListAdapter;
29 import org.turro.entities.IElephantEntity;
30 import org.turro.path.Path;
31 import org.turro.tags.Tags;
40 private boolean hiring, idi, investment, startUp, formation;
63 this.investment = investment;
71 this.startUp = startUp;
79 this.formation = formation;
85 return !(hiring | idi | investment | startUp);
89 if(
isEmpty())
return Collections.EMPTY_LIST;
94 if(
isEmpty())
return Collections.EMPTY_LIST;
95 Path path = Path.pathFrom(entityPath);
96 if(
"dossier".equals(path.getRoot())) {
98 }
else if(
"project-grant".equals(path.getRoot())) {
101 return Collections.EMPTY_LIST;
106 wc.
addClause(
"select e from ProjectGrant e");
107 wc.
addClause(
"where (e.recurrent = TRUE or (e.endDate is null or e.endDate > now()))");
110 addTagIds(wc,
"e.id",
"/dossier/" + dossierId,
"project-grant");
121 addTagIds(wc,
"d.id",
"/project-grant/" + projectGrantId,
"dossier");
134 wc.
addClause(
"e.matchCriteria.hiring = :hiring");
140 wc.
addClause(
"e.matchCriteria.idi = :idi");
146 wc.
addClause(
"e.matchCriteria.investment = :investment");
152 wc.
addClause(
"e.matchCriteria.startUp = :startUp");
158 wc.
addClause(
"e.matchCriteria.formation = :formation");
165 private void addEmptyCheck(WhereClause wc) {
166 wc.addClause(
"and (e.matchCriteria.hiring = TRUE");
167 wc.addClause(
"or e.matchCriteria.idi = TRUE");
168 wc.addClause(
"or e.matchCriteria.investment = TRUE");
169 wc.addClause(
"or e.matchCriteria.startUp = TRUE");
170 wc.addClause(
"or e.matchCriteria.formation = TRUE)");
173 private void addTagIds(WhereClause wc, String field, String source, String rootTarget) {
174 List<Long> ids = Tags.getCommonLongIdentifiers(source, rootTarget);
175 if(ids !=
null && !ids.isEmpty()) {
176 wc.addIn(
"and", field, ids);
void setHiring(boolean hiring)
List< IElephantEntity > getMatchingsFor(Object entity)
List< IElephantEntity > getMatchingsForProjectGrant(Long projectGrantId)
void setInvestment(boolean investment)
void setStartUp(boolean startUp)
List< IElephantEntity > getMatchingsFor(String entityPath)
void setFormation(boolean formation)
List< IElephantEntity > getMatchingsForDossier(Long dossierId)
void addClause(String clause)
void addNamedValue(String name, Object value)
static IElephantEntity getController(String path)