Search in sources :

Example 16 with DoubleData

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

the class EVTask method saveDataElement.

private void saveDataElement(String oldTaskListName, String newTaskListName, String dataNamePrefix, int savedValue, int newValue, int defaultValue) {
    if (fullName == null || fullName.length() == 0)
        return;
    String oldDataName = null;
    if (savedValue != defaultValue)
        oldDataName = dataNamePrefix + oldTaskListName;
    if (newTaskListName != null && newValue != defaultValue) {
        String newDataName = dataNamePrefix + newTaskListName;
        if (newDataName.equals(oldDataName))
            oldDataName = null;
        if (newValue != savedValue || oldDataName != null) {
            SimpleData d = new DoubleData(newValue, false);
            String dataName = DataRepository.createDataName(fullName, newDataName);
            data.putValue(dataName, d);
        }
    }
    if (oldDataName != null) {
        String dataName = DataRepository.createDataName(fullName, oldDataName);
        data.putValue(dataName, null);
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 17 with DoubleData

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

the class AbstractSyncWorker method markLeafComplete.

public void markLeafComplete(String path) {
    if (completionPermissions == null || completionPermissions.contains(getOriginalPath(path))) {
        String completionDataName = dataName(path, "Completed");
        if (getSimpleValue(completionDataName) != null)
            return;
        SimpleData actualTime = getSimpleValue(dataName(path, "Time"));
        if (actualTime instanceof NumberData) {
            double time = ((NumberData) actualTime).getDouble();
            DoubleData estimatedTime = new DoubleData(time, true);
            doPutValue(dataName(path, "Estimated Time"), estimatedTime);
            doPutValue(dataName(path, syncDataName("Estimated Time")), estimatedTime);
        }
        DateData now = new DateData();
        doPutValue(completionDataName, now);
        doPutValue(syncDataName(completionDataName), now);
        nodesCompleted.add(path);
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData) NumberData(net.sourceforge.processdash.data.NumberData) SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 18 with DoubleData

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

the class EVTaskListData method save.

public void save(String newName) {
    EVTask r = (EVTask) root;
    boolean nameIsChanging = (!taskListName.equals(newName));
    saveScheduleNotes();
    // First, compile a list of all the elements in the datafile that
    // were previously used to save this task list.  (That way we'll
    // know what we need to delete.)
    String globalPrefix = MAIN_DATA_PREFIX + taskListName + "/";
    String ordinalPrefix = "/" + TASK_ORDINAL_PREFIX + taskListName;
    Iterator i = data.getKeys(null, DataNameFilter.EXPLICIT_ONLY);
    Set oldNames = new HashSet();
    String dataName;
    while (i.hasNext()) {
        dataName = (String) i.next();
        if (dataName.startsWith(globalPrefix) || dataName.endsWith(ordinalPrefix))
            oldNames.add(dataName);
    }
    // Now, save the data to the repository.
    if (newName != null) {
        globalPrefix = MAIN_DATA_PREFIX + newName;
        ordinalPrefix = TASK_ORDINAL_PREFIX + newName;
        for (int j = r.getNumChildren(); j-- > 0; ) {
            dataName = DataRepository.createDataName(r.getChild(j).getFullName(), ordinalPrefix);
            data.putValue(dataName, new DoubleData(j, false));
            oldNames.remove(dataName);
        }
        // save the schedule
        dataName = DataRepository.createDataName(globalPrefix, EST_HOURS_DATA_NAME);
        data.putValue(dataName, schedule.getSaveList());
        oldNames.remove(dataName);
        if (schedule.areDatesLocked()) {
            dataName = DataRepository.createDataName(globalPrefix, DATES_LOCKED_DATA_NAME);
            data.putValue(dataName, ImmutableDoubleData.TRUE);
            oldNames.remove(dataName);
        }
        // save the task list unique ID and the metadata
        oldNames.remove(saveID(newName, data));
        oldNames.remove(saveMetadata(newName, data));
        renameSnapshots(oldNames, newName, data);
        taskListName = newName;
    }
    // Finally, delete any old unused data elements.
    i = oldNames.iterator();
    while (i.hasNext()) {
        dataName = (String) i.next();
        if (!nameIsChanging && dataName.startsWith(MAIN_DATA_PREFIX))
            // (introduced in a later version of the dashboard)
            ;
        else
            data.removeValue(dataName);
    }
    // allow our tasks to do the same thing.
    r.saveStructuralData(newName);
    r.saveDependencyInformation();
    super.save(newName);
    // rearranging tasks might alter data in a lot of data files. Flush
    // all of those changes to disk, then export project data if needed.
    data.saveAllDatafiles();
    maybeStartBackgroundExport();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) DoubleData(net.sourceforge.processdash.data.DoubleData) ImmutableDoubleData(net.sourceforge.processdash.data.ImmutableDoubleData) HashSet(java.util.HashSet)

Example 19 with DoubleData

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

the class RollupAutoData method buildRollupData.

private void buildRollupData(DataRepository data) {
    //System.out.println("buildRollupData for " + definesRollupID);
    Map baseDefinitions = null;
    try {
        baseDefinitions = data.loadIncludedFileDefinitions(basedOnDataFile);
        // can exit immediately.
        if (definitions != null)
            return;
    } catch (Exception e) {
        logger.log(Level.WARNING, "Caught Exception", e);
        return;
    }
    Map rollupDefinitions = new HashMap();
    StringBuffer definitionBuffer = new StringBuffer();
    definitionBuffer.append("#define ROLLUP_ID ").append(esc(definesRollupID));
    // Define macros for rolling up numbers and lists
    definitionBuffer.append("\n#define ROLLUP_NUMBER(Data) ");
    rollupDouble(definitionBuffer, "Data");
    definitionBuffer.append("\n#define ROLLUP_LIST(Data) ");
    rollupList(definitionBuffer, "Data");
    // Include the standard rollup data definitions
    definitionBuffer.append("\n").append(ROLLUP_DATA).append("\n");
    Map toDateAliasDefinitions = new HashMap();
    String toDatePrefix = "/To Date/" + definesRollupID + "/All";
    toDateAliasDefinitions.put(definesRollupID + " To Date Subset Prefix", StringData.create(toDatePrefix));
    StringBuffer toDateAliasBuffer = new StringBuffer();
    Iterator i = baseDefinitions.entrySet().iterator();
    Map.Entry definition;
    String name;
    Object value;
    while (i.hasNext()) {
        definition = (Map.Entry) i.next();
        name = (String) definition.getKey();
        value = definition.getValue();
        if (skipElement(name, value))
            // filter out elements which should not be rolled up.
            continue;
        else if (value instanceof DoubleData) {
            // roll up the values of any literal double data elements.
            rollupDouble(definitionBuffer, name);
            addAlias(toDateAliasBuffer, name, definesRollupID);
        } else if (value instanceof ListFunction)
            // roll up the values of any search()-generated lists.
            rollupList(definitionBuffer, name);
        else if (value != null) {
            if (value instanceof CompiledScript)
                addAlias(toDateAliasBuffer, name, definesRollupID);
            // DO NOT roll up dates, strings, lists, tags,
            // compiled functions, or old-style definitions - just
            // copy them into the rollup set verbatim.
            rollupDefinitions.put(name, value);
        }
    }
    // Calculate the rollup aliases
    parseDefinitions(data, toDateAliasBuffer.toString(), toDateAliasDefinitions);
    aliasDefs = toDateAliasDefinitions;
    // If the user specified a datafile for this rollup, include it.
    if (XMLUtils.hasValue(rollupDataFile))
        try {
            URLConnection conn = TemplateLoader.resolveURLConnection(rollupDataFile);
            String contents = new String(FileUtils.slurpContents(conn.getInputStream(), true));
            definitionBuffer.append("\n").append(contents).append("\n");
        } catch (IOException ioe) {
            logger.log(Level.WARNING, "IOException", ioe);
        }
    // Calculate the rollup definitions and return them.
    parseDefinitions(data, definitionBuffer.toString(), rollupDefinitions);
    definitions = rollupDefinitions;
    debugPrint(rollupDefinitions);
    try {
        // Mount this rollup data set in the repository.
        data.mountPhantomData(toDatePrefix, rollupDefinitions);
    } catch (Exception e) {
        logger.log(Level.WARNING, "Caught Exception", e);
    }
}
Also used : CompiledScript(net.sourceforge.processdash.data.compiler.CompiledScript) ListFunction(net.sourceforge.processdash.data.ListFunction) HashMap(java.util.HashMap) IOException(java.io.IOException) IOException(java.io.IOException) DoubleData(net.sourceforge.processdash.data.DoubleData) URLConnection(java.net.URLConnection) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with DoubleData

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

the class TextMetricsFileImporter method parseValue.

private static Object parseValue(String value) {
    SimpleData result;
    // is it a tag?
    if ("TAG".equalsIgnoreCase(value))
        return TagData.getInstance();
    // first, try to interpret the string as a number.
    if ("0.0".equals(value))
        return ImmutableDoubleData.READ_ONLY_ZERO;
    if ("NaN".equals(value))
        return ImmutableDoubleData.READ_ONLY_NAN;
    if (DoubleData.P_INF_STR.equals(value) || DoubleData.N_INF_STR.equals(value))
        return ImmutableDoubleData.DIVIDE_BY_ZERO;
    if (value.length() > 0)
        switch(value.charAt(0)) {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
            case '-':
            case '+':
            case '.':
            case ',':
                try {
                    result = new DoubleData(value);
                    result.setEditable(false);
                    return result;
                } catch (MalformedValueException mfe) {
                }
        }
    // next, try to interpret the string as a date.
    try {
        result = DateData.create(value);
        result.setEditable(false);
        return result;
    } catch (MalformedValueException mfe) {
    }
    // give up and interpret it as a plain string.
    result = StringData.create(StringData.unescapeString(value));
    result.setEditable(false);
    return result;
}
Also used : MalformedValueException(net.sourceforge.processdash.data.MalformedValueException) SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData) ImmutableDoubleData(net.sourceforge.processdash.data.ImmutableDoubleData)

Aggregations

DoubleData (net.sourceforge.processdash.data.DoubleData)39 SimpleData (net.sourceforge.processdash.data.SimpleData)15 Iterator (java.util.Iterator)7 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)7 ListData (net.sourceforge.processdash.data.ListData)5 NumberData (net.sourceforge.processdash.data.NumberData)5 ResultSet (net.sourceforge.processdash.data.util.ResultSet)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 SaveableData (net.sourceforge.processdash.data.SaveableData)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 NumberFunction (net.sourceforge.processdash.data.NumberFunction)3 StringData (net.sourceforge.processdash.data.StringData)3 CompiledScript (net.sourceforge.processdash.data.compiler.CompiledScript)3 IOException (java.io.IOException)2 DateData (net.sourceforge.processdash.data.DateData)2 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)2 StudyGroupManager (net.sourceforge.processdash.tool.db.StudyGroupManager)2