001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2007
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.faces.beans;
034:
035: import com.flexive.faces.FxJsfUtils;
036: import com.flexive.faces.messages.FxFacesMsgErr;
037: import com.flexive.shared.*;
038: import com.flexive.shared.exceptions.FxApplicationException;
039: import com.flexive.shared.interfaces.TemplateEngine;
040: import com.flexive.shared.interfaces.UserGroupEngine;
041: import com.flexive.shared.scripting.FxScriptEvent;
042: import com.flexive.shared.scripting.FxScriptInfo;
043: import com.flexive.shared.scripting.FxScriptScope;
044: import com.flexive.shared.search.AdminResultLocations;
045: import com.flexive.shared.search.FxSQLSearchParams;
046: import com.flexive.shared.search.ResultViewType;
047: import com.flexive.shared.search.SortDirection;
048: import com.flexive.shared.search.query.PropertyValueComparator;
049: import com.flexive.shared.search.query.QueryOperatorNode;
050: import com.flexive.shared.security.*;
051: import com.flexive.shared.structure.*;
052: import com.flexive.shared.tree.FxTemplateInfo;
053: import com.flexive.shared.value.BinaryDescriptor;
054:
055: import javax.faces.model.SelectItem;
056: import java.io.Serializable;
057: import java.util.ArrayList;
058: import java.util.Collections;
059: import java.util.List;
060: import java.util.Map;
061:
062: /**
063: * Wrapper bean that provides access to most internal flexive3 select lists
064: * via JSF's SelectItem.
065: *
066: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
067: * @version $Rev: 224 $
068: */
069: public class SelectBean implements Serializable {
070: private static final long serialVersionUID = 9155928639067833112L;
071: private FxEnvironment environment;
072:
073: /* Cache select lists during request */
074: private List<SelectItem> workflows = null;
075: private List<SelectItem> userGroups = null;
076: private List<SelectItem> userGroupsNonSystem = null;
077: private List<SelectItem> briefcaseACLs = null;
078: private List<SelectItem> contentACLs = null;
079: private List<SelectItem> globalUserGroups = null;
080: private List<SelectItem> globalUserGroupsNonSystem = null;
081: private List<SelectItem> languages = null;
082: private List<SelectItem> mandators = null;
083: private List<SelectItem> mandatorsForEdit = null;
084: private List<SelectItem> mandatorsForEditNoEmpty = null;
085: private List<SelectItem> queryNodeOperators = null;
086: private List<SelectItem> queryNodeComparators = null;
087: private List<SelectItem> roles = null;
088: private List<SelectItem> stepDefinitions = null;
089: private List<SelectItem> structureACLs = null;
090: private List<SelectItem> workflowACLs = null;
091: private List<SelectItem> acls = null;
092: private List<SelectItem> templates = null;
093: private List<SelectItem> masterTemplates = null;
094: private List<SelectItem> contentTemplates = null;
095: private List<SelectItem> resultViewTypes = null;
096: private List<SelectItem> resultLocations = null;
097: private List<SelectItem> resultDirections = null;
098: private List<SelectItem> previewSizes = null;
099: private List<SelectItem> cacheModes = null;
100: private List<SelectItem> uniqueModes = null;
101: private List<SelectItem> dataTypes = null;
102: private List<SelectItem> languageModes = null;
103: private List<SelectItem> typeModes = null;
104: private List<SelectItem> typeStates = null;
105: private List<SelectItem> typeCategories = null;
106: private List<SelectItem> groupModes = null;
107: private List<SelectItem> restrictedTypeModes = null;
108: private List<SelectItem> restrictedTypeCategories = null;
109: private List<SelectItem> typeScriptEvents = null;
110: private List<SelectItem> assignmentScripts = null;
111: private List<SelectItem> assignmentScriptEvents = null;
112: private List<SelectItem> allScriptEvents = null;
113: private List<SelectItem> allScriptEventsAsEnum = null;
114: private List<SelectItem> scriptScopes = null;
115: private List<SelectItem> allScripts = null;
116: private List<SelectItem> typeScripts = null;
117: private List<SelectItem> aclCategories = null;
118: private List<SelectItem> selectListACLs = null;
119: private List<SelectItem> selectListItemACLs = null;
120: private List<SelectItem> scriptingEngines = null;
121:
122: /**
123: * Constructs a new select bean.
124: */
125: public SelectBean() {
126: environment = CacheAdmin.getFilteredEnvironment();
127: }
128:
129: /**
130: * Format an item to display the items mandator if it is not the users mandator
131: *
132: * @param userMandator user mandator id
133: * @param itemMandator item mandator id
134: * @param item item name
135: * @return formatted item
136: */
137: private String formatSelectItem(long userMandator,
138: long itemMandator, String item) {
139: if (userMandator == itemMandator)
140: return item;
141: return environment.getMandator(itemMandator).getName() + ": "
142: + item;
143: }
144:
145: /**
146: * Returns all workflows currently defined in flexive3.
147: *
148: * @return all workflows currently defined in flexive3.
149: */
150: public List<SelectItem> getWorkflows() {
151: if (workflows == null) {
152: workflows = FxJsfUtils.asIdSelectList(environment
153: .getWorkflows());
154: }
155: return workflows;
156: }
157:
158: /**
159: * Returns all user groups defined for the current mandator.
160: *
161: * @return all user groups defined for the current mandator.
162: * @throws FxApplicationException if the user groups could not be fetched successfully.
163: */
164: public List<SelectItem> getUserGroups()
165: throws FxApplicationException {
166: if (userGroups == null) {
167: UserGroupEngine groupEngine = EJBLookup
168: .getUserGroupEngine();
169: long mandatorId = FxContext.get().getTicket()
170: .getMandatorId();
171: List<UserGroup> groups = groupEngine.loadAll(mandatorId)
172: .getList();
173: userGroups = FxJsfUtils.asSelectList(groups, false);
174: }
175: return userGroups;
176: }
177:
178: /**
179: * Returns all user groups defined for the current mandator that are not flagged as system.
180: *
181: * @return all user groups defined for the current mandator.
182: * @throws FxApplicationException if the user groups could not be fetched successfully.
183: */
184: public List<SelectItem> getUserGroupsNonSystem()
185: throws FxApplicationException {
186: if (userGroupsNonSystem == null) {
187: UserGroupEngine groupEngine = EJBLookup
188: .getUserGroupEngine();
189: long mandatorId = FxContext.get().getTicket()
190: .getMandatorId();
191: List<UserGroup> groups = groupEngine.loadAll(mandatorId)
192: .getList();
193: userGroupsNonSystem = new ArrayList<SelectItem>(groups
194: .size());
195:
196: for (UserGroup group : groups) {
197: if (group.isSystem())
198: continue;
199: userGroupsNonSystem.add(new SelectItem(group, group
200: .getName()));
201: }
202: }
203: return userGroupsNonSystem;
204: }
205:
206: /**
207: * Returns all CONTENT templates.
208: *
209: * @return all CONTENT templates
210: * @throws FxApplicationException if the function failed
211: */
212: public List<SelectItem> getTemplates()
213: throws FxApplicationException {
214: if (templates == null) {
215: TemplateEngine templateEngine = EJBLookup
216: .getTemplateEngine();
217: List<FxTemplateInfo> list = templateEngine.list(null);
218: templates = FxJsfUtils.asSelectList(list, false);
219: }
220: return templates;
221: }
222:
223: /**
224: * Returns all CONTENT templates.
225: *
226: * @return all CONTENT templates
227: * @throws FxApplicationException if the function failed
228: */
229: public List<SelectItem> getContentTemplates()
230: throws FxApplicationException {
231: if (contentTemplates == null) {
232: TemplateEngine templateEngine = EJBLookup
233: .getTemplateEngine();
234: List<FxTemplateInfo> list = templateEngine
235: .list(TemplateEngine.Type.CONTENT);
236: contentTemplates = FxJsfUtils.asSelectList(list, false);
237: }
238: return contentTemplates;
239: }
240:
241: /**
242: * Returns all MASTER templates.
243: *
244: * @return all CONTENT templates
245: * @throws FxApplicationException if the function failed
246: */
247: public List<SelectItem> getMasterTemplates()
248: throws FxApplicationException {
249: if (masterTemplates == null) {
250: TemplateEngine templateEngine = EJBLookup
251: .getTemplateEngine();
252: List<FxTemplateInfo> list = templateEngine
253: .list(TemplateEngine.Type.MASTER);
254: masterTemplates = FxJsfUtils.asSelectList(list, false);
255: }
256: return masterTemplates;
257: }
258:
259: /**
260: * Returns all user groups within the system.
261: *
262: * @return all user groups in the system.
263: * @throws FxApplicationException if the user groups could not be fetched successfully.
264: */
265: public List<SelectItem> getGlobalUserGroups()
266: throws FxApplicationException {
267: if (globalUserGroups == null) {
268: UserGroupEngine groupEngine = EJBLookup
269: .getUserGroupEngine();
270: List<UserGroup> groups = groupEngine.loadAll(-1).getList();
271: globalUserGroups = new ArrayList<SelectItem>(groups.size());
272: long mandator = FxContext.get().getTicket().getMandatorId();
273: for (UserGroup group : groups) {
274: globalUserGroups.add(new SelectItem(group, group
275: .isSystem() ? group.getName()
276: : formatSelectItem(mandator, group
277: .getMandatorId(), group.getName())));
278: }
279: }
280: return globalUserGroups;
281: }
282:
283: /**
284: * Returns all user groups within the system that are not flagged as system.
285: *
286: * @return all user groups in the system.
287: * @throws FxApplicationException if the user groups could not be fetched successfully.
288: */
289: public List<SelectItem> getGlobalUserGroupsNonSystem()
290: throws FxApplicationException {
291: if (globalUserGroupsNonSystem == null) {
292: UserGroupEngine groupEngine = EJBLookup
293: .getUserGroupEngine();
294: List<UserGroup> groups = groupEngine.loadAll(-1).getList();
295: globalUserGroupsNonSystem = new ArrayList<SelectItem>(
296: groups.size());
297: long mandator = FxContext.get().getTicket().getMandatorId();
298: for (UserGroup group : groups) {
299: if (group.isSystem())
300: continue;
301: globalUserGroupsNonSystem.add(new SelectItem(group,
302: formatSelectItem(mandator, group
303: .getMandatorId(), group.getName())));
304: }
305: }
306: return globalUserGroupsNonSystem;
307: }
308:
309: /**
310: * Returns all types within the system.
311: *
312: * @return all type in the system
313: * @throws FxApplicationException if the types could not be fetched successfully.
314: */
315: public List<SelectItem> getTypes() throws FxApplicationException {
316: List<FxType> typesList = CacheAdmin.getFilteredEnvironment()
317: .getTypes(true, true, true, false);
318: return FxJsfUtils.asSelectListWithLabel(typesList);
319: }
320:
321: /**
322: * Returns all roles.
323: *
324: * @return all roles
325: * @throws FxApplicationException if the function fails
326: */
327: public List<SelectItem> getRoles() throws FxApplicationException {
328: if (roles == null) {
329: roles = FxJsfUtils.asSelectList(Role.getList(), false);
330: }
331: return roles;
332: }
333:
334: /**
335: * Returns all mandators that may be selected in a create or edit screen, plus an empty element.
336: *
337: * @return all mandators that may be selected in a create or edit screen
338: */
339: public List<SelectItem> getMandatorsForEdit() {
340: if (mandatorsForEdit == null) {
341: mandatorsForEdit = FxJsfUtils.asSelectList(
342: _getMandatorsForEdit(), true);
343: }
344: return mandatorsForEdit;
345: }
346:
347: /**
348: * Returns all mandators that may be selected in a create or edit screen, with no empty element.
349: *
350: * @return all mandators that may be selected in a create or edit screen
351: */
352: public List<SelectItem> getMandatorsForEditNoEmpty() {
353: if (mandatorsForEditNoEmpty == null) {
354: mandatorsForEditNoEmpty = FxJsfUtils.asSelectList(
355: _getMandatorsForEdit(), false);
356: }
357: return mandatorsForEditNoEmpty;
358: }
359:
360: /**
361: * Helper function for the getMandators__ functions.
362: *
363: * @return a list with all mandators
364: */
365: private List<Mandator> _getMandatorsForEdit() {
366: final UserTicket ticket = FxJsfUtils.getRequest()
367: .getUserTicket();
368: List<Mandator> list;
369:
370: if (ticket.isGlobalSupervisor()) {
371: list = CacheAdmin.getFilteredEnvironment().getMandators(
372: true, false);
373: } else {
374: list = new ArrayList<Mandator>(1);
375: Mandator mand = CacheAdmin.getFilteredEnvironment()
376: .getMandator(ticket.getMandatorId());
377: list.add(mand);
378: }
379: return list;
380: }
381:
382: /**
383: * Returns all active mandators.
384: *
385: * @return all active mandators
386: */
387: public List<SelectItem> getMandators() {
388: if (mandators == null) {
389: List<Mandator> list = CacheAdmin.getFilteredEnvironment()
390: .getMandators(true, false);
391: mandators = FxJsfUtils.asSelectList(list, false);
392: }
393: return mandators;
394: }
395:
396: /**
397: * Returns all select lists including an empty element.
398: *
399: * @return all available selectlists including an empty element.
400: */
401:
402: public List<SelectItem> getSelectListsWithEmpty() {
403: UserTicket ticket = FxJsfUtils.getRequest().getUserTicket();
404: List<FxSelectList> selectLists = CacheAdmin
405: .getFilteredEnvironment().getSelectLists();
406: ArrayList<SelectItem> result = new ArrayList<SelectItem>(
407: selectLists.size() + 1);
408: result.add(new SelectItem((long) -1, ""));
409: for (FxSelectList list : selectLists) {
410: result.add(new SelectItem(list.getId(), list.getLabel()
411: .getBestTranslation(ticket), list.getDescription()
412: .getBestTranslation(ticket)));
413: }
414: return result;
415: }
416:
417: /**
418: * Return all available languages.
419: *
420: * @return all available languages.
421: */
422: public List<SelectItem> getLanguages() {
423: if (languages == null) {
424: final UserTicket ticket = FxJsfUtils.getRequest()
425: .getUserTicket();
426: try {
427: FxLanguage list[] = EJBLookup.getLanguageEngine()
428: .loadAvailable();
429: ArrayList<SelectItem> result = new ArrayList<SelectItem>(
430: list.length);
431: for (FxLanguage item : list) {
432: String label = item.getLabel().getBestTranslation(
433: ticket);
434: result.add(new SelectItem(item, label/*label*/,
435: label/*description*/));
436: }
437: languages = result;
438: } catch (Exception exc) {
439: new FxFacesMsgErr(exc).addToContext();
440: languages = new ArrayList<SelectItem>(0);
441: }
442: }
443: return languages;
444: }
445:
446: /**
447: * Return all available content ACLs.
448: *
449: * @return all available content ACLs.
450: */
451: public List<SelectItem> getContentACLs() {
452: if (contentACLs == null) {
453: contentACLs = FxJsfUtils.asSelectList(environment
454: .getACLs(ACL.Category.INSTANCE), false);
455: }
456: return contentACLs;
457: }
458:
459: /**
460: * Returns all available ACLs.
461: *
462: * @return all available ACLs.
463: */
464: public List<SelectItem> getACLs() {
465: if (acls == null) {
466: acls = FxJsfUtils
467: .asSelectList(environment.getACLs(), false);
468: }
469: return acls;
470: }
471:
472: /**
473: * Return all available briefcase ACLs.
474: *
475: * @return all available briefcase ACLs.
476: */
477: public List<SelectItem> getBriefcaseACLs() {
478: if (briefcaseACLs == null) {
479: briefcaseACLs = FxJsfUtils
480: .asSelectListWithLabel(environment
481: .getACLs(ACL.Category.BRIEFCASE));
482: }
483: return briefcaseACLs;
484: }
485:
486: /**
487: * Return all available structure ACLs.
488: *
489: * @return all available structure ACLs asIdSelectList.
490: */
491: public List<SelectItem> getStructureACLs() {
492: if (structureACLs == null) {
493: structureACLs = FxJsfUtils
494: .asSelectListWithLabel(environment
495: .getACLs(ACL.Category.STRUCTURE));
496: }
497: return structureACLs;
498: }
499:
500: /**
501: * Return all available workflow ACLs.
502: *
503: * @return all available workflow ACLs.
504: */
505: public List<SelectItem> getWorkflowACLs() {
506: if (workflowACLs == null) {
507: workflowACLs = FxJsfUtils.asSelectListWithLabel(environment
508: .getACLs(ACL.Category.WORKFLOW));
509: }
510: return workflowACLs;
511: }
512:
513: /**
514: * Return all available step defintions.
515: *
516: * @return all available step defintions.
517: */
518: public List<SelectItem> getStepDefinitions() {
519: if (stepDefinitions == null) {
520: stepDefinitions = FxJsfUtils
521: .asSelectListWithLabel(environment
522: .getStepDefinitions());
523: }
524: return stepDefinitions;
525: }
526:
527: /**
528: * Return all defined properties.
529: *
530: * @return all defined properties.
531: */
532: public List<SelectItem> getProperties() {
533: return FxJsfUtils.asIdSelectList(environment.getProperties(
534: true, true));
535: }
536:
537: /**
538: * Return all defined language modes.
539: *
540: * @return all defined language modes.
541: */
542: public List<SelectItem> getLanguageModes() {
543: if (languageModes == null) {
544: languageModes = FxJsfUtils.enumsAsSelectList(LanguageMode
545: .values());
546: }
547: return languageModes;
548: }
549:
550: /**
551: * Return all defined group modes.
552: *
553: * @return all defined group modes.
554: */
555: public List<SelectItem> getGroupModes() {
556: if (groupModes == null) {
557: groupModes = FxJsfUtils.enumsAsSelectList(GroupMode
558: .values());
559: }
560: return groupModes;
561: }
562:
563: /**
564: * Return all defined type modes.
565: *
566: * @return all defined type modes.
567: */
568: public List<SelectItem> getTypeModes() {
569: if (typeModes == null) {
570: typeModes = FxJsfUtils.enumsAsSelectList(TypeMode.values());
571: }
572: return typeModes;
573: }
574:
575: /**
576: * Return type modes that are relevant for the structure editor ui
577: *
578: * @return structure editor relevant type modes.
579: */
580: public List<SelectItem> getRestrictedTypeModes() {
581: if (restrictedTypeModes == null) {
582: restrictedTypeModes = FxJsfUtils.enumsAsSelectList(TypeMode
583: .values());
584: SelectItem toRemove = null;
585: for (SelectItem s : restrictedTypeModes) {
586: TypeMode t = (TypeMode) s.getValue();
587: if (t.getId() == TypeMode.Preload.getId()) {
588: toRemove = s;
589: break;
590: }
591: }
592: restrictedTypeModes.remove(toRemove);
593: }
594: return restrictedTypeModes;
595: }
596:
597: /**
598: * Return all defined type states.
599: *
600: * @return all defined type states.
601: */
602: public List<SelectItem> getTypeStates() {
603: if (typeStates == null) {
604: typeStates = FxJsfUtils.enumsAsSelectList(TypeState
605: .values());
606: }
607: return typeStates;
608: }
609:
610: /**
611: * Return all defined type categories.
612: *
613: * @return all defined type categories.
614: */
615: public List<SelectItem> getTypeCategories() {
616: if (typeCategories == null) {
617: typeCategories = FxJsfUtils.enumsAsSelectList(TypeCategory
618: .values());
619: //last element should be TypeCategory.System, so if it isn't switch
620: int systemCatIndex = -1;
621: for (int i = 0; i < typeCategories.size(); i++) {
622: TypeCategory t = (TypeCategory) typeCategories.get(i)
623: .getValue();
624: if (t.getId() == TypeCategory.System.getId())
625: systemCatIndex = i;
626: }
627: if (systemCatIndex >= 0
628: && systemCatIndex != typeCategories.size() - 1) {
629: SelectItem s = typeCategories.get(systemCatIndex);
630: typeCategories.remove(systemCatIndex);
631: typeCategories.add(s);
632: }
633: }
634: return typeCategories;
635: }
636:
637: /**
638: * Return user dependent type categories that are relevant for the structure editor GUI.
639: *
640: * @return GUI relevant type categories.
641: */
642: public List<SelectItem> getRestrictedTypeCategories() {
643: if (FxContext.get().getTicket().isGlobalSupervisor())
644: return getTypeCategories();
645: else {
646: if (restrictedTypeCategories == null) {
647: restrictedTypeCategories = FxJsfUtils
648: .enumsAsSelectList(TypeCategory.values());
649: SelectItem toRemove = null;
650: for (SelectItem s : restrictedTypeCategories) {
651: TypeCategory t = (TypeCategory) s.getValue();
652: if (t.getId() == TypeCategory.System.getId()) {
653: toRemove = s;
654: break;
655: }
656: }
657: restrictedTypeCategories.remove(toRemove);
658: }
659: return restrictedTypeCategories;
660: }
661: }
662:
663: /**
664: * Return all defined query node operators.
665: *
666: * @return all defined query node operators.
667: */
668: public List<SelectItem> getQueryNodeOperators() {
669: if (queryNodeOperators == null) {
670: queryNodeOperators = FxJsfUtils
671: .enumsAsSelectList(QueryOperatorNode.Operator
672: .values());
673: }
674: return queryNodeOperators;
675: }
676:
677: /**
678: * Return all defined query value comparators (=, >, <, ...).
679: *
680: * @return all defined query value comparators (=, >, <, ...).
681: */
682: public List<SelectItem> getQueryValueComparators() {
683: if (queryNodeComparators == null) {
684: queryNodeComparators = FxJsfUtils
685: .enumsAsSelectList(PropertyValueComparator.values());
686: }
687: return queryNodeComparators;
688: }
689:
690: /**
691: * Return all defined searchresult view types (LIST, THUMBNAILS).
692: *
693: * @return all defined searchresult view types (LIST, THUMBNAILS).
694: */
695: public List<SelectItem> getResultViewTypes() {
696: if (resultViewTypes == null) {
697: resultViewTypes = FxJsfUtils
698: .enumsAsSelectList(ResultViewType.values());
699: }
700: return resultViewTypes;
701: }
702:
703: /**
704: * Return all defined search result locations.
705: *
706: * @return all defined search result locations.
707: */
708: public List<SelectItem> getResultLocations() {
709: if (resultLocations == null) {
710: resultLocations = FxJsfUtils
711: .enumsAsSelectList(AdminResultLocations.values());
712: }
713: return resultLocations;
714: }
715:
716: public List<SelectItem> getResultDirections() {
717: if (resultDirections == null) {
718: resultDirections = FxJsfUtils
719: .enumsAsSelectList(new SortDirection[] {
720: SortDirection.ASCENDING,
721: SortDirection.DESCENDING });
722: }
723: return resultDirections;
724: }
725:
726: public List<SelectItem> getPreviewSizes() {
727: if (previewSizes == null) {
728: // filter preview sizes
729: List<BinaryDescriptor.PreviewSizes> values = new ArrayList<BinaryDescriptor.PreviewSizes>();
730: for (BinaryDescriptor.PreviewSizes value : BinaryDescriptor.PreviewSizes
731: .values()) {
732: if (value.getSize() > 0) {
733: values.add(value);
734: }
735: }
736: previewSizes = FxJsfUtils.enumsAsSelectList(values
737: .toArray(new Enum[values.size()]));
738: }
739: return previewSizes;
740: }
741:
742: /**
743: * Return the enum UniqueMode as SelectList.
744: *
745: * @return the enum UniqueMode as SelectList.
746: */
747:
748: public List<SelectItem> getUniqueModes() {
749: if (uniqueModes == null) {
750: uniqueModes = FxJsfUtils.enumsAsSelectList(UniqueMode
751: .values());
752: }
753: return uniqueModes;
754: }
755:
756: /**
757: * Return the enum FxDataType as SelectList.
758: *
759: * @return the enum FxDataType as SelectList.
760: */
761:
762: public List<SelectItem> getDataTypes() {
763: if (dataTypes == null) {
764: dataTypes = FxJsfUtils.enumsAsSelectList(FxDataType
765: .values());
766: }
767: return dataTypes;
768: }
769:
770: public List<SelectItem> getCacheModes() {
771: if (cacheModes == null) {
772: cacheModes = FxJsfUtils
773: .enumsAsSelectList(FxSQLSearchParams.CacheMode
774: .values());
775: }
776: return cacheModes;
777: }
778:
779: /**
780: * Return the enum FxScriptEvent of ScriptScope "Type" as SelectList
781: *
782: * @return the enum of FxScriptEvent of scope "Type" as SelectList
783: */
784: public List<SelectItem> getTypeScriptEvents() {
785: if (typeScriptEvents == null) {
786: typeScriptEvents = new ArrayList<SelectItem>();
787: for (FxScriptEvent e : FxScriptEvent.values()) {
788: if (e.getScope().compareTo(FxScriptScope.Type) == 0)
789: typeScriptEvents.add(new SelectItem(e.getId(), e
790: .getName()));
791: }
792: }
793: return typeScriptEvents;
794: }
795:
796: /**
797: * Return all available FxScriptEvents as SelectList.
798: *
799: * @return all available FxScriptEvents as SelectList
800: */
801: public List<SelectItem> getAllScriptEvents() {
802: if (allScriptEvents == null) {
803: allScriptEvents = new ArrayList<SelectItem>();
804: for (FxScriptEvent e : FxScriptEvent.values()) {
805: allScriptEvents.add(new SelectItem(e.getId(), e
806: .getName()));
807: }
808: }
809: return allScriptEvents;
810: }
811:
812: /**
813: * Return scripts with the default event scope "Assignment "as SelectList.
814: *
815: * @return scripts with the default event scope "Assignment "as SelectList.
816: */
817: public List<SelectItem> getAssignmentScripts() {
818: if (assignmentScripts == null) {
819: List<FxScriptInfo> scriptList = new ArrayList<FxScriptInfo>();
820: for (FxScriptInfo s : CacheAdmin.getFilteredEnvironment()
821: .getScripts()) {
822: if (s.getEvent().getScope() == FxScriptScope.Assignment)
823: scriptList.add(s);
824: }
825: Collections.sort(scriptList,
826: new FxJsfUtils.ScriptInfoSorter());
827: assignmentScripts = FxJsfUtils.asSelectList(scriptList,
828: false);
829: }
830: return assignmentScripts;
831: }
832:
833: /**
834: * Return the enum FxScriptEvent of ScriptScope "Assignment" as SelectList
835: *
836: * @return the enum of FxScriptEvent of scope "Assignment" as SelectList
837: */
838: public List<SelectItem> getAssignmentScriptEvents() {
839: if (assignmentScriptEvents == null) {
840: assignmentScriptEvents = new ArrayList<SelectItem>();
841: for (FxScriptEvent e : FxScriptEvent.values()) {
842: if (e.getScope().compareTo(FxScriptScope.Assignment) == 0)
843: assignmentScriptEvents.add(new SelectItem(
844: e.getId(), e.getName()));
845: }
846: }
847: return assignmentScriptEvents;
848: }
849:
850: /**
851: * Return all available scripts as SelectList.
852: *
853: * @return all available scripts as SelectList
854: */
855: public List<SelectItem> getAllScripts() {
856: if (allScripts == null) {
857: allScripts = FxJsfUtils.asSelectList(CacheAdmin
858: .getFilteredEnvironment().getScripts(), false);
859: }
860: return allScripts;
861: }
862:
863: /**
864: * Return scripts with the default event scope "Type "as SelectList.
865: *
866: * @return scripts with the default event scope "Type "as SelectList.
867: */
868: public List<SelectItem> getTypeScripts() {
869: if (typeScripts == null) {
870: List<FxScriptInfo> scriptList = new ArrayList<FxScriptInfo>();
871: for (FxScriptInfo s : CacheAdmin.getFilteredEnvironment()
872: .getScripts()) {
873: if (s.getEvent().getScope() == FxScriptScope.Type)
874: scriptList.add(s);
875: }
876: Collections.sort(scriptList,
877: new FxJsfUtils.ScriptInfoSorter());
878: typeScripts = FxJsfUtils.asSelectList(scriptList, false);
879: }
880: return typeScripts;
881: }
882:
883: /**
884: * returns scriptScope enum as select list.
885: *
886: * @return scriptScope enum as select list.
887: */
888: public List<SelectItem> getScriptScopes() {
889: if (scriptScopes == null) {
890: scriptScopes = FxJsfUtils.enumsAsSelectList(FxScriptScope
891: .values());
892: }
893: return scriptScopes;
894: }
895:
896: /**
897: * returns FxScriptEvent enum as select list.
898: *
899: * @return FxScriptEvent enum as select list.
900: */
901: public List<SelectItem> getAllScriptEventsAsEnum() {
902: if (allScriptEventsAsEnum == null) {
903: allScriptEventsAsEnum = FxJsfUtils
904: .enumsAsSelectList(FxScriptEvent.values());
905: }
906: return allScriptEventsAsEnum;
907: }
908:
909: /**
910: * Returns a list of all available scripting engines
911: *
912: * @return list of all available scripting engines
913: */
914: public List<SelectItem> getScriptingEngines() {
915: if (scriptingEngines == null) {
916: try {
917: scriptingEngines = FxJsfUtils.asSelectList(EJBLookup
918: .getScriptingEngine()
919: .getAvailableScriptEngines());
920: } catch (FxApplicationException e) {
921: scriptingEngines = new ArrayList<SelectItem>(0);
922: }
923: }
924: return scriptingEngines;
925: }
926:
927: /**
928: * Return the enum ACL.CATEGORY as SelectList
929: *
930: * @return the enum ACL.CATEGORY as SelectList
931: */
932: public List<SelectItem> getACLCategories() {
933: if (aclCategories == null)
934: aclCategories = FxJsfUtils.enumsAsSelectList(ACL.Category
935: .values());
936: return aclCategories;
937: }
938:
939: /**
940: * Return all available select list ACLs.
941: *
942: * @return all available select list ACLs
943: */
944: public List<SelectItem> getSelectListACLs() {
945: if (selectListACLs == null) {
946: selectListACLs = FxJsfUtils
947: .asSelectListWithLabel(CacheAdmin.getEnvironment()
948: .getACLs(ACL.Category.SELECTLIST));
949: }
950: return selectListACLs;
951: }
952:
953: /**
954: * Return all available select list item ACLs.
955: *
956: * @return all available select list item ACLs
957: */
958:
959: public List<SelectItem> getSelectListItemACLs() {
960: if (selectListItemACLs == null) {
961: selectListItemACLs = FxJsfUtils.asSelectList(CacheAdmin
962: .getEnvironment().getACLs(
963: ACL.Category.SELECTLISTITEM), false);
964: }
965: return selectListItemACLs;
966: }
967:
968: /**
969: * Provides programmatic access for the creation of select lists out of enum values.
970: * This method takes a list of Enum values, and returns a corresponding list of select items.
971: *
972: * @return a map that maps enum lists to select item lists
973: */
974: public Map getEnumSelect() {
975: return FxSharedUtils
976: .getMappedFunction(new FxSharedUtils.ParameterMapper<List<Enum>, List<SelectItem>>() {
977: private static final long serialVersionUID = 597032145345226494L;
978:
979: public List<SelectItem> get(Object key) {
980: //noinspection unchecked
981: final List<Enum> enums = (List<Enum>) key;
982: return FxJsfUtils.enumsAsSelectList(enums
983: .toArray(new Enum[enums.size()]));
984: }
985: });
986: }
987:
988: }
|