Search in sources :

Example 6 with Entry

use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.

the class ProjectHistoryBridgedAbstract method initTimeDelta.

protected void initTimeDelta(ManifestEntry changeHist) {
    // these back to UTC timestamps.
    if (timeDelta == 0 && changeHist != null) {
        try {
            Element xml = parseXml(changeHist.getStream());
            ChangeHistory changes = new ChangeHistory(xml);
            Entry lastChange = changes.getLastEntry();
            long lastTimestamp = lastChange.getTimestamp().getTime();
            timeDelta = changeHist.lastMod - lastTimestamp;
            // the file modification time can normally differ from the
            // change timestamp by a second or two; but we are only
            // interested in the delta caused by time zone differences.
            // round the delta to an even half-hour interval.
            double fraction = timeDelta / (30.0 * DateUtils.MINUTES);
            timeDelta = (int) Math.round(fraction) * 30 * DateUtils.MINUTES;
        } catch (Exception e) {
        }
    }
}
Also used : ChangeHistory(teamdash.wbs.ChangeHistory) ZipEntry(java.util.zip.ZipEntry) Entry(teamdash.wbs.ChangeHistory.Entry) Element(org.w3c.dom.Element) ParseException(java.text.ParseException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 7 with Entry

use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.

the class TeamProjectMergeCoordinator method recordMergedChangeHistoryEntries.

private void recordMergedChangeHistoryEntries() {
    ChangeHistory baseChanges = new ChangeHistory(baseDir.getDirectory());
    ChangeHistory mainChanges = new ChangeHistory(mainDir.getDirectory());
    Entry lastBaseChange = baseChanges.getLastEntry();
    if (lastBaseChange == null)
        return;
    String lastBaseChangeUid = lastBaseChange.getUid();
    boolean sawLastBaseChange = false;
    for (Entry mainChange : mainChanges.getEntries()) {
        if (sawLastBaseChange)
            mergedChanges.add(mainChange);
        else if (mainChange.getUid().equals(lastBaseChangeUid))
            sawLastBaseChange = true;
    }
}
Also used : Entry(teamdash.wbs.ChangeHistory.Entry)

Example 8 with Entry

use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.

the class WBSReplaceAction method confirmLostChanges.

/**
     * Display a dialog to the user warning them about changes they are about
     * to overwrite, and get confirmation that they wish to continue.
     */
private boolean confirmLostChanges(File srcFile, List<Entry> lostChanges) {
    if (lostChanges == null || lostChanges.isEmpty())
        return true;
    boolean sameWbs = true;
    if (lostChanges.get(0) == null) {
        lostChanges.remove(0);
        sameWbs = false;
    }
    Object[] items = new Object[lostChanges.size()];
    for (int i = 0; i < items.length; i++) {
        Entry e = lostChanges.get(i);
        items[i] = resources.format("Lost_Changes.Item_FMT", e.getUser(), e.getTimestamp());
    }
    JList list = new JList(items);
    JScrollPane sp = new JScrollPane(list);
    Dimension d = list.getPreferredSize();
    d.height = Math.min(d.height + 5, 200);
    sp.setPreferredSize(d);
    String title = resources.getString("Lost_Changes.Title");
    Object[] message = new Object[] { resources.formatStrings("Lost_Changes.Header_FMT", srcFile.getPath()), " ", resources.getStrings(sameWbs ? "Lost_Changes.Same_WBS_Message" : "Lost_Changes.Different_WBS_Message"), sp, resources.getString("Lost_Changes.Footer") };
    int userChoice = JOptionPane.showConfirmDialog(wbsEditor.frame, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
    return userChoice == JOptionPane.YES_OPTION;
}
Also used : JScrollPane(javax.swing.JScrollPane) ZipEntry(java.util.zip.ZipEntry) Entry(teamdash.wbs.ChangeHistory.Entry) Dimension(java.awt.Dimension) JList(javax.swing.JList)

Example 9 with Entry

use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.

the class WBSReplaceAction method getMostRecentCommonChange.

/**
     * Search through the change history of the current team project and the
     * replacement project, and find the most recent change entry that they
     * have in common.  If they have no changes in common, returns null.
     */
private Entry getMostRecentCommonChange(File replacementDir) {
    // make a list of the change UIDs for the main WBS.
    Set<String> wbsEntryUids = new HashSet<String>();
    for (Entry e : wbsEditor.changeHistory.getEntries()) wbsEntryUids.add(e.getUid());
    // Load the change history for the replacement file.
    ChangeHistory replacementHist = new ChangeHistory(replacementDir);
    List<Entry> replacementChanges = replacementHist.getEntries();
    // find the latest change history that is shared in common.
    for (int i = replacementChanges.size(); i-- > 0; ) {
        Entry e = replacementChanges.get(i);
        String uid = e.getUid();
        if (wbsEntryUids.contains(uid))
            return e;
    }
    // no common change entry was found.
    return null;
}
Also used : ZipEntry(java.util.zip.ZipEntry) Entry(teamdash.wbs.ChangeHistory.Entry) HashSet(java.util.HashSet)

Example 10 with Entry

use of teamdash.wbs.ChangeHistory.Entry in project processdash by dtuma.

the class WBSReplaceAction method getChangesThatWillBeLost.

/**
     * Get a list of past edits to the current team project that will be
     * overwritten if the replacement proceeds.
     */
private List<Entry> getChangesThatWillBeLost(File replacementDir) {
    List<Entry> wbsChanges = wbsEditor.changeHistory.getEntries();
    Entry e = getMostRecentCommonChange(replacementDir);
    if (e == null) {
        // condition has occurred.
        if (!wbsChanges.isEmpty())
            wbsChanges.add(0, null);
        return wbsChanges;
    }
    // make a list of the entries in the current team project that follow
    // the most common change ancestor.
    List<Entry> result = new ArrayList<Entry>();
    for (int i = wbsChanges.size(); i-- > 0; ) {
        Entry w = wbsChanges.get(i);
        if (w.getUid().equals(e.getUid()))
            break;
        result.add(0, w);
    }
    return result;
}
Also used : ZipEntry(java.util.zip.ZipEntry) Entry(teamdash.wbs.ChangeHistory.Entry) ArrayList(java.util.ArrayList)

Aggregations

Entry (teamdash.wbs.ChangeHistory.Entry)12 ZipEntry (java.util.zip.ZipEntry)8 IOException (java.io.IOException)3 ChangeHistory (teamdash.wbs.ChangeHistory)3 File (java.io.File)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 Element (org.w3c.dom.Element)2 SAXException (org.xml.sax.SAXException)2 Dimension (java.awt.Dimension)1 BufferedOutputStream (java.io.BufferedOutputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 TreeSet (java.util.TreeSet)1 Matcher (java.util.regex.Matcher)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 JList (javax.swing.JList)1 JScrollPane (javax.swing.JScrollPane)1 RobustFileOutputStream (net.sourceforge.processdash.util.RobustFileOutputStream)1