aboutsummaryrefslogtreecommitdiffstats
path: root/platform-logic/generic-resource-api/src/main/xml/GENERIC-RESOURCE-API_generate-unique-name.xml
blob: f74af9617b138a7cb6aca18f7558635d294111b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='GENERIC-RESOURCE-API' version='${project.version}'><method rpc='generate-unique-name' mode='sync'>
<block atomic="true"><set>
<parameter name='generate-unique-name-output.error-message' value='' />
<parameter name='generate-unique-name-output.generated-name' value='' />
</set><switch test='`$generate-unique-name-input.supplied-name`'>
<outcome value='Other'>
<block atomic="true"><switch test='`$generate-unique-name-input.name-table-type`'>
<outcome value=''><return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.name-table-type not supplied' />
</return></outcome></switch><set>
<parameter name='tmp.gun.sql' value="`'SELECT * from GENERIC_RESOURCE_NAME WHERE type = $generate-unique-name-input.name-table-type'
+ ' AND name = $generate-unique-name-input.supplied-name'`" />
</set><get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='tmp.gun.namedb'>

<outcome value='failure'>
<return status='failure'>
<parameter name='generate-unique-name-output.error-message' value="`'Error reading the ' + $generate-unique-name-input.name-table-index + ' table'`" />

</return></outcome><outcome value='not-found'>
<block atomic="true"><set>
<parameter name='tmp.gun.sql' value="`'insert into GENERIC_RESOURCE_NAME values ( '
+ ' $generate-unique-name-input.name-table-type , $generate-unique-name-input.supplied-name )'`" />

</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
<parameter name="generate-unique-name-output.error-message" value="Failed insert into GENERIC_RESOURCE_NAME table" />
</return></outcome></save></block></outcome><outcome value='Other'>
<return status='failure'>
<parameter name='generate-unique-name-output.error-message' value="`'The name ' + $generate-unique-name-input.supplied-name + ' has already been used'`" />

</return></outcome></get-resource></block></outcome><outcome value=''><block atomic="true"><switch test='`$generate-unique-name-input.index-table-name`'>
<outcome value=''><return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.index-table-name not supplied' />
</return></outcome></switch><switch test='`$generate-unique-name-input.index-table-prefix-column`'>
<outcome value=''><return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.index-table-prefix-column not supplied' />
</return></outcome></switch><switch test='`$generate-unique-name-input.name-table-type`'>
<outcome value=''><return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.name-table-type not supplied' />
</return></outcome></switch><switch test='`$generate-unique-name-input.prefix`'>
<outcome value=''><return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.prefix not supplied' />
</return></outcome></switch><switch test='`$generate-unique-name-input.index-length`'>
<outcome value=''><set>
<parameter name='tmp.gun.list-end' value='10000' />
</set></outcome><outcome value='1'>
<set>
<parameter name='tmp.gun.list-end' value='10' />
</set></outcome><outcome value='2'>
<set>
<parameter name='tmp.gun.list-end' value='100' />
</set></outcome><outcome value='3'>
<set>
<parameter name='tmp.gun.list-end' value='1000' />
</set></outcome><outcome value='Other'>
<return status='failure'>
<parameter name='generate-unique-name-output.error-message' value='generate-unique-name-input.prefix not supplied' />
</return></outcome></switch><set>
<parameter name='tmp.gun.sql' value="`'SELECT * from ' + $generate-unique-name-input.index-table-name
+ ' WHERE ' + $generate-unique-name-input.index-table-prefix-column + ' = '
+ '$generate-unique-name-input.prefix'`" />
</set><get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='tmp.gun.prefixdb'>

<outcome value='success'>
<block>
<set>
<parameter name='tmp.gun.index-exists' value='true' />
</set><set>
<parameter name='tmp.gun.index-number' value='`$tmp.gun.prefixdb.index-number + 1`' />
</set></block></outcome><outcome value='not-found'>
<block>
<set>
<parameter name='tmp.gun.index-exists' value='false' />
</set><set>
<parameter name='tmp.gun.index-number' value='1' />
</set></block></outcome><outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="`'Error reading the ' + $generate-unique-name-input.index-table-name + ' table'`" />
</return></outcome></get-resource><set>
<parameter name='tmp.gun.found-flag' value='false' />
</set><block>
<for index='tmp.gun.idx' start='`$tmp.gun.index-number`' end='`$tmp.gun.list-end`' >
<block atomic="true"><switch test='`$generate-unique-name-input.index-length`'>
<outcome value=''><set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome><outcome value='1'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome><outcome value='2'>
<switch test='`$tmp.gun.idx &lt; 10`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '0' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome></switch></outcome><outcome value='3'>
<switch test='`$tmp.gun.idx &lt; 10`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '00' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<switch test='`$tmp.gun.idx &lt; 100`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '0' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome></switch></outcome></switch></outcome></switch><set>
<parameter name='tmp.gun.generated-name' value='`$generate-unique-name-input.prefix + $tmp.gun.index-string`' />
</set><set>
<parameter name='tmp.gun.sql' value="`'SELECT * from GENERIC_RESOURCE_NAME WHERE type = $generate-unique-name-input.name-table-type'
+ ' AND name = $tmp.gun.generated-name'`" />
</set><get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='tmp.gun.namedb'>

<outcome value='failure'>
<block atomic="true"><set>
<parameter name='generate-unique-name-output.error-message' value="`'Error reading the GENERIC_RESOURCE_NAME table'`" />
</set><return status='failure'>
</return></block></outcome><outcome value='not-found'>
<block atomic="true"><set>
<parameter name='tmp.gun.found-flag' value='true' />
</set><return status='failure'>
</return></block></outcome></get-resource></block></for><return status='success'>

</return></block><switch test='`$generate-unique-name-output.error-message`'>
<outcome value=''><block>
</block></outcome><outcome value='Other'>
<return status='failure'>
</return></outcome></switch><switch test='`$tmp.gun.found-flag`'>
<outcome value='true'><block atomic="true"><set>
<parameter name='generate-unique-name-output.generated-name' value='`$tmp.gun.generated-name`' />
</set><switch test='`$tmp.gun.index-exists`'>
<outcome value='true'>
<block atomic="true"><set>
<parameter name='tmp.gun.sql' value="`'update ' + $generate-unique-name-input.index-table-name
+ ' set index_number = ' + $tmp.gun.index-string + ' where '
+ $generate-unique-name-input.index-table-prefix-column
+ ' = $generate-unique-name-input.prefix'`" />
</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="`'Failed to update ' + $generate-unique-name-input.index-table-name + ' table'`" />
</return></outcome></save></block></outcome><outcome value='false'>
<block atomic="true"><set>
<parameter name='tmp.gun.sql' value="`'insert into ' + $generate-unique-name-input.index-table-name
+ '(' + $generate-unique-name-input.index-table-prefix-column + ', index_number) values ('
+ ' $generate-unique-name-input.prefix , ' + $tmp.gun.index-string + ')'`" />

</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="`'Failed to insert record into ' + $generate-unique-name-input.index-table-name + ' table'`" />
</return></outcome></save></block></outcome></switch><set>
<parameter name='tmp.gun.sql' value="`'insert into GENERIC_RESOURCE_NAME values ( '
+ ' $generate-unique-name-input.name-table-type , $tmp.gun.generated-name )'`" />

</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="Failed insert into GENERIC_RESOURCE_NAME table" />
</return></outcome></save><return status='success'>
</return></block></outcome><outcome value='false'>
<block atomic="true"><switch test='`$generate-unique-name-input.index-length`'>
<outcome value=''><return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="We have exhausted the naming index count" />
</return></outcome></switch><block>
<for index='tmp.gun.idx' start='1' end='`$tmp.gun.index-number`' >
<block atomic="true"><switch test='`$generate-unique-name-input.index-length`'>
<outcome value=''><set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome><outcome value='1'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome><outcome value='2'>
<switch test='`$tmp.gun.idx &lt; 10`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '0' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome></switch></outcome><outcome value='3'>
<switch test='`$tmp.gun.idx &lt; 10`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '00' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<switch test='`$tmp.gun.idx &lt; 100`'>
<outcome value='true'>
<set>
<parameter name='tmp.gun.index-string' value="`'' + '0' + $tmp.gun.idx`" />
</set></outcome><outcome value='false'>
<set>
<parameter name='tmp.gun.index-string' value='`$tmp.gun.idx`' />
</set></outcome></switch></outcome></switch></outcome></switch><set>
<parameter name='tmp.gun.generated-name' value='`$generate-unique-name-input.prefix + $tmp.gun.index-string`' />
</set><set>
<parameter name='tmp.gun.namedb.name' value='' />
</set><set>
<parameter name='tmp.gun.sql' value="`'SELECT * from GENERIC_RESOURCE_NAME WHERE type = $generate-unique-name-input.name-table-type'
+ ' AND name = $tmp.gun.generated-name'`" />
</set><get-resource plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='tmp.gun.namedb'>

<outcome value='failure'>
<block atomic="true"><set>
<parameter name='generate-unique-name-output.error-message' value="Error reading the GENERIC_RESOURCE_NAME table" />
</set><return status='failure'>
</return></block></outcome><outcome value='not-found'>
<block atomic="true"><set>
<parameter name='tmp.gun.found-flag' value='true' />
</set><return status='failure'>
</return></block></outcome></get-resource></block></for><return status='success'>

</return></block><switch test='`$generate-unique-name-output.error-message`'>
<outcome value=''><block>
</block></outcome><outcome value='Other'>
<return status='failure'>
</return></outcome></switch><switch test='`$tmp.gun.found-flag`'>
<outcome value='true'><block atomic="true"><set>
<parameter name='generate-unique-name-output.generated-name' value='`$tmp.gun.generated-name`' />
</set><switch test='`$tmp.gun.index-exists`'>
<outcome value='true'>
<block atomic="true"><set>
<parameter name='tmp.gun.sql' value="`'update ' + $generate-unique-name-input.index-table-name
+ ' set index_number = ' + $tmp.gun.index-string + ' where '
+ $generate-unique-name-input.index-table-prefix-column
+ ' = $generate-unique-name-input.prefix'`" />
</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="`'Failed to update ' + $generate-unique-name-input.index-table-name + ' table'`" />
</return></outcome></save></block></outcome><outcome value='false'>
<block atomic="true"><set>
<parameter name='tmp.gun.sql' value="`'insert into ' + $generate-unique-name-input.index-table-name
+ '(' + $generate-unique-name-input.index-table-prefix-column + ', index_number) values ('
+ ' $generate-unique-name-input.prefix , ' + $tmp.gun.index-string + ')'`" />

</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="`'Failed to insert record into ' + $generate-unique-name-input.index-table-name + ' table'`" />
</return></outcome></save></block></outcome></switch><set>
<parameter name='tmp.gun.sql' value="`'insert into GENERIC_RESOURCE_NAME values ( '
+ ' $generate-unique-name-input.name-table-type , $tmp.gun.generated-name )'`" />

</set><save plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' resource='SQL'
  key="`$tmp.gun.sql`" pfx='pfx'>
<outcome value='failure'>
<return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="Failed insert into GENERIC_RESOURCE_NAME table" />
</return></outcome></save><return status='success'>

</return></block></outcome></switch><return status='failure'>
    <parameter name="generate-unique-name-output.error-message" value="We have exhausted the naming index count" />
</return></block></outcome></switch></block></outcome></switch></block></method></service-logic>