001    /**
002     * Copyright 2005-2014 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     */
016    package edu.sampleu.bookstore.document.attribs;
017    
018    import org.apache.log4j.Logger;
019    import org.kuali.rice.core.api.uif.DataType;
020    import org.kuali.rice.core.api.uif.RemotableAttributeError;
021    import org.kuali.rice.core.api.uif.RemotableAttributeField;
022    import org.kuali.rice.kew.api.KewApiConstants;
023    import org.kuali.rice.kew.api.document.DocumentWithContent;
024    import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
025    import org.kuali.rice.kew.api.document.attribute.DocumentAttributeFactory;
026    import org.kuali.rice.kew.api.document.attribute.WorkflowAttributeDefinition;
027    import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
028    import org.kuali.rice.kew.api.extension.ExtensionDefinition;
029    import org.kuali.rice.kew.docsearch.DocumentSearchInternalUtils;
030    import org.kuali.rice.kew.docsearch.SearchableAttributeValue;
031    import org.kuali.rice.kew.framework.document.attribute.SearchableAttribute;
032    import org.kuali.rice.kew.rule.xmlrouting.XPathHelper;
033    import org.kuali.rice.kns.util.FieldUtils;
034    
035    import javax.jws.WebParam;
036    import javax.xml.xpath.XPath;
037    import javax.xml.xpath.XPathConstants;
038    import javax.xml.xpath.XPathExpressionException;
039    import java.io.StringReader;
040    import java.util.ArrayList;
041    import java.util.List;
042    
043    /**
044     * Searchable attribute for book title
045     * TODO: probably needs to be wired up to extension repository for remote invocation
046     *
047     * <documentContent>
048       <applicationContent>
049       <org.kuali.rice.krad.workflow.KualiDocumentXmlMaterializer>
050       ...
051       <newMaintainableObject class="edu.sampleu.bookstore.maintenance.BookMaintainable">
052          <businessObject class="edu.sampleu.bookstore.bo.Book">
053            <title>asdfasdf</title>
054            <typeCode>ROM</typeCode>
055            <isbn/>
056            <publisher>asfdasdd</publisher>
057            <price>
058              <value>1212.00</value>
059            </price>
060            <rating>
061              <value>1</value>
062            </rating>
063            <authors>
064              <edu.sampleu.bookstore.bo.Author>
065                <authorName>asdfasdf</authorName>
066                <email>asdfasdf@gmailc.om</email>
067                <phoneNbr>123-123-1234</phoneNbr>
068                <active>true</active>
069                <addresses/>
070                <books/>
071                <newCollectionRecord>false</newCollectionRecord>
072                <extension class="edu.sampleu.bookstore.bo.Account">
073                  <bankName>asdfasdf</bankName>
074                  <accountNumber>12345</accountNumber>
075                  <newCollectionRecord>false</newCollectionRecord>
076                </extension>
077              </edu.sampleu.bookstore.bo.Author>
078            </authors>
079            <newCollectionRecord>false</newCollectionRecord>
080          </businessObject>
081          <newCollectionLines/>
082          <inactiveRecordDisplay/>
083          <newCollectionLineNames/>
084          <documentNumber>3020</documentNumber>
085          <dataObject class="edu.sampleu.bookstore.bo.Book" reference="../businessObject"/>
086          <dataObjectClass>edu.sampleu.bookstore.bo.Book</dataObjectClass>
087          <maintenanceAction>New</maintenanceAction>
088        </newMaintainableObject>
089        ..
090     */
091    public class BookTitleSearchableAttribute extends XPathSearchableAttribute {
092        public BookTitleSearchableAttribute() {
093            super("book_title", KewApiConstants.SearchableAttributeConstants.DATA_TYPE_STRING, "//newMaintainableObject/businessObject/title/text()", "Book Title");
094        }
095    }