View Javadoc

1   /*
2    * Copyright 2006-2011 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  
17  package org.kuali.rice.edl.impl.lookupable;
18  
19  import org.kuali.rice.core.api.config.property.ConfigContext;
20  import org.kuali.rice.edl.impl.UserAction;
21  import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
22  import org.kuali.rice.kns.bo.BusinessObject;
23  import org.kuali.rice.kns.lookup.HtmlData;
24  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
25  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
26  import org.kuali.rice.kns.util.UrlFactory;
27  import org.kuali.rice.kns.web.struts.form.LookupForm;
28  
29  import java.util.ArrayList;
30  import java.util.Collection;
31  import java.util.List;
32  import java.util.Properties;
33  
34  /**
35   * This is a description of what this class does - sp20369 don't forget to fill this in.
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   *
39   */
40  
41  public class EDocLiteLookupableHelperServiceImpl  extends KualiLookupableHelperServiceImpl{ //KualiLookupableHelperServiceImpl {
42  
43      private static final long serialVersionUID = 3157354920258155881L;
44  
45  	/**
46       * @returns links to "Create Document" action for the current edoclite
47       */
48  	@Override
49  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
50  		List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
51      	anchorHtmlDataList.add(getCreateDocumentUrl((EDocLiteAssociation) businessObject));	
52      	return anchorHtmlDataList;
53  	}
54  	
55      protected HtmlData getCreateDocumentUrl(EDocLiteAssociation edlAssociation) {
56      	String href = "";
57  
58          Properties parameters = new Properties();
59          parameters.put("userAction", UserAction.ACTION_CREATE);
60          parameters.put("edlName", edlAssociation.getEdlName());
61          href = UrlFactory.parameterizeUrl(
62          		ConfigContext.getCurrentContextConfig().getKEWBaseURL()+"/EDocLite", 
63          		parameters);
64          
65          AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, null, "Create Document");
66          return anchorHtmlData;
67      }
68  
69  	/**
70  	 * Since we don't have a maintenance document for EDocLiteAssociations, we need to
71  	 * set showMaintenanceLinks to true manually.  Otherwise our "Create Document" link
72  	 * won't show up.
73  	 */
74  	@Override
75  	public Collection performLookup(LookupForm lookupForm,
76  			Collection resultTable, boolean bounded) {
77  		lookupForm.setShowMaintenanceLinks(true);
78  		return super.performLookup(lookupForm, resultTable, bounded);
79  	}
80  
81  }