112: -- Function : This function navigates the XML Tree and gets all the
113: -- children for a given element
114: -- **********************************************************************
115:
116: FUNCTION getChildEntities(e IN xmldom.DOMElement) return childEntities_table IS
117: childEntities_tab childEntities_table; /* childEntities_table is table of xmldom.DOMNode */
118: nl xmldom.DOMNodeList;
119: len number;
120: n xmldom.DOMNode;
113: -- children for a given element
114: -- **********************************************************************
115:
116: FUNCTION getChildEntities(e IN xmldom.DOMElement) return childEntities_table IS
117: childEntities_tab childEntities_table; /* childEntities_table is table of xmldom.DOMNode */
118: nl xmldom.DOMNodeList;
119: len number;
120: n xmldom.DOMNode;
121: counter number := 0; /* represents index in table */
114: -- **********************************************************************
115:
116: FUNCTION getChildEntities(e IN xmldom.DOMElement) return childEntities_table IS
117: childEntities_tab childEntities_table; /* childEntities_table is table of xmldom.DOMNode */
118: nl xmldom.DOMNodeList;
119: len number;
120: n xmldom.DOMNode;
121: counter number := 0; /* represents index in table */
122: dummyNode xmldom.DOMNode;
116: FUNCTION getChildEntities(e IN xmldom.DOMElement) return childEntities_table IS
117: childEntities_tab childEntities_table; /* childEntities_table is table of xmldom.DOMNode */
118: nl xmldom.DOMNodeList;
119: len number;
120: n xmldom.DOMNode;
121: counter number := 0; /* represents index in table */
122: dummyNode xmldom.DOMNode;
123: dummyElem xmldom.DOMElement;
124: s varchar2(256);
118: nl xmldom.DOMNodeList;
119: len number;
120: n xmldom.DOMNode;
121: counter number := 0; /* represents index in table */
122: dummyNode xmldom.DOMNode;
123: dummyElem xmldom.DOMElement;
124: s varchar2(256);
125: BEGIN
126: if NOT (xmldom.isnull(e)) then /* Navigate tree only if element IS NOT NULL */
119: len number;
120: n xmldom.DOMNode;
121: counter number := 0; /* represents index in table */
122: dummyNode xmldom.DOMNode;
123: dummyElem xmldom.DOMElement;
124: s varchar2(256);
125: BEGIN
126: if NOT (xmldom.isnull(e)) then /* Navigate tree only if element IS NOT NULL */
127: nl := xmldom.getChildNodes(xmldom.makeNode(e));
122: dummyNode xmldom.DOMNode;
123: dummyElem xmldom.DOMElement;
124: s varchar2(256);
125: BEGIN
126: if NOT (xmldom.isnull(e)) then /* Navigate tree only if element IS NOT NULL */
127: nl := xmldom.getChildNodes(xmldom.makeNode(e));
128: len := xmldom.getLength(nl);
129:
130: for i in 0..len-1 loop /* For all child nodes of root element */
123: dummyElem xmldom.DOMElement;
124: s varchar2(256);
125: BEGIN
126: if NOT (xmldom.isnull(e)) then /* Navigate tree only if element IS NOT NULL */
127: nl := xmldom.getChildNodes(xmldom.makeNode(e));
128: len := xmldom.getLength(nl);
129:
130: for i in 0..len-1 loop /* For all child nodes of root element */
131: n := xmldom.item(nl, i);
124: s varchar2(256);
125: BEGIN
126: if NOT (xmldom.isnull(e)) then /* Navigate tree only if element IS NOT NULL */
127: nl := xmldom.getChildNodes(xmldom.makeNode(e));
128: len := xmldom.getLength(nl);
129:
130: for i in 0..len-1 loop /* For all child nodes of root element */
131: n := xmldom.item(nl, i);
132:
127: nl := xmldom.getChildNodes(xmldom.makeNode(e));
128: len := xmldom.getLength(nl);
129:
130: for i in 0..len-1 loop /* For all child nodes of root element */
131: n := xmldom.item(nl, i);
132:
133: dummyElem := xmldom.makeElement(n);
134:
135: if (xmldom.getTagName(dummyElem) = 'Properties') then /* Still in root's properties */
129:
130: for i in 0..len-1 loop /* For all child nodes of root element */
131: n := xmldom.item(nl, i);
132:
133: dummyElem := xmldom.makeElement(n);
134:
135: if (xmldom.getTagName(dummyElem) = 'Properties') then /* Still in root's properties */
136: childEntities_tab := getChildEntities(dummyElem);
137: end if;
131: n := xmldom.item(nl, i);
132:
133: dummyElem := xmldom.makeElement(n);
134:
135: if (xmldom.getTagName(dummyElem) = 'Properties') then /* Still in root's properties */
136: childEntities_tab := getChildEntities(dummyElem);
137: end if;
138:
139: if (xmldom.getTagName(dummyElem) = 'CCTPropertyList') then /* Child named CCTPropertyList */
135: if (xmldom.getTagName(dummyElem) = 'Properties') then /* Still in root's properties */
136: childEntities_tab := getChildEntities(dummyElem);
137: end if;
138:
139: if (xmldom.getTagName(dummyElem) = 'CCTPropertyList') then /* Child named CCTPropertyList */
140: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
142: elsif (xmldom.getTagName(dummyElem) = 'CCTPropertyMapList') then /* Child named CCTPropertyMapList */
143: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
136: childEntities_tab := getChildEntities(dummyElem);
137: end if;
138:
139: if (xmldom.getTagName(dummyElem) = 'CCTPropertyList') then /* Child named CCTPropertyList */
140: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
142: elsif (xmldom.getTagName(dummyElem) = 'CCTPropertyMapList') then /* Child named CCTPropertyMapList */
143: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
138:
139: if (xmldom.getTagName(dummyElem) = 'CCTPropertyList') then /* Child named CCTPropertyList */
140: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
142: elsif (xmldom.getTagName(dummyElem) = 'CCTPropertyMapList') then /* Child named CCTPropertyMapList */
143: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
145: elsif (xmldom.getTagName(dummyElem) = 'ChildObject') then /* ChildObject */
146: childEntities_tab(counter) := n; /* Node starting with
139: if (xmldom.getTagName(dummyElem) = 'CCTPropertyList') then /* Child named CCTPropertyList */
140: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
142: elsif (xmldom.getTagName(dummyElem) = 'CCTPropertyMapList') then /* Child named CCTPropertyMapList */
143: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
145: elsif (xmldom.getTagName(dummyElem) = 'ChildObject') then /* ChildObject */
146: childEntities_tab(counter) := n; /* Node starting with
141: counter := counter + 1;
142: elsif (xmldom.getTagName(dummyElem) = 'CCTPropertyMapList') then /* Child named CCTPropertyMapList */
143: childEntities_tab(counter) := xmldom.getFirstChild(n); /* Node starting with
145: elsif (xmldom.getTagName(dummyElem) = 'ChildObject') then /* ChildObject */
146: childEntities_tab(counter) := n; /* Node starting with
148: end if;
149: end loop;
157: -- Function : This procedure saves children objects by calling
158: -- saveObjectTobDB recursively in the tree
159: -- **********************************************************************
160:
161: PROCEDURE saveChildObjectsToDB(element IN xmldom.DOMElement, rootObjId IN NUMBER) IS
162: namedMap xmldom.DOMNamedNodeMap;
163: childEntities_tab childEntities_table;
164: child xmldom.DOMElement;
165: objId number;
158: -- saveObjectTobDB recursively in the tree
159: -- **********************************************************************
160:
161: PROCEDURE saveChildObjectsToDB(element IN xmldom.DOMElement, rootObjId IN NUMBER) IS
162: namedMap xmldom.DOMNamedNodeMap;
163: childEntities_tab childEntities_table;
164: child xmldom.DOMElement;
165: objId number;
166: objOrder number;
160:
161: PROCEDURE saveChildObjectsToDB(element IN xmldom.DOMElement, rootObjId IN NUMBER) IS
162: namedMap xmldom.DOMNamedNodeMap;
163: childEntities_tab childEntities_table;
164: child xmldom.DOMElement;
165: objId number;
166: objOrder number;
167: BEGIN
168: childEntities_tab := getChildEntities(element); /* Get all child elements */
167: BEGIN
168: childEntities_tab := getChildEntities(element); /* Get all child elements */
169:
170: for i in 0..childEntities_tab.count-1 loop
171: child := xmldom.makeElement(childEntities_tab(i));
172: objOrder := xmldom.getAttribute(child, 'OBJECT_ORDER'); /* Elements like CCTPropertyList and CCTPropertyMapList have this attribute */
173: objId := saveObjectToDB(child, rootObjId, objOrder); /* rootObjId is the parents object id */
174: end loop;
175: END saveChildObjectsToDB;
168: childEntities_tab := getChildEntities(element); /* Get all child elements */
169:
170: for i in 0..childEntities_tab.count-1 loop
171: child := xmldom.makeElement(childEntities_tab(i));
172: objOrder := xmldom.getAttribute(child, 'OBJECT_ORDER'); /* Elements like CCTPropertyList and CCTPropertyMapList have this attribute */
173: objId := saveObjectToDB(child, rootObjId, objOrder); /* rootObjId is the parents object id */
174: end loop;
175: END saveChildObjectsToDB;
176:
242: -- appropriate tables
243: -- **********************************************************************
244:
245:
246: FUNCTION saveObjectToDB(element IN xmldom.DOMElement, rootObjId IN NUMBER, objOrder IN NUMBER) return NUMBER IS
247: objId NUMBER := -1; /* for the parent, rootObjId is -1 */
248: name VARCHAR2(256);
249: objUID VARCHAR2(256);
250:
248: name VARCHAR2(256);
249: objUID VARCHAR2(256);
250:
251: relationship VARCHAR2(256);
252: e xmldom.DOMElement;
253: n xmldom.DOMNode;
254: BEGIN
255: relationship := xmldom.getAttribute(element, 'NAME'); /* It does not exist for parent */
256:
249: objUID VARCHAR2(256);
250:
251: relationship VARCHAR2(256);
252: e xmldom.DOMElement;
253: n xmldom.DOMNode;
254: BEGIN
255: relationship := xmldom.getAttribute(element, 'NAME'); /* It does not exist for parent */
256:
257: /* The first if check is for child elements which are CCTPropertyList/CCTPropertyMapList OR
251: relationship VARCHAR2(256);
252: e xmldom.DOMElement;
253: n xmldom.DOMNode;
254: BEGIN
255: relationship := xmldom.getAttribute(element, 'NAME'); /* It does not exist for parent */
256:
257: /* The first if check is for child elements which are CCTPropertyList/CCTPropertyMapList OR
258: ChildObject, the next line starts with
259:
256:
257: /* The first if check is for child elements which are CCTPropertyList/CCTPropertyMapList OR
258: ChildObject, the next line starts with
259:
260: if (xmldom.getTagName(element) = 'Property' OR xmldom.getTagName(element) = 'ChildObject') then
261: n := xmldom.makeNode(element);
262: e := xmldom.makeElement(xmldom.getFirstChild(n));
263: else
264: e := element;
257: /* The first if check is for child elements which are CCTPropertyList/CCTPropertyMapList OR
258: ChildObject, the next line starts with
259:
260: if (xmldom.getTagName(element) = 'Property' OR xmldom.getTagName(element) = 'ChildObject') then
261: n := xmldom.makeNode(element);
262: e := xmldom.makeElement(xmldom.getFirstChild(n));
263: else
264: e := element;
265: end if;
258: ChildObject, the next line starts with
259:
260: if (xmldom.getTagName(element) = 'Property' OR xmldom.getTagName(element) = 'ChildObject') then
261: n := xmldom.makeNode(element);
262: e := xmldom.makeElement(xmldom.getFirstChild(n));
263: else
264: e := element;
265: end if;
266:
263: else
264: e := element;
265: end if;
266:
267: if NOT (xmldom.isNull(e)) then
268: name := IES_META_DATA_UTIL.getProperty(e, 'name');
269: objUID := IES_META_DATA_UTIL.getProperty(e, 'UID');
270:
271: if NOT (existsObject(objUID)) then
303:
304: PROCEDURE writeMetaDataObject(obj IN Clob) IS
305: objId NUMBER := -1;
306: parser xmlparser.parser;
307: doc xmldom.DOMDocument;
308: element xmlDom.DOMElement;
309: BEGIN
310: parser := xmlparser.newParser;
311:
304: PROCEDURE writeMetaDataObject(obj IN Clob) IS
305: objId NUMBER := -1;
306: parser xmlparser.parser;
307: doc xmldom.DOMDocument;
308: element xmlDom.DOMElement;
309: BEGIN
310: parser := xmlparser.newParser;
311:
312: xmlparser.setValidationMode(parser, FALSE);
313: xmlparser.showWarnings(parser, TRUE);
314: xmlparser.parseClob(parser, obj);
315:
316: doc := xmlparser.getDocument(parser);
317: element := xmldom.getDocumentElement(doc);
318:
319: objId := saveObjectToDB(element, -1, null);
320: writeLibraryRecord(objId);
321: END writeMetaDataObject;
329:
330: PROCEDURE writeMetaDataObjectDebug(obj IN VARCHAR2) IS
331: objId NUMBER := -1;
332: parser xmlparser.parser;
333: doc xmldom.DOMDocument;
334: element xmlDom.DOMElement;
335: BEGIN
336: parser := xmlparser.newParser;
337:
330: PROCEDURE writeMetaDataObjectDebug(obj IN VARCHAR2) IS
331: objId NUMBER := -1;
332: parser xmlparser.parser;
333: doc xmldom.DOMDocument;
334: element xmlDom.DOMElement;
335: BEGIN
336: parser := xmlparser.newParser;
337:
338: xmlparser.setValidationMode(parser, FALSE);
339: xmlparser.showWarnings(parser, TRUE);
340: xmlparser.parseBuffer(parser, obj);
341:
342: doc := xmlparser.getDocument(parser);
343: element := xmldom.getDocumentElement(doc);
344:
345: objId := saveObjectToDB(element, -1, null);
346: writeLibraryRecord(objId);
347: END writeMetaDataObjectDebug;