Search in sources :

Example 1 with DatabasePlugin

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;
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) ListData(net.sourceforge.processdash.data.ListData)

Example 2 with DatabasePlugin

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;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) WorkflowHistDataHelper(net.sourceforge.processdash.tool.db.WorkflowHistDataHelper) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner)

Example 3 with DatabasePlugin

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();
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) DataReloader(net.sourceforge.processdash.tool.db.DataReloader)

Example 4 with DatabasePlugin

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));
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner) HashSet(java.util.HashSet)

Example 5 with DatabasePlugin

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;
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) LinkedList(java.util.LinkedList) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) TamperException(net.sourceforge.processdash.security.TamperDeterrent.TamperException) CannotCreateLockException(net.sourceforge.processdash.util.lock.CannotCreateLockException) IOException(java.io.IOException) SentLockMessageException(net.sourceforge.processdash.util.lock.SentLockMessageException) ReadOnlyLockFailureException(net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException) FileNotFoundException(java.io.FileNotFoundException) OfflineLockLostException(net.sourceforge.processdash.util.lock.OfflineLockLostException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

DatabasePlugin (net.sourceforge.processdash.tool.db.DatabasePlugin)8 QueryRunner (net.sourceforge.processdash.tool.db.QueryRunner)4 ListData (net.sourceforge.processdash.data.ListData)3 IOException (java.io.IOException)2 List (java.util.List)2 DashboardContext (net.sourceforge.processdash.DashboardContext)2 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 EventListenerList (javax.swing.event.EventListenerList)1 PDashContext (net.sourceforge.processdash.api.PDashContext)1 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)1 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)1 TamperException (net.sourceforge.processdash.security.TamperDeterrent.TamperException)1 DataReloader (net.sourceforge.processdash.tool.db.DataReloader)1 ProjectLocator (net.sourceforge.processdash.tool.db.ProjectLocator)1 WorkflowHistDataHelper (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper)1