1 | /** | | 1 | /** |
2 | * Find a class in a package. If it does not exist, a new class is | | 2 | * Search the attribute named <code>attributeName</code> in the given |
3 | * created. | | 3 | * relation. If there exist more than one attribute the first one is |
4 | * | | 4 | * returned. |
5 | * @param mPackage Look in this package. | | 5 | * |
6 | * @param name The name of the class. | | 6 | * @param relation |
7 | * @return The class found or created. | | 7 | * The relation in which to search the attribute. |
8 | */ | | 8 | * @param attributeName |
9 | private Object getClass(Object mPackage, String name) { | | 9 | * The name of the attribute to search. |
10 | Object mClass = null; | | 10 | * @return The attribute if found, <code>null</code> else. |
11 | for (Object c : Model.getCoreHelper().getAllClasses(mPackage)) { | | 11 | */ |
12 | if (name.equals(Model.getFacade().getName(c))) { | | 12 | public static Object getAttributeForName(Object relation, |
13 | mClass = c; | | 13 | String attributeName) { |
14 | break; | | 14 | Object attribute = null; |
15 | } | | 15 | |
16 | } | | 16 | Collection attributes = Model.getFacade().getAttributes(relation); |
17 | if (mClass == null) { | | 17 | for (Iterator it = attributes.iterator(); it.hasNext();) { |
18 | mClass = Model.getCoreFactory().buildClass(name, mPackage); | | 18 | Object attr = it.next(); |
19 | newElements.add(mClass); | | 19 | if (Model.getFacade().getName(attr).equals(attributeName)) { |
20 | } | | 20 | attribute = attr; |
21 | return mClass; | | 21 | break; |
22 | } | | 22 | } |
| | | 23 | } |
| | | 24 | |
| | | 25 | return attribute; |
| | | 26 | } |