PackageDefinitionDao packageDefinitionDao = (PackageDefinitionDao) AppUtil.getApplicationContext().getBean("packageDefinitionDao");
WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
Collection<Plugin> pluginList = pluginManager.list(DeadlinePlugin.class);
for (Plugin plugin : pluginList) {
DeadlinePlugin p = (DeadlinePlugin) plugin;
try {
AppDefinition appDef = null;
//get package definition by process id
WorkflowProcess process = workflowManager.getRunningProcessById(processId);
if (process != null) {
PackageDefinition packageDef = packageDefinitionDao.loadPackageDefinition(process.getPackageId(), Long.parseLong(process.getVersion()));
if (packageDef != null) {
appDef = packageDef.getAppDefinition();
}
}
if (appDef != null) {
PluginDefaultPropertiesDao pluginDefaultPropertiesDao = (PluginDefaultPropertiesDao) AppUtil.getApplicationContext().getBean("pluginDefaultPropertiesDao");
PluginDefaultProperties pluginDefaultProperties = pluginDefaultPropertiesDao.loadById(plugin.getClass().getName(), appDef);
if (pluginDefaultProperties != null) {
Map propertiesMap = new HashMap();
if (!(plugin instanceof PropertyEditable)) {
propertiesMap = CsvUtil.getPluginPropertyMap(pluginDefaultProperties.getPluginProperties());
} else {
String json = pluginDefaultProperties.getPluginProperties();
//process basic hash variable
json = AppUtil.processHashVariable(json, null, StringUtil.TYPE_JSON, null);
propertiesMap = PropertyUtil.getPropertiesValueFromJson(json);
}
propertiesMap.put("processId", processId);
propertiesMap.put("activityId", activityId);
propertiesMap.put("workflowDeadline", deadline);
propertiesMap.put("processStartedTime", processStartedTime);
propertiesMap.put("activityAcceptedTime", activityAcceptedTime);
propertiesMap.put("activityActivatedTime", activityActivatedTime);
propertiesMap.put("pluginManager", pluginManager);
return p.evaluateDeadline(propertiesMap);
}
}
} catch (Exception e) {
LogUtil.error(getClass().getName(), e, "Error executing Deadline plugin " + p.getClass().getName());
}
}
return deadline;
}