View Javadoc
1   /*
2    * Copyright 2006 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.ole.coa.businessobject.inquiry;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Properties;
21  
22  import org.kuali.ole.coa.businessobject.Organization;
23  import org.kuali.ole.coa.identity.OrgReviewRole;
24  import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl;
25  import org.kuali.ole.sys.identity.OleKimAttributes;
26  import org.kuali.rice.kim.api.KimConstants;
27  import org.kuali.rice.kns.lookup.HtmlData;
28  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
29  import org.kuali.rice.kns.web.ui.Field;
30  import org.kuali.rice.kns.web.ui.Row;
31  import org.kuali.rice.kns.web.ui.Section;
32  import org.kuali.rice.krad.bo.BusinessObject;
33  import org.kuali.rice.krad.util.KRADConstants;
34  import org.kuali.rice.krad.util.UrlFactory;
35  
36  /**
37   * This class adds in some new sections for {@link Org} inquiries, specifically Org Hierarchy Org Review Hierarchy
38   */
39  public class OrgInquirable extends KfsInquirableImpl {
40  
41      /**
42       * KRAD Conversion: Inquirable adds new fields to sections and then adds new sections.
43       * But all field/section definitions are built here for the new section.
44       */
45      public void addAdditionalSections(List sections, BusinessObject bo) {
46          if (bo instanceof Organization) {
47              Organization org = (Organization) bo;
48  
49              List rows = new ArrayList();
50  
51              Field f = new Field();
52              f.setPropertyName("Organization Hierarchy");
53              f.setFieldLabel("Organization Hierarchy");
54              f.setPropertyValue(org.getOrganizationHierarchy());
55              f.setFieldType(Field.TEXT);
56              rows.add(new Row(f));
57  
58              f = new Field();
59              f.setPropertyName("Organization Review Hierarchy");
60              f.setFieldLabel("Organization Review Hierarchy");
61              f.setPropertyValue("run search");
62              f.setFieldType(Field.TEXT);
63              Properties parameters = new Properties();
64              parameters.put(OleKimAttributes.CHART_OF_ACCOUNTS_CODE, org.getChartOfAccountsCode());
65              parameters.put(OleKimAttributes.ORGANIZATION_CODE, org.getOrganizationCode());
66              parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, OrgReviewRole.class.getName());
67              parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, KRADConstants.PORTAL_ACTION);
68              parameters.put(KRADConstants.DOC_FORM_KEY, KimConstants.KimUIConstants.KIM_ROLE_DOCUMENT_SHORT_KEY);
69              String hrefStr = UrlFactory.parameterizeUrl(KRADConstants.LOOKUP_ACTION, parameters);
70              HtmlData hRef = new AnchorHtmlData(hrefStr, KRADConstants.EMPTY_STRING);
71              f.setInquiryURL(hRef);
72              rows.add(new Row(f));
73  
74              Section section = new Section();
75              section.setRows(rows);
76              section.setSectionTitle("Organization Hierarchy");
77              sections.add(section);
78          }
79      }
80  
81  
82  }