| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DataObjectEntry |
|
| 1.2173913043478262;1.217 |
| 1 | /* | |
| 2 | * Copyright 2011 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.datadictionary; | |
| 17 | ||
| 18 | import java.util.List; | |
| 19 | ||
| 20 | import org.apache.commons.lang.StringUtils; | |
| 21 | import org.kuali.rice.kns.bo.Exporter; | |
| 22 | import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; | |
| 23 | import org.kuali.rice.kns.datadictionary.validation.capability.MustOccurConstrainable; | |
| 24 | import org.kuali.rice.kns.datadictionary.validation.constraint.MustOccurConstraint; | |
| 25 | ||
| 26 | /** | |
| 27 | * This is a generic dictionary entry for an object that does not have to implement BusinessObject. It provides support | |
| 28 | * for general objects. | |
| 29 | * | |
| 30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 31 | */ | |
| 32 | 0 | public class DataObjectEntry extends DataDictionaryEntryBase implements MustOccurConstrainable { |
| 33 | ||
| 34 | protected String name; | |
| 35 | protected Class<?> objectClass; | |
| 36 | ||
| 37 | protected String titleAttribute; | |
| 38 | protected String objectLabel; | |
| 39 | protected String objectDescription; | |
| 40 | ||
| 41 | protected List<String> primaryKeys; | |
| 42 | protected Class<? extends Exporter> exporterClass; | |
| 43 | ||
| 44 | protected List<MustOccurConstraint> mustOccurConstraints; | |
| 45 | ||
| 46 | ||
| 47 | protected HelpDefinition helpDefinition; | |
| 48 | ||
| 49 | ||
| 50 | @Override | |
| 51 | public void completeValidation() { | |
| 52 | //KFSMI-1340 - Object label should never be blank | |
| 53 | 0 | if (StringUtils.isBlank(getObjectLabel())) { |
| 54 | 0 | throw new AttributeValidationException("Object label cannot be blank for class " + objectClass.getName()); |
| 55 | } | |
| 56 | ||
| 57 | 0 | super.completeValidation(); |
| 58 | 0 | } |
| 59 | ||
| 60 | /** | |
| 61 | * @see org.kuali.rice.kns.datadictionary.DataDictionaryEntry#getJstlKey() | |
| 62 | */ | |
| 63 | @Override | |
| 64 | public String getJstlKey() { | |
| 65 | 0 | if (objectClass == null) { |
| 66 | 0 | throw new IllegalStateException("cannot generate JSTL key: objectClass is null"); |
| 67 | } | |
| 68 | ||
| 69 | 0 | return (objectClass != null) ? objectClass.getSimpleName() : objectClass.getSimpleName(); |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * @see org.kuali.rice.kns.datadictionary.DataDictionaryEntry#getFullClassName() | |
| 74 | */ | |
| 75 | @Override | |
| 76 | public String getFullClassName() { | |
| 77 | 0 | return objectClass.getName(); |
| 78 | } | |
| 79 | ||
| 80 | /** | |
| 81 | * @see org.kuali.rice.kns.datadictionary.DataDictionaryEntryBase#getEntryClass() | |
| 82 | */ | |
| 83 | @Override | |
| 84 | public Class<?> getEntryClass() { | |
| 85 | 0 | return objectClass; |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * @return the objectClass | |
| 90 | */ | |
| 91 | public Class<?> getObjectClass() { | |
| 92 | 0 | return this.objectClass; |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * @param objectClass the objectClass to set | |
| 97 | */ | |
| 98 | public void setObjectClass(Class<?> objectClass) { | |
| 99 | 0 | this.objectClass = objectClass; |
| 100 | 0 | } |
| 101 | ||
| 102 | /** | |
| 103 | * @return the name | |
| 104 | */ | |
| 105 | public String getName() { | |
| 106 | 0 | return this.name; |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * @param name the name to set | |
| 111 | */ | |
| 112 | public void setName(String name) { | |
| 113 | 0 | this.name = name; |
| 114 | 0 | } |
| 115 | ||
| 116 | /** | |
| 117 | * @return Returns the objectLabel. | |
| 118 | */ | |
| 119 | public String getObjectLabel() { | |
| 120 | 0 | return objectLabel; |
| 121 | } | |
| 122 | ||
| 123 | /** | |
| 124 | The objectLabel provides a short name of the business | |
| 125 | object for use on help screens. | |
| 126 | * | |
| 127 | * @param objectLabel The objectLabel to set. | |
| 128 | */ | |
| 129 | public void setObjectLabel(String objectLabel) { | |
| 130 | 0 | this.objectLabel = objectLabel; |
| 131 | 0 | } |
| 132 | ||
| 133 | /** | |
| 134 | * @return Returns the description. | |
| 135 | */ | |
| 136 | public String getObjectDescription() { | |
| 137 | 0 | return objectDescription; |
| 138 | } | |
| 139 | ||
| 140 | /** | |
| 141 | The objectDescription provides a brief description | |
| 142 | of the business object for use on help screens. | |
| 143 | * | |
| 144 | * @param description The description to set. | |
| 145 | */ | |
| 146 | public void setObjectDescription(String objectDescription) { | |
| 147 | 0 | this.objectDescription = objectDescription; |
| 148 | 0 | } |
| 149 | ||
| 150 | ||
| 151 | ||
| 152 | ||
| 153 | ||
| 154 | /** | |
| 155 | * Gets the helpDefinition attribute. | |
| 156 | * | |
| 157 | * @return Returns the helpDefinition. | |
| 158 | */ | |
| 159 | public HelpDefinition getHelpDefinition() { | |
| 160 | 0 | return helpDefinition; |
| 161 | } | |
| 162 | ||
| 163 | /** | |
| 164 | * Sets the helpDefinition attribute value. | |
| 165 | * | |
| 166 | The objectHelp element provides the keys to | |
| 167 | obtain a help description from the system parameters table. | |
| 168 | ||
| 169 | parameterNamespace the namespace of the parameter containing help information | |
| 170 | parameterName the name of the parameter containing help information | |
| 171 | parameterDetailType the detail type of the parameter containing help information | |
| 172 | * | |
| 173 | * @param helpDefinition The helpDefinition to set. | |
| 174 | */ | |
| 175 | public void setHelpDefinition(HelpDefinition helpDefinition) { | |
| 176 | 0 | this.helpDefinition = helpDefinition; |
| 177 | 0 | } |
| 178 | ||
| 179 | /** | |
| 180 | * @see java.lang.Object#toString() | |
| 181 | */ | |
| 182 | @Override | |
| 183 | public String toString() { | |
| 184 | 0 | return "DataObjectEntry for " + getObjectClass(); |
| 185 | } | |
| 186 | ||
| 187 | /** | |
| 188 | * @return the mustOccurConstraints | |
| 189 | */ | |
| 190 | public List<MustOccurConstraint> getMustOccurConstraints() { | |
| 191 | 0 | return this.mustOccurConstraints; |
| 192 | } | |
| 193 | ||
| 194 | /** | |
| 195 | * @param mustOccurConstraints the mustOccurConstraints to set | |
| 196 | */ | |
| 197 | public void setMustOccurConstraints( | |
| 198 | List<MustOccurConstraint> mustOccurConstraints) { | |
| 199 | 0 | this.mustOccurConstraints = mustOccurConstraints; |
| 200 | 0 | } |
| 201 | ||
| 202 | /** | |
| 203 | * @return the titleAttribute | |
| 204 | */ | |
| 205 | public String getTitleAttribute() { | |
| 206 | 0 | return this.titleAttribute; |
| 207 | } | |
| 208 | ||
| 209 | /** | |
| 210 | The titleAttribute element is the name of the attribute that | |
| 211 | will be used as an inquiry field when the lookup search results | |
| 212 | fields are displayed. | |
| 213 | ||
| 214 | For some business objects, there is no obvious field to serve | |
| 215 | as the inquiry field. in that case a special field may be required | |
| 216 | for inquiry purposes. | |
| 217 | */ | |
| 218 | public void setTitleAttribute(String titleAttribute) { | |
| 219 | 0 | this.titleAttribute = titleAttribute; |
| 220 | 0 | } |
| 221 | ||
| 222 | /** | |
| 223 | * @return the primaryKeys | |
| 224 | */ | |
| 225 | public List<String> getPrimaryKeys() { | |
| 226 | 0 | return this.primaryKeys; |
| 227 | } | |
| 228 | ||
| 229 | /** | |
| 230 | * @param primaryKeys the primaryKeys to set | |
| 231 | */ | |
| 232 | public void setPrimaryKeys(List<String> primaryKeys) { | |
| 233 | 0 | this.primaryKeys = primaryKeys; |
| 234 | 0 | } |
| 235 | ||
| 236 | public Class<? extends Exporter> getExporterClass() { | |
| 237 | 0 | return this.exporterClass; |
| 238 | } | |
| 239 | ||
| 240 | public void setExporterClass(Class<? extends Exporter> exporterClass) { | |
| 241 | 0 | this.exporterClass = exporterClass; |
| 242 | 0 | } |
| 243 | } |