0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 function collectedHist = attachToDom(objs, dom, parent, collectedHist)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 if isempty(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % Create empty param node with the attribute 'shape'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 utils.xml.attachEmptyObjectNode(objs, dom, parent);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 for oo = 1:numel(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 obj = objs(oo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % Create object node
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 paramNode = dom.createElement('param');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 paramNode.setAttribute('shape', sprintf('%dx%d', size(objs)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % Call superclass
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 collectedHist = attachToDom@ltpda_nuo(obj, dom, paramNode, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % Add key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 paramNode.setAttribute('key', obj.key);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % Add param value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 val = obj.getVal;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 valNode = dom.createElement('val');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 valNode.setAttribute('shape', sprintf('%dx%d', size(val)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 if isnumeric(val) || islogical(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % We should have helper utilities for the types which are not objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % Again, we don't care here what happens inside the helper utility, it
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % may add one or more nodes, or just write to attributes.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 valNode.setAttribute('type', 'double');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 utils.xml.attachNumberToDom(val, dom, valNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 elseif ischar(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 valNode.setAttribute('type', 'char');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 utils.xml.attachCharToDom(val, dom, valNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 elseif iscellstr(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 content = dom.createTextNode(utils.xml.cellstr2str(val));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 valNode.setAttribute('type', 'cellstr');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 valNode.appendChild(content);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 elseif iscell(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 valNode.setAttribute('type', 'cell');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 collectedHist = utils.xml.attachCellToDom(val, dom, valNode, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 elseif isstruct(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 valNode.setAttribute('type', 'struct');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 collectedHist = utils.xml.attachStructToDom(val, dom, valNode, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 elseif isa(val, 'sym')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 valNode.setAttribute('type', 'sym');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 utils.xml.attachSymToDom(val, dom, valNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 elseif isa(val, 'history')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 histUUIDs = val(1).UUID;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 for hh = 2:numel(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 histUUIDs = [histUUIDs, ' ', val(hh).UUID];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 valNode.setAttribute('type', 'history');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 valNode.setAttribute('val', histUUIDs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 collectedHist = val.attachToDom(dom, parent, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 elseif isa(val, 'ltpda_obj')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 valNode.setAttribute('type', class(val));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 collectedHist = val.attachToDom(dom, valNode, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 elseif isa(val, 'sun.util.calendar.ZoneInfo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 content = dom.createTextNode(char(val.getID));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 valNode.setAttribute('type', class(val));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 valNode.appendChild(content);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 error('### Unknown data type to attach [%s]', class(val));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 paramNode.appendChild(valNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % Add desc
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 paramNode.setAttribute('desc', obj.desc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 % Add the properties of the paramValue object to the param node
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 if isa(obj.val, 'paramValue')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 prop = obj.val.property;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 if ~isempty(prop)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 paramPropertiesNode = dom.createElement('properties');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 collectedHist = utils.xml.attachStructToDom(prop, dom, paramPropertiesNode, collectedHist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 paramNode.appendChild(paramPropertiesNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % Add to parent node
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 parent.appendChild(paramNode);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 end
|