01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.workflow.module.purap.docsearch.attribute;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.module.purap.PurapConstants;
22: import org.kuali.workflow.attribute.KualiXmlSearchableAttributeImpl;
23:
24: import edu.iu.uis.eden.docsearch.SearchableAttributeStringValue;
25: import edu.iu.uis.eden.docsearch.SearchableAttributeValue;
26: import edu.iu.uis.eden.lookupable.Field;
27:
28: /**
29: * This class...
30: */
31: public class KualiPurchaseOrderIncompleteStatusesAttribute extends
32: KualiXmlSearchableAttributeImpl {
33: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
34: .getLogger(KualiPurchaseOrderIncompleteStatusesAttribute.class);
35:
36: public static final String FIELD_DEF_NAME = "purchaseOrderDocumentIncompleteStatuses";
37: public static final String VALUE_FOR_YES = Field.CHECKBOX_VALUE_CHECKED;
38: public static final String VALUE_FOR_NO = Field.CHECKBOX_VALUE_UNCHECKED;
39:
40: /**
41: * This method will use the given value which should be the document's status code and translate that into
42: */
43: @Override
44: public List getSearchStorageValues(String docContent) {
45: List<SearchableAttributeValue> newSearchAttributeValues = new ArrayList();
46: List<SearchableAttributeValue> super List = super
47: .getSearchStorageValues(docContent);
48: if (super List.size() != 1) {
49: String errorMessage = "Exactly one field with an xpath expression that finds one status code should be defined for this attribute (found "
50: + super List.size() + ").";
51: LOG.error(errorMessage);
52: throw new RuntimeException(errorMessage);
53: }
54: SearchableAttributeValue super SearchAttValue = super List.get(0);
55: SearchableAttributeStringValue sav = new SearchableAttributeStringValue();
56: sav.setSearchableAttributeKey(super SearchAttValue
57: .getSearchableAttributeKey());
58: if (PurapConstants.PurchaseOrderStatuses.INCOMPLETE_STATUSES
59: .contains((String) superSearchAttValue
60: .getSearchableAttributeValue())) {
61: sav.setSearchableAttributeValue(VALUE_FOR_YES);
62: } else {
63: sav.setSearchableAttributeValue(VALUE_FOR_NO);
64: }
65: newSearchAttributeValues.add(sav);
66: return newSearchAttributeValues;
67: }
68:
69: }
|