View Javadoc
1   package org.kuali.ole.alert.keyValue;
2   
3   import org.kuali.ole.alert.bo.AlertDocument;
4   import org.kuali.ole.alert.bo.AlertDocumentType;
5   import org.kuali.ole.alert.bo.AlertEvent;
6   import org.kuali.rice.core.api.util.ConcreteKeyValue;
7   import org.kuali.rice.core.api.util.KeyValue;
8   import org.kuali.rice.krad.maintenance.MaintenanceDocument;
9   import org.kuali.rice.krad.service.KRADServiceLocator;
10  import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
11  import org.kuali.rice.krad.uif.view.ViewModel;
12  import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
13  
14  import java.util.ArrayList;
15  import java.util.HashMap;
16  import java.util.List;
17  import java.util.Map;
18  
19  /**
20   * Created by maheswarang on 12/26/14.
21   */
22  public class AlertEventValueFinder extends UifKeyValuesFinderBase {
23      private Map<String,String> criteriaMap;
24      private List<AlertDocumentType> alertDocumentTypes;
25      private List<AlertEvent> alertEvents;
26      public List<KeyValue> getKeyValues(ViewModel viewModel) {
27          MaintenanceDocument maintenanceDocument= ((MaintenanceDocumentForm) viewModel).getDocument();
28          AlertDocument alertDocument=(AlertDocument)maintenanceDocument.getDocumentDataObject();
29          List<KeyValue> keyValues = new ArrayList<KeyValue>();
30          String documentTypeName = alertDocument.getDocumentTypeName();
31          criteriaMap = new HashMap<String,String>();
32          criteriaMap.put("alertDocumentTypeName",documentTypeName);
33          String documentTypeId ;
34           alertDocumentTypes = (List<AlertDocumentType>)KRADServiceLocator.getBusinessObjectService().findMatching(AlertDocumentType.class,criteriaMap);
35      if(alertDocumentTypes!=null && alertDocumentTypes.size()>0){
36          documentTypeId = alertDocumentTypes.get(0).getAlertDocumentId();
37          criteriaMap = new HashMap<String,String>();
38          criteriaMap.put("alertDocumentTypeId",documentTypeId);
39          criteriaMap.put("active","true");
40          alertEvents = (List<AlertEvent>)KRADServiceLocator.getBusinessObjectService().findMatching(AlertEvent.class,criteriaMap);
41          if(alertEvents!=null && alertEvents.size()>0){
42              for(AlertEvent alertEvent : alertEvents){
43                  keyValues.add(new ConcreteKeyValue(alertEvent.getAlertEventId(),alertEvent.getAlertEventName()));
44              }
45          }
46      }
47          return keyValues;
48      }
49  
50  
51  }