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.kew.rule.bo;
17  
18  import org.kuali.rice.core.api.config.property.ConfigContext;
19  import org.kuali.rice.kew.rule.RuleBaseValues;
20  import org.kuali.rice.kew.rule.web.WebRuleUtils;
21  import org.kuali.rice.kew.api.KewApiConstants;
22  import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
23  import org.kuali.rice.kns.lookup.HtmlData;
24  import org.kuali.rice.kns.web.ui.Section;
25  import org.kuali.rice.krad.bo.BusinessObject;
26  
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * Inquirable implementation for KEW routing rules.
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   *
35   */
36  public class RuleBaseValuesInquirableImpl extends KualiInquirableImpl {
37  
38  	public static final String DOCUMENT_ID = "documentId";
39  
40  	@Override
41  	public Object retrieveDataObject(Map fieldValues){
42  		RuleBaseValues rule = (RuleBaseValues)super.retrieveDataObject(fieldValues);
43  		WebRuleUtils.populateRuleMaintenanceFields(rule);
44  		return rule;
45      }
46  	
47  	/**
48  	 * This overridden method ...
49  	 * 
50  	 * @see org.kuali.rice.krad.inquiry.Inquirable#getBusinessObject(java.util.Map)
51  	 */
52  	public BusinessObject getBusinessObject(Map fieldValues) {
53  		RuleBaseValues rule = (RuleBaseValues)super.getBusinessObject(fieldValues);
54  		WebRuleUtils.populateRuleMaintenanceFields(rule);
55  		return rule;
56  	}
57  
58  	/**
59  	 * This overridden method ...
60  	 * 
61  	 * @see org.kuali.rice.krad.inquiry.Inquirable#getSections(org.kuali.rice.krad.bo.BusinessObject)
62  	 */
63  	public List<Section> getSections(BusinessObject bo) {
64  		List<Section> sections = super.getSections(bo);
65  
66  		return WebRuleUtils.customizeSections((RuleBaseValues)bo, sections, false);
67  
68  	}
69  	
70  
71      @Override
72      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
73      	
74  		if(DOCUMENT_ID.equals(attributeName)) {
75  
76  			HtmlData.AnchorHtmlData link = new HtmlData.AnchorHtmlData();
77  			RuleBaseValues rule = (RuleBaseValues)businessObject;
78  
79  			String documentId = rule.getDocumentId();
80  			link.setDisplayText(documentId+"");
81  
82  			String href = ConfigContext.getCurrentContextConfig().getKEWBaseURL() + "/" +
83  			KewApiConstants.DOC_HANDLER_REDIRECT_PAGE + "?" + KewApiConstants.COMMAND_PARAMETER + "=" +
84  			KewApiConstants.DOCSEARCH_COMMAND + "&" + KewApiConstants.DOCUMENT_ID_PARAMETER + "=" + documentId;
85  
86  			link.setHref(href);
87  
88  			return link;
89  		}		
90          return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
91      }
92  
93  }