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

Public Member Functions

String getParserName ()
 
Long getCount (IConstructor constructor, String syndicationId)
 
String getPublished (IConstructor constructor, int count, String syndicationId, String summaryTemplate, String fullTemplate, String context, boolean navigator)
 
String getPublished (IConstructor constructor, int count, String connector, String values, String summaryTemplate, String fullTemplate, String context, boolean navigator)
 
String getGroups (IConstructor constructor, String summaryTemplate, String fullTemplate, String context, String category)
 
- Public Member Functions inherited from org.turro.parser.AbstractParser
 AbstractParser ()
 
ParserMacroSet getParserMacros ()
 
boolean execute (IConstructor constructor, PrintWriter out, String[] tokens)
 

Protected Member Functions

boolean doExecute ()
 
void explainMacros (ParserMacroSet macros)
 
- Protected Member Functions inherited from org.turro.parser.AbstractParser
String getMacroName ()
 
String getToken (String name)
 
String getToken (String name, boolean defParameter)
 
String getToken (String name, String def)
 
String getToken (int index)
 
String getToken (int index, boolean defParameter)
 
String getToken (int index, String def)
 
int getTokenSize ()
 
String getDefaultFor (int index)
 
void prepareProperties (ElephantMarker marker, String properties)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.parser.AbstractParser
IConstructor constructor
 
String[] tokens
 
PrintWriter out
 
String parserName
 
ParserMacroSet parserMacros = new ParserMacroSet()
 

Detailed Description

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

Definition at line 54 of file ContactsParser.java.

Member Function Documentation

◆ doExecute()

boolean org.turro.parser.ContactsParser.doExecute ( )
protected

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 62 of file ContactsParser.java.

62  {
63  boolean done = false;
64  if("groups".equals(getMacroName())) {
65  out.write(getGroups(constructor,
66  null,
67  null,
68  getToken(1),
69  getToken(2)));
70  done = true;
71  } else if("contacts".equals(getMacroName()) || "contacts-summary".equals(getMacroName())) {
73  (Integer) ObjectString.parseNativeString(getToken(1), Integer.class, true),
74  getToken(2),
75  getToken(3),
76  getToken(5),
77  getToken(4),
78  "contacts".equals(getMacroName())));
79  done = true;
80  } else if("contacts-by-group".equals(getMacroName()) || "contacts-by-group-summary".equals(getMacroName())) {
81  out.write(getContactByGroup(constructor,
82  (Integer) ObjectString.parseNativeString(getToken(1), Integer.class, true),
83  getToken(2),
84  getToken(3),
85  null,
86  "contacts-by-group".equals(getMacroName())));
87  done = true;
88  } else if("contactcount".equals(getMacroName())) {
89  Long count = getCount(constructor, getToken(1));
90  out.write(count != null ? count + "" : "0");
91  done = true;
92  } else if("contacts-connector".equals(getMacroName()) || "contacts-connector-summary".equals(getMacroName())) {
94  (Integer) ObjectString.parseNativeString(getToken(1), Integer.class, true),
95  getToken(2),
96  getToken(3),
97  getToken(4),
98  getToken(6),
99  getToken(5),
100  "contacts-connector".equals(getMacroName())));
101  done = true;
102  } else if("my-data".equals(getMacroName())) {
103  out.write(checkMyData() ? getToken(1) : getToken(2));
104  done = true;
105  } else if("describe-it".equals(getMacroName())) {
106  if(!Strings.isBlank(getToken(1))) {
107  DescribeItCtrl dic = new DescribeItCtrl(constructor);
108  dic.setEntityPath(getToken(1));
109  dic.renderDescriptions(getToken(2), true);
110  done = true;
111  }
112  } else if("convocation-check".equals(getMacroName())) {
113  ConvocationCheck cc = new ConvocationCheck(constructor);
114  if(tokens.length == 2) {
115  cc.setTemplate(getToken(1));
116  }
117  out.write(cc.check());
118  } else if("convocations".equals(getMacroName()) || "convocation-summary".equals(getMacroName()) ||
119  "public-convocations".equals(getMacroName()) || "public-convocation-summary".equals(getMacroName()) ||
120  "myconvocations".equals(getMacroName()) || "myconvocation-summary".equals(getMacroName())) {
121  DaoHtmlSearch.renderInstance(constructor);
122  ConvocationContentIterator cci = new ConvocationContentIterator(constructor, out, Authentication.getIContact(), false,
123  Strings.isBlank(getToken(2)) ? null : ElephantContext.getRootWebPath() + getToken(2));
124  cci.setMode(getToken(1));
125  cci.setPage((Integer) ObjectString.parseNativeString(getToken(3), Integer.class, true));
126  cci.setAllowAttachments(true);
127  cci.setAllowComments(true);
128  cci.setSummaryTemplate(getToken(4));
129  if(getMacroName().contains("summary")) {
130  cci.setNavigatorTop(false);
131  cci.setNavigatorBottom(false);
132  }
133  if(getMacroName().contains("myconvocation")) {
134  cci.setRestricted(true);
135  }
136  if(getMacroName().contains("public-")) {
137  cci.setPublishable(true);
138  }
139  cci.load();
140  cci.render();
141  done = true;
142  } else if("old-directory".equals(getMacroName())) {
143  DaoHtmlSearch.renderInstance(constructor);
144  OldDirectoryContentIterator dci = new OldDirectoryContentIterator(constructor, out, Authentication.getIContact(), false,
145  Strings.isBlank(getToken(1)) ? null : ElephantContext.getRootWebPath() + getToken(1));
146  dci.setPage((Integer) ObjectString.parseNativeString(getToken(2), Integer.class, true));
147  dci.setAllowAttachments(true);
148  dci.setAllowFiles(true);
149  dci.setAllowComments(true);
150  dci.setRestricted(true);
151  dci.setSummaryTemplate(getToken(3));
152  dci.load();
153  dci.render();
154  done = true;
155  } else if(getMacroName().startsWith("directory")) {
156  DaoHtmlSearch.renderInstance(constructor);
157  DirectoryContentIterator pci = new DirectoryContentIterator(constructor, out, Authentication.getIContact(), false,
158  Strings.isBlank(getToken(2)) ? null : ElephantContext.getRootWebPath() + getToken(2));
159  pci.setPage((Integer) ObjectString.parseNativeString(getToken(3), Integer.class, true));
160  pci.setAllowAttachments(true);
161  pci.setAllowFiles(true);
162  pci.setRestricted(false);
163  pci.setTypes(getToken(1));
164  pci.setSummaryTemplate(getToken(4));
165  pci.assignDefaultsByName(getMacroName());
166  pci.load();
167  pci.render();
168  done = true;
169  } else if(getMacroName().startsWith("syndications")) {
170  DaoHtmlSearch.renderInstance(constructor);
171  DirectoryContentIterator pci = new DirectoryContentIterator(constructor, out, Authentication.getIContact(), false,
172  Strings.isBlank(getToken(3)) ? null : ElephantContext.getRootWebPath() + getToken(3));
173  pci.setPage((Integer) ObjectString.parseNativeString(getToken(4), Integer.class, true));
174  pci.setAllowAttachments(true);
175  pci.setAllowFiles(true);
176  pci.setRestricted(false);
177  pci.setTypes(getToken(1));
178  pci.setSyndications(getToken(2));
179  pci.setSummaryTemplate(getToken(5));
180  pci.assignDefaultsByName(getMacroName());
181  pci.load();
182  pci.render();
183  done = true;
184  } else if("services".equals(getMacroName()) || "service-summary".equals(getMacroName()) ||
185  "myservices".equals(getMacroName()) || "myservice-summary".equals(getMacroName()) ||
186  "lastservices".equals(getMacroName()) || "lastservice-summary".equals(getMacroName()) ||
187  "mylastservices".equals(getMacroName()) || "mylastservice-summary".equals(getMacroName())) {
188  ContactServiceContentIterator csci = new ContactServiceContentIterator(constructor, out, Authentication.getIContact(), false,
189  Strings.isBlank(getToken(3)) ? null : ElephantContext.getRootWebPath() + getToken(3));
190  String role = getToken(1);
191  csci.setRole("all".equals(role) ? null : ContactServiceRole.valueOf(role));
192  String type = getToken(2);
193  csci.setType("all".equals(type) ? null : type);
194  csci.setPage((Integer) ObjectString.parseNativeString(getToken(4), Integer.class, true));
195  csci.setAllowAttachments(true);
196  csci.setAllowComments(true);
197  csci.setSummaryTemplate(getToken(5));
198  if(getMacroName().contains("summary")) {
199  csci.setNavigatorTop(false);
200  csci.setNavigatorBottom(false);
201  }
202  if(getMacroName().contains("my")) {
203  csci.setRestricted(true);
204  }
205  if(getMacroName().contains("last")) {
206  csci.setLastEntries(true);
207  csci.setForceSummary(true);
208  }
209  csci.load();
210  csci.render();
211  done = true;
212  } else if("register".equals(getMacroName())) {
213  SignUpCtrl ctrl = new SignUpCtrl();
214  ctrl.setConstructor(constructor);
215  ctrl.setTemplate(getToken(1));
216  out.write(ctrl.parse(constructor));
217  } else if("profile".equals(getMacroName())) {
218  DirectoryContentIterator pci = new DirectoryContentIterator(constructor, out, Authentication.getIContact(), false, null);
219  pci.setPage(100);
220  pci.setNavigatorTop(false);
221  pci.setNavigatorBottom(false);
222  pci.setAllowAttachments(true);
223  pci.setAllowFiles(true);
224  pci.setRestricted(false);
225  pci.setContactIds(Strings.toList(getToken(1), ";"));
226  pci.setSummaryTemplate(getToken(2));
227  pci.assignDefaultsByName(getMacroName());
228  pci.load();
229  pci.render();
230  done = true;
231  } else if("myprofile".equals(getMacroName())) {
232  ProfileCtrl ctrl = new ProfileCtrl();
233  ctrl.setConstructor(constructor);
234  ctrl.setTemplate(getToken(1));
235  ctrl.setContact(null); // forces current
236  out.write(ctrl.parse(constructor));
237  }
238  return done;
239  }
Long getCount(IConstructor constructor, String syndicationId)
String getGroups(IConstructor constructor, String summaryTemplate, String fullTemplate, String context, String category)
String getPublished(IConstructor constructor, int count, String syndicationId, String summaryTemplate, String fullTemplate, String context, boolean navigator)
Here is the call graph for this function:

◆ explainMacros()

void org.turro.parser.ContactsParser.explainMacros ( ParserMacroSet  macros)
protected

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 242 of file ContactsParser.java.

242  {
243  macros.addMacro("groups")
244  .addParameter("context", false)
245  .addParameter("group-category", false);
246  macros.addMacro("contacts")
247  .addParameter("count", true, "10")
248  .addParameter("syndicationId", true)
249  .addParameter("summaryTemplate", true, "summary")
250  .addParameter("context", true)
251  .addParameter("fullTemplate", true, "full");
252  macros.addMacro("contacts-summary")
253  .copyParametersFrom("contacts", macros);
254  macros.addMacro("contacts-by-group")
255  .addParameter("count", true, "10")
256  .addParameter("groupings", true)
257  .addParameter("summaryTemplate", true, "summary");
258  macros.addMacro("contacts-by-group-summary")
259  .copyParametersFrom("contacts-by-group", macros);
260  macros.addMacro("contactcount")
261  .addParameter("syndicationId", true);
262  macros.addMacro("contacts-connector")
263  .addParameter("count", false, "10")
264  .addParameter("connector", false)
265  .addParameter("value", true, null, true)
266  .addParameter("summaryTemplate", true, "summary")
267  .addParameter("context", true)
268  .addParameter("fullTemplate", true, "full");
269  macros.addMacro("contacts-connector-summary")
270  .copyParametersFrom("contacts-connector", macros);
271  macros.addMacro("my-data")
272  .addParameter("valid", false)
273  .addParameter("not-valid", false);
274  macros.addMacro("describe-it")
275  .addParameter("entityPath", false)
276  .addParameter("id", true, "Default");
277  macros.addMacro("convocation-check")
278  .addParameter("template", true, "check");
279  macros.addMacro("convocations")
280  .addParameter("mode", false)
281  .addPossibleValue("open")
282  .addPossibleValue("closed")
283  .addPossibleValue("all")
284  .addParameter("context", true)
285  .addParameter("count", true, "10")
286  .addParameter("template", true, "summary");
287  macros.addMacro("convocation-summary")
288  .copyParametersFrom("convocations", macros);
289  macros.addMacro("myconvocations")
290  .copyParametersFrom("convocations", macros);
291  macros.addMacro("myconvocation-summary")
292  .copyParametersFrom("convocations", macros);
293  macros.addMacro("public-convocations")
294  .copyParametersFrom("convocations", macros);
295  macros.addMacro("public-convocation-summary")
296  .copyParametersFrom("convocations", macros);
297  macros.addMacro("old-directory")
298  .addParameter("context", true)
299  .addParameter("count", true, "12")
300  .addParameter("template", true, "summary");
301  macros.addMacro("directory")
302  .addParameter("type", true, "all", true)
303  .addPossibleValue("all")
304  .addPossibleValue("typed")
305  .addPossibleValue("companies")
306  .addPossibleValue("centers")
307  .addPossibleValue("professionals")
308  .addPossibleValue("educators")
309  .addPossibleValue("students")
310  .addPossibleValue("singletons")
311  .addParameter("context", true)
312  .addParameter("count", true, "12")
313  .addParameter("template", true, "summary");
314  macros.addDefaultsFor("directory", macros);
315  macros.addMacro("syndications")
316  .addParameter("type", true, "all", true)
317  .addPossibleValue("all")
318  .addPossibleValue("typed")
319  .addPossibleValue("companies")
320  .addPossibleValue("centers")
321  .addPossibleValue("professionals")
322  .addPossibleValue("educators")
323  .addPossibleValue("students")
324  .addPossibleValue("singletons")
325  .addParameter("syndicationId", true)
326  .addParameter("context", true)
327  .addParameter("count", true, "12")
328  .addParameter("template", true, "summary");
329  macros.addDefaultsFor("syndications", macros);
330  macros.addMacro("services")
331  .addParameter("role", false)
332  .addPossibleValue("SERVICE_SUPPLY")
333  .addPossibleValue("SERVICE_DEMAND")
334  .addParameter("type", false)
335  .addParameter("context", true)
336  .addParameter("count", true, "10")
337  .addParameter("template", true, "summary");
338  macros.addMacro("service-summary")
339  .copyParametersFrom("services", macros);
340  macros.addMacro("myservices")
341  .copyParametersFrom("services", macros);
342  macros.addMacro("myservice-summary")
343  .copyParametersFrom("services", macros);
344  macros.addMacro("lastservices")
345  .copyParametersFrom("services", macros);
346  macros.addMacro("lastservice-summary")
347  .copyParametersFrom("services", macros);
348  macros.addMacro("mylastservices")
349  .copyParametersFrom("services", macros);
350  macros.addMacro("mylastservice-summary")
351  .copyParametersFrom("services", macros);
352  macros.addMacro("register")
353  .addParameter("template", true, "signup");
354  macros.addMacro("profile")
355  .addParameter("contactIds", false)
356  .addParameter("template", true, "summary");
357  macros.addMacro("myprofile")
358  .addParameter("template", true, "profile");
359  }
Here is the call graph for this function:

◆ getCount()

Long org.turro.parser.ContactsParser.getCount ( IConstructor  constructor,
String  syndicationId 
)

Definition at line 361 of file ContactsParser.java.

361  {
362  WhereClause wc = new WhereClause();
363  wc.addClause("select count(c) from Contact as c");
364  if(!Strings.isBlank(syndicationId)) {
365  wc.addClause("join c.syndications as s");
366  wc.addClause("where s.name = :syndication");
367  wc.addNamedValue("syndication", syndicationId);
368  }
369  return (Long) new ContactsPU().getSingleResultOrNull(wc);
370  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGroups()

String org.turro.parser.ContactsParser.getGroups ( IConstructor  constructor,
String  summaryTemplate,
String  fullTemplate,
String  context,
String  category 
)

Definition at line 441 of file ContactsParser.java.

441  {
442  try {
444  GroupsTree pi = new GroupsTree(constructor, ElephantContext.getRootWebPath() + context, category);
445  pi.fillTree("");
446  pi.render();
447  constructor.setOut(null);
448  return constructor.getOutputString();
449  } catch (IOException ex) {
450  Logger.getLogger(ContactsParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
451  }
452  return null;
453  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParserName()

String org.turro.parser.ContactsParser.getParserName ( )

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 57 of file ContactsParser.java.

57  {
58  return "Contacts";
59  }

◆ getPublished() [1/2]

String org.turro.parser.ContactsParser.getPublished ( IConstructor  constructor,
int  count,
String  connector,
String  values,
String  summaryTemplate,
String  fullTemplate,
String  context,
boolean  navigator 
)

Definition at line 397 of file ContactsParser.java.

398  {
399  try {
401  DaoHtmlSearch.renderInstance(constructor);
402  ContactIterator pi = new ContactIterator(constructor, ElephantContext.getRootWebPath() + context, null);
403  pi.setNavigatorTop(navigator);
404  pi.setNavigatorBottom(navigator);
405  pi.setFullTemplate(fullTemplate);
406  pi.setSummaryTemplate(summaryTemplate);
407  pi.setPage(count);
408  pi.setConnector(connector, values);
409  pi.load();
410  pi.render();
411  constructor.setOut(null);
412  return constructor.getOutputString();
413  } catch (IOException ex) {
414  Logger.getLogger(ContactsParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
415  }
416  return null;
417  }

◆ getPublished() [2/2]

String org.turro.parser.ContactsParser.getPublished ( IConstructor  constructor,
int  count,
String  syndicationId,
String  summaryTemplate,
String  fullTemplate,
String  context,
boolean  navigator 
)

Definition at line 372 of file ContactsParser.java.

373  {
374  try {
375  if(context == null) {
376  context = constructor.getCurrentContext().getPath();
377  }
379  DaoHtmlSearch.renderInstance(constructor);
380  ContactIterator pi = new ContactIterator(constructor, ElephantContext.getRootWebPath() + context, null);
381  pi.setNavigatorTop(navigator);
382  pi.setNavigatorBottom(navigator);
383  pi.setFullTemplate(fullTemplate);
384  pi.setSummaryTemplate(summaryTemplate);
385  pi.setPage(count);
386  pi.setSyndicationId(syndicationId);
387  pi.load();
388  pi.render();
389  constructor.setOut(null);
390  return constructor.getOutputString();
391  } catch (IOException ex) {
392  Logger.getLogger(ContactsParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
393  }
394  return null;
395  }
Here is the call graph for this function:
Here is the caller graph for this function:

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