glexchange 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/glexchange.rb +487 -0
- data/lib/glexchange/header/WsseHeaders.rb +31 -0
- data/lib/glexchange/model/CustomAttribute.rb +20 -0
- data/lib/glexchange/model/Document.rb +85 -0
- data/lib/glexchange/model/LanguageDirection.rb +13 -0
- data/lib/glexchange/model/Project.rb +49 -0
- data/lib/glexchange/model/ProjectDirectorConfig.rb +11 -0
- data/lib/glexchange/model/ReferenceDocument.rb +15 -0
- data/lib/glexchange/model/Submission.rb +19 -0
- data/lib/glexchange/model/Target.rb +35 -0
- data/lib/glexchange/model/WordCount.rb +20 -0
- data/lib/glexchange/model/Workflow.rb +14 -0
- data/lib/glexchange/pdws/DocumentService_4110.rb +1847 -0
- data/lib/glexchange/pdws/DocumentService_4110Driver.rb +81 -0
- data/lib/glexchange/pdws/DocumentService_4110MappingRegistry.rb +1866 -0
- data/lib/glexchange/pdws/ProjectService_4110.rb +1748 -0
- data/lib/glexchange/pdws/ProjectService_4110Driver.rb +74 -0
- data/lib/glexchange/pdws/ProjectService_4110MappingRegistry.rb +1846 -0
- data/lib/glexchange/pdws/SubmissionService_4110.rb +2045 -0
- data/lib/glexchange/pdws/SubmissionService_4110Driver.rb +154 -0
- data/lib/glexchange/pdws/SubmissionService_4110MappingRegistry.rb +2018 -0
- data/lib/glexchange/pdws/TargetService_4110.rb +2041 -0
- data/lib/glexchange/pdws/TargetService_4110Driver.rb +178 -0
- data/lib/glexchange/pdws/TargetService_4110MappingRegistry.rb +2065 -0
- data/lib/glexchange/pdws/UserProfileService_4110.rb +1732 -0
- data/lib/glexchange/pdws/UserProfileService_4110Driver.rb +81 -0
- data/lib/glexchange/pdws/UserProfileService_4110MappingRegistry.rb +1855 -0
- data/lib/glexchange/pdws/WorkflowService_4110.rb +1852 -0
- data/lib/glexchange/pdws/WorkflowService_4110Driver.rb +114 -0
- data/lib/glexchange/pdws/WorkflowService_4110MappingRegistry.rb +1927 -0
- metadata +87 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a3c2d765532d6f675afa34861775d0d7de492f29
|
|
4
|
+
data.tar.gz: 10b97291b7c6c89b7213a3ec3cfaa2fbcae60ea9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8b8e58fb00c542513d696891ac8a491c428175dabad10267d4863400695d2e0a5348b2d537a435402872dfc117b139afb0951b6f5c41ac99b266b62b3ec4cd80
|
|
7
|
+
data.tar.gz: 71eb6104d6eaa5b9ecb9f98d5d360deb0b3c13510fff965b86665725468725c270f454a7b0bbd796cfb5e2f243c7ec631b22400efba19fb8e2f3535b765cfec5
|
data/lib/glexchange.rb
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "base64"
|
|
3
|
+
require 'glexchange/pdws/DocumentService_4110Driver.rb'
|
|
4
|
+
require 'glexchange/pdws/ProjectService_4110Driver.rb'
|
|
5
|
+
require 'glexchange/pdws/SubmissionService_4110Driver.rb'
|
|
6
|
+
require 'glexchange/pdws/TargetService_4110Driver.rb'
|
|
7
|
+
require 'glexchange/pdws/UserProfileService_4110Driver.rb'
|
|
8
|
+
require 'glexchange/pdws/WorkflowService_4110Driver.rb'
|
|
9
|
+
require 'glexchange/header/WsseHeaders.rb'
|
|
10
|
+
require 'glexchange/model/ProjectDirectorConfig'
|
|
11
|
+
require 'glexchange/model/Project'
|
|
12
|
+
require 'glexchange/model/Document'
|
|
13
|
+
require 'glexchange/model/Submission'
|
|
14
|
+
require 'glexchange/model/Target'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GLExchange
|
|
18
|
+
@connectionConfig
|
|
19
|
+
@submission
|
|
20
|
+
|
|
21
|
+
@documentService
|
|
22
|
+
@projectService
|
|
23
|
+
@submissionService
|
|
24
|
+
@targetService
|
|
25
|
+
@userProfileService
|
|
26
|
+
@workflowService
|
|
27
|
+
|
|
28
|
+
def initialize(config)
|
|
29
|
+
setConnectionConfig(config)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def cancelDocument (documentTicket, locale = nil)
|
|
33
|
+
if locale != nil
|
|
34
|
+
cancelTargetRequest = Glexchange::Pdws::CancelDocument.new (documentTicket)
|
|
35
|
+
return @targetService.cancelTarget ( cancelTargetRequest )
|
|
36
|
+
else
|
|
37
|
+
dticket = Glexchange::Pdws::DocumentTicket.new
|
|
38
|
+
dticket.ticketId = documentTicket
|
|
39
|
+
cancelDocumentRequest = Glexchange::Pdws::CancelTargetByDocumentId.new(dticket, locale)
|
|
40
|
+
return @targetService.cancelTargetByDocumentId ( cancelDocumentRequest )
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def cancelSubmission (submissionTicket, comment = nil)
|
|
45
|
+
if comment == nil
|
|
46
|
+
cancelSubmissionRequest = Glexchange::Pdws::CancelSubmission.new(submissionTicket)
|
|
47
|
+
response = @submissionService.cancelSubmission ( cancelSubmissionRequest )
|
|
48
|
+
return response.m_return
|
|
49
|
+
else
|
|
50
|
+
cancelSubmissionRequest = Glexchange::Pdws::CancelSubmissionWithComment.new(submissionTicket, comment)
|
|
51
|
+
response = @submissionService.cancelSubmissionWithComment ( cancelSubmissionRequest )
|
|
52
|
+
return response.m_return
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def downloadTarget (ticket)
|
|
57
|
+
downloadTargetResourceRequest = Glexchange::Pdws::DownloadTargetResource.new(ticket)
|
|
58
|
+
response = @targetService.downloadTargetResource ( downloadTargetResourceRequest )
|
|
59
|
+
repositoryItem = response.m_return
|
|
60
|
+
|
|
61
|
+
return Base64.decode64(repositoryItem.data)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def getCancelledTargets (maxResults)
|
|
65
|
+
projects = getProjects
|
|
66
|
+
tickets = Array.new
|
|
67
|
+
for project in projects
|
|
68
|
+
tickets << project.ticket
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
getCanceledTargetsByProjectsRequest = Glexchange::Pdws::GetCanceledTargetsByProjects.new(tickets, maxResults)
|
|
72
|
+
cancelledTargets = @targetService.getCanceledTargetsByProjects ( getCanceledTargetsByProjectsRequest )
|
|
73
|
+
|
|
74
|
+
result = Array.new
|
|
75
|
+
for externalTarget in cancelledTargets
|
|
76
|
+
result << Glexchange::Model::PDTarget.new(externalTarget)
|
|
77
|
+
end
|
|
78
|
+
return result
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def getCancelledTargetsBySubmission(submissionTicket, maxResults)
|
|
82
|
+
getCancelledTargetsBySubmissionRequest = Glexchange::Pdws::GetCanceledTargetsBySubmissions.new
|
|
83
|
+
getCancelledTargetsBySubmissionRequest.maxResults = maxResults
|
|
84
|
+
getCancelledTargetsBySubmissionRequest.submissionTickets = Array.new
|
|
85
|
+
getCancelledTargetsBySubmissionRequest.submissionTickets << submissionTicket
|
|
86
|
+
|
|
87
|
+
cancelledTargets = @targetService.getCanceledTargetsBySubmissions ( getCancelledTargetsBySubmissionRequest )
|
|
88
|
+
result = Array.new
|
|
89
|
+
for externalTarget in cancelledTargets
|
|
90
|
+
result << Glexchange::Model::PDTarget.new(externalTarget)
|
|
91
|
+
end
|
|
92
|
+
return result
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def getCompletedTargets (maxResults)
|
|
97
|
+
projects = getProjects
|
|
98
|
+
tickets = Array.new
|
|
99
|
+
for project in projects
|
|
100
|
+
tickets << project.ticket
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
getCompletedTargetsByProjectsRequest = Glexchange::Pdws::GetCompletedTargetsByProjects.new(tickets, maxResults)
|
|
104
|
+
|
|
105
|
+
completedTargets = @targetService.getCompletedTargetsByProjects ( getCompletedTargetsByProjectsRequest )
|
|
106
|
+
|
|
107
|
+
result = Array.new
|
|
108
|
+
for externalTarget in completedTargets
|
|
109
|
+
result << Glexchange::Model::PDTarget.new(externalTarget)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def getCompletedTargetsByProject (project, maxResults )
|
|
116
|
+
getCompletedTargetsByProjectsRequest = Glexchange::Pdws::GetCompletedTargetsByProjects.new
|
|
117
|
+
|
|
118
|
+
getCompletedTargetsByProjectsRequest.projectTickets = Array.new
|
|
119
|
+
getCompletedTargetsByProjectsRequest.projectTickets << project.ticket
|
|
120
|
+
getCompletedTargetsByProjectsRequest.maxResults = maxResults
|
|
121
|
+
|
|
122
|
+
completedTargets = @targetService.getCompletedTargetsByProjects ( getCompletedTargetsByProjectsRequest )
|
|
123
|
+
result = Array.new
|
|
124
|
+
for externalTarget in completedTargets
|
|
125
|
+
result << Glexchange::Model::PDTarget.new(externalTarget)
|
|
126
|
+
end
|
|
127
|
+
return result
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def getCompletedTargetsBySubmission(submissionTicket, maxResults)
|
|
131
|
+
getCompletedTargetsBySubmissionsRequest = Glexchange::Pdws::GetCompletedTargetsBySubmissions.new
|
|
132
|
+
|
|
133
|
+
getCompletedTargetsBySubmissionsRequest.submissionTickets = Array.new
|
|
134
|
+
getCompletedTargetsBySubmissionsRequest.submissionTickets << submissionTicket
|
|
135
|
+
getCompletedTargetsBySubmissionsRequest.maxResults = maxResults
|
|
136
|
+
|
|
137
|
+
completedTargets = @targetService.getCompletedTargetsBySubmissions ( getCompletedTargetsBySubmissionsRequest )
|
|
138
|
+
|
|
139
|
+
result = Array.new
|
|
140
|
+
for externalTarget in completedTargets
|
|
141
|
+
result << Glexchange::Model::PDTarget.new(externalTarget)
|
|
142
|
+
end
|
|
143
|
+
return result
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def getProject(shortCode)
|
|
147
|
+
request = Glexchange::Pdws::FindProjectByShortCode.new
|
|
148
|
+
request.projectShortCode = shortCode
|
|
149
|
+
return Glexchange::Model::PDProject.new(@projectService.findProjectByShortCode(request).m_return)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def getProjects
|
|
153
|
+
projects = Array.new
|
|
154
|
+
getUserProjectsResponse= @projectService.getUserProjects(Glexchange::Pdws::GetUserProjects.new(true))
|
|
155
|
+
for project in getUserProjectsResponse
|
|
156
|
+
projects << Glexchange::Model::PDProject.new(project)
|
|
157
|
+
end
|
|
158
|
+
return projects
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def getSubmissionName (submissionTicket)
|
|
162
|
+
findSubmissionByTicketRequest = Glexchange::Pdws::FindByTicket.new (submissionTicket)
|
|
163
|
+
|
|
164
|
+
response = @submissionService.findByTicket ( findSubmissionByTicketRequest )
|
|
165
|
+
if response != nil
|
|
166
|
+
return response.m_return.submissionInfo.name
|
|
167
|
+
else
|
|
168
|
+
raise "Invalid submission ticket"
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def getSubmissionTicket
|
|
173
|
+
if @submission != nil && @submission.ticket != nil
|
|
174
|
+
return @submission.ticket
|
|
175
|
+
else
|
|
176
|
+
raise "Submission not initialized"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def getUnstartedSubmissions (project)
|
|
181
|
+
submissions = Array.new
|
|
182
|
+
findCreatingSubmissionsByProjectShortCodeRequest = Glexchange::Pdws::FindCreatingSubmissionsByProjectShortCode.new (project.shortCode)
|
|
183
|
+
creatingSubmissions = @submissionService.findCreatingSubmissionsByProjectShortCode(findCreatingSubmissionsByProjectShortCodeRequest)
|
|
184
|
+
for creatingSubmission in creatingSubmissions
|
|
185
|
+
sub = Glexchange::Model::Submission.new
|
|
186
|
+
sub.ticket = creatingSubmission.ticket
|
|
187
|
+
sub.name = creatingSubmission.submissionInfo.name
|
|
188
|
+
submissions << sub
|
|
189
|
+
end
|
|
190
|
+
return submissions
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def initSubmission(submission)
|
|
194
|
+
validateSubmission ( submission )
|
|
195
|
+
|
|
196
|
+
@submission = submission
|
|
197
|
+
@submission.ticket = ""
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def isSubmitterValid(shortCode, submitter)
|
|
201
|
+
getSubmittersRequest = Glexchange::Pdws::GetSubmitters.new (shortCode)
|
|
202
|
+
submitters = @userProfileService.GetSubmitters(getSubmittersRequest)
|
|
203
|
+
for submitter in submitters
|
|
204
|
+
info = submitter.userInfo
|
|
205
|
+
if(info.userName == submitter && info.enabled && !info.accountLocked && info.accountNonExpired)
|
|
206
|
+
return true
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
return false
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def sendDownloadConfirmation (ticket)
|
|
214
|
+
sendDownloadConfirmationRequest = Glexchange::Pdws::SendDownloadConfirmation.new (ticket)
|
|
215
|
+
response = @targetService.sendDownloadConfirmation ( sendDownloadConfirmationRequest )
|
|
216
|
+
|
|
217
|
+
return response.m_return
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def startSubmission
|
|
221
|
+
if @submission == nil || @submission.project == nil || @submission.name == nil
|
|
222
|
+
raise "Please initialize submission first."
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
if @submission.ticket == nil || @submission.ticket == ""
|
|
226
|
+
raise "Please upload a translatable document first."
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
submissionInfo = createSubmissionInfo
|
|
230
|
+
|
|
231
|
+
startSubmissionRequest = Glexchange::Pdws::StartSubmission.new(@submission.ticket, submissionInfo)
|
|
232
|
+
@submissionService.startSubmission ( startSubmissionRequest )
|
|
233
|
+
|
|
234
|
+
submissionTicket = @submission.ticket
|
|
235
|
+
@submission = nil
|
|
236
|
+
|
|
237
|
+
return submissionTicket
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def uploadReference (referenceDocument)
|
|
241
|
+
if referenceDocument == nil || referenceDocument.data == nil
|
|
242
|
+
raise "Document is empty"
|
|
243
|
+
end
|
|
244
|
+
if referenceDocument.name == nil
|
|
245
|
+
raise "Document name not set"
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
if @submission == nil || @submission.ticket == nil
|
|
249
|
+
raise "Submission not initialized."
|
|
250
|
+
end
|
|
251
|
+
if @submission.ticket == ""
|
|
252
|
+
raise "Invalid submission ticket. Please upload a translatable document before attempting to upload reference documents."
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
uploadReferenceRequest = Glexchange::Pdws::UploadReference.new
|
|
256
|
+
uploadReferenceRequest.data = Base64.encode64(referenceDocument.data)
|
|
257
|
+
uploadReferenceRequest.submissionId = @submission.ticket
|
|
258
|
+
uploadReferenceRequest.resourceInfo = referenceDocument.getResourceInfo
|
|
259
|
+
|
|
260
|
+
response = @submissionService.uploadReference ( uploadReferenceRequest )
|
|
261
|
+
return response.m_return
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def uploadTranslatable (document)
|
|
265
|
+
if @submission==nil or @submission.ticket==nil
|
|
266
|
+
raise "Submission not initialized."
|
|
267
|
+
end
|
|
268
|
+
validateDocument ( document )
|
|
269
|
+
|
|
270
|
+
documentInfo = document.getDocumentInfo ( @submission )
|
|
271
|
+
resourceInfo = document.getResourceInfo
|
|
272
|
+
|
|
273
|
+
submitDocumentWithBinaryTextRequest = Glexchange::Pdws::SubmitDocumentWithTextResource.new(documentInfo, resourceInfo, document.data)
|
|
274
|
+
response = @documentService.submitDocumentWithTextResource ( submitDocumentWithBinaryTextRequest )
|
|
275
|
+
documentTicket = response.m_return
|
|
276
|
+
|
|
277
|
+
if documentTicket != nil
|
|
278
|
+
@submission.ticket = documentTicket.submissionTicket
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
return documentTicket.ticketId
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
private
|
|
285
|
+
def createSubmissionInfo
|
|
286
|
+
submissionInfo = Glexchange::Pdws::SubmissionInfo.new
|
|
287
|
+
submissionInfo.projectTicket = @submission.project.ticket
|
|
288
|
+
submissionInfo.name = @submission.name
|
|
289
|
+
if @submission.pmNotes != nil
|
|
290
|
+
submissionInfo.internalNotes = @submission.pmNotes
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
if @submission.dueDate != nil
|
|
294
|
+
dateRequested = Glexchange::Pdws::Date.new
|
|
295
|
+
dateRequested.date = @submission.dueDate*1000
|
|
296
|
+
dateRequested.critical = false
|
|
297
|
+
submissionInfo.dateRequested = dateRequested
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
metadatas = Array.new
|
|
301
|
+
if @submission.metadata != nil
|
|
302
|
+
for key in @submission.metadata.keys
|
|
303
|
+
metadatas << Glexchange::Pdws::Metadata.new(key[0...255], @submission.metadata[key][0...1024])
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
submissionInfo.metadata = metadatas
|
|
307
|
+
|
|
308
|
+
if @submission.submitter != nil
|
|
309
|
+
submissionInfo.submitters = Array.new
|
|
310
|
+
submissionInfo.submitters << @submission.submitter
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
priority = Glexchange::Pdws::Priority.new
|
|
314
|
+
priority.value = 1
|
|
315
|
+
if @submission.isUrgent != nil && @submission.isUrgent == true
|
|
316
|
+
priority.value = 2
|
|
317
|
+
end
|
|
318
|
+
submissionInfo.priority = priority
|
|
319
|
+
|
|
320
|
+
attributes = Array.new
|
|
321
|
+
if @submission.customAttributes != nil
|
|
322
|
+
for key in @submission.customAttributes.keys
|
|
323
|
+
attributes << Glexchange::Pdws::SubmissionCustomFields.new(key, @submission.customAttributes[key])
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
submissionInfo.submissionCustomFields = attributes
|
|
327
|
+
|
|
328
|
+
if @submission.workflow != nil && @submission.workflow.ticket != ""
|
|
329
|
+
submissionInfo.workflowDefinitionTicket = @submission.workflow.ticket
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
return submissionInfo
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def validateDocument (document)
|
|
336
|
+
if document == nil || document.data == nil || document.data.length < 1
|
|
337
|
+
raise "Document is empty"
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
if document.name == nil
|
|
341
|
+
raise "Document name not set"
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
if document.fileformat != "Non-Parsable"
|
|
345
|
+
isFileFormatCorrect = false
|
|
346
|
+
for fileFormat in @submission.project.fileFormats
|
|
347
|
+
if fileFormat == document.fileformat
|
|
348
|
+
isFileFormatCorrect = true
|
|
349
|
+
break
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
if isFileFormatCorrect == false
|
|
353
|
+
raise "Specified file format '#{document.fileformat}' doesn`t exist in specified project"
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
if document.sourceLanguage == nil || document.sourceLanguage.length < 2
|
|
359
|
+
raise "Source language not set"
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
if document.targetLanguages == nil || document.targetLanguages.length < 1
|
|
363
|
+
raise "Target languages are not set"
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
for language in document.targetLanguages
|
|
367
|
+
isTargetLanguageFound = false
|
|
368
|
+
for languageDirection in @submission.project.languageDirections
|
|
369
|
+
if languageDirection.sourceLanguage == document.sourceLanguage && languageDirection.targetLanguage == language
|
|
370
|
+
isTargetLanguageFound = true
|
|
371
|
+
break
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
if isTargetLanguageFound == false
|
|
375
|
+
raise "Project is not configured for language direction '#{document.sourceLanguage} - #{language}'"
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
def validateSubmission (submission)
|
|
381
|
+
if submission == nil
|
|
382
|
+
raise "Please initialize submission first."
|
|
383
|
+
end
|
|
384
|
+
if submission.project == nil
|
|
385
|
+
raise "Please set submission project"
|
|
386
|
+
end
|
|
387
|
+
if submission.name == nil
|
|
388
|
+
raise "Please set submission name"
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
if submission.workflow != nil
|
|
392
|
+
isSet = false
|
|
393
|
+
for workflow in submission.project.workflows
|
|
394
|
+
if workflow.ticket == submission.workflow.ticket
|
|
395
|
+
isSet = true
|
|
396
|
+
break
|
|
397
|
+
end
|
|
398
|
+
end
|
|
399
|
+
if isSet == false
|
|
400
|
+
raise "Invalid submission workflow #{submission.workflow.name}"
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
if submission.dueDate != nil
|
|
405
|
+
if ((Date.today.to_time.to_i) > submission.dueDate)
|
|
406
|
+
raise "Submission due date should be greater than current date"
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
if submission.submitter != nil
|
|
411
|
+
isSubmitterExists = false
|
|
412
|
+
|
|
413
|
+
submitters = @userProfileService.getSubmitters( Glexchange::Pdws::GetSubmitters.new(submission.project.shortCode) )
|
|
414
|
+
if submitters != nil
|
|
415
|
+
for submitter in submitters
|
|
416
|
+
if submission.submitter == submitter.userInfo.userName
|
|
417
|
+
isSubmitterExists = true
|
|
418
|
+
break
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
if isSubmitterExists == false
|
|
424
|
+
raise "Specified submitter '#{submission.submitter}' doesn`t exist"
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
if submission.project.customAttributes != nil
|
|
429
|
+
for projectCustomAttribute in submission.project.customAttributes
|
|
430
|
+
if projectCustomAttribute.mandatory
|
|
431
|
+
isSet = false
|
|
432
|
+
if submission.customAttributes !=nil
|
|
433
|
+
for submissionCustomAttribute in submission.customAttributes
|
|
434
|
+
if submissionCustomAttribute.name == projectCustomAttribute.name
|
|
435
|
+
isSet = true
|
|
436
|
+
break
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
if isSet == false
|
|
441
|
+
raise "Mandatory custom field '#{projectCustomAttribute.name}' is not set"
|
|
442
|
+
end
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def addHeaders (obj)
|
|
449
|
+
obj.headerhandler << Glexchange::Header::WsseAuthHeader.new(@connectionConfig.username, @connectionConfig.password)
|
|
450
|
+
obj.headerhandler << Glexchange::Header::WsseUserAgentHeader.new(@connectionConfig.userAgent)
|
|
451
|
+
#obj.options["soap.envelope.no_indent"] = true
|
|
452
|
+
return obj
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def setConnectionConfig(config = nil)
|
|
456
|
+
if config==nil
|
|
457
|
+
raise "Config is nil"
|
|
458
|
+
elsif config.url==nil or config.url.length<7
|
|
459
|
+
raise "PD Url not set"
|
|
460
|
+
elsif config.username==nil or config.username.length<=0
|
|
461
|
+
raise "Username not set"
|
|
462
|
+
elsif config.password==nil or config.password.length<=0
|
|
463
|
+
raise "Password not set"
|
|
464
|
+
elsif config.userAgent==nil or config.userAgent.length<=0
|
|
465
|
+
raise "UserAgent not set"
|
|
466
|
+
end
|
|
467
|
+
@connectionConfig = config
|
|
468
|
+
|
|
469
|
+
if @connectionConfig.url[-1,1]=='/' then
|
|
470
|
+
@connectionConfig.url = @connectionConfig.url.chomp.chop
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
@documentService = addHeaders(Glexchange::Pdws::DocumentServicePortType.new(@connectionConfig.url + "/services/DocumentService"))
|
|
474
|
+
@projectService = addHeaders(Glexchange::Pdws::ProjectServicePortType.new(@connectionConfig.url + "/services/ProjectService"))
|
|
475
|
+
@submissionService = addHeaders(Glexchange::Pdws::SubmissionServicePortType.new(@connectionConfig.url + "/services/SubmissionService"))
|
|
476
|
+
@targetService = addHeaders(Glexchange::Pdws::TargetServicePortType.new(@connectionConfig.url + "/services/TargetService"))
|
|
477
|
+
@userProfileService = addHeaders(Glexchange::Pdws::UserProfileServicePortType.new(@connectionConfig.url + "/services/UserProfileService"))
|
|
478
|
+
@workflowService = addHeaders(Glexchange::Pdws::WorkflowServicePortType.new(@connectionConfig.url + "/services/WorkflowService"))
|
|
479
|
+
|
|
480
|
+
begin
|
|
481
|
+
@projectService.getUserProjects(Glexchange::Pdws::GetUserProjects.new(true))
|
|
482
|
+
rescue Exception
|
|
483
|
+
raise "Invalid config. " + $!.to_s
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
end
|
|
487
|
+
end
|