comparison m-toolbox/classes/@history/fromDom.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 hists = fromDom(obj, node, inhists)
3
4 % <historyRoot>
5 % <history UUID="1111" ...>
6 % ...
7 % </history>
8 % <history UUID="2222" methodInfo="#setDescription#ltpda_uoh#Helper#(ID): setDescription.m,v 1.8 2009/09/10 10:05:00 ingo Exp $#[1 -1 1 -1]#true#(ID): minfo.m,v 1.31 2010/04/27 15:49:26 ingo Exp $" methodInvars="{'a'}" proctime="1272392086974" shape="1x1">
9 % ...
10 % <inhists UUID="1111"/>
11 % </history>
12 % <history UUID="3333" ...>
13 % ...
14 % <inhists UUID="2222"/>
15 % </history>
16 % </historyRoot>
17
18 hists = [history.initObjectWithSize(1,0), inhists];
19
20 % Get history
21 histNodes = utils.xml.getChildrenByName(node, 'history');
22 for ii=0:histNodes.getLength()-1
23
24 %%%%%%%%%% Make sure that we always have a new history object
25 h = history();
26
27 %%%%%%%%%% Call super-class
28 fromDom@ltpda_nuo(obj, histNodes.item(ii), inhists);
29
30 h = getHistoryObj(h, histNodes.item(ii), hists);
31
32 if ~isempty(h.inhists)
33 inhistUUIDs = regexp(h.inhists, ' ', 'split');
34 if ~isempty(inhistUUIDs)
35 h.inhists = [];
36 for uu = 1:numel(inhistUUIDs)
37 h.inhists = [h.inhists utils.xml.getHistoryFromUUID(hists, inhistUUIDs{uu})];
38 end
39 end
40 end
41
42 hists = [hists h];
43 end
44
45 end
46
47 function obj = getHistoryObj(obj, node, hists)
48
49 % <history UUID="..." methodInfo="..." methodInvars="cell(0,0)" proctime="1">
50 % <plistUsed UUID="8a9a33c2-94c7-435b-a42d-ae02f50a3b6f" created="1272388257003" creator="#indiep#127.0.1.1#hws169#GLNX86#7.9 (R2009b)#6.12 (R2009b)#5.3 (R2009b)#4.3 (R2009b)#3.6 (R2009b)#8.4 (R2009b)#2.2 (R2009b)#(ID): provenance.m,v 1.54 2010/04/27 15:49:26 ingo Exp $" shape="1x1">
51 % ...
52 % </plistUsed>
53 % </history>
54
55 % Get shape
56 objShape = utils.xml.getShape(node);
57
58 if any(objShape==0)
59
60 obj = history.initObjectWithSize(objShape(1), objShape(2));
61
62 else
63
64 %%%%%%%%%% Get properties from the node attributes
65
66 % Get methodInfo
67 if node.hasAttribute('methodInfo')
68 obj.methodInfo = minfo.setFromEncodedInfo(minfo(), utils.xml.mchar(node.getAttribute('methodInfo')));
69 end
70
71 % Get methodInvars
72 obj.methodInvars = eval(utils.xml.mchar(node.getAttribute('methodInvars')));
73
74 % Get proctime
75 obj.proctime = str2double(utils.xml.mchar(node.getAttribute('proctime')));
76
77 % Get UUID
78 obj.UUID = utils.xml.mchar(node.getAttribute('UUID'));
79
80 % Get objectClass
81 obj.objectClass = utils.xml.recoverString(node.getAttribute('objectClass'));
82
83 % Get creator
84 if node.hasAttribute('creator')
85 obj.creator = provenance.setFromEncodedInfo(provenance(), utils.xml.mchar(node.getAttribute('creator')));
86 else
87 % XML file saved with LTPDA 2.3.1
88 % Get the creator from the plistUsed
89 plistUsedNode = utils.xml.getChildByName(node, 'plistUsed');
90 if ~isempty(plistUsedNode) && plistUsedNode.hasAttribute('creator')
91 obj.creator = provenance.setFromEncodedInfo(provenance(), utils.xml.mchar(plistUsedNode.getAttribute('creator')));
92 end
93 end
94
95 %%%%%%%%%% Get properties from the child nodes
96
97 % Get plistUsed
98 plistUsedNode = utils.xml.getChildByName(node, 'plistUsed');
99 if ~isempty(plistUsedNode)
100 obj.plistUsed = plist(plistUsedNode, hists);
101 end
102
103 % Get minfo
104 minfoNode = utils.xml.getChildByName(node, 'minfo');
105 if ~isempty(minfoNode)
106 obj.methodInfo = minfo(minfoNode, hists);
107 end
108
109 % Get inhists
110 inhistsNode = utils.xml.getChildByName(node, 'inhists');
111 if ~isempty(inhistsNode)
112 obj.inhists = utils.xml.mchar(inhistsNode.getAttribute('UUID'));
113 end
114
115 end
116
117 end