提交 052d1a38 编写于 作者: T tombaeyens

ACT-258 Added form service and form instances

上级 4f37a868
/* 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;
import java.util.Map;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.form.TaskFormInstance;
/** Access to forms for starting new process instances and completing tasks.
*
* @author Tom Baeyens
*/
public interface FormService {
StartFormInstance getStartFormInstance(String processDefinitionId);
Object getRenderedStartForm(String processDefinitionId);
Object getRenderedStartForm(String processDefinitionId, String formEngineName);
void submitStartFormInstance(String processDefinitionId, Map<String, Object> properties);
TaskFormInstance getTaskFormInstance(String taskId);
Object getRenderedTaskForm(String taskId);
Object getRenderedTaskForm(String taskId, String formEngineName);
void submitTaskFormInstance(String taskId, Map<String, Object> properties);
}
......@@ -58,6 +58,7 @@ public interface ProcessEngine {
RepositoryService getRepositoryService();
RuntimeService getRuntimeService();
FormService getFormService();
TaskService getTaskService();
HistoryService getHistoryService();
IdentityService getIdentityService();
......
......@@ -147,7 +147,7 @@ public interface RuntimeService {
* @throws ActivitiException when no process definition is deployed with the given key.
*/
ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, Map<String, Object> variables);
/** Delete an existing runtime process instance.
* @param processInstanceId id of process instance to delete, cannot be null.
* @param deleteReason reason for deleting, can be null.
......@@ -207,5 +207,4 @@ public interface RuntimeService {
* to query process instances.
*/
ProcessInstanceQuery createProcessInstanceQuery();
}
\ No newline at end of file
......@@ -151,26 +151,4 @@ public interface TaskService {
* Returns a new {@link TaskQuery} that can be used to dynamically query tasks.
*/
TaskQuery createTaskQuery();
// forms ////////////////////////////////////////////////////////////////////
/** Get a rendered startform, for collecting parameters from a user to start
* a new process instance. Returns null if the processdefinition doesn't have a start form.
* @param processDefinitionId process definition id, cannot be null.
* @throws ActivitiException when no deployed process exists with the given key.
*/
Object getRenderedStartFormById(String processDefinitionId);
/** Get a rendered startform, for collecting parameters from a user to start
* a new process instance. Returns null if the processdefinition doesn't have a start form.
* @param processDefinitionKey process definition key, cannot be null.
* @throws ActivitiException when no deployed process exists with the given key.
*/
Object getRenderedStartFormByKey(String processDefinitionKey);
/** Get the rendered task form for the given task.
* @param taskId the id of the task to render the form for, cannot be null.
* @return rendered task form. Returns null when the given task has no task form.
*/
Object getRenderedTaskForm(String taskId);
}
/* 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.form;
import java.util.Map;
/**
* @author Tom Baeyens
*/
public interface FormInstance {
String getFormKey();
String getDeploymentId();
Map<String, Object> getProperties();
Object getProperty(String propertyName);
void setProperty(String propertyName, Object propertyValue);
}
/* 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.form;
import org.activiti.engine.repository.ProcessDefinition;
/**
* @author Tom Baeyens
*/
public interface StartFormInstance extends FormInstance {
ProcessDefinition getProcessDefinition();
}
/* 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.form;
import org.activiti.engine.task.Task;
/**
* @author Tom Baeyens
*/
public interface TaskFormInstance extends FormInstance {
Task getTask();
}
/* 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.history;
import java.util.Date;
/**
* @author Tom Baeyens
*/
public interface HistoricFormInstance {
String getId();
String getProcessInstanceId();
String getExecutionId();
String getActivityId();
String getAuthenticatedUserId();
Date getTime();
}
......@@ -13,7 +13,6 @@
package org.activiti.engine.history;
import java.util.Date;
/**
......@@ -21,11 +20,11 @@ import java.util.Date;
*/
public interface HistoricVariableUpdate {
String getHistoricFormInstanceId();
String getProcessInstanceId();
String getExecutionId();
String getVariableName();
String getVariableType();
Object getValue();
int getIndex();
Date getTime();
int getRevision();
}
/* 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;
import java.util.Map;
import org.activiti.engine.FormService;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.cmd.GetRenderedStartFormCmd;
import org.activiti.engine.impl.cmd.GetRenderedTaskFormCmd;
import org.activiti.engine.impl.cmd.GetStartFormInstanceCmd;
import org.activiti.engine.impl.cmd.GetTaskFormInstanceCmd;
/**
* @author Tom Baeyens
*/
public class FormServiceImpl extends ServiceImpl implements FormService {
public Object getRenderedStartForm(String processDefinitionId) {
return commandExecutor.execute(new GetRenderedStartFormCmd(processDefinitionId, null));
}
public Object getRenderedStartForm(String processDefinitionId, String engineName) {
return commandExecutor.execute(new GetRenderedStartFormCmd(processDefinitionId, engineName));
}
public Object getRenderedTaskForm(String taskId) {
return commandExecutor.execute(new GetRenderedTaskFormCmd(taskId, null));
}
public Object getRenderedTaskForm(String taskId, String engineName) {
return commandExecutor.execute(new GetRenderedTaskFormCmd(taskId, engineName));
}
public StartFormInstance getStartFormInstance(String processDefinitionId) {
return commandExecutor.execute(new GetStartFormInstanceCmd(processDefinitionId));
}
public TaskFormInstance getTaskFormInstance(String taskId) {
return commandExecutor.execute(new GetTaskFormInstanceCmd(taskId));
}
public void submitStartFormInstance(String processDefinitionId, Map<String, Object> properties) {
}
public void submitTaskFormInstance(String taskId, Map<String, Object> properties) {
}
}
......@@ -48,12 +48,12 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
super(commandExecutor);
}
public ProcessDefinitionQuery id(String processDefinitionId) {
public ProcessDefinitionQueryImpl id(String processDefinitionId) {
this.id = processDefinitionId;
return this;
}
public ProcessDefinitionQuery name(String name) {
public ProcessDefinitionQueryImpl name(String name) {
if (name == null) {
throw new ActivitiException("name is null");
}
......@@ -61,7 +61,7 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery nameLike(String nameLike) {
public ProcessDefinitionQueryImpl nameLike(String nameLike) {
if (nameLike == null) {
throw new ActivitiException("nameLike is null");
}
......@@ -77,7 +77,7 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery key(String key) {
public ProcessDefinitionQueryImpl key(String key) {
if (key == null) {
throw new ActivitiException("key is null");
}
......@@ -85,7 +85,7 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery keyLike(String keyLike) {
public ProcessDefinitionQueryImpl keyLike(String keyLike) {
if (keyLike == null) {
throw new ActivitiException("keyLike is null");
}
......@@ -93,7 +93,7 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery version(Integer version) {
public ProcessDefinitionQueryImpl version(Integer version) {
if (version == null) {
throw new ActivitiException("version is null");
} else if (version <= 0) {
......@@ -103,30 +103,30 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery latest() {
public ProcessDefinitionQueryImpl latest() {
this.latest = true;
return this;
}
//sorting ////////////////////////////////////////////
public ProcessDefinitionQuery orderByDeploymentId() {
public ProcessDefinitionQueryImpl orderByDeploymentId() {
return orderBy(ProcessDefinitionQueryProperty.DEPLOYMENT_ID);
}
public ProcessDefinitionQuery orderById() {
public ProcessDefinitionQueryImpl orderById() {
return orderBy(ProcessDefinitionQueryProperty.ID);
}
public ProcessDefinitionQuery orderByKey() {
public ProcessDefinitionQueryImpl orderByKey() {
return orderBy(ProcessDefinitionQueryProperty.KEY);
}
public ProcessDefinitionQuery orderByVersion() {
public ProcessDefinitionQueryImpl orderByVersion() {
return orderBy(ProcessDefinitionQueryProperty.VERSION);
}
public ProcessDefinitionQuery orderBy(QueryProperty property) {
public ProcessDefinitionQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof ProcessDefinitionQueryProperty)) {
throw new ActivitiException("Only ProcessDefinitionQueryProperty can be used with orderBy");
}
......@@ -134,15 +134,15 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQ
return this;
}
public ProcessDefinitionQuery asc() {
public ProcessDefinitionQueryImpl asc() {
return direction(Direction.ASCENDING);
}
public ProcessDefinitionQuery desc() {
public ProcessDefinitionQueryImpl desc() {
return direction(Direction.DESCENDING);
}
public ProcessDefinitionQuery direction(Direction direction) {
public ProcessDefinitionQueryImpl direction(Direction direction) {
if (orderProperty==null) {
throw new ActivitiException("You should call any of the orderBy methods first before specifying a direction");
}
......
......@@ -15,12 +15,13 @@ package org.activiti.engine.impl;
import java.util.logging.Logger;
import org.activiti.engine.DbSchemaStrategy;
import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.db.DbSqlSessionFactory;
......@@ -43,6 +44,7 @@ public class ProcessEngineImpl implements ProcessEngine {
protected HistoryService historicDataService;
protected IdentityService identityService;
protected TaskService taskService;
protected FormService formService;
protected ManagementService managementService;
protected String dbSchemaStrategy;
protected JobExecutor jobExecutor;
......@@ -56,6 +58,7 @@ public class ProcessEngineImpl implements ProcessEngine {
this.historicDataService = processEngineConfiguration.getHistoryService();
this.identityService = processEngineConfiguration.getIdentityService();
this.taskService = processEngineConfiguration.getTaskService();
this.formService = processEngineConfiguration.getFormService();
this.managementService = processEngineConfiguration.getManagementService();
this.dbSchemaStrategy = processEngineConfiguration.getDbSchemaStrategy();
this.jobExecutor = processEngineConfiguration.getJobExecutor();
......@@ -155,9 +158,11 @@ public class ProcessEngineImpl implements ProcessEngine {
public RuntimeService getRuntimeService() {
return runtimeService;
}
public String getDbSchemaStrategy() {
return dbSchemaStrategy;
}
public ProcessEngineConfiguration getProcessEngineConfiguration() {
return processEngineConfiguration;
}
......@@ -165,4 +170,8 @@ public class ProcessEngineImpl implements ProcessEngine {
public RepositoryService getRepositoryService() {
return repositoryService;
}
public FormService getFormService() {
return formService;
}
}
......@@ -18,8 +18,10 @@ import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.form.FormInstance;
import org.activiti.engine.impl.cmd.DeleteProcessInstanceCmd;
import org.activiti.engine.impl.cmd.FindActiveActivityIdsCmd;
import org.activiti.engine.impl.cmd.GetStartFormInstanceCmd;
import org.activiti.engine.impl.cmd.GetVariableCmd;
import org.activiti.engine.impl.cmd.GetVariablesCmd;
import org.activiti.engine.impl.cmd.SetVariablesCmd;
......@@ -106,4 +108,8 @@ public class RuntimeServiceImpl extends ServiceImpl implements RuntimeService {
public List<String> getActiveActivityIds(String executionId) {
return commandExecutor.execute(new FindActiveActivityIdsCmd(executionId));
}
public FormInstance getFormInstanceById(String processDefinitionId) {
return commandExecutor.execute(new GetStartFormInstanceCmd(processDefinitionId));
}
}
......@@ -21,15 +21,14 @@ import org.activiti.engine.impl.cmd.AddIdentityLinkCmd;
import org.activiti.engine.impl.cmd.ClaimTaskCmd;
import org.activiti.engine.impl.cmd.CompleteTaskCmd;
import org.activiti.engine.impl.cmd.DeleteTaskCmd;
import org.activiti.engine.impl.cmd.GetRenderedFormCmd;
import org.activiti.engine.impl.cmd.GetIdentityLinksForTaskCmd;
import org.activiti.engine.impl.cmd.SaveTaskCmd;
import org.activiti.engine.impl.cmd.SetTaskPriorityCmd;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.IdentityLinkType;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
......@@ -109,18 +108,6 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
return new TaskQueryImpl(commandExecutor);
}
public Object getRenderedStartFormById(String processDefinitionId) {
return commandExecutor.execute(new GetRenderedFormCmd(processDefinitionId, null, null));
}
public Object getRenderedStartFormByKey(String processDefinitionKey) {
return commandExecutor.execute(new GetRenderedFormCmd(null, processDefinitionKey, null));
}
public Object getRenderedTaskForm(String taskId) {
return commandExecutor.execute(new GetRenderedFormCmd(null, null, taskId));
}
// getters and setters //////////////////////////////////////////////////////
public CommandExecutor getCommandExecutor() {
......
......@@ -36,7 +36,7 @@ public class UserTaskActivity extends TaskActivity {
public void execute(ActivityExecution execution) throws Exception {
TaskEntity task = TaskEntity.createAndInsert();
task.setExecution(execution);
task.setFormResourceKey(taskDefinition.getFormResourceKey());
task.setTaskDefinition(taskDefinition);
if (taskDefinition.getNameValueExpression() != null) {
String name = (String) taskDefinition.getNameValueExpression().getValue(execution);
......
......@@ -54,6 +54,8 @@ import org.activiti.engine.impl.el.ActivitiValueExpression;
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.StartFormHandler;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
......@@ -83,6 +85,9 @@ public class BpmnParse extends Parse {
public static final String PROPERTYNAME_VARIABLE_DECLARATIONS = "variableDeclarations";
public static final String PROPERTYNAME_TIMER_DECLARATION = "timerDeclarations";
public static final String PROPERTYNAME_INITIAL = "initial";
public static final String PROPERTYNAME_INITIATOR_VARIABLE_NAME = "initiatorVariableName";
private static final StartFormHandler DEFAULT_FORM_INSTANCE_FACTORY = new DefaultStartFormHandler();
private static final Logger LOG = Logger.getLogger(BpmnParse.class.getName());
......@@ -363,6 +368,7 @@ public class BpmnParse extends Parse {
processDefinition.setKey(processElement.attribute("id"));
processDefinition.setProperty("name", processElement.attribute("name"));
processDefinition.setProperty("documentation", parseDocumentation(processElement));
processDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
String historyLevelText = processElement.attribute("history");
if (historyLevelText!=null) {
......@@ -439,14 +445,15 @@ public class BpmnParse extends Parse {
}
processDefinition.setInitial(startEventActivity);
String startFormResourceKey = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "form");
if (startFormResourceKey != null) {
processDefinition.setStartFormResourceKey(startFormResourceKey);
String formKey = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "form");
if (formKey != null) {
processDefinition.setFormKey(formKey);
processDefinition.setStartFormHandler(DEFAULT_FORM_INSTANCE_FACTORY);
}
String initiatorVariableName = startEventElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "initiator");
if (initiatorVariableName != null) {
processDefinition.setProperty("initiatorVariableName", initiatorVariableName);
processDefinition.setProperty(PROPERTYNAME_INITIATOR_VARIABLE_NAME, initiatorVariableName);
}
} else {
......@@ -774,11 +781,12 @@ public class BpmnParse extends Parse {
*/
public void parseUserTask(Element userTaskElement, ScopeImpl scope) {
ActivityImpl activity = parseAndCreateActivityOnScopeElement(userTaskElement, scope);
TaskDefinition taskDefinition = parseTaskDefinition(userTaskElement);
TaskDefinition taskDefinition = parseTaskDefinition(userTaskElement, activity.getId(), (ProcessDefinitionEntity) scope.getProcessDefinition());
UserTaskActivity userTaskActivity = new UserTaskActivity(expressionManager, taskDefinition);
String formResourceKey = userTaskElement.attributeNS(BpmnParser.BPMN_EXTENSIONS_NS, "form");
taskDefinition.setFormResourceKey(formResourceKey);
taskDefinition.setFormKey(formResourceKey);
activity.setActivityBehavior(userTaskActivity);
......@@ -789,9 +797,12 @@ public class BpmnParse extends Parse {
}
}
public TaskDefinition parseTaskDefinition(Element taskElement) {
public TaskDefinition parseTaskDefinition(Element taskElement, String taskDefinitionKey, ProcessDefinitionEntity processDefinition) {
TaskDefinition taskDefinition = new TaskDefinition();
taskDefinition.setKey(taskDefinitionKey);
processDefinition.getTaskDefinitions().put(taskDefinitionKey, taskDefinition);
String name = taskElement.attribute("name");
if (name != null) {
taskDefinition.setNameValueExpression(expressionManager.createValueExpression(name));
......
......@@ -21,6 +21,7 @@ import javax.sql.DataSource;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.DbSchemaStrategy;
import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ManagementService;
......@@ -29,6 +30,7 @@ import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.FormServiceImpl;
import org.activiti.engine.impl.HistoryServiceImpl;
import org.activiti.engine.impl.IdentityServiceImpl;
import org.activiti.engine.impl.ManagementServiceImpl;
......@@ -51,6 +53,8 @@ import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.DbSqlSessionFactory;
import org.activiti.engine.impl.db.DbTaskSessionFactory;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.form.FormEngine;
import org.activiti.engine.impl.form.JuelFormEngine;
import org.activiti.engine.impl.history.handler.HistoryTaskAssignmentHandler;
import org.activiti.engine.impl.interceptor.CommandContextFactory;
import org.activiti.engine.impl.interceptor.CommandContextInterceptor;
......@@ -136,6 +140,7 @@ public class ProcessEngineConfiguration {
protected HistoryService historyService;
protected IdentityService identityService;
protected TaskService taskService;
protected FormService formService;
protected ManagementService managementService;
protected Map<Class<?>, SessionFactory> sessionFactories;
......@@ -173,6 +178,8 @@ public class ProcessEngineConfiguration {
protected String mailServerSmtpPassword;
protected int mailServerSmtpPort;
protected String mailServerDefaultFrom;
protected Map<String, FormEngine> formEngines;
public ProcessEngineConfiguration() {
processEngineName = ProcessEngines.NAME_DEFAULT;
......@@ -189,6 +196,7 @@ public class ProcessEngineConfiguration {
repositoryService = new RepositoryServiceImpl();
runtimeService = new RuntimeServiceImpl();
taskService = new TaskServiceImpl();
formService = new FormServiceImpl();
managementService = new ManagementServiceImpl();
identityService = new IdentityServiceImpl();
historyService = new HistoryServiceImpl();
......@@ -232,6 +240,11 @@ public class ProcessEngineConfiguration {
mailServerDefaultFrom = DEFAULT_FROM_EMAIL_ADDRESS;
mailServerSmtpPort = DEFAULT_MAIL_SERVER_SMTP_PORT;
formEngines = new HashMap<String, FormEngine>();
FormEngine defaultFormEngine = new JuelFormEngine();
formEngines.put(null, defaultFormEngine); // default form engine is looked up with null
formEngines.put("juel", defaultFormEngine);
}
public ProcessEngine buildProcessEngine() {
......@@ -254,6 +267,7 @@ public class ProcessEngineConfiguration {
notifyConfigurationComplete(repositoryService);
notifyConfigurationComplete(runtimeService);
notifyConfigurationComplete(taskService);
notifyConfigurationComplete(formService);
notifyConfigurationComplete(managementService);
notifyConfigurationComplete(identityService);
notifyConfigurationComplete(historyService);
......@@ -660,17 +674,14 @@ public class ProcessEngineConfiguration {
this.commandInterceptorsTxRequired = commandInterceptorsTxRequired;
}
public List<CommandInterceptor> getCommandInterceptorsTxRequiresNew() {
return commandInterceptorsTxRequiresNew;
}
public void setCommandInterceptorsTxRequiresNew(List<CommandInterceptor> commandInterceptorsTxRequiresNew) {
this.commandInterceptorsTxRequiresNew = commandInterceptorsTxRequiresNew;
}
public CommandExecutor getCommandExecutorTxRequiresNew() {
return commandExecutorTxRequiresNew;
}
......@@ -678,9 +689,24 @@ public class ProcessEngineConfiguration {
public int getHistoryLevel() {
return historyLevel;
}
public void setHistoryLevel(int historyLevel) {
this.historyLevel = historyLevel;
}
public Map<String, FormEngine> getFormEngines() {
return formEngines;
}
public void setFormEngines(Map<String, FormEngine> formEngines) {
this.formEngines = formEngines;
}
public FormService getFormService() {
return formService;
}
public void setFormService(FormService formService) {
this.formService = formService;
}
}
/* 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.cmd;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.repository.ResourceEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.scripting.ScriptingEngines;
import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class GetRenderedFormCmd implements Command<Object> {
protected String processDefinitionId;
protected String processDefinitionKey;
protected String taskId;
public GetRenderedFormCmd(String processDefinitionId, String processDefinitionKey, String taskId) {
this.processDefinitionId = processDefinitionId;
this.processDefinitionKey = processDefinitionKey;
this.taskId = taskId;
}
public Object execute(CommandContext commandContext) {
RepositorySession repositorySession = commandContext.getRepositorySession();
ProcessDefinitionEntity processDefinition = null;
TaskEntity task = null;
ExecutionEntity execution = null;
String formResourceKey = null;
if (taskId!=null) {
task = commandContext
.getTaskSession()
.findTaskById(taskId);
if (task == null) {
throw new ActivitiException("No task found for id = '" + taskId + "'");
}
execution = task.getExecution();
processDefinition = (ProcessDefinitionEntity) execution.getProcessDefinition();
formResourceKey = task.getFormResourceKey();
} else if (processDefinitionId!=null) {
processDefinition = repositorySession.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiException("No process definition found for id = '" + processDefinitionId + "'");
}
formResourceKey = processDefinition.getStartFormResourceKey();
} else if (processDefinitionKey!=null) {
processDefinition = repositorySession.findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
if (processDefinition == null) {
throw new ActivitiException("No process definition found for key '" + processDefinitionKey +"'");
}
formResourceKey = processDefinition.getStartFormResourceKey();
} else {
throw new ActivitiException("processDefinitionKey, processDefinitionId and taskId are null");
}
Object result = null;
if (formResourceKey != null) {
String deploymentId = processDefinition.getDeploymentId();
DeploymentEntity deployment = repositorySession.findDeploymentById(deploymentId);
String formTemplateString = getFormTemplateString(formResourceKey, deployment);
ScriptingEngines scriptingEngines = commandContext.getProcessEngineConfiguration().getScriptingEngines();
result = scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, execution);
}
return result;
}
protected String getFormTemplateString(String formResourceName, DeploymentEntity deployment) {
// get the template
ResourceEntity formResource = deployment.getResource(formResourceName);
if (formResource==null) {
throw new ActivitiException("form '"+formResourceName+"' not available in "+deployment);
}
byte[] formResourceBytes = formResource.getBytes();
return new String(formResourceBytes);
}
}
/* 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.cmd;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.form.FormEngine;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class GetRenderedStartFormCmd implements Command<Object> {
protected String processDefinitionId;
protected String formEngineName;
public GetRenderedStartFormCmd(String processDefinitionId, String formEngineName) {
this.processDefinitionId = processDefinitionId;
this.formEngineName = formEngineName;
}
public Object execute(CommandContext commandContext) {
RepositorySession repositorySession = commandContext.getRepositorySession();
ProcessDefinitionEntity processDefinition = repositorySession.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiException("Process Definition '" + processDefinitionId +"' not found");
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
return null;
}
FormEngine formEngine = commandContext
.getProcessEngineConfiguration()
.getFormEngines()
.get(formEngineName);
if (formEngine==null) {
throw new ActivitiException("No formEngine '" + formEngineName +"' defined process engine configuration");
}
StartFormInstance startFormInstance = startFormHandler.createStartFormInstance(processDefinition);
return formEngine.renderStartForm(startFormInstance);
}
}
/* 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.cmd;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.cfg.TaskSession;
import org.activiti.engine.impl.form.FormEngine;
import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
*/
public class GetRenderedTaskFormCmd implements Command<Object> {
protected String taskId;
protected String formEngineName;
public GetRenderedTaskFormCmd(String taskId, String formEngineName) {
this.taskId = taskId;
this.formEngineName = formEngineName;
}
public Object execute(CommandContext commandContext) {
TaskSession taskSession = commandContext.getTaskSession();
TaskEntity task = taskSession.findTaskById(taskId);
if (task == null) {
throw new ActivitiException("Task '" + taskId +"' not found");
}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
return null;
}
FormEngine formEngine = commandContext
.getProcessEngineConfiguration()
.getFormEngines()
.get(formEngineName);
if (formEngine==null) {
throw new ActivitiException("No formEngine '" + formEngineName +"' defined process engine configuration");
}
TaskFormInstance taskFormInstance = taskFormHandler.createTaskFormInstance(task);
return formEngine.renderTaskForm(taskFormInstance);
}
}
/* 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.cmd;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
/**
* @author Tom Baeyens
*/
public class GetStartFormInstanceCmd implements Command<StartFormInstance> {
protected String processDefinitionId;
public GetStartFormInstanceCmd(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
public StartFormInstance execute(CommandContext commandContext) {
RepositorySession repositorySession = commandContext.getRepositorySession();
ProcessDefinitionEntity processDefinition = repositorySession.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiException("No process definition found for id '" + processDefinitionId +"'");
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
throw new ActivitiException("No startFormHandler defined in process '" + processDefinitionId +"'");
}
return startFormHandler.createStartFormInstance(processDefinition);
}
}
/* 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.cmd;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.cfg.TaskSession;
import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
*/
public class GetTaskFormInstanceCmd implements Command<TaskFormInstance> {
protected String taskId;
public GetTaskFormInstanceCmd(String taskId) {
this.taskId = taskId;
}
public TaskFormInstance execute(CommandContext commandContext) {
TaskSession taskSession = commandContext.getTaskSession();
TaskEntity task = taskSession.findTaskById(taskId);
if (task == null) {
throw new ActivitiException("No task found for taskId '" + taskId +"'");
}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
throw new ActivitiException("No taskFormHandler specified for task '" + taskId +"'");
}
return taskFormHandler.createTaskFormInstance(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 java.util.Map;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
/**
* @author Tom Baeyens
*/
public class DefaultStartFormHandler implements StartFormHandler {
public StartFormInstance createStartFormInstance(ProcessDefinitionEntity processDefinition) {
StartFormInstanceImpl startFormInstance = new StartFormInstanceImpl(processDefinition);
//...
return startFormInstance;
}
public void submitStartFormInstance(String processDefinitionId, Map<String, Object> properties) {
}
}
/* 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.Map;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
*/
public class DefaultTaskFormHandler implements TaskFormHandler {
public TaskFormInstance createTaskFormInstance(TaskEntity task) {
TaskFormInstance taskFormInstance = new TaskFormInstanceImpl(task);
return taskFormInstance;
}
public void submitTaskFormInstance(String taskId, Map<String, Object> properties) {
}
}
......@@ -12,8 +12,8 @@
*/
package org.activiti.engine.impl.form;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.form.TaskFormInstance;
/**
......@@ -21,6 +21,7 @@ import org.activiti.engine.impl.task.TaskEntity;
*/
public interface FormEngine {
Object render(DeploymentEntity deployment, String formReference, TaskEntity taskImpl);
Object renderStartForm(StartFormInstance startFormInstance);
Object renderTaskForm(TaskFormInstance taskFormInstance);
}
/* 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.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.form.FormInstance;
/**
* @author Tom Baeyens
*/
public abstract class FormInstanceImpl implements FormInstance, Serializable {
private static final long serialVersionUID = 1L;
protected String formKey;
protected String deploymentId;
protected Map<String, Object> properties = new HashMap<String, Object>();
public Object getProperty(String propertyName) {
return properties.get(propertyName);
}
public void setProperty(String propertyName, Object propertyValue) {
properties.put(propertyName, propertyValue);
}
// getters and setters //////////////////////////////////////////////////////
public String getFormKey() {
return formKey;
}
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
}
public Map<String, Object> getProperties() {
return properties;
}
public String getDeploymentId() {
return deploymentId;
}
}
......@@ -12,14 +12,13 @@
*/
package org.activiti.engine.impl.form;
import org.activiti.el.juel.ExpressionFactoryImpl;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.form.FormInstance;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ResourceEntity;
import org.activiti.engine.impl.scripting.ScriptingEngines;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.javax.el.ELContext;
import org.activiti.javax.el.ExpressionFactory;
import org.activiti.javax.el.ValueExpression;
/**
......@@ -27,31 +26,37 @@ import org.activiti.javax.el.ValueExpression;
*/
public class JuelFormEngine implements FormEngine {
ExpressionFactory expressionFactory = new ExpressionFactoryImpl();
public Object renderStartForm(StartFormInstance startFormInstance) {
if (startFormInstance.getFormKey()==null) {
return null;
}
CommandContext commandContext = CommandContext.getCurrent();
String formTemplateString = getFormTemplateString(startFormInstance, commandContext);
ScriptingEngines scriptingEngines = commandContext.getProcessEngineConfiguration().getScriptingEngines();
return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, null);
}
public String render(DeploymentEntity deployment, String formReference, TaskEntity task) {
try {
// get the template
ResourceEntity formResourceEntity = deployment.getResource(formReference);
if (formResourceEntity==null) {
throw new ActivitiException("form '"+formReference+"' not available in "+deployment);
}
byte[] formResourceBytes = formResourceEntity.getBytes();
String formString = new String(formResourceBytes);
ELContext elContext = new TaskElContext(task);
ValueExpression result = expressionFactory.createValueExpression(elContext, formString, String.class);
return (String) result.getValue(elContext);
} catch (Exception e) {
throw new ActivitiException("problem rendering template: "+e.getMessage(), e);
public Object renderTaskForm(TaskFormInstance taskFormInstance) {
if (taskFormInstance.getFormKey()==null) {
return null;
}
CommandContext commandContext = CommandContext.getCurrent();
String formTemplateString = getFormTemplateString(taskFormInstance, commandContext);
ScriptingEngines scriptingEngines = commandContext.getProcessEngineConfiguration().getScriptingEngines();
TaskEntity task = (TaskEntity) taskFormInstance.getTask();
return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, task.getExecution());
}
// private Object createFormData(TaskEntity task) {
// if (task!=null) {
// return task.getActivityInstanceVariables();
// }
// return null;
// }
private String getFormTemplateString(FormInstance formInstance, CommandContext commandContext) {
String deploymentId = formInstance.getDeploymentId();
String formKey = formInstance.getFormKey();
ResourceEntity resourceStream = commandContext
.getRepositorySession()
.findResourceByDeploymentIdAndResourceName(deploymentId, formKey);
byte[] resourceBytes = resourceStream.getBytes();
String formTemplateString = new String(resourceBytes);
return formTemplateString;
}
}
/* 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.Map;
import org.activiti.engine.form.StartFormInstance;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
/**
* @author Tom Baeyens
*/
public interface StartFormHandler {
StartFormInstance createStartFormInstance(ProcessDefinitionEntity processDefinition);
void submitStartFormInstance(String processDefinitionId, Map<String, Object> properties);
}
/* 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.form.StartFormInstance;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.repository.ProcessDefinition;
/**
* @author Tom Baeyens
*/
public class StartFormInstanceImpl extends FormInstanceImpl implements StartFormInstance, Command<Object> {
private static final long serialVersionUID = 1L;
protected ProcessDefinition processDefinition;
public StartFormInstanceImpl(ProcessDefinitionEntity processDefinition) {
this.formKey = (String) processDefinition.getFormKey();
this.deploymentId = processDefinition.getDeploymentId();
this.processDefinition = processDefinition;
}
public Object execute(CommandContext commandContext) {
return null;
}
// getters and setters //////////////////////////////////////////////////////
public ProcessDefinition getProcessDefinition() {
return processDefinition;
}
}
/* 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.Map;
import org.activiti.engine.form.TaskFormInstance;
import org.activiti.engine.impl.task.TaskEntity;
/**
* @author Tom Baeyens
*/
public interface TaskFormHandler {
TaskFormInstance createTaskFormInstance(TaskEntity task);
void submitTaskFormInstance(String taskId, Map<String, Object> properties);
}
/* 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.form.TaskFormInstance;
import org.activiti.engine.impl.ProcessDefinitionQueryImpl;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.task.Task;
/**
* @author Tom Baeyens
*/
public class TaskFormInstanceImpl extends FormInstanceImpl implements TaskFormInstance {
private static final long serialVersionUID = 1L;
protected Task task;
public TaskFormInstanceImpl(TaskEntity task) {
this.task = task;
this.formKey = task.getTaskDefinition().getFormKey();
String processDefinitionId = task.getProcessDefinitionId();
ProcessDefinition processDefinition = new ProcessDefinitionQueryImpl()
.id(processDefinitionId)
.executeSingleResult(CommandContext.getCurrent());
this.deploymentId = processDefinition.getDeploymentId();
}
public Task getTask() {
return task;
}
}
......@@ -32,7 +32,7 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
private static final long serialVersionUID = 1L;
protected int index;
protected String historicFormInstanceId;
protected Date time;
public HistoricVariableUpdateEntity() {
......@@ -47,10 +47,10 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
if (executionId==null) {
throw new ActivitiException("bug");
}
this.revision = variableInstance.getRevision();
this.name = variableInstance.getName();
this.type = variableInstance.getType();
this.time = ClockUtil.getCurrentTime();
this.index = variableInstance.generateNextHistoryIndex();
if (variableInstance.getByteArrayValueId()!=null) {
// TODO test and review. name ok here?
this.byteArrayValue = new ByteArrayEntity(name, variableInstance.getByteArrayValue().getBytes());
......@@ -84,14 +84,6 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
return HistoricVariableUpdateEntity.class;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public Date getTime() {
return time;
......@@ -108,4 +100,12 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
public String getVariableType() {
return type.getTypeName();
}
public String getHistoricFormInstanceId() {
return historicFormInstanceId;
}
public void setHistoricFormInstanceId(String historicFormInstanceId) {
this.historicFormInstanceId = historicFormInstanceId;
}
}
......@@ -13,12 +13,15 @@
package org.activiti.engine.impl.repository;
import java.util.ArrayList;
import java.util.Map;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.runtime.VariableMap;
import org.activiti.engine.impl.task.TaskDefinition;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.pvm.impl.process.ProcessDefinitionImpl;
import org.activiti.pvm.impl.runtime.ExecutionImpl;
......@@ -35,8 +38,11 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
protected int version;
protected String deploymentId;
protected String resourceName;
protected String startFormResourceKey;
protected String formKey;
protected Integer historyLevel;
protected StartFormHandler startFormHandler;
protected Map<String, TaskDefinition> taskDefinitions;
public ProcessDefinitionEntity() {
super(null);
......@@ -129,14 +135,6 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
this.resourceName = resourceName;
}
public String getStartFormResourceKey() {
return startFormResourceKey;
}
public void setStartFormResourceKey(String startFormResourceKey) {
this.startFormResourceKey = startFormResourceKey;
}
public Integer getHistoryLevel() {
return historyLevel;
}
......@@ -144,4 +142,28 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
public void setHistoryLevel(Integer historyLevel) {
this.historyLevel = historyLevel;
}
public StartFormHandler getStartFormHandler() {
return startFormHandler;
}
public void setStartFormHandler(StartFormHandler startFormHandler) {
this.startFormHandler = startFormHandler;
}
public String getFormKey() {
return formKey;
}
public void setFormKey(String formKey) {
this.formKey = formKey;
}
public Map<String, TaskDefinition> getTaskDefinitions() {
return taskDefinitions;
}
public void setTaskDefinitions(Map<String, TaskDefinition> taskDefinitions) {
this.taskDefinitions = taskDefinitions;
}
}
......@@ -31,6 +31,7 @@ import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.impl.variable.VariableDeclaration;
import org.activiti.engine.runtime.Execution;
......@@ -445,7 +446,7 @@ public class ExecutionEntity extends ExecutionImpl implements PersistentObject,
}
// getters and setters //////////////////////////////////////////////////////
public String getProcessInstanceId() {
return processInstanceId;
}
......
......@@ -46,8 +46,6 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
protected ByteArrayEntity byteArrayValue;
protected String byteArrayValueId;
protected int historyNextIndex;
protected Object cachedValue;
protected Type type;
......@@ -71,7 +69,6 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
VariableInstanceEntity variableInstance = new VariableInstanceEntity();
variableInstance.name = name;
variableInstance.type = type;
variableInstance.historyNextIndex = 0;
variableInstance.setValue(value);
return variableInstance;
......@@ -99,6 +96,10 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
dbSqlSession.delete(VariableInstanceEntity.class, id);
if (byteArrayValueId != null) {
// the next apparently useless line is probably to ensure consistency in the DbSqlSession
// cache, but should be checked and docced here (or removed if it turns out to be unnecessary)
// @see also HistoricVariableUpdateEntity
getByteArrayValue();
dbSqlSession.delete(ByteArrayEntity.class, byteArrayValueId);
}
}
......@@ -157,10 +158,6 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
return byteArrayValue;
}
public int generateNextHistoryIndex() {
return historyNextIndex++;
}
// type /////////////////////////////////////////////////////////////////////
public Object getValue() {
......@@ -243,10 +240,4 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
public void setTextValue2(String textValue2) {
this.textValue2 = textValue2;
}
public int getHistoryNextIndex() {
return historyNextIndex;
}
public void setHistoryNextIndex(int historyNextIndex) {
this.historyNextIndex = historyNextIndex;
}
}
......@@ -16,6 +16,8 @@ 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;
/**
* Container for task definition information gathered at parsing time.
......@@ -24,12 +26,16 @@ import org.activiti.engine.impl.el.ActivitiValueExpression;
*/
public class TaskDefinition {
protected String key;
// assignment fields
protected ActivitiValueExpression nameValueExpression;
protected ActivitiValueExpression descriptionValueExpression;
protected ActivitiValueExpression assigneeValueExpression;
protected Set<ActivitiValueExpression> candidateUserIdValueExpressions = new HashSet<ActivitiValueExpression>();
protected Set<ActivitiValueExpression> candidateGroupIdValueExpressions = new HashSet<ActivitiValueExpression>();
protected String formResourceKey;
// form fields
protected String formKey;
protected TaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
// getters and setters //////////////////////////////////////////////////////
......@@ -73,12 +79,27 @@ public class TaskDefinition {
candidateGroupIdValueExpressions.add(groupId);
}
public String getFormResourceKey() {
return formResourceKey;
public String getFormKey() {
return formKey;
}
public void setFormResourceKey(String formResourceKey) {
this.formResourceKey = formResourceKey;
public void setFormKey(String formKey) {
this.formKey = formKey;
}
public TaskFormHandler getTaskFormHandler() {
return taskFormHandler;
}
public void setTaskFormHandler(TaskFormHandler taskFormHandler) {
this.taskFormHandler = taskFormHandler;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
......@@ -22,8 +22,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.runtime.VariableMap;
import org.activiti.engine.impl.util.ClockUtil;
......@@ -45,7 +47,6 @@ public class TaskEntity implements Task, Serializable, PersistentObject {
protected String assignee;
protected String name;
protected String description;
protected String formResourceKey;
protected int priority = Task.PRIORITY_NORMAL;
protected Date createTime; // The time when the task has been created
protected boolean isIdentityLinksInitialized = false;
......@@ -59,6 +60,9 @@ public class TaskEntity implements Task, Serializable, PersistentObject {
protected String processDefinitionId;
protected String taskDefinitionKey;
protected TaskDefinition taskDefinition;
public TaskEntity() {
}
......@@ -249,6 +253,22 @@ public class TaskEntity implements Task, Serializable, PersistentObject {
}
}
// modified getters and setters /////////////////////////////////////////////
public void setTaskDefinition(TaskDefinition taskDefinition) {
this.taskDefinition = taskDefinition;
this.taskDefinitionKey = taskDefinition.getKey();
}
public TaskDefinition getTaskDefinition() {
if (taskDefinition==null && taskDefinitionKey!=null) {
RepositorySession repositorySession = CommandContext.getCurrentSession(RepositorySession.class);
ProcessDefinitionEntity processDefinition = repositorySession.findDeployedProcessDefinitionById(processDefinitionId);
taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
}
return taskDefinition;
}
// getters and setters //////////////////////////////////////////////////////
public String getId() {
......@@ -319,12 +339,11 @@ public class TaskEntity implements Task, Serializable, PersistentObject {
return assignee;
}
public String getFormResourceKey() {
return formResourceKey;
}
public void setFormResourceKey(String formResourceKey) {
this.formResourceKey = formResourceKey;
public String getTaskDefinitionKey() {
return taskDefinitionKey;
}
public void setTaskDefinitionKey(String taskDefinitionKey) {
this.taskDefinitionKey = taskDefinitionKey;
}
}
......@@ -26,6 +26,7 @@ import java.util.logging.Logger;
import junit.framework.AssertionFailedError;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ManagementService;
......@@ -74,6 +75,7 @@ public class ActivitiInternalTestCase extends PvmTestCase {
protected RepositoryService repositoryService;
protected RuntimeService runtimeService;
protected TaskService taskService;
protected FormService formService;
protected HistoryService historyService;
protected IdentityService identityService;
protected ManagementService managementService;
......@@ -193,6 +195,7 @@ public class ActivitiInternalTestCase extends PvmTestCase {
repositoryService = processEngine.getRepositoryService();
runtimeService = processEngine.getRuntimeService();
taskService = processEngine.getTaskService();
formService = processEngine.getFormService();
historyService = processEngine.getHistoryService();
identityService = processEngine.getIdentityService();
managementService = processEngine.getManagementService();
......
......@@ -12,6 +12,8 @@
*/
package org.activiti.engine.repository;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
/** Is an object structure representing an executable process composed of
......@@ -42,9 +44,13 @@ public interface ProcessDefinition {
/** label used for display purposes */
String getName();
/** name of {@link RepositoryService#getResourceAsStream(String, String) the resource}
* of this process definition. */
String getResourceName();
/** The deployment in which this process definition is contained. */
String getDeploymentId();
String getStartFormResourceKey();
/** logical name for the form that can be used by UI's to render the form. */
String getFormKey();
}
......@@ -13,8 +13,6 @@
package org.activiti.engine.repository;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.query.Query;
......
......@@ -54,8 +54,5 @@ public interface Task {
String getProcessDefinitionId();
String getFormResourceKey();
Date getCreateTime();
}
......@@ -92,7 +92,7 @@ create table ACT_RE_PROC_DEF (
VERSION_ integer,
DEPLOYMENT_ID_ varchar(64),
RESOURCE_NAME_ varchar(255),
START_FORM_ varchar(255),
FORM_KEY_ varchar(255),
primary key (ID_)
);
......@@ -104,7 +104,7 @@ create table ACT_RU_TASK (
PROC_DEF_ID_ varchar(64),
NAME_ varchar(255),
DESCRIPTION_ varchar(255),
FORM_ varchar(255),
TASK_DEF_KEY_ varchar(255),
ASSIGNEE_ varchar(64),
PRIORITY_ integer,
CREATE_TIME_ timestamp,
......
......@@ -93,7 +93,7 @@ create table ACT_RE_PROC_DEF (
VERSION_ integer,
DEPLOYMENT_ID_ varchar(64),
RESOURCE_NAME_ varchar(255),
START_FORM_ varchar(255),
FORM_KEY_ varchar(255),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
......@@ -105,7 +105,7 @@ create table ACT_RU_TASK (
PROC_DEF_ID_ varchar(64),
NAME_ varchar(255),
DESCRIPTION_ varchar(255),
FORM_ varchar(255),
TASK_DEF_KEY_ varchar(255),
ASSIGNEE_ varchar(64),
PRIORITY_ integer,
CREATE_TIME_ timestamp,
......
......@@ -92,7 +92,7 @@ create table ACT_RE_PROC_DEF (
VERSION_ INTEGER,
DEPLOYMENT_ID_ NVARCHAR2(64),
RESOURCE_NAME_ NVARCHAR2(255),
START_FORM_ NVARCHAR2(255),
FORM_KEY_ NVARCHAR2(255),
primary key (ID_)
);
......@@ -104,7 +104,7 @@ create table ACT_RU_TASK (
PROC_DEF_ID_ NVARCHAR2(64),
NAME_ NVARCHAR2(255),
DESCRIPTION_ NVARCHAR2(255),
FORM_ NVARCHAR2(255),
TASK_DEF_KEY_ NVARCHAR2(255),
ASSIGNEE_ NVARCHAR2(64),
PRIORITY_ INTEGER,
CREATE_TIME_ TIMESTAMP(6),
......
......@@ -93,7 +93,7 @@ create table ACT_RE_PROC_DEF (
VERSION_ integer,
DEPLOYMENT_ID_ varchar(64),
RESOURCE_NAME_ varchar(255),
START_FORM_ varchar(255),
FORM_KEY_ varchar(255),
primary key (ID_)
);
......@@ -105,7 +105,7 @@ create table ACT_RU_TASK (
PROC_DEF_ID_ varchar(64),
NAME_ varchar(255),
DESCRIPTION_ varchar(255),
FORM_ varchar(255),
TASK_DEF_KEY_ varchar(255),
ASSIGNEE_ varchar(64),
PRIORITY_ integer,
CREATE_TIME_ timestamp,
......
......@@ -227,7 +227,7 @@
<!-- HISTORIC VARIABLE UPDATE INSERT -->
<insert id="insertHistoricVariableUpdate" parameterType="org.activiti.engine.impl.history.HistoricVariableUpdateEntity">
insert into ACT_HI_VAR_UPDATE (ID_, PROC_INST_ID_, EXECUTION_ID_, TASK_ID_, NAME_, TYPE_, INDEX_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT1_, TEXT2_)
insert into ACT_HI_VAR_UPDATE (ID_, PROC_INST_ID_, EXECUTION_ID_, TASK_ID_, NAME_, TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT1_, TEXT2_)
values (
#{id, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
......@@ -235,7 +235,6 @@
#{taskId, jdbcType=VARCHAR},
#{variableName, jdbcType=VARCHAR},
#{variableType, jdbcType=VARCHAR },
#{index, jdbcType=INTEGER },
#{time, jdbcType=TIMESTAMP },
#{byteArrayValueId, jdbcType=VARCHAR},
#{doubleValue, jdbcType=DOUBLE},
......@@ -261,7 +260,6 @@
<result property="name" column="NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="TYPE_" javaType="org.activiti.engine.impl.variable.Type" jdbcType="VARCHAR"/>
<result property="activityId" column="ACTIVITY_ID_" jdbcType="VARCHAR" />
<result property="index" column="INDEX_" jdbcType="INTEGER" />
<result property="time" column="TIME_" jdbcType="TIMESTAMP" />
<result property="activityId" column="ACTIVITY_ID_" jdbcType="VARCHAR" />
<result property="byteArrayValueId" column="BYTEARRAY_ID_" />
......
......@@ -118,13 +118,13 @@
<!-- PROCESSDEFINITION INSERT -->
<insert id="insertProcessDefinition" parameterType="org.activiti.engine.impl.repository.ProcessDefinitionEntity">
insert into ACT_RE_PROC_DEF(ID_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, START_FORM_, RESOURCE_NAME_)
insert into ACT_RE_PROC_DEF(ID_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, FORM_KEY_, RESOURCE_NAME_)
values (#{id, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{key, jdbcType=VARCHAR},
#{version, jdbcType=INTEGER},
#{deploymentId, jdbcType=VARCHAR},
#{startFormResourceKey, jdbcType=VARCHAR},
#{formKey, jdbcType=VARCHAR},
#{resourceName, jdbcType=VARCHAR})
</insert>
......@@ -145,7 +145,7 @@
<result property="version" column="VERSION_" jdbcType="INTEGER"/>
<result property="deploymentId" column="DEPLOYMENT_ID_" jdbcType="VARCHAR"/>
<result property="resourceName" column="RESOURCE_NAME_" jdbcType="VARCHAR"/>
<result property="startFormResourceKey" column="START_FORM_" jdbcType="VARCHAR"/>
<result property="formKey" column="FORM_KEY_" jdbcType="VARCHAR"/>
</resultMap>
<!-- PROCESSDEFINITION SELECT -->
......
......@@ -7,19 +7,19 @@
<!-- TASK INSERT -->
<insert id="insertTask" parameterType="org.activiti.engine.impl.task.TaskEntity">
insert into ACT_RU_TASK (ID_, REV_, NAME_, DESCRIPTION_, FORM_, PRIORITY_, CREATE_TIME_,
ASSIGNEE_, EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_)
insert into ACT_RU_TASK (ID_, REV_, NAME_, DESCRIPTION_, PRIORITY_, CREATE_TIME_,
ASSIGNEE_, EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_KEY_)
values (#{id, jdbcType=VARCHAR},
1,
#{name, jdbcType=VARCHAR},
#{description, jdbcType=VARCHAR},
#{formResourceKey, jdbcType=VARCHAR},
#{priority, jdbcType=INTEGER},
#{createTime, jdbcType=TIMESTAMP},
#{assignee, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
#{processDefinitionId, jdbcType=VARCHAR}
#{processDefinitionId, jdbcType=VARCHAR},
#{taskDefinitionKey, jdbcType=VARCHAR}
)
</insert>
......@@ -52,12 +52,12 @@
<result property="revision" column="REV_" jdbcType="INTEGER"/>
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="description" column="DESCRIPTION_" jdbcType="VARCHAR"/>
<result property="formResourceKey" column="FORM_" jdbcType="VARCHAR"/>
<result property="priority" column="PRIORITY_" jdbcType="INTEGER"/>
<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP" />
<result property="assignee" column="ASSIGNEE_" jdbcType="VARCHAR"/>
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
<result property="taskDefinitionKey" column="TASK_DEF_KEY_" jdbcType="VARCHAR"/>
</resultMap>
<!-- TASK SELECT -->
......
......@@ -106,7 +106,7 @@ public class RepositoryServiceTest extends ActivitiInternalTestCase {
assertEquals(1, processDefinitions.size());
ProcessDefinition processDefinition = processDefinitions.get(0);
Object startForm = taskService.getRenderedStartFormById(processDefinition.getId());
Object startForm = formService.getRenderedStartForm(processDefinition.getId());
assertNotNull(startForm);
}
......@@ -116,31 +116,22 @@ public class RepositoryServiceTest extends ActivitiInternalTestCase {
assertEquals(1, processDefinitions.size());
ProcessDefinition processDefinition = processDefinitions.get(0);
Object startForm = taskService.getRenderedStartFormById(processDefinition.getId());
Object startForm = formService.getRenderedStartForm(processDefinition.getId());
assertNull(startForm);
}
public void testGetStartFormByKeyNullKey() {
try {
taskService.getRenderedStartFormByKey(null);
formService.getRenderedStartForm(null);
fail("ActivitiException expected");
} catch (ActivitiException ae) {
// Exception expected
}
}
public void testGetStartFormByKeyUnexistingProcessDefinitionKey() {
try {
taskService.getRenderedStartFormByKey("unexisting");
fail("ActivitiException expected");
} catch (ActivitiException ae) {
assertTextPresent("no processes deployed with key", ae.getMessage());
}
}
public void testGetStartFormByIdNullId() {
try {
taskService.getRenderedStartFormById(null);
formService.getRenderedStartForm(null);
fail("ActivitiException expected");
} catch (ActivitiException ae) {
// Exception expected
......@@ -149,7 +140,7 @@ public class RepositoryServiceTest extends ActivitiInternalTestCase {
public void testGetStartFormByIdUnexistingProcessDefinitionId() {
try {
taskService.getRenderedStartFormById("unexistingId");
formService.getRenderedStartForm("unexistingId");
fail("ActivitiException expected");
} catch (ActivitiException ae) {
assertTextPresent("no deployed process definition found with id", ae.getMessage());
......
......@@ -208,7 +208,7 @@ public class TaskServiceTest extends ActivitiInternalTestCase {
public void testGetTaskFormNullTaskId() {
try {
taskService.getRenderedTaskForm(null);
formService.getRenderedTaskForm(null);
fail("ActivitiException expected");
} catch (ActivitiException ae) {
// Expected Exception
......@@ -217,10 +217,10 @@ public class TaskServiceTest extends ActivitiInternalTestCase {
public void testGetTaskFormUnexistingTaskId() {
try {
taskService.getRenderedTaskForm("unexistingtask");
formService.getRenderedTaskForm("unexistingtask");
fail("ActivitiException expected");
} catch (ActivitiException ae) {
assertTextPresent("No task found for id = 'unexistingtask'", ae.getMessage());
assertTextPresent("Task 'unexistingtask' not found", ae.getMessage());
}
}
......
......@@ -45,11 +45,11 @@ public class TaskFormsTest extends ActivitiInternalTestCase {
public void testTaskFormsWithVacationRequestProcess() {
// Get start form
Object startForm = taskService.getRenderedStartFormByKey("vacationRequest");
Object startForm = formService.getRenderedStartForm("vacationRequest:1");
assertNotNull(startForm);
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertEquals("org/activiti/examples/taskforms/request.form", processDefinition.getStartFormResourceKey());
assertEquals("org/activiti/examples/taskforms/request.form", processDefinition.getFormKey());
// Define variables that would be filled in through the form
Map<String, Object> variables = new HashMap<String, Object>();
......@@ -61,18 +61,18 @@ public class TaskFormsTest extends ActivitiInternalTestCase {
// Management should now have a task assigned to them
Task task = taskService.createTaskQuery().candidateGroup("management").singleResult();
assertEquals("Vacation request by kermit", task.getDescription());
Object taskForm = taskService.getRenderedTaskForm(task.getId());
Object taskForm = formService.getRenderedTaskForm(task.getId());
assertNotNull(taskForm);
}
@Deployment
public void testTaskFormUnavailable() {
assertNull(taskService.getRenderedStartFormByKey("noStartOrTaskForm"));
assertNull(formService.getRenderedStartForm("noStartOrTaskForm:1"));
runtimeService.startProcessInstanceByKey("noStartOrTaskForm");
Task task = taskService.createTaskQuery().singleResult();
assertNull(taskService.getRenderedTaskForm(task.getId()));
assertNull(formService.getRenderedTaskForm(task.getId()));
}
}
......@@ -28,7 +28,7 @@ public class ProcessDefinitionFormGet extends ActivitiStreamingWebScript
@Override
protected void executeStreamingWebScript(ActivitiRequest req, WebScriptResponse res) {
String processDefinitionId = req.getMandatoryPathParameter("processDefinitionId");
Object form = getTaskService().getRenderedStartFormById(processDefinitionId);
Object form = getFormService().getRenderedStartForm(processDefinitionId);
InputStream is = null;
if (form != null && form instanceof String) {
is = new ByteArrayInputStream(((String) form).getBytes());
......
......@@ -31,7 +31,7 @@ public class TaskFormGet extends ActivitiStreamingWebScript
@Override
protected void executeStreamingWebScript(ActivitiRequest req, WebScriptResponse res) {
String taskId = req.getMandatoryPathParameter("taskId");
Object form = getTaskService().getRenderedTaskForm(taskId);
Object form = getFormService().getRenderedTaskForm(taskId);
InputStream is = null;
if (form != null && form instanceof String) {
is = new ByteArrayInputStream(((String) form).getBytes());
......
......@@ -206,5 +206,12 @@ public class ActivitiStreamingWebScript extends AbstractWebScript {
return getProcessEngine().getTaskService();
}
/**
* Returns the form service.
*
* @return The form service
*/
protected FormService getFormService() {
return getProcessEngine().getFormService();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册