1 package org.kuali.ole.alert.rule;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.ole.alert.bo.AlertDocumentType;
5 import org.kuali.ole.alert.bo.AlertEvent;
6 import org.kuali.ole.deliver.bo.OleDeliverRequestType;
7 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
8 import org.kuali.rice.krad.rules.MaintenanceDocumentRuleBase;
9 import org.kuali.rice.krad.service.KRADServiceLocator;
10
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14
15
16
17
18 public class AlertEventRule extends MaintenanceDocumentRuleBase {
19 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
20 boolean isValid = true;
21 AlertEvent alertEvent = (AlertEvent) document.getNewMaintainableObject().getDataObject();
22 isValid &= validateDocumentTypeName(alertEvent);
23 return isValid;
24 }
25
26
27
28
29
30
31
32 private boolean validateDocumentTypeName(AlertEvent alertEvent) {
33
34 if(alertEvent.getAlertEventId()==null && alertEvent.getAlertEventName() != null){
35 Map<String,String> alertEventMap = new HashMap<String,String>();
36 alertEventMap.put("alertDocumentTypeId",alertEvent.getAlertDocumentTypeId());
37 alertEventMap.put("alertEventName",alertEvent.getAlertEventName());
38 List<AlertEvent> alertEventList = (List<AlertEvent>)KRADServiceLocator.getBusinessObjectService().findMatching(AlertEvent.class, alertEventMap);
39 if(alertEventList!=null && alertEventList.size()>0){
40
41 this.putFieldError(OLEConstants.ALERT_EVENT_NAME, "error.duplicate.event.name");
42 return false;
43 }
44 }
45 return true;
46 }
47
48 }