Mercurial > hg > orthanc
comparison Resources/Toolbox.lua @ 1435:6406f5493d92
refactoring: Lua toolbox
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 Jun 2015 16:46:23 +0200 |
parents | d710ea64f0fd |
children |
comparison
equal
deleted
inserted
replaced
1434:f9cd40166269 | 1435:6406f5493d92 |
---|---|
30 function _AccessJob() | 30 function _AccessJob() |
31 return _job | 31 return _job |
32 end | 32 end |
33 | 33 |
34 | 34 |
35 function SendToModality(instanceId, modality, localAet) | 35 function SendToModality(resourceId, modality, localAet) |
36 if instanceId == nil then | 36 if resourceId == nil then |
37 error('Cannot send a nonexistent instance') | 37 error('Cannot send a nonexistent resource') |
38 end | 38 end |
39 | 39 |
40 table.insert(_job, { | 40 table.insert(_job, { |
41 Operation = 'store-scu', | 41 Operation = 'store-scu', |
42 Instance = instanceId, | 42 Resource = resourceId, |
43 Modality = modality, | 43 Modality = modality, |
44 LocalAet = localAet | 44 LocalAet = localAet |
45 }) | 45 }) |
46 return instanceId | 46 return resourceId |
47 end | 47 end |
48 | 48 |
49 | 49 |
50 function SendToPeer(instanceId, peer) | 50 function SendToPeer(resourceId, peer) |
51 if instanceId == nil then | 51 if resourceId == nil then |
52 error('Cannot send a nonexistent instance') | 52 error('Cannot send a nonexistent resource') |
53 end | 53 end |
54 | 54 |
55 table.insert(_job, { | 55 table.insert(_job, { |
56 Operation = 'store-peer', | 56 Operation = 'store-peer', |
57 Instance = instanceId, | 57 Resource = resourceId, |
58 Peer = peer | 58 Peer = peer |
59 }) | 59 }) |
60 return instanceId | 60 return resourceId |
61 end | 61 end |
62 | 62 |
63 | 63 |
64 function Delete(instanceId) | 64 function Delete(resourceId) |
65 if instanceId == nil then | 65 if resourceId == nil then |
66 error('Cannot delete a nonexistent instance') | 66 error('Cannot delete a nonexistent resource') |
67 end | 67 end |
68 | 68 |
69 table.insert(_job, { | 69 table.insert(_job, { |
70 Operation = 'delete', | 70 Operation = 'delete', |
71 Instance = instanceId | 71 Resource = resourceId |
72 }) | 72 }) |
73 return nil -- Forbid chaining | 73 return nil -- Forbid chaining |
74 end | 74 end |
75 | 75 |
76 | 76 |
77 function ModifyInstance(instanceId, replacements, removals, removePrivateTags) | 77 function ModifyResource(resourceId, replacements, removals, removePrivateTags) |
78 if instanceId == nil then | 78 if resourceId == nil then |
79 error('Cannot modify a nonexistent instance') | 79 error('Cannot modify a nonexistent resource') |
80 end | 80 end |
81 | 81 |
82 if instanceId == '' then | 82 if resourceId == '' then |
83 error('Cannot modify twice an instance'); | 83 error('Cannot modify twice an resource'); |
84 end | 84 end |
85 | 85 |
86 table.insert(_job, { | 86 table.insert(_job, { |
87 Operation = 'modify', | 87 Operation = 'modify', |
88 Instance = instanceId, | 88 Resource = resourceId, |
89 Replace = replacements, | 89 Replace = replacements, |
90 Remove = removals, | 90 Remove = removals, |
91 RemovePrivateTags = removePrivateTags | 91 RemovePrivateTags = removePrivateTags |
92 }) | 92 }) |
93 | |
93 return '' -- Chain with another operation | 94 return '' -- Chain with another operation |
94 end | 95 end |
95 | 96 |
96 | 97 |
97 function CallSystem(instanceId, command, args) | 98 function ModifyInstance(resourceId, replacements, removals, removePrivateTags) |
98 if instanceId == nil then | 99 return ModifyResource(resourceId, replacements, removals, removePrivateTags) |
99 error('Cannot modify a nonexistent instance') | 100 end |
101 | |
102 | |
103 -- This function is only applicable to individual instances | |
104 function CallSystem(resourceId, command, args) | |
105 if resourceId == nil then | |
106 error('Cannot execute a system call on a nonexistent resource') | |
107 end | |
108 | |
109 if command == nil then | |
110 error('No command was specified for system call') | |
100 end | 111 end |
101 | 112 |
102 table.insert(_job, { | 113 table.insert(_job, { |
103 Operation = 'call-system', | 114 Operation = 'call-system', |
104 Instance = instanceId, | 115 Resource = resourceId, |
105 Command = command, | 116 Command = command, |
106 Arguments = args | 117 Arguments = args |
107 }) | 118 }) |
108 | 119 |
109 return instanceId | 120 return resourceId |
110 end | 121 end |
111 | 122 |
112 | 123 |
113 print('Lua toolbox installed') | 124 print('Lua toolbox installed') |