View Javadoc

1   /**
2    * Copyright 2004-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.kpme.tklm.time.web;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.rice.kim.api.KimConstants;
23  import org.kuali.rice.kim.api.identity.Person;
24  import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm;
25  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
26  import org.kuali.rice.krad.service.ModuleService;
27  
28  /**
29   * This is set up in the kr/struts-config.xml, so that our maintenance docs
30   * have some modified header information.
31   */
32  public class TimeMaintenanceForm extends KualiMaintenanceForm {
33  
34  	/**
35  	 * 
36  	 */
37  	private static final long serialVersionUID = 1L;
38  
39  	/*
40  	 * This was cut and pasted from the parent, with some modification.
41  	 */
42  	@Override
43  	protected String getPersonInquiryUrlLink(Person user, String linkBody) {
44          StringBuffer urlBuffer = new StringBuffer();
45                  
46          if(user != null && StringUtils.isNotEmpty(linkBody) ) {
47          	ModuleService moduleService = KRADServiceLocatorWeb.getKualiModuleService().getResponsibleModuleService(Person.class);
48          	Map<String, String[]> parameters = new HashMap<String, String[]>();
49          	parameters.put(KimConstants.AttributeConstants.PRINCIPAL_ID, new String[] { user.getPrincipalId() });
50          	String inquiryUrl = moduleService.getExternalizableBusinessObjectInquiryUrl(Person.class, parameters);
51              if(!StringUtils.equals(KimConstants.EntityTypes.SYSTEM, user.getEntityTypeCode())){
52  	            urlBuffer.append("<a href='");
53  	            urlBuffer.append(inquiryUrl);
54  	            urlBuffer.append("' ");
55  	            urlBuffer.append("target='_blank'");
56  	            urlBuffer.append("title='Person Inquiry'>");
57  	            urlBuffer.append(linkBody);
58  	            urlBuffer.append("</a>");
59  	            
60  	            // Added re: KPME-207 (https://jira.kuali.org/browse/KPME-207)
61  	            urlBuffer.append(" (");
62  	            urlBuffer.append(user.getName());
63  	            urlBuffer.append(")");
64              } else{
65              	urlBuffer.append(linkBody);
66              }
67          }
68          
69          return urlBuffer.toString();
70  	}
71  
72  }