Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BusinessObjectMetaDataService |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007 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.kns.service; | |
17 | ||
18 | import java.util.Collection; | |
19 | import java.util.List; | |
20 | import java.util.Map; | |
21 | ||
22 | import org.kuali.rice.kns.bo.BusinessObject; | |
23 | import org.kuali.rice.kns.bo.BusinessObjectRelationship; | |
24 | import org.kuali.rice.kns.datadictionary.FieldDefinition; | |
25 | import org.kuali.rice.kns.datadictionary.RelationshipDefinition; | |
26 | import org.kuali.rice.kns.lookup.valueFinder.ValueFinder; | |
27 | ||
28 | /** | |
29 | * | |
30 | * This class provides Metadata about a specific BusinessObject. Depending on the circumstance or type | |
31 | * of BO it will retrieve the data it needs from either the DataDictionary or through the | |
32 | * PersistenceStructureService | |
33 | */ | |
34 | public interface BusinessObjectMetaDataService { | |
35 | ||
36 | public BusinessObjectRelationship getBusinessObjectRelationship(RelationshipDefinition ddReference, BusinessObject bo, Class boClass, String attributeName, String attributePrefix, boolean keysOnly ); | |
37 | public RelationshipDefinition getBusinessObjectRelationshipDefinition(Class c, String attributeName); | |
38 | public RelationshipDefinition getBusinessObjectRelationshipDefinition(BusinessObject bo, String attributeName); | |
39 | ||
40 | /** | |
41 | * | |
42 | * This method returns a list of inquirable field names | |
43 | * @param bo | |
44 | * @return a collection of inquirable field names | |
45 | */ | |
46 | public Collection<String> getInquirableFieldNames(Class boClass, String sectionTitle); | |
47 | ||
48 | /** | |
49 | * | |
50 | * This method returns a list of lookupable fields | |
51 | * @param bo | |
52 | * @return a collection of lookupable fields | |
53 | */ | |
54 | public List<String> getLookupableFieldNames(Class boClass); | |
55 | ||
56 | ||
57 | /** | |
58 | * | |
59 | * This method looks up the default value for a given attribute and | |
60 | * returns it | |
61 | * @param businessObjectClass | |
62 | * @param attributeName | |
63 | * @return default value for an attribute | |
64 | */ | |
65 | public String getLookupFieldDefaultValue(Class businessObjectClass, String attributeName); | |
66 | ||
67 | /** | |
68 | * | |
69 | * This method returns the value finder class for a given attribute | |
70 | * @param businessObjectClass | |
71 | * @param attributeName | |
72 | * @return value finder class | |
73 | */ | |
74 | public Class getLookupFieldDefaultValueFinderClass(Class businessObjectClass, String attributeName); | |
75 | ||
76 | /** | |
77 | * | |
78 | * This method looks up the quickfinder parameter string for a given attribute and | |
79 | * returns it. See {@link FieldDefinition#getQuickfinderParameterString()}. | |
80 | * @param businessObjectClass | |
81 | * @param attributeName | |
82 | * @return default values for attributes | |
83 | */ | |
84 | public String getLookupFieldQuickfinderParameterString(Class businessObjectClass, String attributeName); | |
85 | ||
86 | /** | |
87 | * This method returns the quickfinder parameter string builder class for a given attribute. | |
88 | * See {@link FieldDefinition#getQuickfinderParameterStringBuilderClass()}. | |
89 | * @param businessObjectClass | |
90 | * @param attributeName | |
91 | * @return value finder class | |
92 | */ | |
93 | public Class<? extends ValueFinder> getLookupFieldQuickfinderParameterStringBuilderClass(Class businessObjectClass, String attributeName); | |
94 | ||
95 | /** | |
96 | * | |
97 | * This method returns a list of collection names a business object contains | |
98 | * @param bo | |
99 | * @return | |
100 | */ | |
101 | public Collection<String> getCollectionNames(BusinessObject bo); | |
102 | ||
103 | /** | |
104 | * | |
105 | * This method determines if a given field(attribute) is inquirable or not | |
106 | * This handles both nested and non-nested attributes | |
107 | * @param bo | |
108 | * @param attributeName | |
109 | * @param sectionTitle | |
110 | * @return true if field is inquirable | |
111 | */ | |
112 | public boolean isAttributeInquirable(Class boClass, String attributeName, String sectionTitle); | |
113 | ||
114 | /** | |
115 | * | |
116 | * This method determines if a given business object is inquirable | |
117 | * @param bo | |
118 | * @return true if bo is inquirable | |
119 | */ | |
120 | public boolean isInquirable(Class boClass); | |
121 | ||
122 | /** | |
123 | * | |
124 | * This method determines if a given field(attribute) is lookupable or not | |
125 | * This handles both nested and non-nested attributes | |
126 | * @param bo | |
127 | * @param attributeName | |
128 | * @return true if field is lookupable | |
129 | */ | |
130 | public boolean isAttributeLookupable(Class boClass, String attributeName); | |
131 | ||
132 | /** | |
133 | * | |
134 | * This method determines if a given business object is lookupable | |
135 | * @param bo | |
136 | * @return true if bo is lookupable | |
137 | */ | |
138 | public boolean isLookupable(Class boClass); | |
139 | ||
140 | /** | |
141 | * | |
142 | * This method will return a class that is related to the parent BO (either through | |
143 | * the DataDictionary or through the PersistenceStructureService) | |
144 | * @param bo | |
145 | * @param attributes | |
146 | * @return related class | |
147 | */ | |
148 | public BusinessObjectRelationship getBusinessObjectRelationship(BusinessObject bo, String attributeName); | |
149 | ||
150 | public BusinessObjectRelationship getBusinessObjectRelationship(BusinessObject bo, Class boClass, String attributeName, String attributePrefix, boolean keysOnly ); | |
151 | ||
152 | /** | |
153 | * Get all the business object relationships for the given business object. These relationships may be defined | |
154 | * at the ORM-layer or within the data dictionary. | |
155 | */ | |
156 | public List<BusinessObjectRelationship> getBusinessObjectRelationships( BusinessObject bo ); | |
157 | ||
158 | /** | |
159 | * Get all the business object relationships for the given class. These relationships may be defined | |
160 | * at the ORM-layer or within the data dictionary. | |
161 | */ | |
162 | public List<BusinessObjectRelationship> getBusinessObjectRelationships( Class<? extends BusinessObject> boClass ); | |
163 | ||
164 | /** | |
165 | * This method accepts a business object and one of its foreign key attribute names. | |
166 | * It returns a map that has a foreign key attribute name as a key and its respective related class as value. | |
167 | * If the passed in attributeName is not a foreign key, this method will return an empty map. | |
168 | * | |
169 | * @param BusinessObject businessObject | |
170 | * @param String attributeName | |
171 | * @return Map<String, Class> | |
172 | */ | |
173 | public Map<String, Class> getReferencesForForeignKey(BusinessObject businessObject, String attributeName); | |
174 | ||
175 | /** | |
176 | * | |
177 | * This method returns a list of primary keys for the passed in class. | |
178 | * | |
179 | * @param clazz | |
180 | * @return | |
181 | */ | |
182 | public List listPrimaryKeyFieldNames(Class clazz); | |
183 | ||
184 | /** | |
185 | * | |
186 | * This method ... | |
187 | * | |
188 | * @param businessObjectClass | |
189 | * @param attributeName | |
190 | * @param targetName | |
191 | * @return | |
192 | */ | |
193 | public String getForeignKeyFieldName(Class businessObjectClass, String attributeName, String targetName); | |
194 | } |