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.action.IEntityCtrl;
28 import org.turro.action.LinkType;
29 import org.turro.annotation.ElephantEntity;
30 import org.turro.attach.www.AttachCtrl;
31 import org.turro.collections.KeyValueMap;
32 import org.turro.command.LabelControl;
33 import org.turro.elephant.db.WhereClause;
34 import org.turro.file.util.FileAttach;
35 import org.turro.i18n.I_;
36 import org.turro.jpa.Dao;
37 import org.turro.path.Path;
38 import org.turro.plugin.contacts.IContact;
39 import org.turro.polls.PollsCtrl;
40 import org.turro.students.db.StudentsPU;
41 import org.turro.students.entities.Challenge;
42 import org.turro.students.entities.PracticalWork;
43 import org.turro.students.entities.Response;
44 import org.turro.students.entities.TalentCategory;
45 import org.turro.students.menu.StudentsMenu;
46 import org.turro.www.commentit.CommentItCtrl;
47 import org.turro.www.describeit.DescribeItCtrl;
48 import org.turro.www.starit.StarItCtrl;
49 import org.turro.www.voteit.VoteItCtrl;
74 if(
null !=
path.getRoot())
switch (
path.getRoot()) {
84 case "talent-category":
115 String root =
path.getRoot();
116 if(
null != root)
switch (root) {
118 return I_.
get(
"Challenge");
120 return I_.
get(
"Answer");
121 case "practicalwork":
122 return I_.
get(
"Practical work");
123 case "talent-category":
124 return I_.
get(
"Talent category");
148 String root =
path.getRoot();
149 if(
null != root)
switch (root) {
151 return "/_zul/images/challenge.png";
153 return "/_zul/images/response.png";
154 case "practicalwork":
155 return "/_zul/images/operator.png";
156 case "talent-category":
157 return "/_zul/images/group.png";
189 return Collections.EMPTY_LIST;
205 String root =
path.getRoot();
242 public Collection
getEntitites(String search,
int maxResults, KeyValueMap kvm) {
243 ArrayList<Object> list =
new ArrayList<>();
244 list.addAll(searchChallenges(search, maxResults, kvm));
245 list.addAll(searchCategories(search, maxResults, kvm));
250 public Collection
getEntitites(String root, String search,
int maxResults, KeyValueMap kvm) {
251 ArrayList<Object> list =
new ArrayList<>();
252 if(
null != root)
switch (root) {
254 list.addAll(searchChallenges(search, maxResults, kvm));
256 case "talent-category":
257 list.addAll(searchCategories(search, maxResults, kvm));
310 return "challenge".equals(
getRoot()) ?
328 return Arrays.asList(
"challenge",
"response",
"practicalwork",
"talent-category");
346 private List<Object> searchChallenges(String search,
int maxResults, KeyValueMap kvm) {
348 wc.
addClause(
"select c from Challenge c");
349 wc.
addClause(
"where c.question like :search");
352 return getDao().getResultList(wc, maxResults);
355 private List<Object> searchCategories(String search,
int maxResults, KeyValueMap kvm) {
356 WhereClause wc =
new WhereClause();
357 wc.addClause(
"select c from TalentCategory c");
358 wc.addClause(
"where c.name like :search");
359 wc.addClause(
"order by c.name");
360 wc.addNamedValue(
"search",
"%" + search +
"%");
361 return getDao().getResultList(wc, maxResults);
369 return super.getEntityUrl(type, contextPath);
void setPublicOnly(boolean publicOnly)
void setEntityPath(String entityPath)
void addClause(String clause)
void addNamedValue(String name, Object value)
boolean isValidLongEntity()
boolean equals(Object obj)
static IElephantEntity getController(String path)
String getEntityUrl(LinkType type, String contextPath)
Collection< String > getAllowedRoots()
Object configureCtrl(Object ctrl, IContact contact)
StudentsEntities(String entityPath)
Collection getEntitites(String search, int maxResults, KeyValueMap kvm)
IElephantEntity createInstance(String entityPath)
IElephantEntity getParent()
IElephantEntity createInstance(Object entity)
StudentsEntities(Object entity)
boolean itsMine(Object entity)
String getExtendedWebPath()
boolean canEdit(IContact contact)
String getHierarchicalPath()
Collection getEntitites(String root, String search, int maxResults, KeyValueMap kvm)
boolean canShowInContext(IContact contact, Object relatedEntity)
List< IElephantEntity > getChildren()
boolean canPublish(IContact contact)
static String get(String msg)
void setEntityPath(String entityPath)
static String getObjectPath(Object object)
static String getObjectExtendedPath(Object object)
void setEntityPath(String entityPath)
void setEntityPath(String entityPath)
void setEntityPath(String entityPath)
void setEntityPath(String entityPath)