Search in sources :

Example 1 with AttributeMergeWarning

use of teamdash.merge.AttributeMergeWarning in project processdash by dtuma.

the class WBSModelMergeConflictNotificationFactory method refineAttributeNotification.

private static boolean refineAttributeNotification(MergeConflictNotification mcn, DataModelSource dms) {
    if (!(mcn.getMergeWarning() instanceof AttributeMergeWarning))
        return false;
    ModelType modelType = mcn.getModelType();
    AttributeMergeWarning amw = (AttributeMergeWarning) mcn.getMergeWarning();
    DataTableModel dataModel = dms.getDataModel(modelType);
    ConflictCapableDataColumn column = findColumnForAttribute(dataModel, amw.getAttributeName());
    if (column == null)
        return false;
    String columnId = column.getColumnID().replace(' ', '_');
    mcn.putAttribute(COLUMN_ID, columnId);
    mcn.putAttribute(COLUMN_NAME, column.getColumnName());
    String explicitMessageKey = modelType.name() + ".Attribute." + columnId;
    String nullDisplay;
    try {
        nullDisplay = resources.getHTML(explicitMessageKey + ".Blank");
    } catch (MissingResourceException mre) {
        nullDisplay = resources.getHTML("WBSNode_Attribute.Blank");
    }
    WBSNode baseNode = mcn.getAttribute(MergeConflictNotification.BASE_NODE);
    String baseValue = (String) amw.getBaseValue();
    Object baseDisp = (//
    baseNode == null ? //
    baseValue : column.getConflictDisplayValue(baseValue, baseNode));
    if (baseDisp == null)
        baseDisp = nullDisplay;
    WBSNode mainNode = mcn.getAttribute(MergeConflictNotification.MAIN_NODE);
    String mainValue = (String) amw.getMainValue();
    Object mainDisp = (//
    mainNode == null ? //
    mainValue : column.getConflictDisplayValue(mainValue, mainNode));
    if (mainDisp == null)
        mainDisp = nullDisplay;
    WBSNode incNode = mcn.getAttribute(MergeConflictNotification.INCOMING_NODE);
    String incValue = (String) amw.getIncomingValue();
    Object incDisp = (//
    incNode == null ? //
    incValue : column.getConflictDisplayValue(incValue, incNode));
    if (incDisp == null)
        incDisp = nullDisplay;
    mcn.putValueAttributes(baseDisp, mainDisp, incDisp);
    boolean supportsOverride;
    if (MergeConflictNotification.definesDescription(explicitMessageKey)) {
        // this column has explicitly defined a message it wants to
        // display, so we will use that message.
        mcn.setMessageKey(explicitMessageKey);
        // see if this column has defined a message for the
        // 'override' option.
        supportsOverride = mcn.definesMessageForUserOption(MergeConflictNotification.OVERRIDE);
    } else {
        // use a generic message.
        mcn.setMessageKey("WBSNode_Attribute");
        supportsOverride = true;
    }
    // Add "accept" as an option that is always present
    mcn.addUserOption(MergeConflictNotification.ACCEPT, null);
    // Add an "alter" option if it is supported
    if (supportsOverride)
        mcn.addUserOption(MergeConflictNotification.OVERRIDE, new WbsNodeAttributeHandler(dataModel, column));
    // give the column a final chance to tweak the configuration
    column.adjustConflictNotification(mcn);
    return true;
}
Also used : MissingResourceException(java.util.MissingResourceException) ModelType(teamdash.merge.ModelType) AttributeMergeWarning(teamdash.merge.AttributeMergeWarning)

Example 2 with AttributeMergeWarning

use of teamdash.merge.AttributeMergeWarning in project processdash by dtuma.

the class WBSModelMergeConflictNotificationFactory method create.

private static MergeConflictNotification create(AbstractWBSModelMerger merger, ModelType modelType, Map<Integer, WBSNode> baseNodeMap, Map<Integer, WBSNode> mainNodeMap, Map<Integer, WBSNode> incomingNodeMap, MergeWarning<Integer> mw) {
    MergeConflictNotification result = new MergeConflictNotification(modelType, mw);
    // look up the main and incoming nodes, and store them as attributes
    WBSNode mainNode = mainNodeMap.get(mw.getMainNodeID());
    WBSNode incomingNode = incomingNodeMap.get(mw.getIncomingNodeID());
    result.putNodeAttributes(mainNode, incomingNode);
    if (mw instanceof AttributeMergeWarning) {
        if (mw.matches(AbstractWBSModelMerger.NODE_NAME)) {
            NODE_NAME_HANDLER.install(result);
        } else if (mw.matches(AbstractWBSModelMerger.NODE_TYPE)) {
            NODE_TYPE_HANDLER.install(result);
        } else {
            WBSNode baseNode = baseNodeMap.get(mw.getIncomingNodeID());
            result.putAttribute(MergeConflictNotification.BASE_NODE, baseNode, false);
        }
    } else {
        // for structural changes, record the parent nodes in case the
        // conflict message needs them
        WBSNode mainParent = merger.main.getParent(mainNode);
        result.putAttribute("mainParent", mainParent);
        WBSNode incomingParent = merger.incoming.getParent(incomingNode);
        result.putAttribute("incomingParent", incomingParent);
        // structural conflict messages are generic and shared by all of
        // the various WBS model types.  Thus, we switch to a plain
        // resource message key that is not prefixed by the model type.
        result.setMessageKey(mw.getKey());
        // structural conflicts can only be acknowledged and dismissed;
        // resolution options are not available at this time.
        result.addUserOption(MergeConflictNotification.DISMISS, null);
    }
    return result;
}
Also used : MergeConflictNotification(teamdash.merge.ui.MergeConflictNotification) AttributeMergeWarning(teamdash.merge.AttributeMergeWarning)

Aggregations

AttributeMergeWarning (teamdash.merge.AttributeMergeWarning)2 MissingResourceException (java.util.MissingResourceException)1 ModelType (teamdash.merge.ModelType)1 MergeConflictNotification (teamdash.merge.ui.MergeConflictNotification)1