19 package org.turro.entities;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.List;
27 import org.turro.alliance.db.AlliancePU;
28 import org.turro.alliance.db.entities.AxCenter;
29 import org.turro.alliance.db.entities.AxContact;
30 import org.turro.alliance.db.entities.AxProject;
31 import org.turro.alliance.db.entities.AxProjectGrant;
32 import org.turro.alliance.db.entities.AxStudent;
33 import org.turro.alliance.db.entities.ProcedenceId;
34 import org.turro.annotation.ElephantEntity;
35 import org.turro.collections.KeyValueMap;
36 import org.turro.command.LabelControl;
37 import org.turro.i18n.I_;
38 import org.turro.jpa.Dao;
39 import org.turro.path.Path;
40 import org.turro.plugin.contacts.IContact;
41 import org.turro.sql.SqlClause;
65 if(
path.getSize() == 2) {
66 if(
null !=
path.getRoot())
switch (
path.getRoot()) {
73 case "axproject-grant":
112 String root =
path.getRoot();
113 if(
null != root)
switch (root) {
115 return I_.
get(
"Project");
117 return I_.
get(
"Contact");
118 case "axproject-grant":
119 return I_.
get(
"Project grant");
121 return I_.
get(
"Student");
123 return I_.
get(
"Learning center");
147 String root =
path.getRoot();
148 if(
null != root)
switch (root) {
150 return "/_zul/images/project.png";
152 return "/_zul/images/contact.png";
153 case "axproject-grant":
154 return "/_zul/images/handshelp.png";
156 return "/_zul/images/student.png";
158 return "/_zul/images/university.png";
201 return Collections.EMPTY_LIST;
237 public Collection
getEntitites(String search,
int maxResults, KeyValueMap kvm) {
238 ArrayList<Object> list =
new ArrayList<>();
239 list.addAll(searchProjects(search, maxResults, kvm));
240 list.addAll(searchContacts(search, maxResults, kvm));
241 list.addAll(searchProjectGrants(search, maxResults, kvm));
242 list.addAll(searchStudents(search, maxResults, kvm));
243 list.addAll(searchCenters(search, maxResults, kvm));
248 public Collection
getEntitites(String root, String search,
int maxResults, KeyValueMap kvm) {
249 ArrayList<Object> list =
new ArrayList<>();
250 if(
null != root)
switch (root) {
252 list.addAll(searchProjects(search, maxResults, kvm));
255 list.addAll(searchContacts(search, maxResults, kvm));
257 case "axproject-grant":
258 list.addAll(searchProjectGrants(search, maxResults, kvm));
261 list.addAll(searchStudents(search, maxResults, kvm));
264 list.addAll(searchCenters(search, maxResults, kvm));
292 String root =
path.getRoot();
293 if(
null != root)
switch (root) {
295 return "/user/alliance/projects";
317 return Arrays.asList(
"axproject",
"axcontact",
"axproject-grant",
"axstudent",
"axcenter");
335 private List<AxProject> searchProjects(String search,
int maxResults, KeyValueMap kvm) {
336 return SqlClause.select(
"p").from(
"AxProject p")
337 .where().search(search,
"p.name",
"p.code")
344 private List<AxContact> searchContacts(String search,
int maxResults, KeyValueMap kvm) {
345 return SqlClause.select(
"p").from(
"AxContact p")
346 .where().search(search,
"p.name",
"p.company")
350 .resultList(AxContact.class);
353 private List<AxProjectGrant> searchProjectGrants(String search,
int maxResults, KeyValueMap kvm) {
354 return SqlClause.select(
"p").from(
"AxProjectGrant p")
355 .where().search(search,
"p.title")
359 .resultList(AxProjectGrant.class);
362 private List<AxStudent> searchStudents(String search,
int maxResults, KeyValueMap kvm) {
363 return SqlClause.select(
"p").from(
"AxStudent p")
364 .where().search(search,
"p.name",
"p.email")
368 .resultList(AxStudent.class);
371 private List<AxCenter> searchCenters(String search,
int maxResults, KeyValueMap kvm) {
372 return SqlClause.select(
"p").from(
"AxCenter p")
373 .where().search(search,
"p.name",
"p.email")
377 .resultList(AxCenter.class);
static String getObjectPath(Object object)
static ProcedenceId from(String id)
Collection getEntitites(String root, String search, int maxResults, KeyValueMap kvm)
boolean itsMine(Object entity)
AllianceEntities(String entityPath)
Collection< String > getAllowedRoots()
List< IElephantEntity > getChildren()
String getExtendedWebPath()
boolean canPublish(IContact contact)
boolean canShowInContext(IContact contact, Object relatedEntity)
Collection getEntitites(String search, int maxResults, KeyValueMap kvm)
IElephantEntity getParent()
IElephantEntity createInstance(Object entity)
String getHierarchicalPath()
Object configureCtrl(Object ctrl, IContact contact)
AllianceEntities(Object entity)
boolean canEdit(IContact contact)
IElephantEntity createInstance(String entityPath)
static String get(String msg)