Start implimentating report on Node
This commit is contained in:
parent
5426ffcf02
commit
7f5dace718
@ -175,6 +175,26 @@ public class NodeBase implements ChannelObserver {
|
|||||||
return money;
|
return money;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<ChannelBase, ChannelSubscriptionType> getSubscribedChannels() {
|
||||||
|
return subscribedChannels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Product> getProducts() {
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Transaction> getRefusedTransactions() {
|
||||||
|
return refusedTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeType getAllowedSeller() {
|
||||||
|
return allowedSeller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeType getAllowedPurchaser() {
|
||||||
|
return allowedPurchaser;
|
||||||
|
}
|
||||||
|
|
||||||
public void addMoney(MonetaryAmount m) {
|
public void addMoney(MonetaryAmount m) {
|
||||||
this.money = this.money.add(m);
|
this.money = this.money.add(m);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.reporting.ReportTextVisitor;
|
||||||
|
|
||||||
import javax.money.MonetaryAmount;
|
import javax.money.MonetaryAmount;
|
||||||
import javax.naming.InsufficientResourcesException;
|
import javax.naming.InsufficientResourcesException;
|
||||||
@ -40,4 +41,9 @@ public class FinancialTransaction extends Transaction {
|
|||||||
", transactionPaid=" + transactionPaid +
|
", transactionPaid=" + transactionPaid +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String accept(ReportTextVisitor visitor) {
|
||||||
|
return visitor.visit(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package cz.cvut.fel.sit.omo.foodchain.operation;
|
|||||||
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductState;
|
import cz.cvut.fel.sit.omo.foodchain.product.ProductState;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.reporting.ReportTextVisitor;
|
||||||
|
|
||||||
import javax.naming.InsufficientResourcesException;
|
import javax.naming.InsufficientResourcesException;
|
||||||
|
|
||||||
@ -49,4 +50,9 @@ public class ProductTransaction extends Transaction {
|
|||||||
"product=" + product.getName() +
|
"product=" + product.getName() +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String accept(ReportTextVisitor visitor) {
|
||||||
|
return visitor.visit(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.reporting.ReportTextVisitor;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.signature.SignatureManager;
|
import cz.cvut.fel.sit.omo.foodchain.signature.SignatureManager;
|
||||||
|
|
||||||
@ -42,4 +43,6 @@ public abstract class Transaction extends OperationBase {
|
|||||||
", nodeReceiver=" + nodeReceiver.getClass().getSimpleName() +
|
", nodeReceiver=" + nodeReceiver.getClass().getSimpleName() +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract String accept(ReportTextVisitor visitor);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,25 @@ package cz.cvut.fel.sit.omo.foodchain.reporting;
|
|||||||
|
|
||||||
import cz.cvut.fel.sit.omo.foodchain.channel.ChannelBase;
|
import cz.cvut.fel.sit.omo.foodchain.channel.ChannelBase;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
import cz.cvut.fel.sit.omo.foodchain.node.base.NodeBase;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.FinancialTransaction;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.operation.OperationBase;
|
import cz.cvut.fel.sit.omo.foodchain.operation.OperationBase;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.ProductTransaction;
|
||||||
|
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||||
|
|
||||||
public class ReportTextVisitor {
|
public class ReportTextVisitor {
|
||||||
public String visit(NodeBase node){
|
private static final String ln = System.lineSeparator();
|
||||||
|
|
||||||
return null;
|
public String visit(NodeBase node){
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
result.append("Node info: ").append(ln)
|
||||||
|
.append("Allowed seller: ").append(node.getAllowedSeller()).append(ln)
|
||||||
|
.append("Allowed purchaser: ").append(node.getAllowedPurchaser()).append(ln)
|
||||||
|
.append("Money: ").append(node.getMoney()).append(ln)
|
||||||
|
.append("Refused transactions: ");
|
||||||
|
node.getRefusedTransactions().forEach(tr -> result.append(tr.accept(this)));
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String visit(ChannelBase channel){
|
public String visit(ChannelBase channel){
|
||||||
@ -19,4 +31,12 @@ public class ReportTextVisitor {
|
|||||||
public String visit(Product product){
|
public String visit(Product product){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String visit(ProductTransaction transaction){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String visit(FinancialTransaction transaction){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user