View Javadoc
1   /**
2    * Copyright 2005-2014 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.parse.BeanTag;
21  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
22  import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
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-bean")
30  public class InactivationBlockingDefinition extends DataDictionaryDefinitionBase implements InactivationBlockingMetadata {
31      private static final long serialVersionUID = -8765429636173190984L;
32  
33      protected Class<?> blockingReferenceBusinessObjectClass;
34      protected String blockedReferencePropertyName;
35      protected Class<?> blockedBusinessObjectClass;
36      protected String inactivationBlockingDetectionServiceBeanName;
37      protected String relationshipLabel;
38      protected Class<?> businessObjectClass;
39  
40      @Override
41      public void completeValidation(Class<?> rootDataObjectClass, Class<?> otherDataObjectClass, ValidationTrace tracer) {
42          if (StringUtils.isBlank(inactivationBlockingDetectionServiceBeanName)) {
43              if (StringUtils.isBlank(blockedReferencePropertyName)) {
44                  // the default inactivation blocking detection service (used when inactivationBlockingDetectionServiceBeanName is blank) requires that the property name be set
45                  String currentValues[] = {"rootDataObjectClass = " + rootDataObjectClass};
46                  tracer.createError("inactivationBlockingDetectionServiceBeanName and  blockedReferencePropertyName can't both be blank in InactivationBlockingDefinition", currentValues);
47              }
48          }
49          if (getBlockedDataObjectClass() == null) {
50              String currentValues[] = {"rootDataObjectClass = " + rootDataObjectClass};
51              tracer.createError("Unable to determine blockedReferenceBusinessObjectClass in InactivationBlockingDefinition", currentValues);
52          }
53      }
54  
55      @Override
56      @Deprecated
57      @BeanTagAttribute(name = "blockedReferencePropertyName")
58      public String getBlockedReferencePropertyName() {
59          return this.blockedReferencePropertyName;
60      }
61  
62      /**
63       * @deprecated use {@link #setBlockedAttributeName(String)} instead
64       */
65      @Deprecated
66      public void setBlockedReferencePropertyName(String blockedReferencePropertyName) {
67          this.blockedReferencePropertyName = blockedReferencePropertyName;
68      }
69  
70      @Override
71      @BeanTagAttribute(name = "blockedAttributeName")
72      public String getBlockedAttributeName() {
73          return this.blockedReferencePropertyName;
74      }
75  
76      public void setBlockedAttributeName(String blockedAttributeName) {
77          this.blockedReferencePropertyName = blockedAttributeName;
78      }
79  
80      @Override
81      @Deprecated
82      @SuppressWarnings("unchecked")
83      @BeanTagAttribute(name = "blockedBusinessObjectClass")
84      public Class<? extends BusinessObject> getBlockedBusinessObjectClass() {
85          return (Class<? extends BusinessObject>)blockedBusinessObjectClass;
86      }
87  
88      /**
89       * @deprecated use {@link #setBlockedDataObjectClass(Class)} instead
90       */
91      @Deprecated
92      public void setBlockedBusinessObjectClass(Class<? extends BusinessObject> blockedBusinessObjectClass) {
93          this.blockedBusinessObjectClass = blockedBusinessObjectClass;
94      }
95  
96      @Override
97      @BeanTagAttribute(name = "blockedDataObjectClass")
98      public Class<?> getBlockedDataObjectClass() {
99          return blockedBusinessObjectClass;
100     }
101 
102     public void setBlockedDataObjectClass(Class<?> blockedDataObjectClass) {
103         this.blockedBusinessObjectClass = blockedDataObjectClass;
104     }
105 
106     @Override
107     @BeanTagAttribute(name = "inactivationBlockingDetectionServiceBeanName")
108     public String getInactivationBlockingDetectionServiceBeanName() {
109         return this.inactivationBlockingDetectionServiceBeanName;
110     }
111 
112     public void setInactivationBlockingDetectionServiceBeanName(String inactivationBlockingDetectionServiceImpl) {
113         this.inactivationBlockingDetectionServiceBeanName = inactivationBlockingDetectionServiceImpl;
114     }
115 
116     @Override
117     @Deprecated
118     @SuppressWarnings("unchecked")
119     @BeanTagAttribute(name = "blockingReferenceBusinessObjectClass")
120     public Class<? extends BusinessObject> getBlockingReferenceBusinessObjectClass() {
121         return (Class<? extends BusinessObject>)this.blockingReferenceBusinessObjectClass;
122     }
123 
124     /**
125      * @deprecated use {@link #setBlockingReferenceDataObjectClass(Class)}
126      */
127     @Deprecated
128     public void setBlockingReferenceBusinessObjectClass(
129             Class<? extends BusinessObject> blockingReferenceBusinessObjectClass) {
130         this.blockingReferenceBusinessObjectClass = blockingReferenceBusinessObjectClass;
131     }
132 
133     @Override
134     @BeanTagAttribute(name = "blockingDataObjectClass")
135     public Class<?> getBlockingDataObjectClass() {
136         return blockingReferenceBusinessObjectClass;
137     }
138 
139     public void setBlockingReferenceDataObjectClass(Class<?> blockingDataObjectClass) {
140         this.blockingReferenceBusinessObjectClass = blockingDataObjectClass;
141     }
142 
143     @Override
144     @BeanTagAttribute(name = "relationshipLabel")
145     public String getRelationshipLabel() {
146         return this.relationshipLabel;
147     }
148 
149     public void setRelationshipLabel(String relationshipLabel) {
150         this.relationshipLabel = relationshipLabel;
151     }
152 
153     /**
154      * @deprecated the businessObjectClass does not appear to be used anywhere significantly internally or externally,
155      *             no replacement
156      */
157     @Deprecated
158     @SuppressWarnings("unchecked")
159     @BeanTagAttribute(name = "businessObjectClass")
160     public Class<? extends BusinessObject> getBusinessObjectClass() {
161         return (Class<? extends BusinessObject>)this.businessObjectClass;
162     }
163 
164     /**
165      * @deprecated the businessObjectClass does not appear to be used anywhere significantly internally or externally,
166      *             no replacement
167      */
168     @Deprecated
169     public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
170         this.businessObjectClass = businessObjectClass;
171     }
172 
173     @Override
174     public String toString() {
175         return "InactivationBlockingDefinition: blockedClass="
176                 + blockedBusinessObjectClass.getName()
177                 + " /blockingReferenceProperty="
178                 + blockedReferencePropertyName
179                 + " /blockingClass="
180                 + blockingReferenceBusinessObjectClass.getName();
181     }
182 }