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