BrightSide Workbench Full Report + Source Code
org.turro.dossier.dossier.DossierCombobox Class Reference
Inheritance diagram for org.turro.dossier.dossier.DossierCombobox:
Collaboration diagram for org.turro.dossier.dossier.DossierCombobox:

Public Member Functions

void populateList (String value, LinkedList list, int nRows)
 
String getTextFromObject (Dossier value)
 
String getSubjectFromText (String text)
 
String getNameFromText (String text)
 
String getCategoryFromText (String text)
 
long getIdFromText (String text)
 
- Public Member Functions inherited from org.turro.zkoss.input.GenericCombobox< V >
 GenericCombobox ()
 
getObjectValue ()
 
void setObjectValue (V value)
 
boolean isAllowNotInModelValues ()
 
void setAllowNotInModelValues (boolean allowNotInModelValues)
 
void refreshModel ()
 
abstract String getTextFromObject (V value)
 
Object getRelatedEntity ()
 
void setRelatedEntity (Object relatedEntity)
 
void render (Comboitem item, Object data, int index) throws Exception
 

Detailed Description

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

Definition at line 35 of file DossierCombobox.java.

Member Function Documentation

◆ getCategoryFromText()

String org.turro.dossier.dossier.DossierCombobox.getCategoryFromText ( String  text)

Definition at line 123 of file DossierCombobox.java.

123  {
124  String[] s = text.split(Chars.forward().regexp().spaced().toString());
125  if(s.length == 5) {
126  // subject - store '|' name '|' contract + idStore - category
127  return s[4];
128  } else if(s.length == 3) {
129  // subject - name - category
130  return s[2];
131  } else if(s.length == 2) {
132  // name - category
133  return s[1];
134  }
135  return getNameFromText(text);
136  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIdFromText()

long org.turro.dossier.dossier.DossierCombobox.getIdFromText ( String  text)

Definition at line 138 of file DossierCombobox.java.

138  {
139  long id = 0;
140  int p = text.lastIndexOf("#");
141  try {
142  if(p > -1) {
143  id = Long.valueOf(text.substring(p + 1));
144  } else {
145  id = Long.valueOf(text);
146  }
147  } catch(Exception ex) {}
148  return id;
149  }
Here is the caller graph for this function:

◆ getNameFromText()

String org.turro.dossier.dossier.DossierCombobox.getNameFromText ( String  text)

Definition at line 108 of file DossierCombobox.java.

108  {
109  String[] s = text.split(Chars.forward().regexp().spaced().toString());
110  if(s.length == 5) {
111  // subject - store '|' name '|' contract + idStore - category
112  return s[1] + Chars.forward().spaced() + s[2] + Chars.forward().spaced() + s[3];
113  } else if(s.length == 3) {
114  // subject - name - category
115  return s[1];
116  } else if(s.length == 2) {
117  // name - category
118  return s[0];
119  }
120  return text;
121  }
Here is the caller graph for this function:

◆ getSubjectFromText()

String org.turro.dossier.dossier.DossierCombobox.getSubjectFromText ( String  text)

Definition at line 100 of file DossierCombobox.java.

100  {
101  String[] s = text.split(Chars.forward().regexp().spaced().toString());
102  if(s.length > 0) {
103  return s[0];
104  }
105  return getNameFromText(text);
106  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTextFromObject()

String org.turro.dossier.dossier.DossierCombobox.getTextFromObject ( Dossier  value)

Definition at line 96 of file DossierCombobox.java.

96  {
97  return value.getFullDescription() + " #" + value.getId();
98  }
Here is the call graph for this function:

◆ populateList()

void org.turro.dossier.dossier.DossierCombobox.populateList ( String  value,
LinkedList  list,
int  nRows 
)

Reimplemented from org.turro.zkoss.input.GenericCombobox< V >.

Definition at line 38 of file DossierCombobox.java.

38  {
39  boolean all = Application.getApplication().isInRole("dossier:all");
40  Dao dao = new DossierPU();
41  long id = getIdFromText(value);
42  WhereClause wc = new WhereClause();
43  wc.addClause("select distinct dossier from Dossier as dossier");
44  if(id > 0) {
45  wc.addClause("where dossier.id = :id");
46  wc.addNamedValue("id", id);
47  } else {
48  wc.addClause("where 1=1");
49  wc.addClause("and not exists (select p from Participant as p");
50  wc.addClause("where p.dossier = dossier and p.role = :rolenot)");
51  wc.addNamedValue("rolenot", ParticipantRole.PARTICIPANT_SUBJECT);
52  if(!Strings.isBlank(value)) {
53  wc.addClause("and (");
54  wc.setPrefix("");
55  wc.addLikeFields(new String[] {"dossier.description"}, getNameFromText(value));
56  wc.setPrefix("or");
57  wc.addLikeFields(new String[] {"dossier.category.fullDescription"}, getCategoryFromText(value));
58  wc.setPrefix(null);
59  wc.addClause(")");
60  }
61  wc.addClause("order by dossier.description");
62  }
63  for(Object o : dao.getResultList(wc, nRows)) {
64  if(all || new DossierWrapper((Dossier) (o)).isParticipant()) {
65  list.add((Dossier) o);
66  }
67  }
68  if(id < 1) {
69  wc = new WhereClause();
70  wc.addClause("select distinct dossier from Dossier as dossier");
71  wc.addClause("left join dossier.participants participant");
72  wc.addClause("where 1=1");
73  wc.addClause("and participant.role = :role");
74  wc.addNamedValue("role", ParticipantRole.PARTICIPANT_SUBJECT);
75  if(!Strings.isBlank(value)) {
76  wc.addClause("and (");
77  wc.setPrefix("");
78  wc.addLikeFields(new String[] {"participant.name"}, getSubjectFromText(value));
79  wc.setPrefix("or");
80  wc.addLikeFields(new String[] {"dossier.description"}, getNameFromText(value));
81  wc.setPrefix("or");
82  wc.addLikeFields(new String[] {"dossier.category.fullDescription"}, getCategoryFromText(value));
83  wc.setPrefix(null);
84  wc.addClause(")");
85  }
86  wc.addClause("order by dossier.description");
87  for(Object o : dao.getResultList(wc, nRows)) {
88  if(all || new DossierWrapper((Dossier) (o)).isParticipant()) {
89  list.add((Dossier) o);
90  }
91  }
92  }
93  }
Here is the call graph for this function:

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