/machinelearning/5.0.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core/HumanTaskNodeWrapper.java

https://github.com/etirelli/droolsjbpm-contributed-experiments · Java · 102 lines · 69 code · 13 blank · 20 comment · 6 complexity · b7ed32a2d4ae9bc776f511924cd4de2b MD5 · raw file

  1. package org.drools.eclipse.flow.ruleflow.core;
  2. /*
  3. * Copyright 2005 JBoss Inc
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import java.util.HashSet;
  18. import java.util.Set;
  19. import org.drools.eclipse.flow.common.editor.editpart.work.HumanTaskCustomEditor;
  20. import org.drools.process.core.ParameterDefinition;
  21. import org.drools.process.core.WorkDefinition;
  22. import org.drools.process.core.datatype.impl.type.StringDataType;
  23. import org.drools.process.core.impl.ParameterDefinitionImpl;
  24. import org.drools.process.core.impl.WorkDefinitionExtensionImpl;
  25. import org.drools.process.core.impl.WorkDefinitionImpl;
  26. import org.drools.workflow.core.node.HumanTaskNode;
  27. import org.eclipse.ui.views.properties.IPropertyDescriptor;
  28. import org.eclipse.ui.views.properties.TextPropertyDescriptor;
  29. /**
  30. * Wrapper for a human task node.
  31. *
  32. * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
  33. */
  34. public class HumanTaskNodeWrapper extends WorkItemWrapper {
  35. public static final String SWIMLANE = "Swimlane";
  36. private static final long serialVersionUID = 4L;
  37. private static final WorkDefinition WORK_DEFINITION;
  38. static {
  39. WORK_DEFINITION = new WorkDefinitionExtensionImpl();
  40. ((WorkDefinitionImpl) WORK_DEFINITION).setName("Human Task");
  41. Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
  42. parameterDefinitions.add(new ParameterDefinitionImpl("TaskName", new StringDataType()));
  43. parameterDefinitions.add(new ParameterDefinitionImpl("ActorId", new StringDataType()));
  44. parameterDefinitions.add(new ParameterDefinitionImpl("Priority", new StringDataType()));
  45. parameterDefinitions.add(new ParameterDefinitionImpl("Comment", new StringDataType()));
  46. parameterDefinitions.add(new ParameterDefinitionImpl("Skippable", new StringDataType()));
  47. parameterDefinitions.add(new ParameterDefinitionImpl("Content", new StringDataType()));
  48. ((WorkDefinitionExtensionImpl) WORK_DEFINITION).setParameters(parameterDefinitions);
  49. ((WorkDefinitionExtensionImpl) WORK_DEFINITION).setIcon("icons/human_task.gif");
  50. ((WorkDefinitionExtensionImpl) WORK_DEFINITION).setCustomEditor(HumanTaskCustomEditor.class.getName());
  51. }
  52. public HumanTaskNodeWrapper() {
  53. setNode(new HumanTaskNode());
  54. getNode().setName("Human Task");
  55. setWorkDefinition(WORK_DEFINITION);
  56. }
  57. protected void initDescriptors() {
  58. super.initDescriptors();
  59. IPropertyDescriptor[] parentDescriptors = descriptors;
  60. IPropertyDescriptor[] descriptors = new IPropertyDescriptor[parentDescriptors.length + 1];
  61. System.arraycopy(parentDescriptors, 0, descriptors, 0, parentDescriptors.length);
  62. descriptors[descriptors.length - 1] =
  63. new TextPropertyDescriptor(SWIMLANE, "Swimlane");
  64. }
  65. public HumanTaskNode getHumanTaskNode() {
  66. return (HumanTaskNode) getNode();
  67. }
  68. public Object getPropertyValue(Object id) {
  69. if (SWIMLANE.equals(id)) {
  70. String swimlane = getHumanTaskNode().getSwimlane();
  71. return swimlane == null ? "" : swimlane;
  72. }
  73. return super.getPropertyValue(id);
  74. }
  75. public void resetPropertyValue(Object id) {
  76. if (SWIMLANE.equals(id)) {
  77. getHumanTaskNode().setSwimlane(null);
  78. } else {
  79. super.resetPropertyValue(id);
  80. }
  81. }
  82. public void setPropertyValue(Object id, Object value) {
  83. if (SWIMLANE.equals(id)) {
  84. getHumanTaskNode().setSwimlane((String) value);
  85. } else {
  86. super.setPropertyValue(id, value);
  87. }
  88. }
  89. }