comparison m-toolbox/classes/@history/attachToDom.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1
2 function collectedHist = attachToDom(histObjs, dom, parent, collectedHist)
3
4 % Attach the history always to the historyRoot node
5 historyRoot = dom.getElementsByTagName('historyRoot');
6 historyRoot = historyRoot.item(0);
7
8 % Do not call the super class
9 % attachToDom@ltpda_nuo(obj, dom, node);
10
11 addgraph(histObjs);
12
13 function histId = addgraph(histObjs)
14
15 histId = '';
16 for oo = 1:numel(histObjs)
17 histObj = histObjs(oo);
18
19 if ~objectInArray(collectedHist, histObj)
20
21 % Create object node
22 histNode = dom.createElement(class(histObj));
23 histNode.setAttribute('shape', sprintf('%dx%d', size(histObj)));
24
25 % Add methodInfo
26 if isa(histObj.methodInfo, 'minfo')
27
28 if numel(histObj.methodInfo) == 1 && isempty(histObj.methodInfo.children)
29 % Special case if the minfo-object doesn't have children.
30 % Store in this case the minfo-object as an attribute.
31 histNode.setAttribute('methodInfo', histObj.methodInfo.getEncodedString());
32 else
33 % Create an own minfo node if the minfo-object have children or
34 % there are more than one minfo-objects
35 % mInfoNode = dom.createElement('methodInfo');
36 collectedHist = histObj.methodInfo.attachToDom(dom, histNode, collectedHist);
37 % histNode.appendChild(mInfoNode);
38 end
39 end
40
41 % Add plistUsed
42 if isa(histObj.plistUsed, 'plist')
43 pUsedNode = dom.createElement('plistUsed');
44 collectedHist = histObj.plistUsed.attachToDom(dom, pUsedNode, collectedHist);
45 histNode.appendChild(pUsedNode);
46 end
47
48 % Add methodInvars
49 histNode.setAttribute('methodInvars', utils.xml.cellstr2str(histObj.methodInvars));
50
51 % Add proctime
52 histNode.setAttribute('proctime', num2str(histObj.proctime));
53
54 % Add UUID
55 histNode.setAttribute('UUID', histObj.UUID);
56
57 % Add objectClass
58 histNode.setAttribute('objectClass', utils.xml.prepareString(histObj.objectClass));
59
60 % Add creator
61 % Special behavior for the creator of a PLIST because
62 % provenance/attachToDom adds a extra node and this is not what we
63 % want. Store the creator information direct to the plist node as an
64 % attribute.
65 if isa(histObj.creator, 'provenance')
66 SEPARATOR = ' ยง ';
67 creatorInfo = histObj.creator(1).getEncodedString();
68 for cc = 2:numel(histObj.creator)
69 creatorInfo = [creatorInfo, SEPARATOR, histObj.creator(cc).getEncodedString()];
70 end
71 else
72 creatorInfo = '';
73 end
74 histNode.setAttribute('creator', creatorInfo);
75
76 % Add inhists
77 if ~isempty(histObj.inhists)
78 inhistsNode = dom.createElement('inhists');
79 attrHistId = addgraph(histObj.inhists);
80 inhistsNode.setAttribute('UUID', strtrim(attrHistId));
81 histNode.appendChild(inhistsNode);
82 end
83
84 collectedHist = [collectedHist histNode];
85 end
86
87 % Add the object UUID to the output.
88 histId = [histId, ' ', histObj.UUID];
89
90 end
91
92 end
93
94 for hh = 1:numel(collectedHist)
95 historyRoot.appendChild(collectedHist(hh));
96 end
97
98 end
99
100 function res = objectInArray(objects, obj)
101
102 res = false;
103 for kk=1:numel(objects)
104 if strcmp(utils.xml.mchar(objects(kk).getAttribute('UUID')), obj.UUID)
105 res = true;
106 break;
107 end
108 end
109 end