View Javadoc

1   /**
2    * Copyright 2005-2012 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.krad.datadictionary;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.krad.bo.BusinessObject;
20  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
21  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
22  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
23  
24  /**
25   * This is a description of what this class does - wliang don't forget to fill this in.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  @BeanTag(name = "inactivationBlockingDefinition")
30  public class InactivationBlockingDefinition extends DataDictionaryDefinitionBase implements InactivationBlockingMetadata {
31      private static final long serialVersionUID = -8765429636173190984L;
32  
33      protected Class<? extends BusinessObject> blockingReferenceBusinessObjectClass;
34      protected String blockedReferencePropertyName;
35      protected Class<? extends BusinessObject> blockedBusinessObjectClass;
36      protected String inactivationBlockingDetectionServiceBeanName;
37      protected String relationshipLabel;
38      protected Class<? extends BusinessObject> businessObjectClass;
39  
40      public InactivationBlockingDefinition() {
41      }
42  
43      /**
44       * This overridden method ...
45       *
46       * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class,
47       *      java.lang.Class)
48       */
49      @SuppressWarnings("unchecked")
50      public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
51          if (StringUtils.isBlank(inactivationBlockingDetectionServiceBeanName)) {
52              if (StringUtils.isBlank(blockedReferencePropertyName)) {
53                  // the default inactivation blocking detection service (used when inactivationBlockingDetectionServiceBeanName is blank) requires that the property name be set
54                  throw new AttributeValidationException(
55                          "inactivationBlockingDetectionServiceBeanName and  blockedReferencePropertyName can't both be blank in InactivationBlockingDefinition for class "
56                                  + rootBusinessObjectClass.getClass().getName());
57              }
58          }
59          if (getBlockedBusinessObjectClass() == null) {
60              throw new AttributeValidationException(
61                      "Unable to determine blockedReferenceBusinessObjectClass in InactivationBlockingDefinition for class "
62                              + rootBusinessObjectClass.getClass().getName());
63          }
64          if (!BusinessObject.class.isAssignableFrom(getBlockedBusinessObjectClass())) {
65              throw new AttributeValidationException(
66                      "InactivationBlockingDefinitions must block a reference of type BusinessObject.  Class name: "
67                              +
68                              rootBusinessObjectClass.getClass().getName()
69                              + " blockedReferencePropertyName "
70                              + blockedReferencePropertyName
71                              +
72                              " class that should have been a BusinessObject: "
73                              + getBlockedBusinessObjectClass());
74          }
75      }
76  
77      /**
78       * This overridden method ...
79       *
80       * @see org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata#getBlockedReferencePropertyName()
81       */
82      @BeanTagAttribute(name = "blockedReferencePropertyName")
83      public String getBlockedReferencePropertyName() {
84          return this.blockedReferencePropertyName;
85      }
86  
87      public void setBlockedReferencePropertyName(String blockedReferencePropertyName) {
88          this.blockedReferencePropertyName = blockedReferencePropertyName;
89      }
90  
91      /**
92       * This overridden method ...
93       *
94       * @see org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata#getBlockedBusinessObjectClass()
95       */
96      @BeanTagAttribute(name = "blockedBusinessObjectClass")
97      public Class<? extends BusinessObject> getBlockedBusinessObjectClass() {
98          return this.blockedBusinessObjectClass;
99      }
100 
101     public void setBlockedBusinessObjectClass(Class<? extends BusinessObject> blockedBusinessObjectClass) {
102         this.blockedBusinessObjectClass = blockedBusinessObjectClass;
103     }
104 
105     /**
106      * This overridden method ...
107      *
108      * @see org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata#getInactivationBlockingDetectionServiceBeanName()
109      */
110     @BeanTagAttribute(name = "inactivationBlockingDetectionServiceBeanName")
111     public String getInactivationBlockingDetectionServiceBeanName() {
112         return this.inactivationBlockingDetectionServiceBeanName;
113     }
114 
115     public void setInactivationBlockingDetectionServiceBeanName(String inactivationBlockingDetectionServiceImpl) {
116         this.inactivationBlockingDetectionServiceBeanName = inactivationBlockingDetectionServiceImpl;
117     }
118 
119     /**
120      * This overridden method ...
121      *
122      * @see org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata#getBlockingReferenceBusinessObjectClass()
123      */
124     @BeanTagAttribute(name = "blockingReferenceBusinessObjectClass")
125     public Class<? extends BusinessObject> getBlockingReferenceBusinessObjectClass() {
126         return this.blockingReferenceBusinessObjectClass;
127     }
128 
129     public void setBlockingReferenceBusinessObjectClass(
130             Class<? extends BusinessObject> blockingReferenceBusinessObjectClass) {
131         this.blockingReferenceBusinessObjectClass = blockingReferenceBusinessObjectClass;
132     }
133 
134     @BeanTagAttribute(name = "relationshipLabel")
135     public String getRelationshipLabel() {
136         return this.relationshipLabel;
137     }
138 
139     public void setRelationshipLabel(String relationshipLabel) {
140         this.relationshipLabel = relationshipLabel;
141     }
142 
143     @BeanTagAttribute(name = "businessObjectClass")
144     public Class<? extends BusinessObject> getBusinessObjectClass() {
145         return this.businessObjectClass;
146     }
147 
148     public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
149         this.businessObjectClass = businessObjectClass;
150     }
151 
152     @Override
153     public String toString() {
154         return "InactivationBlockingDefinition: blockedClass="
155                 + blockedBusinessObjectClass.getName()
156                 + " /blockingReferenceProperty="
157                 + blockedReferencePropertyName
158                 + " /blockingClass="
159                 + blockingReferenceBusinessObjectClass.getName();
160     }
161 }