Add reason entry to dispute result

This commit is contained in:
Manfred Karrer 2016-06-16 01:38:50 +02:00
parent 6b16f2fbe7
commit 5535ee3167
3 changed files with 100 additions and 8 deletions

View file

@ -47,6 +47,13 @@ public final class DisputeResult implements Payload {
STALE_MATE STALE_MATE
} }
public enum Reason {
BUG,
USABILITY,
SCAM,
OTHER
}
public final String tradeId; public final String tradeId;
public final int traderId; public final int traderId;
private DisputeFeePolicy disputeFeePolicy; private DisputeFeePolicy disputeFeePolicy;
@ -64,6 +71,7 @@ public final class DisputeResult implements Payload {
private byte[] arbitratorPubKey; private byte[] arbitratorPubKey;
private long closeDate; private long closeDate;
private Winner winner; private Winner winner;
private Reason reason;
transient private BooleanProperty tamperProofEvidenceProperty = new SimpleBooleanProperty(); transient private BooleanProperty tamperProofEvidenceProperty = new SimpleBooleanProperty();
transient private BooleanProperty idVerificationProperty = new SimpleBooleanProperty(); transient private BooleanProperty idVerificationProperty = new SimpleBooleanProperty();
@ -137,6 +145,17 @@ public final class DisputeResult implements Payload {
return disputeFeePolicy; return disputeFeePolicy;
} }
public void setReason(Reason reason) {
this.reason = reason;
}
public Reason getReason() {
return reason;
}
public void setSummaryNotes(String summaryNotes) {
this.summaryNotesProperty.set(summaryNotes);
}
public StringProperty summaryNotesProperty() { public StringProperty summaryNotesProperty() {
return summaryNotesProperty; return summaryNotesProperty;
@ -231,6 +250,7 @@ public final class DisputeResult implements Payload {
if (closeDate != that.closeDate) return false; if (closeDate != that.closeDate) return false;
if (tradeId != null ? !tradeId.equals(that.tradeId) : that.tradeId != null) return false; if (tradeId != null ? !tradeId.equals(that.tradeId) : that.tradeId != null) return false;
if (disputeFeePolicy != that.disputeFeePolicy) return false; if (disputeFeePolicy != that.disputeFeePolicy) return false;
if (reason != that.reason) return false;
if (summaryNotes != null ? !summaryNotes.equals(that.summaryNotes) : that.summaryNotes != null) return false; if (summaryNotes != null ? !summaryNotes.equals(that.summaryNotes) : that.summaryNotes != null) return false;
if (disputeCommunicationMessage != null ? !disputeCommunicationMessage.equals(that.disputeCommunicationMessage) : that.disputeCommunicationMessage != null) if (disputeCommunicationMessage != null ? !disputeCommunicationMessage.equals(that.disputeCommunicationMessage) : that.disputeCommunicationMessage != null)
return false; return false;
@ -247,6 +267,7 @@ public final class DisputeResult implements Payload {
int result = tradeId != null ? tradeId.hashCode() : 0; int result = tradeId != null ? tradeId.hashCode() : 0;
result = 31 * result + traderId; result = 31 * result + traderId;
result = 31 * result + (disputeFeePolicy != null ? disputeFeePolicy.hashCode() : 0); result = 31 * result + (disputeFeePolicy != null ? disputeFeePolicy.hashCode() : 0);
result = 31 * result + (reason != null ? reason.hashCode() : 0);
result = 31 * result + (tamperProofEvidence ? 1 : 0); result = 31 * result + (tamperProofEvidence ? 1 : 0);
result = 31 * result + (idVerification ? 1 : 0); result = 31 * result + (idVerification ? 1 : 0);
result = 31 * result + (screenCast ? 1 : 0); result = 31 * result + (screenCast ? 1 : 0);

View file

@ -201,8 +201,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
stringBuilder.append("Summary of all disputes (Nr. of disputes: " + disputeGroups.size() + ")\n\n"); stringBuilder.append("Summary of all disputes (Nr. of disputes: " + disputeGroups.size() + ")\n\n");
disputeGroups.stream().forEach(disputeGroup -> { disputeGroups.stream().forEach(disputeGroup -> {
Dispute dispute0 = disputeGroup.get(0); Dispute dispute0 = disputeGroup.get(0);
stringBuilder stringBuilder.append("##########################################################################################/\n")
.append("##########################################################################################/\n")
.append("## Trade ID: ") .append("## Trade ID: ")
.append(dispute0.getTradeId()) .append(dispute0.getTradeId())
.append("\n") .append("\n")
@ -211,7 +210,13 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
.append("\n") .append("\n")
.append("## Is support ticket: ") .append("## Is support ticket: ")
.append(dispute0.isSupportTicket()) .append(dispute0.isSupportTicket())
.append("\n##########################################################################################/\n") .append("\n");
if (dispute0.disputeResultProperty().get() != null && dispute0.disputeResultProperty().get().getReason() != null) {
stringBuilder.append("## Reason: ")
.append(dispute0.disputeResultProperty().get().getReason())
.append("\n");
}
stringBuilder.append("##########################################################################################/\n")
.append("\n"); .append("\n");
disputeGroup.stream().forEach(dispute -> { disputeGroup.stream().forEach(dispute -> {
stringBuilder stringBuilder

View file

@ -70,16 +70,16 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
private ToggleGroup tradeAmountToggleGroup; private ToggleGroup tradeAmountToggleGroup;
private DisputeResult disputeResult; private DisputeResult disputeResult;
private RadioButton buyerIsWinnerRadioButton, sellerIsWinnerRadioButton, shareRadioButton, loserPaysFeeRadioButton, splitFeeRadioButton, private RadioButton buyerIsWinnerRadioButton, sellerIsWinnerRadioButton, shareRadioButton, loserPaysFeeRadioButton, splitFeeRadioButton,
waiveFeeRadioButton; waiveFeeRadioButton, reasonWasBugRadioButton, reasonWasUsabilityIssueRadioButton, reasonWasScamRadioButton, reasonWasOtherRadioButton;
private Optional<Dispute> peersDisputeOptional; private Optional<Dispute> peersDisputeOptional;
private Coin arbitratorPayoutAmount, winnerPayoutAmount, loserPayoutAmount, stalematePayoutAmount; private Coin arbitratorPayoutAmount, winnerPayoutAmount, loserPayoutAmount, stalematePayoutAmount;
private ToggleGroup feeToggleGroup; private ToggleGroup feeToggleGroup, reasonToggleGroup;
private String role; private String role;
private TextArea summaryNotesTextArea; private TextArea summaryNotesTextArea;
private ObjectBinding<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyChanged; private ObjectBinding<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyChanged;
private ChangeListener<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyListener; private ChangeListener<Tuple2<DisputeResult.DisputeFeePolicy, Toggle>> feePaymentPolicyListener;
private ChangeListener<Boolean> shareRadioButtonSelectedListener; private ChangeListener<Boolean> shareRadioButtonSelectedListener;
private ChangeListener<Toggle> feeToggleSelectionListener; private ChangeListener<Toggle> feeToggleSelectionListener, reasonToggleSelectionListener;
// keep a reference to not get GCed // keep a reference to not get GCed
@ -127,6 +127,9 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
if (feeToggleGroup != null) if (feeToggleGroup != null)
feeToggleGroup.selectedToggleProperty().removeListener(feeToggleSelectionListener); feeToggleGroup.selectedToggleProperty().removeListener(feeToggleSelectionListener);
if (reasonToggleGroup != null)
reasonToggleGroup.selectedToggleProperty().removeListener(reasonToggleSelectionListener);
} }
@Override @Override
@ -169,6 +172,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
addTradeAmountPayoutControls(); addTradeAmountPayoutControls();
addFeeControls(); addFeeControls();
addReasonControls();
boolean applyPeersDisputeResult = peersDisputeOptional.isPresent() && peersDisputeOptional.get().isClosed(); boolean applyPeersDisputeResult = peersDisputeOptional.isPresent() && peersDisputeOptional.get().isClosed();
if (applyPeersDisputeResult) { if (applyPeersDisputeResult) {
@ -179,6 +183,8 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
disputeResult.setArbitratorPayoutAmount(peersDisputeResult.getArbitratorPayoutAmount()); disputeResult.setArbitratorPayoutAmount(peersDisputeResult.getArbitratorPayoutAmount());
disputeResult.setDisputeFeePolicy(peersDisputeResult.getDisputeFeePolicy()); disputeResult.setDisputeFeePolicy(peersDisputeResult.getDisputeFeePolicy());
disputeResult.setWinner(peersDisputeResult.getWinner()); disputeResult.setWinner(peersDisputeResult.getWinner());
disputeResult.setReason(peersDisputeResult.getReason());
disputeResult.setSummaryNotes(peersDisputeResult.summaryNotesProperty().get());
if (disputeResult.getBuyerPayoutAmount() != null) { if (disputeResult.getBuyerPayoutAmount() != null) {
log.debug("buyerPayoutAmount " + disputeResult.getBuyerPayoutAmount().toFriendlyString()); log.debug("buyerPayoutAmount " + disputeResult.getBuyerPayoutAmount().toFriendlyString());
@ -186,8 +192,6 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
log.debug("arbitratorPayoutAmount " + disputeResult.getArbitratorPayoutAmount().toFriendlyString()); log.debug("arbitratorPayoutAmount " + disputeResult.getArbitratorPayoutAmount().toFriendlyString());
} }
//setFeeRadioButtonState();
buyerIsWinnerRadioButton.setDisable(true); buyerIsWinnerRadioButton.setDisable(true);
sellerIsWinnerRadioButton.setDisable(true); sellerIsWinnerRadioButton.setDisable(true);
shareRadioButton.setDisable(true); shareRadioButton.setDisable(true);
@ -195,6 +199,11 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
splitFeeRadioButton.setDisable(true); splitFeeRadioButton.setDisable(true);
waiveFeeRadioButton.setDisable(true); waiveFeeRadioButton.setDisable(true);
reasonWasBugRadioButton.setDisable(true);
reasonWasUsabilityIssueRadioButton.setDisable(true);
reasonWasScamRadioButton.setDisable(true);
reasonWasOtherRadioButton.setDisable(true);
calculatePayoutAmounts(disputeResult.getDisputeFeePolicy()); calculatePayoutAmounts(disputeResult.getDisputeFeePolicy());
applyTradeAmountRadioButtonStates(); applyTradeAmountRadioButtonStates();
} else { } else {
@ -210,6 +219,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
} }
setFeeRadioButtonState(); setFeeRadioButtonState();
setReasonRadioButtonState();
addSummaryNotes(); addSummaryNotes();
addButtons(contract); addButtons(contract);
@ -342,6 +352,62 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
} }
} }
private void addReasonControls() {
Label label = addLabel(gridPane, ++rowIndex, "Reason of dispute:", 10);
GridPane.setValignment(label, VPos.TOP);
reasonWasBugRadioButton = new RadioButton("Bug");
reasonWasUsabilityIssueRadioButton = new RadioButton("Usability");
reasonWasScamRadioButton = new RadioButton("Scam");
reasonWasOtherRadioButton = new RadioButton("Other");
HBox feeRadioButtonPane = new HBox();
feeRadioButtonPane.setSpacing(20);
feeRadioButtonPane.getChildren().addAll(reasonWasBugRadioButton, reasonWasUsabilityIssueRadioButton,
reasonWasScamRadioButton, reasonWasOtherRadioButton);
GridPane.setRowIndex(feeRadioButtonPane, rowIndex);
GridPane.setColumnIndex(feeRadioButtonPane, 1);
GridPane.setMargin(feeRadioButtonPane, new Insets(10, 0, 10, 0));
gridPane.getChildren().add(feeRadioButtonPane);
reasonToggleGroup = new ToggleGroup();
reasonWasBugRadioButton.setToggleGroup(reasonToggleGroup);
reasonWasUsabilityIssueRadioButton.setToggleGroup(reasonToggleGroup);
reasonWasScamRadioButton.setToggleGroup(reasonToggleGroup);
reasonWasOtherRadioButton.setToggleGroup(reasonToggleGroup);
reasonToggleSelectionListener = (observable, oldValue, newValue) -> {
if (newValue == reasonWasBugRadioButton)
disputeResult.setReason(DisputeResult.Reason.BUG);
else if (newValue == reasonWasUsabilityIssueRadioButton)
disputeResult.setReason(DisputeResult.Reason.USABILITY);
else if (newValue == reasonWasScamRadioButton)
disputeResult.setReason(DisputeResult.Reason.SCAM);
else if (newValue == reasonWasOtherRadioButton)
disputeResult.setReason(DisputeResult.Reason.OTHER);
};
reasonToggleGroup.selectedToggleProperty().addListener(reasonToggleSelectionListener);
}
private void setReasonRadioButtonState() {
if (disputeResult.getReason() != null) {
switch (disputeResult.getReason()) {
case BUG:
reasonToggleGroup.selectToggle(reasonWasBugRadioButton);
break;
case USABILITY:
reasonToggleGroup.selectToggle(reasonWasUsabilityIssueRadioButton);
break;
case SCAM:
reasonToggleGroup.selectToggle(reasonWasScamRadioButton);
break;
case OTHER:
reasonToggleGroup.selectToggle(reasonWasOtherRadioButton);
break;
}
}
}
private void addSummaryNotes() { private void addSummaryNotes() {
Label label = addLabel(gridPane, ++rowIndex, "Summary notes:", 0); Label label = addLabel(gridPane, ++rowIndex, "Summary notes:", 0);
GridPane.setValignment(label, VPos.TOP); GridPane.setValignment(label, VPos.TOP);