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.annotation.ElephantEntity;
28 import org.turro.collections.KeyValueMap;
29 import org.turro.command.LabelControl;
30 import org.turro.crm.db.CrmPU;
31 import org.turro.crm.entity.Campaign;
32 import org.turro.crm.entity.Customer;
33 import org.turro.crm.entity.SaleAction;
34 import org.turro.crm.entity.SaleProspect;
35 import org.turro.crm.entity.Vendor;
36 import org.turro.crm.entity.VendorProspect;
37 import org.turro.crm.zul.menu.CrmMenu;
38 import org.turro.elephant.db.WhereClause;
39 import org.turro.i18n.I_;
40 import org.turro.jpa.Dao;
41 import org.turro.path.Path;
42 import org.turro.plugin.contacts.IContact;
67 if(
null !=
path.getRoot())
switch (
path.getRoot()) {
80 case "vendor-prospect":
116 String root =
path.getRoot();
117 if(
null != root)
switch (root) {
119 return I_.
get(
"Vendor");
121 return I_.
get(
"Customer");
123 return I_.
get(
"Campaign");
124 case "sale-prospect":
125 return I_.
get(
"Sale prospect");
126 case "vendor-prospect":
127 return I_.
get(
"Vendor prospect");
129 return I_.
get(
"Sale action");
153 String root =
path.getRoot();
154 if(
null != root)
switch (root) {
156 return "/_zul/images/vendor.png";
158 return "/_zul/images/customer.png";
160 return "/_zul/images/campaign.png";
161 case "sale-prospect":
162 return "/_zul/images/sale.png";
164 return "/_zul/images/appointment.png";
184 return Collections.EMPTY_LIST;
264 public Collection
getEntitites(String search,
int maxResults, KeyValueMap kvm) {
265 ArrayList<Object> list =
new ArrayList<>();
266 list.addAll(searchVendors(search, maxResults, kvm));
267 list.addAll(searchCustomers(search, maxResults, kvm));
272 public Collection
getEntitites(String root, String search,
int maxResults, KeyValueMap kvm) {
273 ArrayList<Object> list =
new ArrayList<>();
274 if(
null != root)
switch (root) {
276 list.addAll(searchVendors(search, maxResults, kvm));
279 list.addAll(searchCustomers(search, maxResults, kvm));
326 return Arrays.asList(
"vendor",
"customer",
"campaign",
"sale-prospect",
327 "vendor-prospect",
"sale-action");
345 private List<Object> searchVendors(String search,
int maxResults, KeyValueMap kvm) {
348 wc.
addClause(
"where c.name like :search");
351 return getDao().getResultList(wc, maxResults);
354 private List<Object> searchCustomers(String search,
int maxResults, KeyValueMap kvm) {
355 WhereClause wc =
new WhereClause();
356 wc.addClause(
"select c from Customer c");
357 wc.addClause(
"where c.name like :search");
358 wc.addClause(
"order by c.name");
359 wc.addNamedValue(
"search",
"%" + search +
"%");
360 return getDao().getResultList(wc, maxResults);
static String getObjectPath(Object object)
VendorProspect getVendorProspect()
SaleProspect getSaleProspect()
void addClause(String clause)
void addNamedValue(String name, Object value)
Collection getEntitites(String search, int maxResults, KeyValueMap kvm)
String getExtendedWebPath()
boolean canShowInContext(IContact contact, Object relatedEntity)
IElephantEntity createInstance(String entityPath)
boolean itsMine(String rootPath)
Collection getEntitites(String root, String search, int maxResults, KeyValueMap kvm)
boolean itsMine(Object entity)
boolean canPublish(IContact contact)
IElephantEntity createInstance(Object entity)
List< IElephantEntity > getChildren()
Object configureCtrl(Object ctrl, IContact contact)
CrmEntities(String entityPath)
CrmEntities(Object entity)
IElephantEntity getParent()
String getHierarchicalPath()
Collection< String > getAllowedRoots()
boolean canEdit(IContact contact)
boolean isValidLongEntity()
static String get(String msg)
boolean isInRole(String role)