提交 ec992659 编写于 作者: T tombaeyens

ACT-258 added form display and form submit properties parsing

上级 5dc90c00
......@@ -33,7 +33,7 @@ import org.activiti.pvm.activity.SignallableActivityBehavior;
public class ServiceTaskDelegateActivityBehaviour implements SignallableActivityBehavior {
protected ActivitiValueExpression expression;
protected ActivityBehavior activityBehaviorImplementation;
protected Class<? extends ActivityBehavior> activityBehaviorType;
protected List<FieldDeclaration> fieldDeclarations;
public ServiceTaskDelegateActivityBehaviour(ActivitiValueExpression expression, List<FieldDeclaration> fieldDeclarations) {
......@@ -41,16 +41,16 @@ public class ServiceTaskDelegateActivityBehaviour implements SignallableActivity
this.fieldDeclarations = fieldDeclarations;
}
public ServiceTaskDelegateActivityBehaviour(ActivityBehavior activityBehaviorImplementation, List<FieldDeclaration> fieldDeclarations) {
this.activityBehaviorImplementation = activityBehaviorImplementation;
public ServiceTaskDelegateActivityBehaviour(Class<? extends ActivityBehavior> activityBehaviorType, List<FieldDeclaration> fieldDeclarations) {
this.activityBehaviorType = activityBehaviorType;
this.fieldDeclarations = fieldDeclarations;
}
public void execute(ActivityExecution execution) throws Exception {
Object object = null;
if (activityBehaviorImplementation != null) {
object = activityBehaviorImplementation;
if (activityBehaviorType != null) {
object = activityBehaviorType.newInstance();
} else {
object = expression.getValue(execution);
......
......@@ -55,12 +55,16 @@ import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.el.UelMethodExpressionCondition;
import org.activiti.engine.impl.el.UelValueExpressionCondition;
import org.activiti.engine.impl.form.DefaultStartFormHandler;
import org.activiti.engine.impl.form.DefaultTaskFormHandler;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.scripting.ScriptingEngines;
import org.activiti.engine.impl.task.TaskDefinition;
import org.activiti.engine.impl.util.ReflectUtil;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.util.xml.Parse;
import org.activiti.engine.impl.variable.VariableDeclaration;
......@@ -449,12 +453,16 @@ public class BpmnParse extends Parse {
}
processDefinition.setInitial(startEventActivity);
String formKey = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "formKey");
if (formKey != null) {
String deploymentId = processDefinition.getDeploymentId();
processDefinition.setStartFormHandler(new DefaultStartFormHandler(formKey, deploymentId));
StartFormHandler startFormHandler;
String startFormHandlerClassName = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "formHandlerClass");
if (startFormHandlerClassName!=null) {
startFormHandler = (StartFormHandler) ReflectUtil.instantiate(startFormHandlerClassName);
} else {
startFormHandler = new DefaultStartFormHandler();
}
startFormHandler.parseConfiguration(deployment, startEventElement);
processDefinition.setStartFormHandler(startFormHandler);
String initiatorVariableName = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "initiator");
if (initiatorVariableName != null) {
processDefinition.setProperty(PROPERTYNAME_INITIATOR_VARIABLE_NAME, initiatorVariableName);
......@@ -653,7 +661,7 @@ public class BpmnParse extends Parse {
protected void parseEmailServiceTask(ActivityImpl activity, Element serviceTaskElement, List<FieldDeclaration> fieldDeclarations) {
validateFieldDeclarationsForEmail(serviceTaskElement, fieldDeclarations);
activity.setActivityBehavior(new ServiceTaskDelegateActivityBehaviour(new MailActivityBehavior(), fieldDeclarations));
activity.setActivityBehavior(new ServiceTaskDelegateActivityBehaviour(MailActivityBehavior.class, fieldDeclarations));
}
protected void validateFieldDeclarationsForEmail(Element serviceTaskElement, List<FieldDeclaration> fieldDeclarations) {
......@@ -799,12 +807,17 @@ public class BpmnParse extends Parse {
}
public TaskDefinition parseTaskDefinition(Element taskElement, String taskDefinitionKey, ProcessDefinitionEntity processDefinition) {
String formKey = taskElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "formKey");
String deploymentId = processDefinition.getDeploymentId();
TaskDefinition taskDefinition = new TaskDefinition(formKey, deploymentId);
TaskFormHandler taskFormHandler;
String taskFormHandlerClassName = taskElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "formHandlerClass");
if (taskFormHandlerClassName!=null) {
taskFormHandler = (TaskFormHandler) ReflectUtil.instantiate(taskFormHandlerClassName);
} else {
taskFormHandler = new DefaultTaskFormHandler();
}
taskFormHandler.parseConfiguration(deployment, taskElement);
TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);
taskDefinition.setKey(taskDefinitionKey);
processDefinition.getTaskDefinitions().put(taskDefinitionKey, taskDefinition);
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.form;
import java.util.List;
import org.activiti.engine.impl.bpmn.parser.BpmnParser;
import org.activiti.engine.impl.el.ActivitiMethodExpression;
import org.activiti.engine.impl.el.ActivitiValueExpression;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public class DefaultFormHandler {
protected String formKey;
protected String deploymentId;
protected List<FormDisplayProperty> formDisplayProperties;
protected List<FormSubmitProperty> formSubmitProperties;
public void parseConfiguration(DeploymentEntity deployment, Element activityElement) {
this.deploymentId = deployment.getId();
this.formKey = activityElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "formKey");
Element extensionElement = activityElement.element("extensionElements");
if (extensionElement != null) {
List<Element> formDisplayPropertyElements = extensionElement.elementsNS(BpmnParser.BPMN_EXTENSIONS_NS, "formDisplay");
for (Element formDisplayPropertyElement : formDisplayPropertyElements) {
FormDisplayProperty formDisplayProperty = new FormDisplayProperty();
String destProperty = formDisplayPropertyElement.attribute("destProperty");
formDisplayProperty.setDestProperty(destProperty);
String srcVariable = formDisplayPropertyElement.attribute("srcVar");
formDisplayProperty.setSrcVariable(srcVariable);
ExpressionManager expressionManager = CommandContext
.getCurrent()
.getProcessEngineConfiguration()
.getExpressionManager();
String srcValueExpressionText = formDisplayPropertyElement.attribute("srcValueExpr");
if (srcValueExpressionText!=null) {
ActivitiValueExpression srcValueExpression = expressionManager.createValueExpression(srcValueExpressionText);
formDisplayProperty.setSrcValueExpression(srcValueExpression);
}
String srcMethodExpressionText = formDisplayPropertyElement.attribute("srcMethodExpr");
if (srcMethodExpressionText!=null) {
ActivitiMethodExpression srcMethodExpression = expressionManager.createMethodExpression(srcMethodExpressionText);
formDisplayProperty.setSrcMethodExpression(srcMethodExpression);
}
}
}
}
// getters and setters //////////////////////////////////////////////////////
public String getFormKey() {
return formKey;
}
public void setFormKey(String formKey) {
this.formKey = formKey;
}
public String getDeploymentId() {
return deploymentId;
}
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
public List<FormDisplayProperty> getFormDisplayProperties() {
return formDisplayProperties;
}
public void setFormDisplayProperties(List<FormDisplayProperty> formDisplayProperties) {
this.formDisplayProperties = formDisplayProperties;
}
public List<FormSubmitProperty> getFormSubmitProperties() {
return formSubmitProperties;
}
public void setFormSubmitProperties(List<FormSubmitProperty> formSubmitProperties) {
this.formSubmitProperties = formSubmitProperties;
}
}
......@@ -13,25 +13,20 @@
package org.activiti.engine.impl.form;
import java.util.List;
import java.util.Map;
import org.activiti.engine.form.StartForm;
import org.activiti.engine.impl.bpmn.parser.BpmnParser;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public class DefaultStartFormHandler implements StartFormHandler {
protected String formKey;
protected String deploymentId;
public DefaultStartFormHandler(String formKey, String deploymentId) {
this.formKey = formKey;
this.deploymentId = deploymentId;
}
public class DefaultStartFormHandler extends DefaultFormHandler implements StartFormHandler {
public StartForm createStartForm(ProcessDefinitionEntity processDefinition) {
StartFormImpl startForm = new StartFormImpl(formKey, deploymentId, processDefinition);
......
......@@ -23,15 +23,7 @@ import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
*/
public class DefaultTaskFormHandler implements TaskFormHandler {
protected String formKey;
protected String deploymentId;
public DefaultTaskFormHandler(String formKey, String deploymentId) {
this.formKey = formKey;
this.deploymentId = deploymentId;
}
public class DefaultTaskFormHandler extends DefaultFormHandler implements TaskFormHandler {
public TaskForm createTaskForm(TaskEntity task) {
return new TaskFormImpl(formKey, deploymentId, task);
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.form;
import org.activiti.engine.impl.el.ActivitiMethodExpression;
import org.activiti.engine.impl.el.ActivitiValueExpression;
/**
* @author Tom Baeyens
*/
public class FormDisplayProperty {
protected String srcVariable;
protected ActivitiValueExpression srcValueExpression;
protected ActivitiMethodExpression srcMethodExpression;
protected String destProperty;
public String getSrcVariable() {
return srcVariable;
}
public void setSrcVariable(String srcVariable) {
this.srcVariable = srcVariable;
}
public String getDestProperty() {
return destProperty;
}
public void setDestProperty(String destProperty) {
this.destProperty = destProperty;
}
public ActivitiValueExpression getSrcValueExpression() {
return srcValueExpression;
}
public void setSrcValueExpression(ActivitiValueExpression srcValueExpression) {
this.srcValueExpression = srcValueExpression;
}
public ActivitiMethodExpression getSrcMethodExpression() {
return srcMethodExpression;
}
public void setSrcMethodExpression(ActivitiMethodExpression srcMethodExpression) {
this.srcMethodExpression = srcMethodExpression;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.form;
import java.util.List;
/**
* @author Tom Baeyens
*/
public class FormSubmitProperty {
protected String srcProperty;
protected String srcExpression;
protected String destVariable;
protected String destExpression;
protected List<String> ignoreProperties;
public String getSrcProperty() {
return srcProperty;
}
public void setSrcProperty(String srcProperty) {
this.srcProperty = srcProperty;
}
public String getSrcExpression() {
return srcExpression;
}
public void setSrcExpression(String srcExpression) {
this.srcExpression = srcExpression;
}
public String getDestVariable() {
return destVariable;
}
public void setDestVariable(String destVariable) {
this.destVariable = destVariable;
}
public String getDestExpression() {
return destExpression;
}
public void setDestExpression(String destExpression) {
this.destExpression = destExpression;
}
public List<String> getIgnoreProperties() {
return ignoreProperties;
}
public void setIgnoreProperties(List<String> ignoreProperties) {
this.ignoreProperties = ignoreProperties;
}
}
......@@ -16,8 +16,10 @@ package org.activiti.engine.impl.form;
import java.util.Map;
import org.activiti.engine.form.StartForm;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
......@@ -27,4 +29,5 @@ public interface StartFormHandler {
StartForm createStartForm(ProcessDefinitionEntity processDefinition);
ExecutionEntity submitStartForm(ProcessDefinitionEntity processDefinition, Map<String, Object> properties);
void parseConfiguration(DeploymentEntity deploymentEntity, Element startEventElement);
}
......@@ -16,7 +16,9 @@ package org.activiti.engine.impl.form;
import java.util.Map;
import org.activiti.engine.form.TaskForm;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
......@@ -26,4 +28,6 @@ public interface TaskFormHandler {
TaskForm createTaskForm(TaskEntity task);
void submitTaskForm(TaskEntity task, Map<String, Object> properties);
void parseConfiguration(DeploymentEntity deploymentEntity, Element userTaskElement);
}
......@@ -16,7 +16,6 @@ import java.util.HashSet;
import java.util.Set;
import org.activiti.engine.impl.el.ActivitiValueExpression;
import org.activiti.engine.impl.form.DefaultTaskFormHandler;
import org.activiti.engine.impl.form.TaskFormHandler;
/**
......@@ -36,8 +35,8 @@ public class TaskDefinition {
// form fields
protected TaskFormHandler taskFormHandler;
public TaskDefinition(String formKey, String deploymentId) {
taskFormHandler = new DefaultTaskFormHandler(formKey, deploymentId);
public TaskDefinition(TaskFormHandler taskFormHandler) {
this.taskFormHandler = taskFormHandler;
}
// getters and setters //////////////////////////////////////////////////////
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册