|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kns.datadictionary;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import java.util.ArrayList;  | 
  |  19 |     | 
   import java.util.LinkedHashMap;  | 
  |  20 |     | 
   import java.util.List;  | 
  |  21 |     | 
   import java.util.Map;  | 
  |  22 |     | 
     | 
  |  23 |     | 
   import org.kuali.rice.kns.document.authorization.MaintenanceDocumentAuthorizer;  | 
  |  24 |     | 
   import org.kuali.rice.kns.bo.BusinessObject;  | 
  |  25 |     | 
   import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException;  | 
  |  26 |     | 
   import org.kuali.rice.kns.datadictionary.exception.ClassValidationException;  | 
  |  27 |     | 
   import org.kuali.rice.kns.datadictionary.exception.DuplicateEntryException;  | 
  |  28 |     | 
   import org.kuali.rice.kns.document.Document;  | 
  |  29 |     | 
   import org.kuali.rice.kns.document.MaintenanceDocumentBase;  | 
  |  30 |     | 
   import org.kuali.rice.kns.maintenance.Maintainable;  | 
  |  31 |     | 
     | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |     | 
   public class MaintenanceDocumentEntry extends DocumentEntry { | 
  |  38 |     | 
     | 
  |  39 |     | 
       protected Class<? extends BusinessObject> businessObjectClass;  | 
  |  40 |     | 
       protected Class<? extends Maintainable> maintainableClass;  | 
  |  41 |     | 
     | 
  |  42 |    0 |        protected List<MaintainableSectionDefinition> maintainableSections = new ArrayList<MaintainableSectionDefinition>();  | 
  |  43 |    0 |        protected List<String> lockingKeys = new ArrayList<String>();  | 
  |  44 |     | 
     | 
  |  45 |    0 |        protected Map<String,MaintainableSectionDefinition> maintainableSectionMap = new LinkedHashMap<String, MaintainableSectionDefinition>();  | 
  |  46 |     | 
     | 
  |  47 |     | 
         | 
  |  48 |    0 |        protected boolean allowsNewOrCopy = true;  | 
  |  49 |     | 
       protected String additionalSectionsFile;  | 
  |  50 |     | 
         | 
  |  51 |     | 
         | 
  |  52 |    0 |        protected boolean preserveLockingKeysOnCopy = false;  | 
  |  53 |     | 
         | 
  |  54 |     | 
         | 
  |  55 |    0 |        protected boolean allowsRecordDeletion = false;  | 
  |  56 |     | 
         | 
  |  57 |    0 |        protected boolean translateCodes = false;  | 
  |  58 |     | 
     | 
  |  59 |     | 
           public MaintenanceDocumentEntry() { | 
  |  60 |    0 |            super();  | 
  |  61 |    0 |            setDocumentClass(getStandardDocumentBaseClass());  | 
  |  62 |    0 |        }  | 
  |  63 |     | 
     | 
  |  64 |     | 
       public Class<? extends Document> getStandardDocumentBaseClass() { | 
  |  65 |    0 |            return MaintenanceDocumentBase.class;  | 
  |  66 |     | 
       }  | 
  |  67 |     | 
     | 
  |  68 |     | 
         | 
  |  69 |     | 
     | 
  |  70 |     | 
     | 
  |  71 |     | 
     | 
  |  72 |     | 
       public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { | 
  |  73 |    0 |            if (businessObjectClass == null) { | 
  |  74 |    0 |                throw new IllegalArgumentException("invalid (null) businessObjectClass"); | 
  |  75 |     | 
           }  | 
  |  76 |     | 
     | 
  |  77 |    0 |            this.businessObjectClass = businessObjectClass;  | 
  |  78 |    0 |        }  | 
  |  79 |     | 
     | 
  |  80 |     | 
       public Class<? extends BusinessObject> getBusinessObjectClass() { | 
  |  81 |    0 |            return businessObjectClass;  | 
  |  82 |     | 
       }  | 
  |  83 |     | 
     | 
  |  84 |     | 
         | 
  |  85 |     | 
     | 
  |  86 |     | 
     | 
  |  87 |     | 
       @SuppressWarnings("unchecked") | 
  |  88 |     | 
           @Override  | 
  |  89 |     | 
       public Class getEntryClass() { | 
  |  90 |    0 |                return businessObjectClass;  | 
  |  91 |     | 
       }  | 
  |  92 |     | 
     | 
  |  93 |     | 
         | 
  |  94 |     | 
     | 
  |  95 |     | 
     | 
  |  96 |     | 
     | 
  |  97 |     | 
     | 
  |  98 |     | 
     | 
  |  99 |     | 
       public void setMaintainableClass(Class<? extends Maintainable> maintainableClass) { | 
  |  100 |    0 |            if (maintainableClass == null) { | 
  |  101 |    0 |                throw new IllegalArgumentException("invalid (null) maintainableClass"); | 
  |  102 |     | 
           }  | 
  |  103 |    0 |            this.maintainableClass = maintainableClass;  | 
  |  104 |    0 |        }     | 
  |  105 |     | 
     | 
  |  106 |     | 
       public Class<? extends Maintainable> getMaintainableClass() { | 
  |  107 |    0 |            return maintainableClass;  | 
  |  108 |     | 
       }  | 
  |  109 |     | 
     | 
  |  110 |     | 
         | 
  |  111 |     | 
     | 
  |  112 |     | 
     | 
  |  113 |     | 
       public List<MaintainableSectionDefinition> getMaintainableSections() { | 
  |  114 |    0 |            return maintainableSections;  | 
  |  115 |     | 
       }  | 
  |  116 |     | 
     | 
  |  117 |     | 
         | 
  |  118 |     | 
     | 
  |  119 |     | 
     | 
  |  120 |     | 
       public List<String> getLockingKeyFieldNames() { | 
  |  121 |    0 |            return lockingKeys;  | 
  |  122 |     | 
       }  | 
  |  123 |     | 
     | 
  |  124 |     | 
         | 
  |  125 |     | 
     | 
  |  126 |     | 
     | 
  |  127 |     | 
     | 
  |  128 |     | 
       public boolean getAllowsNewOrCopy() { | 
  |  129 |    0 |            return allowsNewOrCopy;  | 
  |  130 |     | 
       }  | 
  |  131 |     | 
     | 
  |  132 |     | 
     | 
  |  133 |     | 
         | 
  |  134 |     | 
     | 
  |  135 |     | 
     | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
       public void setAllowsNewOrCopy(boolean allowsNewOrCopy) { | 
  |  139 |    0 |            this.allowsNewOrCopy = allowsNewOrCopy;  | 
  |  140 |    0 |        }  | 
  |  141 |     | 
     | 
  |  142 |     | 
     | 
  |  143 |     | 
         | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |     | 
     | 
  |  147 |     | 
     | 
  |  148 |     | 
       public void completeValidation() { | 
  |  149 |    0 |            super.completeValidation();  | 
  |  150 |     | 
     | 
  |  151 |    0 |            for ( MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections ) { | 
  |  152 |    0 |                maintainableSectionDefinition.completeValidation(businessObjectClass, null);  | 
  |  153 |     | 
           }  | 
  |  154 |     | 
     | 
  |  155 |    0 |            for ( String lockingKey : lockingKeys ) { | 
  |  156 |    0 |                if (!DataDictionary.isPropertyOf(businessObjectClass, lockingKey)) { | 
  |  157 |    0 |                    throw new AttributeValidationException("unable to find attribute '" + lockingKey + "' for lockingKey in businessObjectClass '" + businessObjectClass.getName() ); | 
  |  158 |     | 
               }  | 
  |  159 |     | 
           }  | 
  |  160 |     | 
     | 
  |  161 |    0 |            for ( ReferenceDefinition reference : defaultExistenceChecks ) { | 
  |  162 |    0 |                reference.completeValidation(businessObjectClass, null);  | 
  |  163 |     | 
           }  | 
  |  164 |     | 
     | 
  |  165 |    0 |            if (documentAuthorizerClass != null && !MaintenanceDocumentAuthorizer.class.isAssignableFrom(documentAuthorizerClass)) { | 
  |  166 |    0 |                throw new ClassValidationException("This maintenance document for '" + businessObjectClass.getName() + "' has an invalid " + "documentAuthorizerClass ('" + documentAuthorizerClass.getName() + "').  " + "Maintenance Documents must use an implementation of MaintenanceDocumentAuthorizer."); | 
  |  167 |     | 
           }  | 
  |  168 |    0 |        }  | 
  |  169 |     | 
     | 
  |  170 |     | 
     | 
  |  171 |     | 
         | 
  |  172 |     | 
     | 
  |  173 |     | 
     | 
  |  174 |     | 
       public String toString() { | 
  |  175 |    0 |            return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName();  | 
  |  176 |     | 
       }  | 
  |  177 |     | 
     | 
  |  178 |     | 
       @Deprecated  | 
  |  179 |     | 
       public String getAdditionalSectionsFile() { | 
  |  180 |    0 |            return additionalSectionsFile;  | 
  |  181 |     | 
       }  | 
  |  182 |     | 
     | 
  |  183 |     | 
     | 
  |  184 |     | 
         | 
  |  185 |     | 
     | 
  |  186 |     | 
     | 
  |  187 |     | 
     | 
  |  188 |     | 
     | 
  |  189 |     | 
     | 
  |  190 |     | 
       @Deprecated  | 
  |  191 |     | 
       public void setAdditionalSectionsFile(String additionalSectionsFile) { | 
  |  192 |    0 |            this.additionalSectionsFile = additionalSectionsFile;  | 
  |  193 |    0 |        }  | 
  |  194 |     | 
     | 
  |  195 |     | 
     | 
  |  196 |     | 
       public List<String> getLockingKeys() { | 
  |  197 |    0 |            return lockingKeys;  | 
  |  198 |     | 
       }  | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
         | 
  |  202 |     | 
     | 
  |  203 |     | 
     | 
  |  204 |     | 
     | 
  |  205 |     | 
     | 
  |  206 |     | 
       public void setLockingKeys(List<String> lockingKeys) { | 
  |  207 |    0 |            for ( String lockingKey : lockingKeys ) { | 
  |  208 |    0 |                if (lockingKey == null) { | 
  |  209 |    0 |                    throw new IllegalArgumentException("invalid (null) lockingKey"); | 
  |  210 |     | 
               }  | 
  |  211 |     | 
           }  | 
  |  212 |    0 |            this.lockingKeys = lockingKeys;  | 
  |  213 |    0 |        }  | 
  |  214 |     | 
     | 
  |  215 |     | 
     | 
  |  216 |     | 
         | 
  |  217 |     | 
     | 
  |  218 |     | 
     | 
  |  219 |     | 
     | 
  |  220 |     | 
     | 
  |  221 |     | 
     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
     | 
  |  225 |     | 
     | 
  |  226 |     | 
     | 
  |  227 |     | 
     | 
  |  228 |     | 
     | 
  |  229 |     | 
       @Deprecated  | 
  |  230 |     | 
       public void setMaintainableSections(List<MaintainableSectionDefinition> maintainableSections) { | 
  |  231 |    0 |            maintainableSectionMap.clear();  | 
  |  232 |    0 |            for ( MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections ) { | 
  |  233 |    0 |                if (maintainableSectionDefinition == null) { | 
  |  234 |    0 |                    throw new IllegalArgumentException("invalid (null) maintainableSectionDefinition"); | 
  |  235 |     | 
               }  | 
  |  236 |     | 
         | 
  |  237 |    0 |                String sectionTitle = maintainableSectionDefinition.getTitle();  | 
  |  238 |    0 |                if (maintainableSectionMap.containsKey(sectionTitle)) { | 
  |  239 |    0 |                    throw new DuplicateEntryException("section '" + sectionTitle + "' already defined for maintenanceDocument '" + getDocumentTypeName() + "'"); | 
  |  240 |     | 
               }  | 
  |  241 |     | 
         | 
  |  242 |    0 |                maintainableSectionMap.put(sectionTitle, maintainableSectionDefinition);  | 
  |  243 |    0 |            }  | 
  |  244 |    0 |            this.maintainableSections = maintainableSections;  | 
  |  245 |    0 |        }  | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |     | 
         | 
  |  249 |     | 
         | 
  |  250 |     | 
     | 
  |  251 |     | 
     | 
  |  252 |     | 
           public boolean getPreserveLockingKeysOnCopy() { | 
  |  253 |    0 |                    return this.preserveLockingKeysOnCopy;  | 
  |  254 |     | 
           }  | 
  |  255 |     | 
     | 
  |  256 |     | 
             | 
  |  257 |     | 
     | 
  |  258 |     | 
     | 
  |  259 |     | 
           public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) { | 
  |  260 |    0 |                    this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;  | 
  |  261 |    0 |            }  | 
  |  262 |     | 
             | 
  |  263 |     | 
             | 
  |  264 |     | 
     | 
  |  265 |     | 
     | 
  |  266 |     | 
           public boolean getAllowsRecordDeletion() { | 
  |  267 |    0 |                    return this.allowsRecordDeletion;  | 
  |  268 |     | 
           }  | 
  |  269 |     | 
     | 
  |  270 |     | 
             | 
  |  271 |     | 
     | 
  |  272 |     | 
     | 
  |  273 |     | 
           public void setAllowsRecordDeletion(boolean allowsRecordDeletion) { | 
  |  274 |    0 |                    this.allowsRecordDeletion = allowsRecordDeletion;  | 
  |  275 |    0 |            }  | 
  |  276 |     | 
     | 
  |  277 |     | 
           @Deprecated  | 
  |  278 |     | 
           public boolean isTranslateCodes() { | 
  |  279 |    0 |                    return this.translateCodes;  | 
  |  280 |     | 
           }  | 
  |  281 |     | 
     | 
  |  282 |     | 
           @Deprecated  | 
  |  283 |     | 
           public void setTranslateCodes(boolean translateCodes) { | 
  |  284 |    0 |                    this.translateCodes = translateCodes;  | 
  |  285 |    0 |            }  | 
  |  286 |     | 
     | 
  |  287 |     | 
   }  |