001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kns.workflow.attribute;
017
018import org.kuali.rice.kew.api.extension.ExtensionDefinition;
019import org.w3c.dom.Element;
020
021/**
022 * This is an XML KEW search attribute that can be used where the XML of the attribute has an xpath expression that returns a
023 * boolean. This attribute takes that boolean expression and translates it into true and false values based on the
024 * {@link #getValueForXPathTrueEvaluation()} and {@link #getValueForXPathFalseEvaluation()} method's return variables.
025 * 
026 * NOTE: This will not longer be necessary if the version of xPath being used is every upgrade to 2.x or higher
027 *
028 * @deprecated Only used by KNS classes, no replacement.
029 */
030@Deprecated
031public class KualiXMLBooleanTranslatorSearchableAttributeImpl extends KualiXmlSearchableAttributeImpl {
032        private static final long serialVersionUID = -4627314389844574461L;
033
034        public static final String VALUE_FOR_TRUE = "Yes";
035        public static final String VALUE_FOR_FALSE = "No";
036
037
038
039        /**
040         * This overriden method does the translation of the given xPath expression from the XML definition of the attribute and
041         * translates it into the true and false values based on the {@link #getValueForXPathTrueEvaluation()} and
042         * {@link #getValueForXPathFalseEvaluation()} method's return variables
043         */
044        @Override
045        public Element getConfigXML(ExtensionDefinition extensionDefinition) {
046                String[] xpathElementsToInsert = new String[3];
047                xpathElementsToInsert[0] = "concat( substring('" + getValueForXPathTrueEvaluation() + "', number(not(";
048                xpathElementsToInsert[1] = "))*string-length('" + getValueForXPathTrueEvaluation() + "')+1), substring('" + getValueForXPathFalseEvaluation() + "', number(";
049                xpathElementsToInsert[2] = ")*string-length('" + getValueForXPathFalseEvaluation() + "')+1))";
050                Element root = super.getConfigXML(extensionDefinition);
051                return new KualiXmlAttributeHelper().processConfigXML(root, xpathElementsToInsert);
052        }
053
054        public String getValueForXPathTrueEvaluation() {
055                return VALUE_FOR_TRUE;
056        }
057
058        public String getValueForXPathFalseEvaluation() {
059                return VALUE_FOR_FALSE;
060        }
061
062}