View Javadoc
1   package org.kuali.ole.select.lookup;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   
6   import org.kuali.ole.select.bo.OLEAccessActivationConfiguration;
7   import org.kuali.ole.select.bo.OLEAccessActivationWorkFlow;
8   import org.kuali.ole.select.bo.OLERoleBo;
9   import org.kuali.rice.krad.lookup.LookupUtils;
10  import org.kuali.rice.krad.lookup.LookupableImpl;
11  import org.kuali.rice.krad.service.KRADServiceLocator;
12  import org.kuali.rice.krad.uif.UifConstants;
13  import org.kuali.rice.krad.uif.UifParameters;
14  import org.kuali.rice.krad.uif.view.LookupView;
15  import org.kuali.rice.krad.util.GlobalVariables;
16  import org.kuali.rice.krad.util.KRADConstants;
17  import org.kuali.rice.krad.util.KRADUtils;
18  import org.kuali.rice.krad.util.UrlFactory;
19  import org.kuali.rice.krad.web.form.LookupForm;
20  
21  import java.util.*;
22  
23  /**
24   * Created by hemalathas on 12/22/14.
25   */
26  public class OLEAccessActivationConfigurationLookupableImpl extends LookupableImpl {
27      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLEAccessActivationConfigurationLookupableImpl.class);
28  
29     /* *//**
30       * This method will populate the search criteria and return the search results
31       *
32       * @param form
33       * @param searchCriteria
34       * @param bounded
35       * @return displayList(Collection)
36       *//*
37      @Override
38      public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded) {
39          LOG.debug("Inside performSearch()");
40          Collection<?> displayList;
41          displayList = super.performSearch(form,searchCriteria,bounded);
42          try {
43              // TODO delyea - is this the best way to set that the entire set has a returnable row?
44              for (Object object : displayList) {
45                  if(object instanceof OLEAccessActivationConfiguration){
46                      OLEAccessActivationConfiguration oleAccessActivationConfiguration = (OLEAccessActivationConfiguration) object;
47                      List<OLEAccessActivationWorkFlow> accessActivationWorkFlowList = oleAccessActivationConfiguration.getAccessActivationWorkflowList();
48                      for(OLEAccessActivationWorkFlow oleAccessActivationWorkFlow : accessActivationWorkFlowList){
49                          Map<String,Object> oleBoMap = new HashMap<>();
50                          oleBoMap.put("id",oleAccessActivationWorkFlow.getRoleId());
51                          OLERoleBo oleRoleBo = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OLERoleBo.class,oleBoMap);
52                          oleAccessActivationWorkFlow.setRoleName(oleRoleBo.getName());
53                      }
54  
55                  }
56                  if (isResultReturnable(object)) {
57                      form.setAtLeastOneRowReturnable(true);
58                  }
59              }
60          }
61          catch (Exception e) {
62              e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
63          }
64          return displayList;
65      }*/
66  
67      @Override
68      protected String getActionUrlHref(LookupForm lookupForm, Object dataObject, String methodToCall,
69                                        List<String> pkNames) {
70          LOG.debug("Inside getActionUrlHref()");
71          LookupView lookupView = (LookupView) lookupForm.getView();
72  
73          Properties props = new Properties();
74          props.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, methodToCall);
75          Map<String, String> primaryKeyValues = KRADUtils.getPropertyKeyValuesFromDataObject(pkNames, dataObject);
76          for (String primaryKey : primaryKeyValues.keySet()) {
77              String primaryKeyValue = primaryKeyValues.get(primaryKey);
78  
79              props.put(primaryKey, primaryKeyValue);
80          }
81  
82          if (StringUtils.isNotBlank(lookupForm.getReturnLocation())) {
83              props.put(KRADConstants.RETURN_LOCATION_PARAMETER, lookupForm.getReturnLocation());
84          }
85  
86          props.put(UifParameters.DATA_OBJECT_CLASS_NAME, OLEAccessActivationConfiguration.class.getName());
87          props.put(UifParameters.VIEW_TYPE_NAME, UifConstants.ViewType.MAINTENANCE.name());
88  
89          String maintenanceMapping = OLEConstants.ACCESS_ACTIVATION_CONFIGURATION_CONTROLLER;
90  
91          return UrlFactory.parameterizeUrl(maintenanceMapping, props);
92      }
93  }