| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kew.docsearch.service.impl; |
| 18 | |
|
| 19 | |
import org.apache.commons.collections.CollectionUtils; |
| 20 | |
import org.apache.commons.lang.StringUtils; |
| 21 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 22 | |
import org.kuali.rice.core.api.config.property.ConfigurationService; |
| 23 | |
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
| 24 | |
import org.kuali.rice.core.framework.persistence.jdbc.sql.SqlBuilder; |
| 25 | |
import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform; |
| 26 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 27 | |
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
| 28 | |
import org.kuali.rice.core.util.ConcreteKeyValue; |
| 29 | |
import org.kuali.rice.core.util.KeyValue; |
| 30 | |
import org.kuali.rice.core.util.RiceConstants; |
| 31 | |
import org.kuali.rice.kew.docsearch.DocSearchCriteriaDTO; |
| 32 | |
import org.kuali.rice.kew.docsearch.DocSearchDTO; |
| 33 | |
import org.kuali.rice.kew.docsearch.DocSearchUtils; |
| 34 | |
import org.kuali.rice.kew.docsearch.DocumentSearchGenerator; |
| 35 | |
import org.kuali.rice.kew.docsearch.DocumentSearchResultComponents; |
| 36 | |
import org.kuali.rice.kew.docsearch.DocumentSearchResultProcessor; |
| 37 | |
import org.kuali.rice.kew.docsearch.SavedSearchResult; |
| 38 | |
import org.kuali.rice.kew.docsearch.SearchAttributeCriteriaComponent; |
| 39 | |
import org.kuali.rice.kew.docsearch.StandardDocumentSearchGenerator; |
| 40 | |
import org.kuali.rice.kew.docsearch.StandardDocumentSearchResultProcessor; |
| 41 | |
import org.kuali.rice.kew.docsearch.dao.DocumentSearchDAO; |
| 42 | |
import org.kuali.rice.kew.docsearch.service.DocumentSearchService; |
| 43 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
| 44 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
| 45 | |
import org.kuali.rice.kew.exception.WorkflowServiceError; |
| 46 | |
import org.kuali.rice.kew.exception.WorkflowServiceErrorException; |
| 47 | |
import org.kuali.rice.kew.exception.WorkflowServiceErrorImpl; |
| 48 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 49 | |
import org.kuali.rice.kew.useroptions.UserOptions; |
| 50 | |
import org.kuali.rice.kew.useroptions.UserOptionsService; |
| 51 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 52 | |
import org.kuali.rice.kew.util.Utilities; |
| 53 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
| 54 | |
import org.kuali.rice.kim.api.group.Group; |
| 55 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
| 56 | |
import org.kuali.rice.kns.service.DictionaryValidationService; |
| 57 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
| 58 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 59 | |
import org.kuali.rice.kns.util.GlobalVariables; |
| 60 | |
|
| 61 | |
import java.text.MessageFormat; |
| 62 | |
import java.util.ArrayList; |
| 63 | |
import java.util.Arrays; |
| 64 | |
import java.util.Collection; |
| 65 | |
import java.util.Collections; |
| 66 | |
import java.util.List; |
| 67 | |
|
| 68 | |
|
| 69 | 0 | public class DocumentSearchServiceImpl implements DocumentSearchService { |
| 70 | |
|
| 71 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentSearchServiceImpl.class); |
| 72 | |
|
| 73 | |
private static final int MAX_SEARCH_ITEMS = 5; |
| 74 | |
private static final String LAST_SEARCH_ORDER_OPTION = "DocSearch.LastSearch.Order"; |
| 75 | |
private static final String NAMED_SEARCH_ORDER_BASE = "DocSearch.NamedSearch."; |
| 76 | |
private static final String LAST_SEARCH_BASE_NAME = "DocSearch.LastSearch.Holding"; |
| 77 | |
private static final String DOC_SEARCH_CRITERIA_DTO_CLASS = "org.kuali.rice.kew.docsearch.DocSearchCriteriaDTO"; |
| 78 | |
|
| 79 | |
private static DictionaryValidationService dictionaryValidationService; |
| 80 | |
private static DataDictionaryService dataDictionaryService; |
| 81 | |
private static ConfigurationService kualiConfigurationService; |
| 82 | |
|
| 83 | |
private DocumentSearchDAO docSearchDao; |
| 84 | |
private UserOptionsService userOptionsService; |
| 85 | |
|
| 86 | 0 | private SqlBuilder sqlBuilder = null; |
| 87 | |
|
| 88 | |
public void setDocumentSearchDAO(DocumentSearchDAO docSearchDao) { |
| 89 | 0 | this.docSearchDao = docSearchDao; |
| 90 | 0 | } |
| 91 | |
|
| 92 | |
public void setUserOptionsService(UserOptionsService userOptionsService) { |
| 93 | 0 | this.userOptionsService = userOptionsService; |
| 94 | 0 | } |
| 95 | |
|
| 96 | |
public void clearNamedSearches(String principalId) { |
| 97 | 0 | String[] clearListNames = { NAMED_SEARCH_ORDER_BASE + "%", LAST_SEARCH_BASE_NAME + "%", LAST_SEARCH_ORDER_OPTION + "%" }; |
| 98 | 0 | for (String clearListName : clearListNames) |
| 99 | |
{ |
| 100 | 0 | List<UserOptions> records = userOptionsService.findByUserQualified(principalId, clearListName); |
| 101 | 0 | for (UserOptions userOptions : records) { |
| 102 | 0 | userOptionsService.deleteUserOptions((UserOptions) userOptions); |
| 103 | |
} |
| 104 | |
} |
| 105 | 0 | } |
| 106 | |
|
| 107 | |
public SavedSearchResult getSavedSearchResults(String principalId, String savedSearchName) { |
| 108 | 0 | UserOptions savedSearch = userOptionsService.findByOptionId(savedSearchName, principalId); |
| 109 | 0 | if (savedSearch == null || savedSearch.getOptionId() == null) { |
| 110 | 0 | return null; |
| 111 | |
} |
| 112 | 0 | DocSearchCriteriaDTO criteria = getCriteriaFromSavedSearch(savedSearch); |
| 113 | 0 | return new SavedSearchResult(criteria, getList(principalId, criteria)); |
| 114 | |
} |
| 115 | |
|
| 116 | |
public DocumentSearchResultComponents getList(String principalId, DocSearchCriteriaDTO criteria) { |
| 117 | 0 | return getList(principalId, criteria, false); |
| 118 | |
} |
| 119 | |
|
| 120 | |
public DocumentSearchResultComponents getListRestrictedByCriteria(String principalId, DocSearchCriteriaDTO criteria) { |
| 121 | 0 | return getList(principalId, criteria, true); |
| 122 | |
} |
| 123 | |
|
| 124 | |
private DocumentSearchResultComponents getList(String principalId, DocSearchCriteriaDTO criteria, boolean useCriteriaRestrictions) { |
| 125 | 0 | DocumentSearchGenerator docSearchGenerator = null; |
| 126 | 0 | DocumentSearchResultProcessor docSearchResultProcessor = null; |
| 127 | |
|
| 128 | 0 | DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName(criteria.getDocTypeFullName()); |
| 129 | 0 | if (documentType != null ) { |
| 130 | 0 | docSearchGenerator = documentType.getDocumentSearchGenerator(); |
| 131 | 0 | docSearchResultProcessor = documentType.getDocumentSearchResultProcessor(); |
| 132 | |
} else { |
| 133 | 0 | docSearchGenerator = getStandardDocumentSearchGenerator(); |
| 134 | 0 | docSearchResultProcessor = getStandardDocumentSearchResultProcessor(); |
| 135 | |
} |
| 136 | 0 | docSearchGenerator.setSearchingUser(principalId); |
| 137 | 0 | performPreSearchConditions(docSearchGenerator,principalId,criteria); |
| 138 | 0 | validateDocumentSearchCriteria(docSearchGenerator,criteria); |
| 139 | 0 | DocumentSearchResultComponents searchResult = null; |
| 140 | |
try { |
| 141 | 0 | List<DocSearchDTO> docListResults = null; |
| 142 | 0 | if (useCriteriaRestrictions) { |
| 143 | 0 | docListResults = docSearchDao.getListBoundedByCritera(docSearchGenerator,criteria, principalId); |
| 144 | |
} else { |
| 145 | 0 | docListResults = docSearchDao.getList(docSearchGenerator,criteria, principalId); |
| 146 | |
} |
| 147 | 0 | if (docSearchResultProcessor.isProcessFinalResults()) { |
| 148 | 0 | searchResult = docSearchResultProcessor.processIntoFinalResults(docListResults, criteria, principalId); |
| 149 | |
} else { |
| 150 | 0 | searchResult = new StandardDocumentSearchResultProcessor().processIntoFinalResults(docListResults, criteria, principalId); |
| 151 | |
} |
| 152 | |
|
| 153 | 0 | } catch (Exception e) { |
| 154 | 0 | String errorMsg = "Error received trying to execute search: " + e.getLocalizedMessage(); |
| 155 | 0 | throw new WorkflowServiceErrorException(errorMsg, e, new WorkflowServiceErrorImpl(errorMsg,"docsearch.DocumentSearchService.generalError",errorMsg)); |
| 156 | 0 | } |
| 157 | 0 | if (!useCriteriaRestrictions || !criteria.isSaveSearchForUser()) { |
| 158 | |
try { |
| 159 | 0 | saveSearch(principalId, criteria); |
| 160 | 0 | } catch (RuntimeException e) { |
| 161 | 0 | LOG.warn("Unable to save search due to RuntimeException with message: " + e.getMessage()); |
| 162 | 0 | LOG.warn("RuntimeException will be ignored and may cause transaction problems"); |
| 163 | |
|
| 164 | 0 | } |
| 165 | |
} |
| 166 | 0 | return searchResult; |
| 167 | |
} |
| 168 | |
|
| 169 | |
public DocumentSearchGenerator getStandardDocumentSearchGenerator() { |
| 170 | 0 | String searchGeneratorClass = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.STANDARD_DOC_SEARCH_GENERATOR_CLASS_CONFIG_PARM); |
| 171 | 0 | if (searchGeneratorClass == null){ |
| 172 | 0 | return new StandardDocumentSearchGenerator(); |
| 173 | |
} |
| 174 | 0 | return (DocumentSearchGenerator)GlobalResourceLoader.getObject(new ObjectDefinition(searchGeneratorClass)); |
| 175 | |
} |
| 176 | |
|
| 177 | |
public DocumentSearchResultProcessor getStandardDocumentSearchResultProcessor() { |
| 178 | 0 | String searchGeneratorClass = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.STANDARD_DOC_SEARCH_RESULT_PROCESSOR_CLASS_CONFIG_PARM); |
| 179 | 0 | if (searchGeneratorClass == null){ |
| 180 | 0 | return new StandardDocumentSearchResultProcessor(); |
| 181 | |
} |
| 182 | 0 | return (DocumentSearchResultProcessor)GlobalResourceLoader.getObject(new ObjectDefinition(searchGeneratorClass)); |
| 183 | |
} |
| 184 | |
|
| 185 | |
public void performPreSearchConditions(DocumentSearchGenerator docSearchGenerator,String principalId,DocSearchCriteriaDTO criteria) { |
| 186 | 0 | List<WorkflowServiceError> errors = docSearchGenerator.performPreSearchConditions(principalId,criteria); |
| 187 | 0 | if (!errors.isEmpty()) { |
| 188 | 0 | throw new WorkflowServiceErrorException("Document Search Precondition Errors", errors); |
| 189 | |
} |
| 190 | 0 | } |
| 191 | |
|
| 192 | |
public void validateDocumentSearchCriteria(DocumentSearchGenerator docSearchGenerator,DocSearchCriteriaDTO criteria) { |
| 193 | 0 | List<WorkflowServiceError> errors = this.validateWorkflowDocumentSearchCriteria(criteria); |
| 194 | 0 | errors.addAll(docSearchGenerator.validateSearchableAttributes(criteria)); |
| 195 | 0 | if (!errors.isEmpty() || !GlobalVariables.getMessageMap().hasNoErrors()) { |
| 196 | 0 | throw new WorkflowServiceErrorException("Document Search Validation Errors", errors); |
| 197 | |
} |
| 198 | 0 | } |
| 199 | |
|
| 200 | |
protected List<WorkflowServiceError> validateWorkflowDocumentSearchCriteria(DocSearchCriteriaDTO criteria) { |
| 201 | 0 | List<WorkflowServiceError> errors = new ArrayList<WorkflowServiceError>(); |
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | 0 | if (!StringUtils.isEmpty(criteria.getApprover())) { |
| 206 | 0 | criteria.setApprover(criteria.getApprover().trim()); |
| 207 | |
} |
| 208 | 0 | if (!StringUtils.isEmpty(criteria.getViewer())) { |
| 209 | 0 | criteria.setViewer(criteria.getViewer().trim()); |
| 210 | |
} |
| 211 | 0 | if (!StringUtils.isEmpty(criteria.getInitiator())) { |
| 212 | 0 | criteria.setInitiator(criteria.getInitiator().trim()); |
| 213 | |
} |
| 214 | |
|
| 215 | 0 | if (! validateWorkgroup(criteria.getWorkgroupViewerId(), criteria.getWorkgroupViewerName())) { |
| 216 | 0 | errors.add(new WorkflowServiceErrorImpl("Workgroup Viewer Name is not a workgroup", "docsearch.DocumentSearchService.workgroup.viewer")); |
| 217 | |
} else { |
| 218 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(criteria.getWorkgroupViewerName())){ |
| 219 | 0 | criteria.setWorkgroupViewerName(criteria.getWorkgroupViewerName().trim()); |
| 220 | |
} |
| 221 | |
} |
| 222 | |
|
| 223 | 0 | if (!validateNumber(criteria.getDocVersion())) { |
| 224 | 0 | errors.add(new WorkflowServiceErrorImpl("Non-numeric document version", "docsearch.DocumentSearchService.docVersion")); |
| 225 | |
} else { |
| 226 | 0 | if (criteria.getDocVersion() != null && !"".equals(criteria.getDocVersion().trim())) { |
| 227 | 0 | criteria.setDocVersion(criteria.getDocVersion().trim()); |
| 228 | |
} |
| 229 | |
} |
| 230 | |
|
| 231 | 0 | if (criteria.getDocumentId() != null && !"".equals(criteria.getDocumentId().trim())) { |
| 232 | 0 | criteria.setDocumentId(criteria.getDocumentId().trim()); |
| 233 | |
} |
| 234 | |
|
| 235 | |
|
| 236 | 0 | boolean compareDatePairs = true; |
| 237 | 0 | if (!validateDate("fromDateCreated", criteria.getFromDateCreated(), "fromDateCreated")) { |
| 238 | 0 | compareDatePairs = false; |
| 239 | |
} else { |
| 240 | 0 | if (criteria.getFromDateCreated() != null && !"".equals(criteria.getFromDateCreated().trim())) { |
| 241 | 0 | criteria.setFromDateCreated(criteria.getFromDateCreated().trim()); |
| 242 | |
} else { |
| 243 | 0 | compareDatePairs = false; |
| 244 | |
} |
| 245 | |
} |
| 246 | 0 | if (!validateDate("toDateCreated", criteria.getToDateCreated(), "toDateCreated")) { |
| 247 | 0 | compareDatePairs = false; |
| 248 | |
} else { |
| 249 | 0 | if (criteria.getToDateCreated() != null && !"".equals(criteria.getToDateCreated().trim())) { |
| 250 | 0 | criteria.setToDateCreated(criteria.getToDateCreated().trim()); |
| 251 | |
} else { |
| 252 | 0 | compareDatePairs = false; |
| 253 | |
} |
| 254 | |
} |
| 255 | 0 | if (compareDatePairs) { |
| 256 | 0 | if (!checkDateRanges(criteria.getFromDateCreated(), criteria.getToDateCreated())) { |
| 257 | 0 | String[] messageArgs = getDataDictionaryService().getAttributeValidatingErrorMessageParameters( |
| 258 | |
DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateCreated"); |
| 259 | 0 | errors.add(new WorkflowServiceErrorImpl(MessageFormat.format(getKualiConfigurationService().getPropertyString( |
| 260 | |
getDataDictionaryService().getAttributeValidatingErrorMessageKey(DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateCreated") + |
| 261 | |
".range"), messageArgs[0]), "docsearch.DocumentSearchService.dateCreatedRange")); |
| 262 | |
} |
| 263 | |
} |
| 264 | 0 | compareDatePairs = true; |
| 265 | 0 | if (!validateDate("fromDateApproved", criteria.getFromDateApproved(), "fromDateApproved")) { |
| 266 | 0 | compareDatePairs = false; |
| 267 | |
} else { |
| 268 | 0 | if (criteria.getFromDateApproved() != null && !"".equals(criteria.getFromDateApproved().trim())) { |
| 269 | 0 | criteria.setFromDateApproved(criteria.getFromDateApproved().trim()); |
| 270 | |
} else { |
| 271 | 0 | compareDatePairs = false; |
| 272 | |
} |
| 273 | |
} |
| 274 | 0 | if (!validateDate("toDateApproved", criteria.getToDateApproved(), "toDateApproved")) { |
| 275 | 0 | compareDatePairs = false; |
| 276 | |
} else { |
| 277 | 0 | if (criteria.getToDateApproved() != null && !"".equals(criteria.getToDateApproved().trim())) { |
| 278 | 0 | criteria.setToDateApproved(criteria.getToDateApproved().trim()); |
| 279 | |
} else { |
| 280 | 0 | compareDatePairs = false; |
| 281 | |
} |
| 282 | |
} |
| 283 | 0 | if (compareDatePairs) { |
| 284 | 0 | if (!checkDateRanges(criteria.getFromDateApproved(), criteria.getToDateApproved())) { |
| 285 | 0 | String[] messageArgs = getDataDictionaryService().getAttributeValidatingErrorMessageParameters( |
| 286 | |
DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateApproved"); |
| 287 | 0 | errors.add(new WorkflowServiceErrorImpl(MessageFormat.format(getKualiConfigurationService().getPropertyString( |
| 288 | |
getDataDictionaryService().getAttributeValidatingErrorMessageKey(DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateApproved") + |
| 289 | |
".range"), messageArgs[0]), "docsearch.DocumentSearchService.dateApprovedRange")); |
| 290 | |
} |
| 291 | |
} |
| 292 | 0 | compareDatePairs = true; |
| 293 | 0 | if (!validateDate("fromDateFinalized", criteria.getFromDateFinalized(), "fromDateFinalized")) { |
| 294 | 0 | compareDatePairs = false; |
| 295 | |
} else { |
| 296 | 0 | if (criteria.getFromDateFinalized() != null && !"".equals(criteria.getFromDateFinalized().trim())) { |
| 297 | 0 | criteria.setFromDateFinalized(criteria.getFromDateFinalized().trim()); |
| 298 | |
} else { |
| 299 | 0 | compareDatePairs = false; |
| 300 | |
} |
| 301 | |
} |
| 302 | 0 | if (!validateDate("toDateFinalized", criteria.getToDateFinalized(), "toDateFinalized")) { |
| 303 | 0 | compareDatePairs = false; |
| 304 | |
} else { |
| 305 | 0 | if (criteria.getToDateFinalized() != null && !"".equals(criteria.getToDateFinalized().trim())) { |
| 306 | 0 | criteria.setToDateFinalized(criteria.getToDateFinalized().trim()); |
| 307 | |
} else { |
| 308 | 0 | compareDatePairs = false; |
| 309 | |
} |
| 310 | |
} |
| 311 | 0 | if (compareDatePairs) { |
| 312 | 0 | if (!checkDateRanges(criteria.getFromDateFinalized(), criteria.getToDateFinalized())) { |
| 313 | 0 | String[] messageArgs = getDataDictionaryService().getAttributeValidatingErrorMessageParameters( |
| 314 | |
DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateFinalized"); |
| 315 | 0 | errors.add(new WorkflowServiceErrorImpl(MessageFormat.format(getKualiConfigurationService().getPropertyString( |
| 316 | |
getDataDictionaryService().getAttributeValidatingErrorMessageKey(DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateFinalized") + |
| 317 | |
".range"), messageArgs[0]), "docsearch.DocumentSearchService.dateFinalizedRange")); |
| 318 | |
} |
| 319 | |
} |
| 320 | 0 | compareDatePairs = true; |
| 321 | 0 | if (!validateDate("fromDateLastModified", criteria.getFromDateLastModified(), "fromDateLastModified")) { |
| 322 | 0 | compareDatePairs = false; |
| 323 | |
} else { |
| 324 | 0 | if (criteria.getFromDateLastModified() != null && !"".equals(criteria.getFromDateLastModified().trim())) { |
| 325 | 0 | criteria.setFromDateLastModified(criteria.getFromDateLastModified().trim()); |
| 326 | |
} else { |
| 327 | 0 | compareDatePairs = false; |
| 328 | |
} |
| 329 | |
} |
| 330 | 0 | if (!validateDate("toDateLastModified", criteria.getToDateLastModified(), "toDateLastModified")) { |
| 331 | 0 | compareDatePairs = false; |
| 332 | |
} else { |
| 333 | 0 | if (criteria.getToDateLastModified() != null && !"".equals(criteria.getToDateLastModified().trim())) { |
| 334 | 0 | criteria.setToDateLastModified(criteria.getToDateLastModified().trim()); |
| 335 | |
} else { |
| 336 | 0 | compareDatePairs = false; |
| 337 | |
} |
| 338 | |
} |
| 339 | 0 | if (compareDatePairs) { |
| 340 | 0 | if (!checkDateRanges(criteria.getFromDateLastModified(), criteria.getToDateLastModified())) { |
| 341 | 0 | String[] messageArgs = getDataDictionaryService().getAttributeValidatingErrorMessageParameters( |
| 342 | |
DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateLastModified"); |
| 343 | 0 | errors.add(new WorkflowServiceErrorImpl(MessageFormat.format(getKualiConfigurationService().getPropertyString( |
| 344 | |
getDataDictionaryService().getAttributeValidatingErrorMessageKey(DOC_SEARCH_CRITERIA_DTO_CLASS, "fromDateLastModified") + |
| 345 | |
".range"), messageArgs[0]), "docsearch.DocumentSearchService.dateLastModifiedRange")); |
| 346 | |
} |
| 347 | |
} |
| 348 | 0 | return errors; |
| 349 | |
} |
| 350 | |
|
| 351 | |
private boolean validateNetworkId(List<String> networkIds){ |
| 352 | 0 | for(String networkId: networkIds){ |
| 353 | 0 | if(!this.validateNetworkId(networkId)){ |
| 354 | 0 | return false; |
| 355 | |
} |
| 356 | |
} |
| 357 | 0 | return true; |
| 358 | |
} |
| 359 | |
private boolean validateNetworkId(String networkId) { |
| 360 | 0 | if ((networkId == null) || networkId.trim().equals("")) { |
| 361 | 0 | return true; |
| 362 | |
} |
| 363 | |
try { |
| 364 | 0 | return KimApiServiceLocator.getIdentityManagementService().getPrincipalByPrincipalName(networkId.trim()) != null; |
| 365 | 0 | } catch (Exception ex) { |
| 366 | 0 | LOG.debug(ex, ex); |
| 367 | 0 | return false; |
| 368 | |
} |
| 369 | |
} |
| 370 | |
|
| 371 | |
private boolean validatePersonByPrincipalName(String principalName){ |
| 372 | 0 | return true; |
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
|
| 377 | |
|
| 378 | |
} |
| 379 | |
|
| 380 | |
private boolean validateDate(String dateFieldName, String dateFieldValue, String dateFieldErrorKey) { |
| 381 | |
|
| 382 | 0 | int oldErrorCount = GlobalVariables.getMessageMap().getErrorCount(); |
| 383 | 0 | getDictionaryValidationService().validateAttributeFormat(DOC_SEARCH_CRITERIA_DTO_CLASS, dateFieldName, dateFieldValue, |
| 384 | |
KEWConstants.SearchableAttributeConstants.DATA_TYPE_DATE, dateFieldErrorKey); |
| 385 | 0 | return (GlobalVariables.getMessageMap().getErrorCount() <= oldErrorCount); |
| 386 | |
|
| 387 | |
} |
| 388 | |
|
| 389 | |
private boolean checkDateRanges(String fromDate, String toDate) { |
| 390 | 0 | return Utilities.checkDateRanges(fromDate, toDate); |
| 391 | |
} |
| 392 | |
|
| 393 | |
private boolean validateNumber(List<String> integers) { |
| 394 | 0 | for(String integer: integers){ |
| 395 | 0 | if(!this.validateNumber(integer)){ |
| 396 | 0 | return false; |
| 397 | |
} |
| 398 | |
} |
| 399 | 0 | return true; |
| 400 | |
} |
| 401 | |
|
| 402 | |
private boolean validateNumber(String integer) { |
| 403 | 0 | if ((integer == null) || integer.trim().equals("")) { |
| 404 | 0 | return true; |
| 405 | |
} |
| 406 | 0 | return SqlBuilder.isValidNumber(integer); |
| 407 | |
|
| 408 | |
} |
| 409 | |
|
| 410 | |
private boolean validateWorkgroup(String id, String workgroupName) { |
| 411 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(workgroupName)) { |
| 412 | 0 | return true; |
| 413 | |
} |
| 414 | 0 | Group group = KimApiServiceLocator.getIdentityManagementService().getGroup(id); |
| 415 | 0 | return group != null; |
| 416 | |
} |
| 417 | |
|
| 418 | |
public List<KeyValue> getNamedSearches(String principalId) { |
| 419 | 0 | List<UserOptions> namedSearches = userOptionsService.findByUserQualified(principalId, NAMED_SEARCH_ORDER_BASE + "%"); |
| 420 | 0 | List<KeyValue> sortedNamedSearches = new ArrayList<KeyValue>(0); |
| 421 | 0 | if (namedSearches != null && namedSearches.size() > 0) { |
| 422 | 0 | Collections.sort(namedSearches); |
| 423 | 0 | for (UserOptions namedSearch : namedSearches) { |
| 424 | 0 | KeyValue keyValue = new ConcreteKeyValue(namedSearch.getOptionId(), namedSearch.getOptionId().substring(NAMED_SEARCH_ORDER_BASE.length(), namedSearch.getOptionId().length())); |
| 425 | 0 | sortedNamedSearches.add(keyValue); |
| 426 | 0 | } |
| 427 | |
} |
| 428 | 0 | return sortedNamedSearches; |
| 429 | |
} |
| 430 | |
|
| 431 | |
public List<KeyValue> getMostRecentSearches(String principalId) { |
| 432 | 0 | UserOptions order = userOptionsService.findByOptionId(LAST_SEARCH_ORDER_OPTION, principalId); |
| 433 | 0 | List<KeyValue> sortedMostRecentSearches = new ArrayList<KeyValue>(); |
| 434 | 0 | if (order != null && order.getOptionVal() != null && !"".equals(order.getOptionVal())) { |
| 435 | 0 | List<UserOptions> mostRecentSearches = userOptionsService.findByUserQualified(principalId, LAST_SEARCH_BASE_NAME + "%"); |
| 436 | 0 | String[] ordered = order.getOptionVal().split(","); |
| 437 | 0 | for (String anOrdered : ordered) |
| 438 | |
{ |
| 439 | 0 | UserOptions matchingOption = null; |
| 440 | 0 | for (UserOptions option : mostRecentSearches) |
| 441 | |
{ |
| 442 | 0 | if (anOrdered.equals(option.getOptionId())) |
| 443 | |
{ |
| 444 | 0 | matchingOption = option; |
| 445 | 0 | break; |
| 446 | |
} |
| 447 | |
} |
| 448 | 0 | if (matchingOption != null) |
| 449 | |
{ |
| 450 | 0 | sortedMostRecentSearches.add(new ConcreteKeyValue(anOrdered, getCriteriaFromSavedSearch(matchingOption).getDocumentSearchAbbreviatedString())); |
| 451 | |
} |
| 452 | |
} |
| 453 | |
} |
| 454 | 0 | return sortedMostRecentSearches; |
| 455 | |
} |
| 456 | |
|
| 457 | |
private void saveSearch(String principalId, DocSearchCriteriaDTO criteria) { |
| 458 | 0 | if (StringUtils.isBlank(principalId)) { |
| 459 | 0 | String message = "User given to save search was null."; |
| 460 | 0 | LOG.warn(message); |
| 461 | 0 | throw new IllegalArgumentException(message); |
| 462 | |
} |
| 463 | 0 | StringBuffer savedSearchString = new StringBuffer(); |
| 464 | 0 | savedSearchString.append(criteria.getAppDocId() == null || "".equals(criteria.getAppDocId()) ? "" : ",,appDocId=" + criteria.getAppDocId()); |
| 465 | 0 | savedSearchString.append(criteria.getApprover() == null || "".equals(criteria.getApprover()) ? "" : ",,approver=" + criteria.getApprover()); |
| 466 | |
|
| 467 | 0 | if (! org.apache.commons.lang.StringUtils.isEmpty(criteria.getDocRouteNodeId()) && !criteria.getDocRouteNodeId().equals("-1")) { |
| 468 | 0 | RouteNode routeNode = KEWServiceLocator.getRouteNodeService().findRouteNodeById(new Long(criteria.getDocRouteNodeId())); |
| 469 | |
|
| 470 | |
|
| 471 | 0 | savedSearchString.append(",,docRouteNodeId="); |
| 472 | 0 | savedSearchString.append(routeNode.getRouteNodeId()); |
| 473 | 0 | savedSearchString.append(criteria.getDocRouteNodeLogic() == null || "".equals(criteria.getDocRouteNodeLogic()) ? "" : ",,docRouteNodeLogic=" + criteria.getDocRouteNodeLogic()); |
| 474 | |
} |
| 475 | |
|
| 476 | 0 | savedSearchString.append(criteria.getDocRouteStatus() == null || "".equals(criteria.getDocRouteStatus()) ? "" : ",,docRouteStatus=" + criteria.getDocRouteStatus()); |
| 477 | 0 | savedSearchString.append(criteria.getDocTitle() == null || "".equals(criteria.getDocTitle()) ? "" : ",,docTitle=" + criteria.getDocTitle()); |
| 478 | 0 | savedSearchString.append(criteria.getDocTypeFullName() == null || "".equals(criteria.getDocTypeFullName()) ? "" : ",,docTypeFullName=" + criteria.getDocTypeFullName()); |
| 479 | 0 | savedSearchString.append(criteria.getDocVersion() == null || "".equals(criteria.getDocVersion()) ? "" : ",,docVersion=" + criteria.getDocVersion()); |
| 480 | 0 | savedSearchString.append(criteria.getFromDateApproved() == null || "".equals(criteria.getFromDateApproved()) ? "" : ",,fromDateApproved=" + criteria.getFromDateApproved()); |
| 481 | 0 | savedSearchString.append(criteria.getFromDateCreated() == null || "".equals(criteria.getFromDateCreated()) ? "" : ",,fromDateCreated=" + criteria.getFromDateCreated()); |
| 482 | 0 | savedSearchString.append(criteria.getFromDateFinalized() == null || "".equals(criteria.getFromDateFinalized()) ? "" : ",,fromDateFinalized=" + criteria.getFromDateFinalized()); |
| 483 | 0 | savedSearchString.append(criteria.getFromDateLastModified() == null || "".equals(criteria.getFromDateLastModified()) ? "" : ",,fromDateLastModified=" + criteria.getFromDateLastModified()); |
| 484 | 0 | savedSearchString.append(criteria.getInitiator() == null || "".equals(criteria.getInitiator()) ? "" : ",,initiator=" + criteria.getInitiator()); |
| 485 | 0 | savedSearchString.append(criteria.getOverrideInd() == null || "".equals(criteria.getOverrideInd()) ? "" : ",,overrideInd=" + criteria.getOverrideInd()); |
| 486 | 0 | savedSearchString.append(criteria.getDocumentId() == null || "".equals(criteria.getDocumentId()) ? "" : ",,documentId=" + criteria.getDocumentId()); |
| 487 | 0 | savedSearchString.append(criteria.getToDateApproved() == null || "".equals(criteria.getToDateApproved()) ? "" : ",,toDateApproved=" + criteria.getToDateApproved()); |
| 488 | 0 | savedSearchString.append(criteria.getToDateCreated() == null || "".equals(criteria.getToDateCreated()) ? "" : ",,toDateCreated=" + criteria.getToDateCreated()); |
| 489 | 0 | savedSearchString.append(criteria.getToDateFinalized() == null || "".equals(criteria.getToDateFinalized()) ? "" : ",,toDateFinalized=" + criteria.getToDateFinalized()); |
| 490 | 0 | savedSearchString.append(criteria.getToDateLastModified() == null || "".equals(criteria.getToDateLastModified()) ? "" : ",,toDateLastModified=" + criteria.getToDateLastModified()); |
| 491 | 0 | savedSearchString.append(criteria.getViewer() == null || "".equals(criteria.getViewer()) ? "" : ",,viewer=" + criteria.getViewer()); |
| 492 | 0 | savedSearchString.append(criteria.getWorkgroupViewerName() == null || "".equals(criteria.getWorkgroupViewerName()) ? "" : ",,workgroupViewerName=" + criteria.getWorkgroupViewerName()); |
| 493 | 0 | savedSearchString.append(criteria.getWorkgroupViewerName() == null || "".equals(criteria.getWorkgroupViewerId()) ? "" : ",,workgroupViewerId=" + criteria.getWorkgroupViewerId()); |
| 494 | 0 | savedSearchString.append(criteria.getNamedSearch() == null || "".equals(criteria.getNamedSearch()) ? "" : ",,namedSearch=" + criteria.getNamedSearch()); |
| 495 | 0 | savedSearchString.append(criteria.getSearchableAttributes().isEmpty() ? "" : ",,searchableAttributes=" + buildSearchableAttributeString(criteria.getSearchableAttributes())); |
| 496 | |
|
| 497 | 0 | if (savedSearchString.toString() != null && !"".equals(savedSearchString.toString().trim())) { |
| 498 | |
|
| 499 | 0 | savedSearchString.append(criteria.getIsAdvancedSearch() == null || "".equals(criteria.getIsAdvancedSearch()) ? "" : ",,isAdvancedSearch=" + criteria.getIsAdvancedSearch()); |
| 500 | 0 | savedSearchString.append(criteria.getSuperUserSearch() == null || "".equals(criteria.getSuperUserSearch()) ? "" : ",,superUserSearch=" + criteria.getSuperUserSearch()); |
| 501 | |
|
| 502 | 0 | if (criteria.getNamedSearch() != null && !"".equals(criteria.getNamedSearch().trim())) { |
| 503 | 0 | userOptionsService.save(principalId, NAMED_SEARCH_ORDER_BASE + criteria.getNamedSearch(), savedSearchString.toString()); |
| 504 | |
} else { |
| 505 | |
|
| 506 | 0 | UserOptions searchOrder = userOptionsService.findByOptionId(LAST_SEARCH_ORDER_OPTION, principalId); |
| 507 | 0 | if (searchOrder == null) { |
| 508 | 0 | userOptionsService.save(principalId, LAST_SEARCH_BASE_NAME + "0", savedSearchString.toString()); |
| 509 | 0 | userOptionsService.save(principalId, LAST_SEARCH_ORDER_OPTION, LAST_SEARCH_BASE_NAME + "0"); |
| 510 | |
} else { |
| 511 | 0 | String[] currentOrder = searchOrder.getOptionVal().split(","); |
| 512 | 0 | if (currentOrder.length == MAX_SEARCH_ITEMS) { |
| 513 | 0 | String searchName = currentOrder[currentOrder.length - 1]; |
| 514 | 0 | String[] newOrder = new String[MAX_SEARCH_ITEMS]; |
| 515 | 0 | newOrder[0] = searchName; |
| 516 | 0 | for (int i = 0; i < currentOrder.length - 1; i++) { |
| 517 | 0 | newOrder[i + 1] = currentOrder[i]; |
| 518 | |
} |
| 519 | 0 | String newSearchOrder = ""; |
| 520 | 0 | for (String aNewOrder : newOrder) |
| 521 | |
{ |
| 522 | 0 | if (!"".equals(newSearchOrder)) |
| 523 | |
{ |
| 524 | 0 | newSearchOrder += ","; |
| 525 | |
} |
| 526 | 0 | newSearchOrder += aNewOrder; |
| 527 | |
} |
| 528 | 0 | userOptionsService.save(principalId, searchName, savedSearchString.toString()); |
| 529 | 0 | userOptionsService.save(principalId, LAST_SEARCH_ORDER_OPTION, newSearchOrder); |
| 530 | 0 | } else { |
| 531 | |
|
| 532 | |
|
| 533 | 0 | int absMax = 0; |
| 534 | 0 | for (String aCurrentOrder : currentOrder) |
| 535 | |
{ |
| 536 | 0 | int current = new Integer(aCurrentOrder.substring(LAST_SEARCH_BASE_NAME.length(), aCurrentOrder.length())); |
| 537 | 0 | if (current > absMax) |
| 538 | |
{ |
| 539 | 0 | absMax = current; |
| 540 | |
} |
| 541 | |
} |
| 542 | |
|
| 543 | 0 | String searchName = LAST_SEARCH_BASE_NAME + ++absMax; |
| 544 | 0 | String[] newOrder = new String[currentOrder.length + 1]; |
| 545 | 0 | newOrder[0] = searchName; |
| 546 | 0 | for (int i = 0; i < currentOrder.length; i++) { |
| 547 | 0 | newOrder[i + 1] = currentOrder[i]; |
| 548 | |
} |
| 549 | 0 | String newSearchOrder = ""; |
| 550 | 0 | for (String aNewOrder : newOrder) |
| 551 | |
{ |
| 552 | 0 | if (!"".equals(newSearchOrder)) |
| 553 | |
{ |
| 554 | 0 | newSearchOrder += ","; |
| 555 | |
} |
| 556 | 0 | newSearchOrder += aNewOrder; |
| 557 | |
} |
| 558 | 0 | userOptionsService.save(principalId, searchName, savedSearchString.toString()); |
| 559 | 0 | userOptionsService.save(principalId, LAST_SEARCH_ORDER_OPTION, newSearchOrder); |
| 560 | |
} |
| 561 | |
} |
| 562 | |
} |
| 563 | |
} |
| 564 | 0 | } |
| 565 | |
|
| 566 | |
|
| 567 | |
|
| 568 | |
|
| 569 | |
|
| 570 | |
|
| 571 | |
|
| 572 | |
|
| 573 | |
private String buildSearchableAttributeString(List<SearchAttributeCriteriaComponent> searchableAttributes) { |
| 574 | 0 | final StringBuilder searchableAttributeBuffer = new StringBuilder(); |
| 575 | |
|
| 576 | 0 | for (SearchAttributeCriteriaComponent component : searchableAttributes) { |
| 577 | |
|
| 578 | 0 | if ( (component.getFormKey() == null) || |
| 579 | |
(component.getValue() == null && (CollectionUtils.isEmpty(component.getValues()))) ) { |
| 580 | 0 | continue; |
| 581 | |
} |
| 582 | |
|
| 583 | 0 | if (component.getValue() != null) { |
| 584 | 0 | if (searchableAttributeBuffer.length() > 0) { |
| 585 | 0 | searchableAttributeBuffer.append(","); |
| 586 | |
} |
| 587 | 0 | searchableAttributeBuffer.append(component.getFormKey()); |
| 588 | 0 | searchableAttributeBuffer.append(":"); |
| 589 | 0 | searchableAttributeBuffer.append(component.getValue()); |
| 590 | 0 | } else if (!CollectionUtils.isEmpty(component.getValues())) { |
| 591 | 0 | for (String value : component.getValues()) { |
| 592 | 0 | if (searchableAttributeBuffer.length() > 0) { |
| 593 | 0 | searchableAttributeBuffer.append(","); |
| 594 | |
} |
| 595 | 0 | searchableAttributeBuffer.append(component.getFormKey()); |
| 596 | 0 | searchableAttributeBuffer.append(":"); |
| 597 | 0 | searchableAttributeBuffer.append(value); |
| 598 | |
} |
| 599 | |
} else { |
| 600 | 0 | throw new RuntimeException("Error occurred building searchable attribute string trying to find search attribute component value or values"); |
| 601 | |
} |
| 602 | |
} |
| 603 | |
|
| 604 | 0 | return searchableAttributeBuffer.toString(); |
| 605 | |
} |
| 606 | |
|
| 607 | |
|
| 608 | |
|
| 609 | |
|
| 610 | |
|
| 611 | |
|
| 612 | |
|
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
|
| 617 | |
|
| 618 | |
|
| 619 | |
|
| 620 | |
|
| 621 | |
|
| 622 | |
|
| 623 | |
|
| 624 | |
|
| 625 | |
|
| 626 | |
|
| 627 | |
|
| 628 | |
|
| 629 | |
|
| 630 | |
|
| 631 | |
|
| 632 | |
|
| 633 | |
|
| 634 | |
|
| 635 | |
|
| 636 | |
|
| 637 | |
|
| 638 | |
|
| 639 | |
|
| 640 | |
|
| 641 | |
|
| 642 | |
|
| 643 | |
|
| 644 | |
|
| 645 | |
|
| 646 | |
|
| 647 | |
|
| 648 | |
|
| 649 | |
|
| 650 | |
|
| 651 | |
|
| 652 | |
|
| 653 | |
|
| 654 | |
|
| 655 | |
|
| 656 | |
|
| 657 | |
|
| 658 | |
|
| 659 | |
|
| 660 | |
|
| 661 | |
|
| 662 | |
|
| 663 | |
|
| 664 | |
|
| 665 | |
|
| 666 | |
|
| 667 | |
|
| 668 | |
|
| 669 | |
|
| 670 | |
|
| 671 | |
|
| 672 | |
|
| 673 | |
|
| 674 | |
|
| 675 | |
|
| 676 | |
|
| 677 | |
|
| 678 | |
|
| 679 | |
|
| 680 | |
|
| 681 | |
|
| 682 | |
|
| 683 | |
|
| 684 | |
|
| 685 | |
|
| 686 | |
|
| 687 | |
|
| 688 | |
|
| 689 | |
|
| 690 | |
|
| 691 | |
|
| 692 | |
|
| 693 | |
|
| 694 | |
|
| 695 | |
|
| 696 | |
|
| 697 | |
|
| 698 | |
|
| 699 | |
|
| 700 | |
|
| 701 | |
|
| 702 | |
|
| 703 | |
|
| 704 | |
|
| 705 | |
|
| 706 | |
|
| 707 | |
|
| 708 | |
|
| 709 | |
|
| 710 | |
|
| 711 | |
|
| 712 | |
|
| 713 | |
|
| 714 | |
|
| 715 | |
|
| 716 | |
|
| 717 | |
|
| 718 | |
private static DocumentType getValidDocumentType(String docTypeName) { |
| 719 | |
|
| 720 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(docTypeName)) { |
| 721 | 0 | return null; |
| 722 | |
} |
| 723 | 0 | DocumentType dTypeCriteria = new DocumentType(); |
| 724 | 0 | dTypeCriteria.setName(docTypeName.trim()); |
| 725 | 0 | dTypeCriteria.setActive(true); |
| 726 | 0 | Collection<DocumentType> docTypeList = KEWServiceLocator.getDocumentTypeService().find(dTypeCriteria, null, false); |
| 727 | |
|
| 728 | |
|
| 729 | 0 | DocumentType firstDocumentType = null; |
| 730 | 0 | if(docTypeList != null && !docTypeList.isEmpty()){ |
| 731 | 0 | for(DocumentType dType: docTypeList){ |
| 732 | 0 | if (firstDocumentType == null) { |
| 733 | 0 | firstDocumentType = dType; |
| 734 | |
} |
| 735 | 0 | if (StringUtils.equals(docTypeName.toUpperCase(), dType.getName().toUpperCase())) { |
| 736 | 0 | return dType; |
| 737 | |
} |
| 738 | |
} |
| 739 | 0 | return firstDocumentType; |
| 740 | |
}else{ |
| 741 | 0 | throw new RuntimeException("No Valid Document Type Found for document type name '" + docTypeName + "'"); |
| 742 | |
} |
| 743 | |
} |
| 744 | |
|
| 745 | |
private DocumentType getValidDocumentTypeOld(String documentTypeFullName) { |
| 746 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(documentTypeFullName)) { |
| 747 | 0 | return null; |
| 748 | |
} |
| 749 | 0 | DocumentType docType = KEWServiceLocator.getDocumentTypeService().findByName(documentTypeFullName); |
| 750 | 0 | if (docType == null) { |
| 751 | 0 | throw new RuntimeException("No Valid Document Type Found for document type name '" + documentTypeFullName + "'"); |
| 752 | |
} else { |
| 753 | 0 | return docType; |
| 754 | |
} |
| 755 | |
} |
| 756 | |
|
| 757 | |
private DocSearchCriteriaDTO getCriteriaFromSavedSearch(UserOptions savedSearch) { |
| 758 | 0 | DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO(); |
| 759 | 0 | if (savedSearch != null) { |
| 760 | 0 | String docTypeFullName = getOptionCriteriaField(savedSearch, "docTypeFullName"); |
| 761 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(docTypeFullName)) { |
| 762 | 0 | criteria = new DocSearchCriteriaDTO(); |
| 763 | |
} |
| 764 | 0 | criteria.setDocTypeFullName(getOptionCriteriaField(savedSearch, "docTypeFullName")); |
| 765 | 0 | criteria.setAppDocId(getOptionCriteriaField(savedSearch, "appDocId")); |
| 766 | 0 | criteria.setApprover(getOptionCriteriaField(savedSearch, "approver")); |
| 767 | 0 | criteria.setDocRouteNodeId(getOptionCriteriaField(savedSearch, "docRouteNodeId")); |
| 768 | 0 | if (criteria.getDocRouteNodeId() != null) { |
| 769 | 0 | criteria.setDocRouteNodeLogic(getOptionCriteriaField(savedSearch, "docRouteNodeLogic")); |
| 770 | |
} |
| 771 | 0 | criteria.setIsAdvancedSearch(getOptionCriteriaField(savedSearch, "isAdvancedSearch")); |
| 772 | 0 | criteria.setSuperUserSearch(getOptionCriteriaField(savedSearch, "superUserSearch")); |
| 773 | 0 | criteria.setDocRouteStatus(getOptionCriteriaField(savedSearch, "docRouteStatus")); |
| 774 | 0 | criteria.setDocTitle(getOptionCriteriaField(savedSearch, "docTitle")); |
| 775 | 0 | criteria.setDocVersion(getOptionCriteriaField(savedSearch, "docVersion")); |
| 776 | 0 | criteria.setFromDateApproved(getOptionCriteriaField(savedSearch, "fromDateApproved")); |
| 777 | 0 | criteria.setFromDateCreated(getOptionCriteriaField(savedSearch, "fromDateCreated")); |
| 778 | 0 | criteria.setFromDateFinalized(getOptionCriteriaField(savedSearch, "fromDateFinalized")); |
| 779 | 0 | criteria.setFromDateLastModified(getOptionCriteriaField(savedSearch, "fromDateLastModified")); |
| 780 | 0 | criteria.setInitiator(getOptionCriteriaField(savedSearch, "initiator")); |
| 781 | 0 | criteria.setOverrideInd(getOptionCriteriaField(savedSearch, "overrideInd")); |
| 782 | 0 | criteria.setDocumentId(getOptionCriteriaField(savedSearch, "documentId")); |
| 783 | 0 | criteria.setToDateApproved(getOptionCriteriaField(savedSearch, "toDateApproved")); |
| 784 | 0 | criteria.setToDateCreated(getOptionCriteriaField(savedSearch, "toDateCreated")); |
| 785 | 0 | criteria.setToDateFinalized(getOptionCriteriaField(savedSearch, "toDateFinalized")); |
| 786 | 0 | criteria.setToDateLastModified(getOptionCriteriaField(savedSearch, "toDateLastModified")); |
| 787 | 0 | criteria.setViewer(getOptionCriteriaField(savedSearch, "viewer")); |
| 788 | 0 | criteria.setWorkgroupViewerNamespace(getOptionCriteriaField(savedSearch, "workgroupViewerNamespace")); |
| 789 | 0 | criteria.setWorkgroupViewerName(getOptionCriteriaField(savedSearch, "workgroupViewerName")); |
| 790 | 0 | criteria.setNamedSearch(getOptionCriteriaField(savedSearch, "namedSearch")); |
| 791 | 0 | criteria.setSearchableAttributes(DocSearchUtils.buildSearchableAttributesFromString(getOptionCriteriaField(savedSearch, "searchableAttributes"),criteria.getDocTypeFullName())); |
| 792 | |
} |
| 793 | 0 | return criteria; |
| 794 | |
} |
| 795 | |
|
| 796 | |
private String getOptionCriteriaField(UserOptions userOption, String fieldName) { |
| 797 | 0 | String value = userOption.getOptionVal(); |
| 798 | 0 | if (value != null) { |
| 799 | 0 | String[] fields = value.split(",,"); |
| 800 | 0 | for (String field : fields) |
| 801 | |
{ |
| 802 | 0 | if (field.startsWith(fieldName + "=")) |
| 803 | |
{ |
| 804 | 0 | return field.substring(field.indexOf(fieldName) + fieldName.length() + 1, field.length()); |
| 805 | |
} |
| 806 | |
} |
| 807 | |
} |
| 808 | 0 | return null; |
| 809 | |
} |
| 810 | |
|
| 811 | |
public static DictionaryValidationService getDictionaryValidationService() { |
| 812 | 0 | if (dictionaryValidationService == null) { |
| 813 | 0 | dictionaryValidationService = KNSServiceLocatorWeb.getDictionaryValidationService(); |
| 814 | |
} |
| 815 | 0 | return dictionaryValidationService; |
| 816 | |
} |
| 817 | |
|
| 818 | |
public static DataDictionaryService getDataDictionaryService() { |
| 819 | 0 | if (dataDictionaryService == null) { |
| 820 | 0 | dataDictionaryService = KNSServiceLocatorWeb.getDataDictionaryService(); |
| 821 | |
} |
| 822 | 0 | return dataDictionaryService; |
| 823 | |
} |
| 824 | |
|
| 825 | |
public static ConfigurationService getKualiConfigurationService() { |
| 826 | 0 | if (kualiConfigurationService == null) { |
| 827 | 0 | kualiConfigurationService = KNSServiceLocator.getKualiConfigurationService(); |
| 828 | |
} |
| 829 | 0 | return kualiConfigurationService; |
| 830 | |
} |
| 831 | |
|
| 832 | |
private List<String> tokenizeCriteria(String input){ |
| 833 | 0 | List<String> lRet = null; |
| 834 | |
|
| 835 | 0 | lRet = Arrays.asList(input.split("\\|")); |
| 836 | |
|
| 837 | 0 | return lRet; |
| 838 | |
} |
| 839 | |
|
| 840 | |
|
| 841 | |
|
| 842 | |
|
| 843 | |
public SqlBuilder getSqlBuilder() { |
| 844 | 0 | if(sqlBuilder == null){ |
| 845 | 0 | sqlBuilder = new SqlBuilder(); |
| 846 | 0 | sqlBuilder.setDbPlatform((DatabasePlatform) GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM)); |
| 847 | 0 | sqlBuilder.setDateTimeService(CoreApiServiceLocator.getDateTimeService()); |
| 848 | |
} |
| 849 | 0 | return this.sqlBuilder; |
| 850 | |
} |
| 851 | |
|
| 852 | |
|
| 853 | |
|
| 854 | |
|
| 855 | |
public void setSqlBuilder(SqlBuilder sqlBuilder) { |
| 856 | 0 | this.sqlBuilder = sqlBuilder; |
| 857 | 0 | } |
| 858 | |
} |