View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    *
4    * Copyright 2005-2014 The Kuali Foundation
5    *
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   *
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ar.businessobject.lookup;
20  
21  import java.util.HashMap;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Properties;
25  
26  import org.kuali.kfs.module.ar.ArConstants;
27  import org.kuali.kfs.module.ar.ArKeyConstants;
28  import org.kuali.kfs.module.ar.ArPropertyConstants;
29  import org.kuali.kfs.module.ar.businessobject.CollectionEvent;
30  import org.kuali.kfs.module.ar.businessobject.CollectionsReport;
31  import org.kuali.kfs.sys.KFSConstants;
32  import org.kuali.kfs.sys.KFSPropertyConstants;
33  import org.kuali.rice.core.api.config.property.ConfigurationService;
34  import org.kuali.rice.kim.api.KimConstants;
35  import org.kuali.rice.kim.api.services.IdentityManagementService;
36  import org.kuali.rice.kns.lookup.HtmlData;
37  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
38  import org.kuali.rice.krad.bo.BusinessObject;
39  import org.kuali.rice.krad.util.GlobalVariables;
40  import org.kuali.rice.krad.util.KRADConstants;
41  import org.kuali.rice.krad.util.UrlFactory;
42  
43  public abstract class CollectionsReportLookupableHelperServiceImplBase extends ContractsGrantsReportLookupableHelperServiceImplBase {
44  
45      protected ConfigurationService configurationService;
46      protected IdentityManagementService identityManagementService;
47  
48      /**
49       * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#getCustomActionUrls(org.kuali.rice.krad.bo.BusinessObject, java.util.List)
50       */
51      @Override
52      public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
53          List<HtmlData> urls = super.getCustomActionUrls(businessObject, pkNames);
54  
55          CollectionsReport collectionsReport = (CollectionsReport) businessObject;
56          String url = getContractsGrantsReportHelperService().getInitiateCollectionActivityDocumentUrl(collectionsReport.getProposalNumber().toString(), collectionsReport.getInvoiceNumber());
57          Map<String, String> fieldList = new HashMap<String, String>();
58          fieldList.put(KFSPropertyConstants.PROPOSAL_NUMBER, collectionsReport.getProposalNumber().toString());
59          AnchorHtmlData a = new AnchorHtmlData(url, KRADConstants.EMPTY_STRING);
60          a.setHref(url);
61          a.setTitle(HtmlData.getTitleText(getContractsGrantsReportHelperService().createTitleText(getBusinessObjectClass()), getBusinessObjectClass(), fieldList));
62          a.setDisplayText(getConfigurationService().getPropertyValueAsString(ArKeyConstants.ContractsGrantsCollectionActivityDocumentConstants.TITLE_PROPERTY));
63          urls.add(a);
64  
65          Map<String, String> permissionDetails = new HashMap<String, String>();
66          Map<String, String> qualificationDetails = new HashMap<String, String>();
67          permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, ArConstants.ArDocumentTypeCodes.COLLECTION_EVENT);
68  
69          Map<String, Long> primaryKeys = new HashMap<>();
70          primaryKeys.put(ArPropertyConstants.CollectionEventFields.ID, collectionsReport.getEventId());
71          CollectionEvent event = getBusinessObjectService().findByPrimaryKey(CollectionEvent.class, primaryKeys);
72          if (getBusinessObjectAuthorizationService().canMaintain(event, GlobalVariables.getUserSession().getPerson(), ArConstants.ArDocumentTypeCodes.COLLECTION_EVENT)) {
73              Properties parameters = new Properties();
74              parameters.put(KFSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, CollectionEvent.class.getName());
75              parameters.put(KFSConstants.OVERRIDE_KEYS, ArPropertyConstants.CollectionEventFields.ID);
76              parameters.put(KFSConstants.REFRESH_CALLER, ArPropertyConstants.CollectionEventFields.ID + "::" + collectionsReport.getEventId());
77              parameters.put(ArPropertyConstants.CollectionEventFields.ID, collectionsReport.getEventId().toString());
78              parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL);
79  
80              url = UrlFactory.parameterizeUrl(KFSConstants.RICE_PATH_PREFIX + KFSConstants.MAINTENANCE_ACTION, parameters);
81              AnchorHtmlData anchorHtmlData = new AnchorHtmlData(url, KFSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, KFSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL);
82              urls.add(anchorHtmlData);
83          }
84  
85          return urls;
86      }
87  
88      public ConfigurationService getConfigurationService() {
89          return configurationService;
90      }
91  
92      public void setConfigurationService(ConfigurationService configurationService) {
93          this.configurationService = configurationService;
94      }
95  
96      public IdentityManagementService getIdentityManagementService() {
97          return identityManagementService;
98      }
99  
100     public void setIdentityManagementService(IdentityManagementService identityManagementService) {
101         this.identityManagementService = identityManagementService;
102     }
103 
104 }