use of net.sourceforge.processdash.tool.db.DatabasePlugin in project processdash by dtuma.
the class DbAbstractFunction method getDbObject.
/**
* Return an object from the database plugin's registry.
*/
protected <T> T getDbObject(ExpressionContext context, Class<T> clazz) {
ListData dbItem = (ListData) context.get(DatabasePlugin.DATA_REPOSITORY_NAME);
if (dbItem == null)
return null;
DatabasePlugin plugin = (DatabasePlugin) dbItem.get(0);
T result = plugin.getObject(clazz);
return result;
}
use of net.sourceforge.processdash.tool.db.DatabasePlugin in project processdash by dtuma.
the class AnalysisPage method getChartData.
protected static ChartData getChartData(HttpServletRequest req, boolean applyFilter) {
ChartData result = new ChartData();
String workflowID = req.getParameter("workflow");
if (!StringUtils.hasValue(workflowID))
return null;
DashboardContext ctx = (DashboardContext) PDashServletUtils.buildEnvironment(req).get(TinyCGI.DASHBOARD_CONTEXT);
DatabasePlugin databasePlugin = ctx.getDatabasePlugin();
QueryUtils.waitForAllProjects(databasePlugin);
QueryRunner query = databasePlugin.getObject(QueryRunner.class);
result.histData = new WorkflowHistDataHelper(query, workflowID);
if (result.histData.getWorkflowName() == null)
return null;
if (applyFilter)
configureFilter(result.histData, req);
configureSizeUnits(result, ctx);
return result;
}
use of net.sourceforge.processdash.tool.db.DatabasePlugin in project processdash by dtuma.
the class WorkflowMappingManager method saveChangedMappings.
public void saveChangedMappings(Workflow workflow, Workflow target, Map<String, String> changes, Map env) throws WorkflowMappingException {
// find the project this workflow is associated with, and get a
// workflow alterer for that project
String projectId = getProjectIDForWorkflowID(workflow.getId());
WorkflowMappingAlterer alterer = WorkflowMappingAltererFactory.get((DashboardContext) env.get(TinyCGI.DASHBOARD_CONTEXT), projectId);
if (alterer == null)
throw new NotFound("Could not find project for workflow " + workflow.getId());
// save the requested changes
alterer.applyChanges(workflow, target, changes);
// tell the data importer to reload data from this project. (In bridged
// mode, this will cause it to refresh the project directory.)
DataImporter.refreshLocation(projectId);
// ask the warehouse to reload all data, and wait for it to finish
DatabasePlugin databasePlugin = //
QueryUtils.getDatabasePlugin((DataContext) env.get(TinyCGI.DATA_REPOSITORY));
DataReloader reloader = databasePlugin.getObject(DataReloader.class);
reloader.reloadAllData();
}
use of net.sourceforge.processdash.tool.db.DatabasePlugin in project processdash by dtuma.
the class UserGroupUtil method getProjectIDsForFilter.
public static Set<String> getProjectIDsForFilter(UserFilter filter, DashboardContext ctx) {
if (filter == null)
return null;
Set<String> datasetIDs = filter.getDatasetIDs();
if (datasetIDs == null)
return null;
else if (datasetIDs.isEmpty())
return Collections.EMPTY_SET;
DatabasePlugin databasePlugin = ctx.getDatabasePlugin();
QueryUtils.waitForAllProjects(databasePlugin);
QueryRunner query = databasePlugin.getObject(QueryRunner.class);
return new HashSet(query.queryHql(PROJECT_FILTER_QUERY, datasetIDs));
}
use of net.sourceforge.processdash.tool.db.DatabasePlugin in project processdash by dtuma.
the class ProcessDashboard method createDatabasePlugin.
/**
* Create the database plugin and possibly start it.
*
* @return true if the plugin was started.
*/
private boolean createDatabasePlugin() {
try {
// create the database plugin object
List extensions = ExtensionManager.getExecutableExtensions(DatabasePlugin.EXTENSION_POINT_ID, this);
if (extensions == null || extensions.isEmpty())
return false;
// there should always only be one instance of this extension
// point. If multiple are present, go with the first one
DatabasePlugin plugin = (DatabasePlugin) extensions.get(0);
this.databasePlugin = plugin;
// register the plugin as an element in the data repository
ListData dbItem = new ListData();
dbItem.add(databasePlugin);
data.putValue(DatabasePlugin.DATA_REPOSITORY_NAME, dbItem);
data.pinElement(DatabasePlugin.DATA_REPOSITORY_NAME);
// setting, only start the plugin for team dashboard datasets.
if (Settings.getBool("tpidw.enabled", Settings.isTeamMode())) {
plugin.initialize();
data.addGlobalDefineDeclarations("#define DATABASE_PLUGIN t");
return true;
}
} catch (Exception e) {
// problem starting database plugin
logger.log(Level.SEVERE, "Unable to start the database plugin", e);
}
return false;
}
Aggregations