Coverage Report - org.kuali.rice.krms.impl.repository.AgendaLookupableHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaLookupableHelperServiceImpl
0%
0/26
0%
0/8
1.75
 
 1  
 /**
 2  
  * Copyright 2005-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  
 package org.kuali.rice.krms.impl.repository;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.lookup.LookupableImpl;
 20  
 import org.kuali.rice.krad.uif.UifConstants;
 21  
 import org.kuali.rice.krad.uif.UifParameters;
 22  
 import org.kuali.rice.krad.util.KRADConstants;
 23  
 import org.kuali.rice.krad.util.KRADUtils;
 24  
 import org.kuali.rice.krad.util.UrlFactory;
 25  
 import org.kuali.rice.krad.web.form.LookupForm;
 26  
 import org.kuali.rice.krms.api.KrmsConstants;
 27  
 import org.kuali.rice.krms.impl.ui.AgendaEditor;
 28  
 
 29  
 import java.util.List;
 30  
 import java.util.Map;
 31  
 import java.util.Properties;
 32  
 
 33  0
 public class AgendaLookupableHelperServiceImpl extends LookupableImpl {
 34  
 
 35  
     @Override
 36  
     public boolean allowsMaintenanceNewOrCopyAction() {
 37  0
         boolean allowsEdit = false;
 38  
 
 39  0
         allowsEdit = KrmsRepositoryServiceLocator.getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, null);
 40  
 
 41  0
         return allowsEdit;
 42  
     }
 43  
 
 44  
     @Override
 45  
     public boolean allowsMaintenanceEditAction(Object dataObject) {
 46  0
         boolean allowsEdit = false;
 47  
 
 48  0
         AgendaBo agenda = (AgendaBo) dataObject;
 49  0
         allowsEdit = KrmsRepositoryServiceLocator.getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agenda.getContextId());
 50  
 
 51  0
         return allowsEdit;
 52  
     }
 53  
 
 54  
     @Override
 55  
     public boolean allowsMaintenanceDeleteAction(Object dataObject) {
 56  0
         boolean allowsMaintain = false;
 57  0
         boolean allowsDelete = false;
 58  
 
 59  0
         AgendaBo agenda = (AgendaBo) dataObject;
 60  0
         allowsMaintain = KrmsRepositoryServiceLocator.getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agenda.getContextId());
 61  
 
 62  0
         return allowsDelete && allowsMaintain;
 63  
     }
 64  
 
 65  
     @Override
 66  
     protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall, List<String> pkNames) {
 67  0
         Properties props = new Properties();
 68  0
         props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
 69  
 
 70  0
         Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
 71  0
         for (String primaryKey : primaryKeyValues.keySet()) {
 72  0
             String primaryKeyValue = primaryKeyValues.get(primaryKey);
 73  
 
 74  0
             props.put(primaryKey, primaryKeyValue);
 75  0
             props.put(KRADConstants.OVERRIDE_KEYS, primaryKey);
 76  0
         }
 77  
 
 78  0
         if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
 79  0
             props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
 80  
         }
 81  
 
 82  0
         props.put(UifParameters.DATA_OBJECT_CLASS_NAME, AgendaEditor.class.getName());
 83  0
         props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
 84  
 
 85  0
         return UrlFactory.parameterizeUrl(org.kuali.rice.krms.impl.util.KrmsImplConstants.WebPaths.AGENDA_EDITOR_PATH, props);
 86  
     }
 87  
 }