1 PACKAGE BODY IES_META_DATA_UTIL AS
2 /* $Header: iesmdutb.pls 115.2 2003/01/06 20:41:17 appldev noship $ */
3
4 -- **********************************************************************
5 -- API name : getObjectTypeId
6 -- Type : Private
7 -- Function : This Function returns the object Type id given the object
8 -- type.
9 -- **********************************************************************
10
11 FUNCTION getObjectTypeId(x_name IN VARCHAR2) return NUMBER IS
12 TYPE obj_type IS REF CURSOR;
13 obj obj_type;
14
15 typeId NUMBER := -1;
16 BEGIN
17 OPEN obj FOR
18 'SELECT type_id
19 FROM ies_meta_object_types
20 WHERE type_name = :name' using x_name;
21
22 FETCH obj INTO typeId;
23 CLOSE obj;
24
25 if (typeId = -1) then
26 raise_application_error(-20101, 'name is missing'||x_name);
27 end if;
28
29 return typeId;
30 EXCEPTION
31 WHEN OTHERS THEN
32 RAISE_APPLICATION_ERROR(-20101, sqlerrm||' Error in getting objectTypeId for ' ||x_name);
33 END getObjectTypeId;
34
35 -- **********************************************************************
36 -- API name : getRelationshipTypeId
37 -- Type : Private
38 -- Function : This function returns relationship_id for a given
39 -- relationship type name
40 -- **********************************************************************
41
42 FUNCTION getRelationshipTypeId(typeName VARCHAR2) RETURN NUMBER IS
43 TYPE relId_type IS REF CURSOR;
44 relid relId_type;
45
46 typeId NUMBER := -1;
47 BEGIN
48 OPEN relId FOR
49 'SELECT type_id
50 FROM ies_meta_relationship_types
51 WHERE type_name = :typeName' using typeName;
52
53 FETCH relid INTO typeId;
54 CLOSE relid;
55 if (typeId = -1) then
56 raise_application_error(-20110, 'Error in getting relationship type id for ' || typeName);
57 end if;
58 return typeId;
59 END getRelationshipTypeId;
60
61 -- **********************************************************************
62 -- API name : getLookupId
63 -- Type : Private
64 -- Function : This Function returns the lookupId for the given
65 -- propId and property name
66 -- **********************************************************************
67
68
69
70 FUNCTION getLookupId(propId IN NUMBER, key IN VARCHAR2) return NUMBER IS
71 TYPE lookup_type IS REF CURSOR;
72 lookup_x lookup_type;
73
74 lookupId NUMBER := -1;
75 BEGIN
76 OPEN lookup_x FOR
77 'SELECT a.prop_lookup_id
78 FROM IES_META_PROPERTY_LOOKUPS a
79 WHERE a.property_id = :propId
80 AND a.lookup_key = :key' using propId, key;
81
82 FETCH lookup_x INTO lookupId;
83 CLOSE lookup_x;
84
85 return lookupId;
86 exception when no_data_found then return -1;
87 END;
88
89
90 -- **********************************************************************
91 -- API name : getProperty
92 -- Type : Private
93 -- Function : This Function navigates the XML tree and finds out the
94 -- value of the given key in the tree.
95 -- **********************************************************************
96
97 /* '<JavaBean CLASS="JavaCommand"> Sample xml doc used for saving metadata object
98 <Properties>
99 <Property NAME="command" ><![CDATA[myApp.CustomJavaClass::isValid]]></Property>
100 <Property NAME="name" ><![CDATA[firstCmd]]></Property>
101 <Property NAME="propertyMapIndex"><![CDATA[11]]></Property>
102 <CCTPropertyList NAME="parameters">
103 <Property NAME="parameters">
104 <JavaBean CLASS="Command$CommandParameter">
105 <Properties>
106 <Property NAME="paramType" ><![CDATA[class java.lang.String]]></Property>
107 <Property NAME="name" ><![CDATA[Untitled]]></Property>
108 <Property NAME="UID" ><![CDATA[1e0278:eb09c9e0e1:-7fc9]]></Property>
109 <Property NAME="paramVal" ><![CDATA[hello]]></Property>
110 <Property NAME="paramName" ><![CDATA[param1]]></Property>
111 </Properties>
112 </JavaBean>
113 </Property>
114 </CCTPropertyList>
115 <Property NAME="UID" ><![CDATA[1e0278:eb09c9e0e1:-7fc8]]></Property>
116 </Properties>
117 </JavaBean>'; */
118
119 FUNCTION getProperty(element IN xmldom.DOMElement, key IN VARCHAR2) return VARCHAR2 IS
120 nl xmldom.DOMNodeList;
121 len number;
122 n xmldom.DOMNode;
123 dummyElem xmldom.DOMElement;
124 child xmldom.DOMNode;
125 BEGIN
126 nl := xmldom.getChildNodes(xmldom.makeNode(element)); /* Get all childNodes for the element */
127 len := xmldom.getLength(nl);
128
129 for i in 0..len-1 loop /* Iterate thru the child nodes */
130 n := xmldom.item(nl, i);
131 dummyElem := xmldom.makeElement(n);
132
133 if (xmldom.getTagName(dummyElem) = 'Properties') then /* Still inspect the children of Properties */
134 return getProperty(dummyElem, key);
135 elsif (xmldom.getAttribute(dummyElem,'NAME') = key) then /* if key matches value of NAME attr */
136 child := xmldom.getFirstChild(n); /* this is how the node is retrieved for the NAME key */
137 if NOT (xmldom.isNull(child)) then
138 return xmldom.getNodeValue(child);
139 else
140 return NULL;
141 end if;
142 end if;
143 end loop;
144 return NULL; /* No match found */
145 END getProperty;
146
147
148 END IES_META_DATA_UTIL;