Search in sources :

Example 6 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class Max method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    SimpleData result = null;
    arguments = collapseLists(arguments, 0);
    for (int i = 0; i < arguments.size(); i++) if (result == null || result.lessThan(getArg(arguments, i)))
        result = getArg(arguments, i);
    return result;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 7 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class Min method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    SimpleData result = null;
    arguments = collapseLists(arguments, 0);
    for (int i = 0; i < arguments.size(); i++) if (result == null || result.greaterThan(getArg(arguments, i)))
        result = getArg(arguments, i);
    return result;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 8 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class HTMLPreprocessor method getList.

/** Lookup the named list and return it.
     *
     * if the name is enclosed in braces [] it refers to a data
     * element - otherwise it refers to a cgi environment variable or
     * a query/post parameter.
     *
     * If no list is found by that name, will return an empty list.
     */
private ListData getList(String listName) {
    if (listName.startsWith("[")) {
        // listName names a data element
        listName = trimDelim(listName);
        SimpleData d = getSimpleValue(listName);
        if (d instanceof ListData)
            return (ListData) d;
        if (d instanceof StringData)
            return ((StringData) d).asList();
        if (d instanceof SimpleData) {
            ListData result = new ListData();
            result.add(d.format());
        }
        return EMPTY_LIST;
    } else {
        // listName names an environment variable or parameter
        ListData result = new ListData();
        // try for an environment variable first.
        Object envVal = env.get(listName);
        if (envVal instanceof String) {
            result.add((String) envVal);
            return result;
        }
        // look for a parameter value.
        Object allParam = params.get(listName + "_ALL");
        if (allParam instanceof String[]) {
            String[] param = (String[]) allParam;
            for (int i = 0; i < param.length; i++) result.add(param[i]);
        } else {
            Object p = params.get(listName);
            if (p == null)
                p = getResource(listName);
            if (p instanceof String) {
                String paramVal = (String) p;
                if (paramVal.startsWith("LIST="))
                    return new ListData(paramVal.substring(5));
                else
                    result.add(paramVal);
            }
        }
        return result;
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) EscapeString(net.sourceforge.processdash.util.EscapeString) StringData(net.sourceforge.processdash.data.StringData) ListData(net.sourceforge.processdash.data.ListData)

Example 9 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class HTMLPreprocessor method getString.

/** Lookup the named string and return it.
     *
     * if the name is enclosed in braces [] it refers to a data
     * element - otherwise it refers to a cgi environment variable or
     * a query/post parameter.
     *
     * If no string is found by that name, will return an empty string.
     */
private String getString(String name) {
    if (name.startsWith("[")) {
        // listName names a data element
        name = trimDelim(name);
        SimpleData d = getSimpleValue(name);
        return (d == null ? "" : d.format());
    } else if ("_UNIQUE_".equals(name)) {
        return Long.toString(uniqueNumber++);
    } else {
        // try for an environment variable first.
        Object result = env.get(name);
        if (result instanceof String)
            return (String) result;
        // look for a parameter value.
        result = params.get(name);
        if (result instanceof String)
            return (String) result;
        if (result != null)
            return result.toString();
        // look for a resource value.
        result = getResource(name);
        if (result != null)
            return (String) result;
        // look for a user setting
        result = Settings.getVal(name);
        if (result != null)
            return result.toString();
        return "";
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) EscapeString(net.sourceforge.processdash.util.EscapeString)

Example 10 with SimpleData

use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.

the class SyncWBS method getWBSLocation.

private URL getWBSLocation(DataRepository data) throws MalformedURLException, TinyCGIException {
    String urlDataName = DataRepository.createDataName(projectRoot, TeamDataConstants.TEAM_DATA_DIRECTORY_URL);
    URL wbsLocation = getWBSLocationFromUrlDataElement(data, urlDataName);
    if (wbsLocation == null) {
        // find the data directory for this team project.
        String teamDirectoryLocation = null;
        File teamDirectory = null;
        SimpleData d = data.getSimpleValue(DataRepository.createDataName(projectRoot, TeamDataConstants.TEAM_DATA_DIRECTORY));
        if (d == null || !d.test() || "Enter network directory path".equals(teamDirectoryLocation = d.format()))
            signalError(TEAM_DIR_MISSING);
        teamDirectoryLocation = ExternalResourceManager.getInstance().remapFilename(teamDirectoryLocation);
        teamDirectory = new File(teamDirectoryLocation);
        if (!teamDirectory.isDirectory())
            signalError(TEAM_DIR_UNAVAILABLE, teamDirectoryLocation);
        URL serverURL = TeamServerSelector.getServerURL(teamDirectory);
        if (serverURL != null) {
            data.putValue(urlDataName, StringData.create(serverURL.toString()));
            wbsLocation = new URL(serverURL.toString() + "/" + HIER_FILENAME);
            // if the physical directory is now obsolete, remove the pointers
            // to that directory so we never attempt to look there again.
            File obsoleteDirMarkerFile = new File(teamDirectory, TeamDataConstants.OBSOLETE_DIR_MARKER_FILENAME);
            if (obsoleteDirMarkerFile.isFile()) {
                data.putValue(DataRepository.createDataName(projectRoot, TeamDataConstants.TEAM_DIRECTORY), null);
                data.putValue(DataRepository.createDataName(projectRoot, TeamDataConstants.TEAM_DIRECTORY_UNC), null);
            }
        } else {
            // locate the wbs file in the team data directory.
            File wbsFile = new File(teamDirectoryLocation, HIER_FILENAME);
            if (!wbsFile.exists())
                signalError(WBS_FILE_MISSING);
            if (!wbsFile.canRead())
                signalError(WBS_FILE_INACCESSIBLE + "&wbsFile", wbsFile.toString());
            // locate the workflow file and the templates directory
            workflowFile = new File(teamDirectoryLocation, WORKFLOW_FILENAME);
            templatesDir = new File(teamDirectory.getParentFile().getParentFile(), "Templates");
            wbsLocation = wbsFile.toURI().toURL();
        }
    }
    return wbsLocation;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) File(java.io.File) URL(java.net.URL)

Aggregations

SimpleData (net.sourceforge.processdash.data.SimpleData)164 ListData (net.sourceforge.processdash.data.ListData)20 DoubleData (net.sourceforge.processdash.data.DoubleData)15 SaveableData (net.sourceforge.processdash.data.SaveableData)14 StringData (net.sourceforge.processdash.data.StringData)13 IOException (java.io.IOException)11 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)11 DateData (net.sourceforge.processdash.data.DateData)10 Iterator (java.util.Iterator)9 List (java.util.List)7 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)6 NumberData (net.sourceforge.processdash.data.NumberData)6 Element (org.w3c.dom.Element)6 Map (java.util.Map)5 DataContext (net.sourceforge.processdash.data.DataContext)5 EscapeString (net.sourceforge.processdash.util.EscapeString)5 File (java.io.File)4