BrightSide Workbench Full Report + Source Code
org.turro.alliance.provider.ProjectProvider Class Reference
Inheritance diagram for org.turro.alliance.provider.ProjectProvider:
Collaboration diagram for org.turro.alliance.provider.ProjectProvider:

Public Member Functions

 ProjectProvider (WsMember member, String reason, Jsons criteria)
 

Protected Member Functions

Jsons loadData (WsMember member, String reason, Jsons criteria)
 
long count (WsMember member, String reason, Jsons criteria)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file ProjectProvider.java.

Constructor & Destructor Documentation

◆ ProjectProvider()

org.turro.alliance.provider.ProjectProvider.ProjectProvider ( WsMember  member,
String  reason,
Jsons  criteria 
)

Definition at line 41 of file ProjectProvider.java.

41  {
42  super(member, reason, criteria);
43  banned = Banned.of(member).getBannedIds();
44  }
Here is the call graph for this function:

Member Function Documentation

◆ count()

long org.turro.alliance.provider.ProjectProvider.count ( WsMember  member,
String  reason,
Jsons  criteria 
)
protected

Definition at line 76 of file ProjectProvider.java.

76  {
77  List<Long> ids = criteria.getArrayValues("categoryIds", Long.class);
78  String search = criteria.getString("search", "");
79  int phase = criteria.getInt("phase", -1);
80  boolean withBanned = criteria.getBoolean("withBanned", false);
81  return SqlClause.select("count(p)").from("AxProject p")
82  .startIf(ids != null && !ids.isEmpty())
83  .where().in("categoryId", ids)
84  .endIf()
85  .startIf(!Strings.isBlank(search))
86  .whereOrAnd().partial(search, "p.code", "p.name", "p.summary")
87  .endIf()
88  .startIf(phase > -1)
89  .whereOrAnd().equal("p.phaseIndex", phase)
90  .endIf()
91  .startIf(!withBanned)
92  .whereOrAnd().notIn("id", banned)
93  .endIf()
94  .dao(dao.get())
95  .singleResult(Long.class, 0L);
96  }

◆ loadData()

Jsons org.turro.alliance.provider.ProjectProvider.loadData ( WsMember  member,
String  reason,
Jsons  criteria 
)
protected

Definition at line 47 of file ProjectProvider.java.

47  {
48  Jsons projects = Jsons.array();
49  List<Long> ids = criteria.getArrayValues("categoryIds", Long.class);
50  String search = criteria.getString("search", "");
51  int phase = criteria.getInt("phase", -1);
52  boolean withBanned = criteria.getBoolean("withBanned", false);
53  SqlClause.select("p").from("AxProject p")
54  .startIf(ids != null && !ids.isEmpty())
55  .where().in("categoryId", ids)
56  .endIf()
57  .startIf(!Strings.isBlank(search))
58  .whereOrAnd().partial(search, "p.code", "p.name", "p.summary")
59  .endIf()
60  .startIf(phase > -1)
61  .whereOrAnd().equal("p.phaseIndex", phase)
62  .endIf()
63  .startIf(!withBanned)
64  .whereOrAnd().notIn("id", banned)
65  .endIf()
66  .orderBy("p.creation desc")
67  .start(criteria.getInt("curr", -1)).max(criteria.getInt("page", -1))
68  .dao(dao.get())
69  .resultList(AxProject.class).forEach(project -> {
70  projects.addValue(Jsons.read(project.toJson(Map.of("banned", withBanned && banned.contains(project.getId())))));
71  });
72  return projects;
73  }

The documentation for this class was generated from the following file: