19 package org.turro.alliance.client;
21 import java.time.Instant;
22 import java.util.ArrayList;
23 import javax.json.JsonValue;
24 import org.turro.alliance.db.entities.AxProjectGrant;
25 import org.turro.alliance.db.entities.ProcedenceId;
26 import org.turro.alliance.service.AxConstants;
27 import org.turro.alliance.service.AxServer;
28 import org.turro.cache.ObjectCache;
29 import org.turro.dossier.db.DossierPU;
30 import org.turro.dossier.entity.ProjectGrant;
31 import org.turro.jpa.search.DaoHtmlSearch;
32 import org.turro.jpa.search.DaoSearchKey;
33 import org.turro.json.Jsons;
34 import org.turro.sql.SqlClause;
35 import org.turro.string.Strings;
36 import org.turro.time.Time;
37 import org.turro.util.Comparison;
38 import org.turro.ws.content.JsonProvider;
39 import org.turro.ws.service.member.Servers;
52 return stream().filter(pg -> pg.getProjectGrantId().equals(
id)).findFirst().orElse(
null);
60 removeIf(pg -> !Strings.findsIgnoreCase(pg.getTitle(), search));
62 dsk = dhs.get(
"minimis");
66 if(
"minimis".equals(minimis)) {
67 return !pg.isMinimis();
68 }
else if(
"nominimis".equals(minimis)) {
69 return pg.isMinimis();
75 dsk = dhs.get(
"grant");
79 if(
"subvention".equals(grant)) {
80 return !pg.isSubvention();
81 }
else if(
"loan".equals(grant)) {
83 }
else if(
"combination".equals(grant)) {
84 return !pg.isLoan() && !pg.isSubvention();
90 dsk = dhs.get(
"collab");
94 if(
"collaboration".equals(collab)) {
95 return !pg.isCollaboration();
96 }
else if(
"individual".equals(collab)) {
97 return pg.isCollaboration();
103 dsk = dhs.get(
"micro");
106 removeIf(pg ->
"true".equals(micro) && !pg.isMicro());
108 dsk = dhs.get(
"small");
111 removeIf(pg ->
"true".equals(small) && !pg.isSmall());
113 dsk = dhs.get(
"medium");
116 removeIf(pg ->
"true".equals(medium) && !pg.isMedium());
118 dsk = dhs.get(
"big");
121 removeIf(pg ->
"true".equals(big) && !pg.isBig());
123 dsk = dhs.get(
"hiring");
126 removeIf(pg ->
"true".equals(hiring) && !pg.isHiring());
128 dsk = dhs.get(
"idi");
131 removeIf(pg ->
"true".equals(idi) && !pg.isIdi());
133 dsk = dhs.get(
"investment");
136 removeIf(pg ->
"true".equals(investment) && !pg.isInvestment());
138 dsk = dhs.get(
"start-up");
141 removeIf(pg ->
"true".equals(startup) && !pg.isStartUp());
143 dsk = dhs.get(
"deadline");
147 if(pg.getEndDate() !=
null) {
148 if(
"active".equals(deadline)) {
149 return Time.from(pg.getEndDate()).isBefore(Instant.now());
150 }
else if(
"ended".equals(deadline)) {
151 return Time.from(pg.getEndDate()).isAfter(Instant.now());
152 }
else if(
"recurrent".equals(deadline)) {
153 return pg.isRecurrent();
163 ArrayList<AxProjectGrant> list =
new ArrayList<>();
165 Jsons criteria = Jsons.object();
166 criteria.add(JsonProvider.JSON_ONLY_ITEMS,
true);
167 criteria.add(
"notSelf",
true);
168 Jsons data = Servers.getData(server,
AxConstants.PROJECT_GRANT_ITERATOR, criteria);
169 Jsons items = data.getArray(JsonProvider.JSON_ITEMS);
170 for(JsonValue e : items.getStructure().asArray()) {
171 list.add(AxProjectGrant.fromJson(e));
174 list.addAll(SqlClause.select(
"pg").from(
"ProjectGrant pg")
180 list.sort((pg1, pg2) -> {
181 return Comparison.descendant().compare(pg1.getEndDate(), pg2.getEndDate()).get();
AxProjectGrant getProjectGrant(ProcedenceId id)
void doFilter(DaoHtmlSearch dhs)
static ArrayList< AxProjectGrant > getGrants()
static AxProjectGrant from(long memberId, ProjectGrant projectGrant)
static final String SERVER_SERVICE