提交 a2bfafed 编写于 作者: T tombaeyens

ACT-242 added getDeployedprocessDefinition to expose process definitions for introspection

上级 1982939c
......@@ -19,6 +19,7 @@ import java.util.List;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.DeploymentQuery;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.pvm.process.ReadOnlyProcessDefinition;
/** Service providing access to the repository of process definitions and deployments.
......@@ -63,7 +64,9 @@ public interface RepositoryService {
/** Query process definitions. */
ProcessDefinitionQuery createProcessDefinitionQuery();
/** exposes a fully deployed process definition for introspection purposes. */
ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId);
/** Query process definitions. */
DeploymentQuery createDeploymentQuery();
}
......@@ -19,6 +19,7 @@ import java.util.List;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.cmd.DeleteDeploymentCmd;
import org.activiti.engine.impl.cmd.DeployCmd;
import org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd;
import org.activiti.engine.impl.cmd.GetDeploymentResourceCmd;
import org.activiti.engine.impl.cmd.GetDeploymentResourceNamesCmd;
import org.activiti.engine.impl.repository.DeploymentBuilderImpl;
......@@ -26,6 +27,7 @@ import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.DeploymentQuery;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.pvm.process.ReadOnlyProcessDefinition;
/**
......@@ -65,5 +67,9 @@ public class RepositoryServiceImpl extends ServiceImpl implements RepositoryServ
public DeploymentQuery createDeploymentQuery() {
return new DeploymentQueryImpl(commandExecutor);
}
public ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId) {
return commandExecutor.execute(new GetDeploymentProcessDefinitionCmd(processDefinitionId));
}
}
/* 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.impl.cfg.RepositorySession;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.pvm.process.ReadOnlyProcessDefinition;
/**
* @author Tom Baeyens
*/
public class GetDeploymentProcessDefinitionCmd implements Command<ReadOnlyProcessDefinition> {
protected String processDefinitionId;
public GetDeploymentProcessDefinitionCmd(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
public ReadOnlyProcessDefinition execute(CommandContext commandContext) {
RepositorySession repositorySession = commandContext.getRepositorySession();
return repositorySession.findDeployedProcessDefinitionById(processDefinitionId);
}
}
......@@ -13,10 +13,15 @@
package org.activiti.engine.test.db;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.activiti.engine.impl.test.ActivitiInternalTestCase;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.pvm.process.PvmActivity;
import org.activiti.pvm.process.PvmTransition;
import org.activiti.pvm.process.ReadOnlyProcessDefinition;
/**
......@@ -40,4 +45,34 @@ public class ProcessDefinitionPersistenceTest extends ActivitiInternalTestCase {
repositoryService.deleteDeployment(deploymentId);
}
public void testProcessDefinitionIntrospection() {
String deploymentId = repositoryService
.createDeployment()
.addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml")
.deploy()
.getId();
ReadOnlyProcessDefinition processDefinition = repositoryService.getDeployedProcessDefinition("processOne:1");
assertEquals("processOne:1", processDefinition.getId());
PvmActivity start = processDefinition.findActivity("start");
assertNotNull(start);
assertEquals("start", start.getId());
assertEquals(Collections.EMPTY_LIST, start.getActivities());
List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
assertEquals(1, outgoingTransitions.size());
PvmActivity end = processDefinition.findActivity("end");
assertNotNull(end);
assertEquals("end", end.getId());
PvmTransition transition = outgoingTransitions.get(0);
assertEquals("flow1", transition.getId());
assertSame(start, transition.getSource());
assertSame(end, transition.getDestination());
repositoryService.deleteDeployment(deploymentId);
}
}
......@@ -19,10 +19,8 @@ import org.activiti.pvm.runtime.PvmProcessInstance;
/**
* @author Tom Baeyens
*/
public interface PvmProcessDefinition extends PvmScope {
public interface PvmProcessDefinition extends ReadOnlyProcessDefinition {
PvmProcessInstance createProcessInstance();
PvmActivity getInitial();
}
/* 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.pvm.process;
/**
* @author Tom Baeyens
*/
public interface ReadOnlyProcessDefinition extends PvmScope {
PvmActivity getInitial();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册