1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.module.purap.document.validation.event;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.log4j.Logger;
20  import org.kuali.ole.integration.purap.CapitalAssetLocation;
21  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEventBase;
22  import org.kuali.rice.krad.document.Document;
23  
24  
25  
26  
27  
28  
29  public abstract class AttributedPurchasingCapitalAssetLocationEventBase extends AttributedDocumentEventBase implements AttributedPurchasingCapitalAssetLocationEvent {
30      private static final Logger LOG = Logger.getLogger(AttributedPurchasingCapitalAssetLocationEventBase.class);
31  
32  
33      private final CapitalAssetLocation capitalAssetLocation;
34  
35      
36  
37  
38  
39  
40  
41  
42  
43      public AttributedPurchasingCapitalAssetLocationEventBase(String description, String errorPathPrefix, Document document, CapitalAssetLocation capitalAssetLocation) {
44          super(description, errorPathPrefix, document);
45  
46          this.capitalAssetLocation = capitalAssetLocation;
47  
48          logEvent();
49      }
50  
51      
52  
53  
54      public CapitalAssetLocation getCapitalAssetLocation() {
55          return capitalAssetLocation;
56      }
57  
58      
59  
60  
61      public void validate() {
62          super.validate();
63          if (getCapitalAssetLocation() == null) {
64              throw new IllegalArgumentException("invalid (null) location");
65          }
66      }
67  
68      
69  
70  
71      private void logEvent() {
72          StringBuffer logMessage = new StringBuffer(StringUtils.substringAfterLast(this.getClass().getName(), "."));
73          logMessage.append(" with ");
74  
75          
76          if (capitalAssetLocation == null) {
77              logMessage.append("null capital asset location");
78          } else {
79              logMessage.append(" capital asset location# ");
80              logMessage.append(capitalAssetLocation.getCapitalAssetLocationIdentifier());
81          }
82  
83          LOG.debug(logMessage);
84      }
85  }