Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
KrmsAttributeDefinitionService |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2006-2011 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 | ||
17 | package org.kuali.rice.krms.impl.repository; | |
18 | ||
19 | import java.util.List; | |
20 | import java.util.Map; | |
21 | ||
22 | import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition; | |
23 | ||
24 | ||
25 | public interface KrmsAttributeDefinitionService { | |
26 | ||
27 | /** | |
28 | * This will create a {@link KrmsAttributeDefinition} exactly like the parameter passed in. | |
29 | * | |
30 | * @param attributeDefinition - KrmsAttributeDefinition | |
31 | * @throws IllegalArgumentException if the attribute definition is null | |
32 | * @throws IllegalStateException if the attribute definition already exists in the system | |
33 | */ | |
34 | public KrmsAttributeDefinition createAttributeDefinition(KrmsAttributeDefinition attributeDefinition); | |
35 | ||
36 | /** | |
37 | * This will update a {@link KrmsAttributeDefinition}. | |
38 | * | |
39 | * | |
40 | * @param attributeDefinition - KrmsAttributeDefinition | |
41 | * @throws IllegalArgumentException if the attribute definition is null | |
42 | * @throws IllegalStateException if the attribute definition does not exist in the system | |
43 | */ | |
44 | public void updateAttributeDefinition(KrmsAttributeDefinition attributeDefinition); | |
45 | ||
46 | /** | |
47 | * Lookup a KrmsAttributeDefinition based on the given id. | |
48 | * | |
49 | * @param id the given KrmsAttributeDefinition id | |
50 | * @return a KrmsAttributeDefinition object with the given id. A null reference is returned if an invalid or | |
51 | * non-existant id is supplied. | |
52 | */ | |
53 | public KrmsAttributeDefinition getAttributeDefinitionById(String id); | |
54 | ||
55 | /** | |
56 | * Get a KrmsAttributeDefinition object based on name and namespace | |
57 | * | |
58 | * @param name the given name | |
59 | * @param namespace the given type namespace | |
60 | * @return A KrmsAttributeDefinition object with the given namespace and name if one with that name and namespace | |
61 | * exists. Otherwise, null is returned. | |
62 | * @throws IllegalStateException if multiple KrmsAttributeDefinitions exist with the same name and namespace | |
63 | */ | |
64 | public KrmsAttributeDefinition getAttributeDefinitionByNameAndNamespace(String name, String namespace); | |
65 | ||
66 | /** | |
67 | * Returns all KrmsAttributeDefinition that for a given namespace. | |
68 | * | |
69 | * @return all KrmsAttributeDefinition for a namespace | |
70 | */ | |
71 | public List<KrmsAttributeDefinition> findAttributeDefinitionsByNamespace(String namespace); | |
72 | ||
73 | /** | |
74 | * Returns all KrmsAttributeDefinitions | |
75 | * | |
76 | * @return all KrmsAttributeDefinitions | |
77 | */ | |
78 | public List<KrmsAttributeDefinition> findAllAttributeDefinitions(); | |
79 | ||
80 | /** | |
81 | * This method converts a collection of name/value attribute pairs to | |
82 | * id/value attribute pairs. | |
83 | * <p> | |
84 | * At the api layer, attributes are represented as name/value pairs. | |
85 | * However, in the database, the names of the attribute and the values are | |
86 | * stored separately. The attribute definitions contain the attribute names. | |
87 | * All defined attributes(for the various krms entity types) are stored | |
88 | * together in a single table. The attribute values themselves are stored | |
89 | * in separate tables for each entity type, and then reference the attribute | |
90 | * definitions by the attribute definition id. | |
91 | * <p> | |
92 | * This method converts the name/value pairs to id/value pairs so they | |
93 | * can be searched from a single table. This simplifies the queries for | |
94 | * attributes. | |
95 | * <p> | |
96 | * | |
97 | * @param attributesByName - a Map<String/String> containing the name/value | |
98 | * pairs for the set of attributes. | |
99 | * @param namespace - the namespace code of the set of attributes | |
100 | * @return a Map<String,String> containing the id/value pairs for the set | |
101 | * of attributes. | |
102 | */ | |
103 | public Map<String,String> convertAttributeKeys(Map<String,String> attributesByName, String namespace); | |
104 | ||
105 | /** | |
106 | * This method gets the attribute definition ID for a given attribute | |
107 | * | |
108 | * @param attributeName - the name of the attribute | |
109 | * @param namespace - the namespace code of the attribute | |
110 | * @return - the attribute definition id | |
111 | */ | |
112 | public String getKrmsAttributeId( String attributeName, String namespace); | |
113 | ||
114 | /** | |
115 | * This method gets a KrmsAttributeDefinitionBo object for a given attribute. | |
116 | * | |
117 | * @param attributeName - the name of the attribute | |
118 | * @param namespace - the namespace code of the attribute | |
119 | * @return - the attribute definition id | |
120 | */ | |
121 | public KrmsAttributeDefinitionBo getKrmsAttributeBo( String attributeName, String namespace); | |
122 | ||
123 | /** | |
124 | * This method clears the cache of AttributeDefinitionBo objects. | |
125 | * <p> | |
126 | * Since searching for attribute definitions is a common operation, | |
127 | * the attribute definitions fetched from the database are cached to | |
128 | * improve performance. | |
129 | * <p> | |
130 | */ | |
131 | public void clearCache(); | |
132 | ||
133 | } |