use of org.jbpm.services.task.commands.TaskCommand in project jbpm by kiegroup.
the class UserTaskServiceImpl method getRuntimeManager.
protected RuntimeManager getRuntimeManager(String deploymentId, Command<?> command) {
if (deploymentId == null && command instanceof TaskCommand<?>) {
Long taskId = ((TaskCommand<?>) command).getTaskId();
if (taskId != null) {
UserTaskInstanceDesc task = dataService.getTaskById(taskId);
deploymentId = task.getDeploymentId();
}
}
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentId);
if (manager == null) {
InternalTaskService internalTaskService = getInternalTaskService();
if (internalTaskService != null) {
manager = new FalbackRuntimeManager(internalTaskService);
} else {
logger.warn("Cannot find runtime manager for deployment {}", deploymentId);
throw new RuntimeException("No runtime manager found for deployment " + deploymentId);
}
}
return manager;
}
use of org.jbpm.services.task.commands.TaskCommand in project jbpm by kiegroup.
the class JaxbTaskSerializationTest method compositeCommandXmlElementsAnnoTest.
@Test
public void compositeCommandXmlElementsAnnoTest() throws Exception {
Field[] comCmdFields = CompositeCommand.class.getDeclaredFields();
for (Field field : comCmdFields) {
XmlElements xmlElemsAnno = field.getAnnotation(XmlElements.class);
if (xmlElemsAnno != null) {
Set<Class<? extends TaskCommand>> taskCmdSubTypes = reflections.getSubTypesOf(TaskCommand.class);
Set<Class<? extends UserGroupCallbackTaskCommand>> userGrpTaskCmdSubTypes = reflections.getSubTypesOf(UserGroupCallbackTaskCommand.class);
taskCmdSubTypes.addAll(userGrpTaskCmdSubTypes);
Class[] exclTaskCmds = { UserGroupCallbackTaskCommand.class, CompositeCommand.class, GetCurrentTxTasksCommand.class };
taskCmdSubTypes.removeAll(Arrays.asList(exclTaskCmds));
for (XmlElement xmlElemAnno : xmlElemsAnno.value()) {
Class xmlElemAnnoType = xmlElemAnno.type();
assertTrue(xmlElemAnnoType.getName() + " does not extend the " + TaskCommand.class.getSimpleName() + " class!", taskCmdSubTypes.contains(xmlElemAnnoType));
}
for (XmlElement xmlElemAnno : xmlElemsAnno.value()) {
Class xmlElemAnnoType = xmlElemAnno.type();
taskCmdSubTypes.remove(xmlElemAnnoType);
}
if (!taskCmdSubTypes.isEmpty()) {
System.out.println("##### " + taskCmdSubTypes.iterator().next().getCanonicalName());
fail("(" + taskCmdSubTypes.iterator().next().getSimpleName() + ") Not all " + TaskCommand.class.getSimpleName() + " sub types have been added to the @XmlElements in the CompositeCommand." + field.getName() + " field.");
}
} else {
assertFalse("TaskCommand fields need to be annotated with @XmlElements annotations!", TaskCommand.class.equals(field.getType()));
if (field.getType().isArray()) {
Class arrElemType = field.getType().getComponentType();
if (arrElemType != null) {
assertFalse("TaskCommand fields (CompositeCommand." + field.getName() + ") need to be annotated with @XmlElements annotations!", TaskCommand.class.equals(arrElemType));
}
} else if (Collection.class.isAssignableFrom(field.getType())) {
ParameterizedType fieldGenericType = (ParameterizedType) field.getGenericType();
Type listType = fieldGenericType.getActualTypeArguments()[0];
if (listType != null) {
assertFalse("TaskCommand fields (CompositeCommand." + field.getName() + ") need to be annotated with @XmlElements annotations!", TaskCommand.class.equals(listType));
}
}
}
}
}
Aggregations