public class AppWorkflowHelper implements WorkflowHelper {
@Override
public boolean executeTool(WorkflowAssignment assignment) {
ApplicationContext appContext = AppUtil.getApplicationContext();
PluginManager pluginManager = (PluginManager) appContext.getBean("pluginManager");
AppDefinition appDef = null;
if (assignment != null) {
WorkflowManager workflowManager = (WorkflowManager) appContext.getBean("workflowManager");
PackageDefinitionDao packageDefinitionDao = (PackageDefinitionDao) appContext.getBean("packageDefinitionDao");
String processDefId = assignment.getProcessDefId();
WorkflowProcess process = workflowManager.getProcess(processDefId);
if (process != null) {
String packageId = process.getPackageId();
Long packageVersion = Long.parseLong(process.getVersion());
PackageDefinition packageDef = packageDefinitionDao.loadPackageDefinition(packageId, packageVersion);
if (packageDef != null) {
appDef = packageDef.getAppDefinition();
}
}
}
if (appDef != null && appDef.getPackageDefinition() != null) {
PackageDefinition packageDef = appDef.getPackageDefinition();
String processDefId = WorkflowUtil.getProcessDefIdWithoutVersion(assignment.getProcessDefId());
PackageActivityPlugin activityPluginMeta = packageDef.getPackageActivityPlugin(processDefId, assignment.getActivityDefId());
Plugin plugin = null;
if (activityPluginMeta != null) {
plugin = pluginManager.getPlugin(activityPluginMeta.getPluginName());
}
if (plugin != null) {
Map propertiesMap = AppPluginUtil.getDefaultProperties(plugin, activityPluginMeta.getPluginProperties(), appDef);
propertiesMap.put("workflowAssignment", assignment);