001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.docsearch.web;
018:
019: import java.io.IOException;
020: import java.math.BigDecimal;
021: import java.sql.Timestamp;
022: import java.util.ArrayList;
023: import java.util.Collections;
024: import java.util.Comparator;
025: import java.util.Iterator;
026: import java.util.List;
027: import java.util.Locale;
028:
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.commons.beanutils.PropertyUtils;
034: import org.apache.commons.lang.StringUtils;
035: import org.apache.struts.Globals;
036: import org.apache.struts.action.ActionErrors;
037: import org.apache.struts.action.ActionForm;
038: import org.apache.struts.action.ActionForward;
039: import org.apache.struts.action.ActionMapping;
040: import org.apache.struts.action.ActionMessage;
041: import org.apache.struts.action.ActionMessages;
042: import org.apache.struts.util.MessageResources;
043: import org.displaytag.tags.TableTagParameters;
044: import org.displaytag.util.ParamEncoder;
045: import org.kuali.rice.resourceloader.GlobalResourceLoader;
046:
047: import edu.iu.uis.eden.EdenConstants;
048: import edu.iu.uis.eden.KEWServiceLocator;
049: import edu.iu.uis.eden.docsearch.DocSearchCriteriaVO;
050: import edu.iu.uis.eden.docsearch.DocumentSearchGenerator;
051: import edu.iu.uis.eden.docsearch.DocumentSearchResult;
052: import edu.iu.uis.eden.docsearch.DocumentSearchResultComponents;
053: import edu.iu.uis.eden.docsearch.DocumentSearchService;
054: import edu.iu.uis.eden.docsearch.SavedSearchResult;
055: import edu.iu.uis.eden.doctype.DocumentType;
056: import edu.iu.uis.eden.engine.node.RouteNode;
057: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
058: import edu.iu.uis.eden.lookupable.Column;
059: import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
060: import edu.iu.uis.eden.preferences.Preferences;
061: import edu.iu.uis.eden.user.WorkflowUser;
062: import edu.iu.uis.eden.util.Utilities;
063: import edu.iu.uis.eden.web.KeyValue;
064: import edu.iu.uis.eden.web.WorkflowAction;
065: import edu.iu.uis.eden.workgroup.WorkflowGroupId;
066: import edu.iu.uis.eden.workgroup.Workgroup;
067:
068: /**
069: * Document search struts action
070: *
071: * @author rkirkend
072: * @author ewestfal
073: */
074: public class DocumentSearchAction extends WorkflowAction {
075:
076: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
077: .getLogger(DocumentSearchAction.class);
078:
079: public ActionForward start(ActionMapping mapping, ActionForm form,
080: HttpServletRequest request, HttpServletResponse response)
081: throws IOException, ServletException {
082: return mapping.findForward("success");
083: }
084:
085: public ActionForward performLookup(ActionMapping mapping,
086: ActionForm form, HttpServletRequest request,
087: HttpServletResponse response) throws Exception {
088: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
089: String basePath = request.getScheme() + "://"
090: + request.getServerName() + ":"
091: + request.getServerPort() + request.getContextPath()
092: + mapping.getModuleConfig().getPrefix();
093: ;
094: StringBuffer lookupUrl = new StringBuffer(basePath);
095:
096: String lookupType = docSearchForm.getLookupType();
097: docSearchForm.setLookupType(null);
098:
099: lookupUrl
100: .append("/Lookup.do?methodToCall=start&docFormKey=")
101: .append(getUserSession(request).addObject(form))
102: .append("&lookupableImplServiceName=")
103: .append(
104: request
105: .getParameter("lookupableImplServiceName"));
106:
107: if (lookupType != null && !lookupType.equals("")) {
108: lookupUrl.append("&conversionFields=");
109: WorkflowLookupable workflowLookupable = (WorkflowLookupable) GlobalResourceLoader
110: .getService(request
111: .getParameter("lookupableImplServiceName"));//(WorkflowLookupable) SpringServiceLocator.getExtensionService().getLookupable(request.getParameter("lookupableImplServiceName"));
112: for (Iterator iterator = workflowLookupable
113: .getDefaultReturnType().iterator(); iterator
114: .hasNext();) {
115: String returnType = (String) iterator.next();
116: lookupUrl.append(returnType).append(":").append(
117: lookupType);
118: }
119: } else if (!Utilities.isEmpty(docSearchForm
120: .getConversionFields())) {
121: lookupUrl.append("&conversionFields=");
122: lookupUrl.append(docSearchForm.getConversionFields());
123: }
124:
125: lookupUrl.append("&returnLocation=").append(basePath).append(
126: mapping.getPath()).append(".do");
127: return new ActionForward(lookupUrl.toString(), true);
128: }
129:
130: public ActionForward basic(ActionMapping mapping, ActionForm form,
131: HttpServletRequest request, HttpServletResponse response)
132: throws IOException, ServletException {
133: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
134: docSearchForm.setIsAdvancedSearch("NO");
135: return mapping.findForward("success");
136: }
137:
138: public ActionForward resetNamedSearches(ActionMapping mapping,
139: ActionForm form, HttpServletRequest request,
140: HttpServletResponse response) throws IOException,
141: ServletException, RuntimeException {
142: getDocumentSearchService().clearNamedSearches(
143: getUserSession(request).getWorkflowUser());
144: // request.setAttribute("namedSearches", getSavedSearches(getUserSession(request).getWorkflowUser()));
145: return mapping.findForward("success");
146: }
147:
148: public ActionForward advanced(ActionMapping mapping,
149: ActionForm form, HttpServletRequest request,
150: HttpServletResponse response) throws IOException,
151: ServletException {
152: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
153: docSearchForm.setIsAdvancedSearch("YES");
154: return mapping.findForward("success");
155: }
156:
157: public ActionForward super UserSearch(ActionMapping mapping,
158: ActionForm form, HttpServletRequest request,
159: HttpServletResponse response) throws IOException,
160: ServletException {
161: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
162: docSearchForm.setSuperUserSearch("YES");
163: return mapping.findForward("success");
164: }
165:
166: public ActionForward clearSuperUserSearch(ActionMapping mapping,
167: ActionForm form, HttpServletRequest request,
168: HttpServletResponse response) throws IOException,
169: ServletException {
170: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
171: docSearchForm.setSuperUserSearch("NO");
172: return mapping.findForward("success");
173: }
174:
175: public ActionForward clear(ActionMapping mapping, ActionForm form,
176: HttpServletRequest request, HttpServletResponse response)
177: throws Exception {
178: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
179: //retain screen placement vars
180: DocSearchCriteriaVO criteria = new DocSearchCriteriaVO();
181: if (StringUtils.isNotBlank(docSearchForm.getCriteria()
182: .getDocTypeFullName())) {
183: DocumentType documentType = KEWServiceLocator
184: .getDocumentTypeService().findByName(
185: docSearchForm.getCriteria()
186: .getDocTypeFullName());
187: if (documentType == null) {
188: throw new RuntimeException("Document Type invalid : "
189: + docSearchForm.getCriteria()
190: .getDocTypeFullName());
191: }
192: DocumentSearchGenerator generator = documentType
193: .getDocumentSearchGenerator();
194: criteria = generator.clearSearch(docSearchForm
195: .getCriteria());
196: }
197: criteria.setIsAdvancedSearch(docSearchForm
198: .getIsAdvancedSearch());
199: criteria.setSuperUserSearch(docSearchForm.getSuperUserSearch());
200: docSearchForm.setCriteria(criteria);
201: docSearchForm.clearSearchableAttributes();
202: return mapping.findForward("success");
203: }
204:
205: public ActionForward doDocSearch(ActionMapping mapping,
206: ActionForm form, HttpServletRequest request,
207: HttpServletResponse response) throws Exception {
208: LOG.info("started doDocSearch");
209: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
210: try {
211: String previousDocTypeName = docSearchForm
212: .getDocTypeDisplayName();
213: DocumentSearchResultComponents results = null;
214: SavedSearchResult result = null;
215: if (docSearchForm.getNamedSearch() != null
216: && !"".equals(docSearchForm.getNamedSearch())
217: && !"ignore".equals(docSearchForm.getNamedSearch())) {
218: result = getDocumentSearchService()
219: .getSavedSearchResults(
220: getUserSession(request)
221: .getWorkflowUser(),
222: docSearchForm.getNamedSearch());
223: // DocSearchCriteriaVO criteria = result.getDocSearchCriteriaVO();
224: // docSearchForm.setCriteria(criteria);
225: // String currentDocTypeName = docSearchForm.getDocTypeDisplayName();
226: // // if the previous search had no doc type and the new one does... we need to populate the potential searchable attributes
227: // if ( (previousDocTypeName == null) && (currentDocTypeName != null) ) {
228: // setDropdowns(docSearchForm, request);
229: // docSearchForm.checkForAdditionalFields();
230: // }
231: //// docSearchForm.checkForAdditionalFields(criteria.getDocTypeFullName());
232: //// docSearchForm.setPropertyFields(criteria.getSearchableAttributes());
233: //
234: // docSearchForm.setNamedSearch("");
235: // //TODO this is for historic reasons only and can be deleted after release 2.1
236: // // but we need to check and notify that any user option saved search without a key containing 'isAdvancedSearch'
237: // // will lose the search location context and will always be brought to the 'basic' search screen
238: // //if ("".equals(docSearchForm.getIsAdvancedSearch()) || "NO".equals(docSearchForm.getIsAdvancedSearch())) {
239: // // docSearchForm.setIsAdvancedSearch(result.isAdvancedSearch() ? "YES" : "NO");
240: // //}
241: docSearchForm.updateFormUsingSavedSearch(result);
242: setDropdowns(docSearchForm, request);
243: results = result.getSearchResult();
244: } else {
245: docSearchForm.addSearchableAttributesToCriteria();
246: DocSearchCriteriaVO criteria = docSearchForm
247: .getCriteria();
248: results = getDocumentSearchService().getList(
249: getUserSession(request).getWorkflowUser(),
250: docSearchForm.getCriteria());
251: result = new SavedSearchResult(criteria, results);
252: }
253: List columns = results.getColumns();
254: MessageResources mr = getResources(request);
255: mr.setReturnNull(true);
256: Locale locale = (Locale) request
257: .getAttribute(Globals.LOCALE_KEY);
258: for (Iterator iter = columns.iterator(); iter.hasNext();) {
259: Column column = (Column) iter.next();
260: if ((column.getColumnTitle() == null)
261: || (column.getColumnTitle().trim().length() == 0)) {
262: String title = mr.getMessage(locale,
263: "docSearch.DocumentSearch.results.label."
264: + column.getKey());
265: if (StringUtils.isBlank(title)) {
266: title = "** No Title Available **";
267: }
268: column.setColumnTitle(title);
269: }
270: }
271:
272: // adjust results and result objects
273: result = new SavedSearchResult(docSearchForm.getCriteria(),
274: new DocumentSearchResultComponents(columns, results
275: .getSearchResults()));
276: request.setAttribute("reqSearchResultColumns", result
277: .getSearchResult().getColumns());
278: request.setAttribute("reqSearchResults", result
279: .getSearchResult().getSearchResults());
280: // request.setAttribute("namedSearches", getSavedSearches(getUserSession(request).getWorkflowUser()));
281: request.setAttribute("key", getUserSession(request)
282: .addObject(result));
283: if (docSearchForm.getCriteria().isOverThreshold()) {
284: ActionErrors errors = new ActionErrors();
285: errors
286: .add(
287: Globals.ERROR_KEY,
288: new ActionMessage(
289: "docsearch.DocumentSearchService.exceededThreshold",
290: String.valueOf(results
291: .getSearchResults()
292: .size())));
293: saveErrors(request, errors);
294: }
295: LOG.info("end doDocSearch");
296: return mapping.findForward("success");
297: } catch (Exception e) {
298: establishFinalState(request, docSearchForm);
299: throw e;
300: }
301: }
302:
303: public ActionMessages establishRequiredState(
304: HttpServletRequest request, ActionForm form)
305: throws Exception {
306: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
307: Preferences preferences = getUserSession(request)
308: .getPreferences();
309: request.setAttribute("preferences", preferences);
310: // request.setAttribute("namedSearches", getSavedSearches(getUserSession(request).getWorkflowUser()));
311: setDropdowns(docSearchForm, request);
312: return null;
313: }
314:
315: public ActionMessages establishFinalState(
316: HttpServletRequest request, ActionForm form)
317: throws Exception {
318: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
319: request.setAttribute("namedSearches",
320: getSavedSearches(getUserSession(request)
321: .getWorkflowUser()));
322: docSearchForm.checkForAdditionalFields();
323: // List namedSearches = (List)request.getAttribute("namedSearches");
324: // if ( (namedSearches == null) || (namedSearches.isEmpty()) ) {
325: // request.setAttribute("namedSearches", getSavedSearches(getUserSession(request).getWorkflowUser()));
326: // }
327: return null;
328: }
329:
330: private List getSavedSearches(WorkflowUser workflowUser) {
331: List savedSearches = new ArrayList();
332: savedSearches.add(new KeyValue("", "Searches"));
333: savedSearches.add(new KeyValue("ignore", "-----"));
334: savedSearches.add(new KeyValue("ignore",
335: " Named Searches"));
336: List namedSearches = getDocumentSearchService()
337: .getNamedSearches(workflowUser);
338: for (Iterator iter = namedSearches.iterator(); iter.hasNext();) {
339: KeyValue namedSearch = (KeyValue) iter.next();
340: savedSearches
341: .add(new KeyValue(namedSearch.getKey(),
342: " "
343: + namedSearch.getValue()));
344: }
345: savedSearches.add(new KeyValue("ignore", "-----"));
346: savedSearches.add(new KeyValue("ignore",
347: " Recent Searches"));
348: List mostRecentSearches = getDocumentSearchService()
349: .getMostRecentSearches(workflowUser);
350: for (Iterator iter = mostRecentSearches.iterator(); iter
351: .hasNext();) {
352: KeyValue recentSearch = (KeyValue) iter.next();
353: savedSearches
354: .add(new KeyValue(
355: recentSearch.getKey(),
356: " "
357: + (recentSearch.getValue().length() > 100 ? recentSearch
358: .getValue().substring(0,
359: 100)
360: + "..."
361: : recentSearch.getValue())));
362: }
363: return savedSearches;
364: }
365:
366: private DocumentSearchService getDocumentSearchService() {
367: return ((DocumentSearchService) KEWServiceLocator
368: .getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE));
369: }
370:
371: public ActionForward refresh(ActionMapping mapping,
372: ActionForm form, HttpServletRequest request,
373: HttpServletResponse response) throws Exception {
374: DocumentSearchForm documentSearchForm = (DocumentSearchForm) form;
375:
376: if (request.getParameter("docTypeFullName") != null) {
377: documentSearchForm.setNamedSearch("");
378: documentSearchForm.getCriteria().setNamedSearch("");
379: documentSearchForm.clearSearchableAttributes();
380: }
381: if (request.getParameter("workgroupId") != null) {
382: Long groupId = new Long(request.getParameter("workgroupId"));
383: Workgroup workgroup = KEWServiceLocator
384: .getWorkgroupService().getWorkgroup(
385: new WorkflowGroupId(groupId));
386: documentSearchForm.getCriteria().setWorkgroupViewerName(
387: workgroup.getDisplayName());
388: }
389: return mapping.findForward("success");
390: }
391:
392: private static void setDropdowns(DocumentSearchForm dsForm,
393: HttpServletRequest request) {
394: LOG.debug("Entered setDropDowns");
395:
396: List documentRouteStatus = new ArrayList();
397: documentRouteStatus.add(new KeyValue("", "All"));
398: documentRouteStatus
399: .addAll(EdenConstants.DOCUMENT_SEARCH_SEARCHABLE_DOCUMENT_STATUSES);
400: request
401: .setAttribute("documentRouteStatus",
402: documentRouteStatus);
403:
404: if (!Utilities.isEmpty(dsForm.getCriteria()
405: .getDocTypeFullName())) {
406: List qualifierLogic = new ArrayList();
407: qualifierLogic.add(new KeyValue("equal", "Exactly"));
408: qualifierLogic.add(new KeyValue("before", "Before"));
409: qualifierLogic.add(new KeyValue("after", "After"));
410: request.setAttribute("qualifierLogic", qualifierLogic);
411:
412: //people are going to be feeding us doctype names by url for inline doc search so check for a null doctype to give
413: //a sensible error
414: DocumentType documentType = KEWServiceLocator
415: .getDocumentTypeService().findByName(
416: dsForm.getCriteria().getDocTypeFullName());
417: if (documentType == null) {
418: throw new RuntimeException("Document Type invalid : "
419: + dsForm.getCriteria().getDocTypeFullName());
420: }
421: List routeNodes = KEWServiceLocator.getRouteNodeService()
422: .getFlattenedNodes(documentType, true);
423: RouteNode blankNode = new RouteNode();//for a default no choice option
424: blankNode.setRouteNodeId(new Long(-1));
425: blankNode.setRouteNodeName("");
426: routeNodes.add(0, blankNode);
427: request.setAttribute("routeNodes", routeNodes);
428: }
429: LOG.debug("Leaving setDropDowns");
430: }
431:
432: public ActionForward viewResults(ActionMapping mapping,
433: ActionForm form, HttpServletRequest request,
434: HttpServletResponse response) throws IOException,
435: ServletException {
436: DocumentSearchForm docSearchForm = (DocumentSearchForm) form;
437:
438: SavedSearchResult result = (SavedSearchResult) getUserSession(
439: request).retrieveObject(request.getParameter("key"));
440: DocumentSearchResultComponents searchComponents = result
441: .getSearchResult();
442: List<Column> columns = searchComponents.getColumns();
443: List<DocumentSearchResult> displayResults = searchComponents
444: .getSearchResults();
445: DocSearchCriteriaVO criteria = result.getDocSearchCriteriaVO();
446:
447: docSearchForm.setCriteria(criteria);
448: // docSearchForm.checkForAdditionalFields(criteria.getDocTypeFullName());
449: // docSearchForm.setPropertyFields(criteria.getSearchableAttributes());
450: setDropdowns(docSearchForm, request);
451: docSearchForm.setNamedSearch("");
452:
453: boolean ascending = true;
454: String sortOrderParameter = new ParamEncoder("result")
455: .encodeParameterName(TableTagParameters.PARAMETER_ORDER);
456: String sortOrder = request.getParameter(sortOrderParameter);
457: if (sortOrder == null) {
458: sortOrder = "1";
459: }
460: if (sortOrder.equals("2")) {
461: ascending = false;
462: }
463: String sortNameParameter = new ParamEncoder("result")
464: .encodeParameterName(TableTagParameters.PARAMETER_SORT);
465: String sortName = request.getParameter(sortNameParameter);
466: Column sortColumn = getSortColumn(columns, sortName);
467: sortDisplayList(sortColumn, displayResults, ascending);
468: result.setSearchResult(new DocumentSearchResultComponents(
469: columns, displayResults));
470: request.setAttribute("key", getUserSession(request).addObject(
471: result));
472: request.setAttribute("reqSearchResultColumns", result
473: .getSearchResult().getColumns());
474: request.setAttribute("reqSearchResults", result
475: .getSearchResult().getSearchResults());
476: return mapping.findForward("success");
477: }
478:
479: private Column getSortColumn(List columns, String sortName) {
480: if (StringUtils.isEmpty(sortName)) {
481: return (Column) columns.get(0);
482: }
483: for (Iterator iterator = columns.iterator(); iterator.hasNext();) {
484: Column column = (Column) iterator.next();
485: if (column.getSortName().equals(sortName)) {
486: return column;
487: }
488: }
489: throw new WorkflowRuntimeException(
490: "Could not sort based on the given sort name of "
491: + sortName);
492: }
493:
494: private void sortDisplayList(Column sortColumn,
495: List<DocumentSearchResult> displayList, boolean ascending) {
496: Collections.sort(displayList, new ColumnComparator(sortColumn,
497: ascending));
498: }
499:
500: private class ColumnComparator implements Comparator<Object> {
501:
502: private Column column;
503: private boolean ascending;
504:
505: public ColumnComparator(Column column, boolean ascending) {
506: this .column = column;
507: this .ascending = ascending;
508: }
509:
510: public int compare(Object row1, Object row2) {
511: try {
512: Object property1 = PropertyUtils.getProperty(row1,
513: column.getSortName());
514: Object property2 = PropertyUtils.getProperty(row2,
515: column.getSortName());
516: int compare = 0;
517: if ((property1 != null) || (property2 != null)) {
518: if ((property1 != null)
519: && (property2 != null)
520: && (!(property1.getClass().equals(property2
521: .getClass())))) {
522: // two classes are unequal... throw exception
523: String errorMessage = "Found classes in this comparator that are unequal (property class '"
524: + property1.getClass().getName()
525: + "' is not equal to property class '"
526: + property2.getClass().getName() + "')";
527: LOG.error("compare() " + errorMessage);
528: throw new RuntimeException(errorMessage);
529: }
530: if ((property1 instanceof Integer)
531: || (property2 instanceof Integer)) {
532: Integer value1 = (property1 != null) ? (Integer) property1
533: : Integer.MIN_VALUE;
534: Integer value2 = (property2 != null) ? (Integer) property2
535: : Integer.MIN_VALUE;
536: compare = value1.compareTo(value2);
537: } else if ((property1 instanceof Long)
538: || (property2 instanceof Long)) {
539: Long value1 = (property1 != null) ? (Long) property1
540: : Long.MIN_VALUE;
541: Long value2 = (property2 != null) ? (Long) property2
542: : Long.MIN_VALUE;
543: compare = value1.compareTo(value2);
544: } else if ((property1 instanceof BigDecimal)
545: || (property2 instanceof BigDecimal)) {
546: BigDecimal value1 = (property1 != null) ? (BigDecimal) property1
547: : BigDecimal.ZERO;
548: BigDecimal value2 = (property2 != null) ? (BigDecimal) property2
549: : BigDecimal.ZERO;
550: compare = value1.compareTo(value2);
551: } else if ((property1 instanceof Timestamp)
552: || (property2 instanceof Timestamp)) {
553: Timestamp value1 = (Timestamp) property1;
554: Timestamp value2 = (Timestamp) property2;
555: if ((value1 != null) && (value2 != null)) {
556: compare = value1.compareTo(value2);
557: } else if ((value1 == null) && (value2 != null)) {
558: compare = -1;
559: } else if ((value1 != null) && (value2 == null)) {
560: compare = 1;
561: }
562: } else {
563: // at this point... assume String
564: String value1 = (property1 != null) ? (String) property1
565: : "";
566: String value2 = (property2 != null) ? (String) property2
567: : "";
568: compare = String.CASE_INSENSITIVE_ORDER
569: .compare(value1, value2);
570: }
571: }
572:
573: // String property1Value = (property1 != null) ? property1.toString() : "";
574: // String property2Value = (property2 != null) ? property2.toString() : "";
575: // if (Column.INTEGER.equals(column.getType())) {
576: // Integer i1 = Integer.valueOf(property1Value);
577: // Integer i2 = Integer.valueOf(property2Value);
578: // compare = i1.compareTo(i2);
579: // } else if (Column.LONG.equals(column.getType())) {
580: // Long l1 = Long.valueOf(property1Value);
581: // Long l2 = Long.valueOf(property2Value);
582: // compare = l1.compareTo(l2);
583: // } else if (Column.FLOAT.equals(column.getType())) {
584: // Float f1 = Float.valueOf(property1Value);
585: // Float f2 = Float.valueOf(property2Value);
586: // compare = f1.compareTo(f2);
587: // } else if (Column.DATETIME.equals(column.getType())) {
588: // Timestamp t1 = Timestamp.valueOf(property1Value);
589: // Timestamp t2 = Timestamp.valueOf(property2Value);
590: // compare = t1.compareTo(t2);
591: // } else {
592: // compare = property1Value.compareTo(property2Value);
593: // }
594: if (!ascending) {
595: compare *= -1;
596: }
597: return compare;
598: } catch (Exception e) {
599: throw new WorkflowRuntimeException(e);
600: }
601: }
602:
603: }
604: }
|