View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.rice.kns.workflow.attribute;
17  
18  import org.kuali.rice.kew.api.extension.ExtensionDefinition;
19  import org.w3c.dom.Element;
20  
21  /**
22   * This is an XML KEW search attribute that can be used where the XML of the attribute has an xpath expression that returns a
23   * boolean. This attribute takes that boolean expression and translates it into true and false values based on the
24   * {@link #getValueForXPathTrueEvaluation()} and {@link #getValueForXPathFalseEvaluation()} method's return variables.
25   * 
26   * NOTE: This will not longer be necessary if the version of xPath being used is every upgrade to 2.x or higher
27   *
28   * @deprecated Only used by KNS classes, no replacement.
29   */
30  @Deprecated
31  public class KualiXMLBooleanTranslatorSearchableAttributeImpl extends KualiXmlSearchableAttributeImpl {
32  	private static final long serialVersionUID = -4627314389844574461L;
33  
34  	public static final String VALUE_FOR_TRUE = "Yes";
35  	public static final String VALUE_FOR_FALSE = "No";
36  
37  
38  
39  	/**
40  	 * This overriden method does the translation of the given xPath expression from the XML definition of the attribute and
41  	 * translates it into the true and false values based on the {@link #getValueForXPathTrueEvaluation()} and
42  	 * {@link #getValueForXPathFalseEvaluation()} method's return variables
43  	 */
44  	@Override
45  	public Element getConfigXML(ExtensionDefinition extensionDefinition) {
46  		String[] xpathElementsToInsert = new String[3];
47  		xpathElementsToInsert[0] = "concat( substring('" + getValueForXPathTrueEvaluation() + "', number(not(";
48  		xpathElementsToInsert[1] = "))*string-length('" + getValueForXPathTrueEvaluation() + "')+1), substring('" + getValueForXPathFalseEvaluation() + "', number(";
49  		xpathElementsToInsert[2] = ")*string-length('" + getValueForXPathFalseEvaluation() + "')+1))";
50  		Element root = super.getConfigXML(extensionDefinition);
51  		return new KualiXmlAttributeHelper().processConfigXML(root, xpathElementsToInsert);
52  	}
53  
54  	public String getValueForXPathTrueEvaluation() {
55  		return VALUE_FOR_TRUE;
56  	}
57  
58  	public String getValueForXPathFalseEvaluation() {
59  		return VALUE_FOR_FALSE;
60  	}
61  
62  }