001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.edl.impl.lookupable;
017
018import org.kuali.rice.core.api.config.property.ConfigContext;
019import org.kuali.rice.edl.impl.UserAction;
020import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
021import org.kuali.rice.kns.lookup.HtmlData;
022import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
023import org.kuali.rice.kns.web.struts.form.LookupForm;
024import org.kuali.rice.krad.bo.BusinessObject;
025import org.kuali.rice.krad.util.UrlFactory;
026
027import java.util.ArrayList;
028import java.util.Collection;
029import java.util.List;
030import java.util.Properties;
031
032/**
033 * This is a description of what this class does - sp20369 don't forget to fill this in.
034 *
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 *
037 */
038
039public class EDocLiteLookupableHelperServiceImpl  extends KualiLookupableHelperServiceImpl { //KualiLookupableHelperServiceImpl {
040
041    private static final long serialVersionUID = 3157354920258155881L;
042
043        /**
044     * @returns links to "Create Document" action for the current edoclite
045     */
046        @Override
047        public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
048                List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
049        anchorHtmlDataList.add(getCreateDocumentUrl((EDocLiteAssociation) businessObject));     
050        return anchorHtmlDataList;
051        }
052        
053    protected HtmlData getCreateDocumentUrl(EDocLiteAssociation edlAssociation) {
054        String href = "";
055
056        Properties parameters = new Properties();
057        parameters.put("userAction", UserAction.ACTION_CREATE);
058        parameters.put("edlName", edlAssociation.getEdlName());
059        href = UrlFactory.parameterizeUrl(
060                        ConfigContext.getCurrentContextConfig().getKEWBaseURL()+"/EDocLite", 
061                        parameters);
062        
063        HtmlData.AnchorHtmlData anchorHtmlData = new HtmlData.AnchorHtmlData(href, null, "Create Document");
064        return anchorHtmlData;
065    }
066
067        /**
068         * Since we don't have a maintenance document for EDocLiteAssociations, we need to
069         * set showMaintenanceLinks to true manually.  Otherwise our "Create Document" link
070         * won't show up.
071         */
072        @Override
073        public Collection performLookup(LookupForm lookupForm,
074                        Collection resultTable, boolean bounded) {
075                lookupForm.setShowMaintenanceLinks(true);
076                return super.performLookup(lookupForm, resultTable, bounded);
077        }
078
079}