|
39 | 39 | import org.silverpeas.core.contribution.content.form.Form;
|
40 | 40 | import org.silverpeas.core.contribution.content.form.RecordTemplate;
|
41 | 41 | import org.silverpeas.core.contribution.content.form.field.MultipleUserField;
|
| 42 | +import org.silverpeas.core.contribution.content.form.record.GenericDataRecord; |
42 | 43 | import org.silverpeas.core.util.DateUtil;
|
43 | 44 | import org.silverpeas.core.util.file.FileRepositoryManager;
|
| 45 | +import org.silverpeas.core.workflow.api.event.TaskDoneEvent; |
| 46 | +import org.silverpeas.core.workflow.api.model.Action; |
44 | 47 | import org.silverpeas.kernel.logging.SilverLogger;
|
45 | 48 | import org.silverpeas.core.web.rs.annotation.Authorized;
|
46 | 49 | import org.silverpeas.core.workflow.api.Workflow;
|
@@ -409,66 +412,66 @@ public WorkflowFormActionDTO getActionForm(@PathParam("instanceId") String insta
|
409 | 412 | } else {
|
410 | 413 | ProcessInstance instance =
|
411 | 414 | Workflow.getProcessInstanceManager().getProcessInstance(instanceId);
|
412 |
| - |
413 | 415 | form = instance.getProcessModel().getActionForm(action);
|
414 | 416 | data = instance.getFolder();
|
415 | 417 | dto.setId(instance.getInstanceId());
|
416 | 418 | }
|
417 |
| - |
418 |
| - for (Input input : form.getInputs()) { |
419 |
| - WorkflowFieldDTO fdto = new WorkflowFieldDTO(); |
420 |
| - fdto.setId(getComponentId()); |
421 |
| - fdto.setDisplayerName(input.getDisplayerName()); |
422 |
| - fdto.setMandatory(input.isMandatory()); |
423 |
| - fdto.setReadOnly(input.isReadonly()); |
424 |
| - fdto.setName(input.getItem().getName()); |
425 |
| - fdto.setActionName(action); |
426 |
| - fdto.setLabel( |
427 |
| - input.getItem().getLabel(role, getUser().getUserPreferences().getLanguage())); |
428 |
| - fdto.setValue(input.getValue()); |
429 |
| - if (!action.equals("create")) { |
430 |
| - Field f = data.getField(input.getItem().getName()); |
431 |
| - if (f.getValue() != null && !f.getValue().isEmpty()) { |
432 |
| - if (input.getItem().getType().equalsIgnoreCase("date")) { |
433 |
| - fdto.setValue(f.getValue().replaceAll("/", "-")); |
434 |
| - //TODO : user, multipleUser, group data |
435 |
| - } else if (input.getItem().getType().equalsIgnoreCase("user")) { |
436 |
| - UserDetail u = (UserDetail) f.getObjectValue(); |
437 |
| - fdto.setValueId(u.getId()); |
438 |
| - fdto.setValue(f.getValue()); |
439 |
| - } else if (input.getItem().getType().equalsIgnoreCase("multipleUser")) { |
440 |
| - String[] usersId = ((MultipleUserField) f).getUserIds(); |
441 |
| - if (usersId.length > 0) { |
442 |
| - String ids = Arrays.toString(usersId); |
443 |
| - ids = ids.substring(1, ids.length() - 1); |
444 |
| - fdto.setValueId(ids); |
445 |
| - String value = ""; |
446 |
| - for (String id : usersId) { |
447 |
| - value += Administration.get().getUserDetail(id).getDisplayedName() + ","; |
| 419 | + if (form != null) { |
| 420 | + for (Input input : form.getInputs()) { |
| 421 | + WorkflowFieldDTO fdto = new WorkflowFieldDTO(); |
| 422 | + fdto.setId(getComponentId()); |
| 423 | + fdto.setDisplayerName(input.getDisplayerName()); |
| 424 | + fdto.setMandatory(input.isMandatory()); |
| 425 | + fdto.setReadOnly(input.isReadonly()); |
| 426 | + fdto.setName(input.getItem().getName()); |
| 427 | + fdto.setActionName(action); |
| 428 | + fdto.setLabel( |
| 429 | + input.getItem().getLabel(role, getUser().getUserPreferences().getLanguage())); |
| 430 | + fdto.setValue(input.getValue()); |
| 431 | + if (!action.equals("create")) { |
| 432 | + Field f = data.getField(input.getItem().getName()); |
| 433 | + if (f.getValue() != null && !f.getValue().isEmpty()) { |
| 434 | + if (input.getItem().getType().equalsIgnoreCase("date")) { |
| 435 | + fdto.setValue(f.getValue().replaceAll("/", "-")); |
| 436 | + //TODO : user, multipleUser, group data |
| 437 | + } else if (input.getItem().getType().equalsIgnoreCase("user")) { |
| 438 | + UserDetail u = (UserDetail) f.getObjectValue(); |
| 439 | + fdto.setValueId(u.getId()); |
| 440 | + fdto.setValue(f.getValue()); |
| 441 | + } else if (input.getItem().getType().equalsIgnoreCase("multipleUser")) { |
| 442 | + String[] usersId = ((MultipleUserField) f).getUserIds(); |
| 443 | + if (usersId.length > 0) { |
| 444 | + String ids = Arrays.toString(usersId); |
| 445 | + ids = ids.substring(1, ids.length() - 1); |
| 446 | + fdto.setValueId(ids); |
| 447 | + String value = ""; |
| 448 | + for (String id : usersId) { |
| 449 | + value += Administration.get().getUserDetail(id).getDisplayedName() + ","; |
| 450 | + } |
| 451 | + value = value.substring(0, value.length() - 1); |
| 452 | + fdto.setValue(value); |
448 | 453 | }
|
449 |
| - value = value.substring(0, value.length() - 1); |
450 |
| - fdto.setValue(value); |
| 454 | + } else if (input.getItem().getType().equalsIgnoreCase("group")) { |
| 455 | + GroupDetail g = (GroupDetail) f.getObjectValue(); |
| 456 | + fdto.setValueId(g.getId()); |
| 457 | + fdto.setValue(f.getValue()); |
| 458 | + } else if (input.getItem().getType().equalsIgnoreCase("file")) { |
| 459 | + SimpleDocument doc = AttachmentServiceProvider.getAttachmentService() |
| 460 | + .searchDocumentById(new SimpleDocumentPK(f.getValue()), |
| 461 | + getUser().getUserPreferences().getLanguage()); |
| 462 | + fdto.setValue(doc.getTitle()); |
| 463 | + fdto.setValueId(doc.getId()); |
| 464 | + } else { |
| 465 | + fdto.setValue(f.getValue()); |
451 | 466 | }
|
452 |
| - } else if (input.getItem().getType().equalsIgnoreCase("group")) { |
453 |
| - GroupDetail g = (GroupDetail) f.getObjectValue(); |
454 |
| - fdto.setValueId(g.getId()); |
455 |
| - fdto.setValue(f.getValue()); |
456 |
| - } else if (input.getItem().getType().equalsIgnoreCase("file")) { |
457 |
| - SimpleDocument doc = AttachmentServiceProvider.getAttachmentService() |
458 |
| - .searchDocumentById(new SimpleDocumentPK(f.getValue()), |
459 |
| - getUser().getUserPreferences().getLanguage()); |
460 |
| - fdto.setValue(doc.getTitle()); |
461 |
| - fdto.setValueId(doc.getId()); |
462 |
| - } else { |
463 |
| - fdto.setValue(f.getValue()); |
464 | 467 | }
|
465 | 468 | }
|
| 469 | + fdto.setType(input.getItem().getType()); |
| 470 | + fdto.setValues(input.getItem().getKeyValuePairs()); |
| 471 | + dto.addField(fdto); |
466 | 472 | }
|
467 |
| - fdto.setType(input.getItem().getType()); |
468 |
| - fdto.setValues(input.getItem().getKeyValuePairs()); |
469 |
| - dto.addField(fdto); |
| 473 | + dto.setTitle(form.getTitle(role, getUser().getUserPreferences().getLanguage())); |
470 | 474 | }
|
471 |
| - dto.setTitle(form.getTitle(role, getUser().getUserPreferences().getLanguage())); |
472 | 475 | } catch (Exception e) {
|
473 | 476 | SilverLogger.getLogger(this).error(e);
|
474 | 477 | throw e;
|
|
0 commit comments