| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| KualiXMLBooleanTranslatorSearchableAttributeImpl | 
  | 
  | 1.0;1 | 
| 1 |  /** | |
| 2 |   * Copyright 2005-2011 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.krad.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 | 0 |  public class KualiXMLBooleanTranslatorSearchableAttributeImpl extends KualiXmlSearchableAttributeImpl { | 
| 29 | private static final long serialVersionUID = -4627314389844574461L;  | |
| 30 | ||
| 31 | public static final String VALUE_FOR_TRUE = "Yes";  | |
| 32 | public static final String VALUE_FOR_FALSE = "No";  | |
| 33 | ||
| 34 | ||
| 35 | ||
| 36 |          /** | |
| 37 |           * This overriden method does the translation of the given xPath expression from the XML definition of the attribute and | |
| 38 |           * translates it into the true and false values based on the {@link #getValueForXPathTrueEvaluation()} and | |
| 39 |           * {@link #getValueForXPathFalseEvaluation()} method's return variables | |
| 40 |           */ | |
| 41 | @Override  | |
| 42 |          public Element getConfigXML(ExtensionDefinition extensionDefinition) { | |
| 43 | 0 |                  String[] xpathElementsToInsert = new String[3]; | 
| 44 | 0 |                  xpathElementsToInsert[0] = "concat( substring('" + getValueForXPathTrueEvaluation() + "', number(not("; | 
| 45 | 0 |                  xpathElementsToInsert[1] = "))*string-length('" + getValueForXPathTrueEvaluation() + "')+1), substring('" + getValueForXPathFalseEvaluation() + "', number("; | 
| 46 | 0 |                  xpathElementsToInsert[2] = ")*string-length('" + getValueForXPathFalseEvaluation() + "')+1))"; | 
| 47 | 0 |                  Element root = super.getConfigXML(extensionDefinition); | 
| 48 | 0 |                  return new KualiXmlAttributeHelper().processConfigXML(root, xpathElementsToInsert); | 
| 49 | }  | |
| 50 | ||
| 51 |          public String getValueForXPathTrueEvaluation() { | |
| 52 | 0 |                  return VALUE_FOR_TRUE; | 
| 53 | }  | |
| 54 | ||
| 55 |          public String getValueForXPathFalseEvaluation() { | |
| 56 | 0 |                  return VALUE_FOR_FALSE; | 
| 57 | }  | |
| 58 | ||
| 59 | }  |