After-merge repair, delete all unnecessary interfaces
This commit is contained in:
parent
e0b53db736
commit
6f7c11a878
7
pom.xml
7
pom.xml
@ -7,6 +7,13 @@
|
||||
<groupId>cz.cvut.fel.sit.omo.foodchain</groupId>
|
||||
<artifactId>FoodChain</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.money</groupId>
|
||||
<artifactId>money-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.target>12</maven.compiler.target>
|
||||
|
||||
@ -10,7 +10,7 @@ import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class ChannelBase implements IChannel, Observable {
|
||||
public abstract class ChannelBase implements Observable {
|
||||
protected ProductType productType;
|
||||
protected Queue<Requirement> requirements;
|
||||
protected Queue<Transaction> transactions;
|
||||
@ -31,13 +31,11 @@ public abstract class ChannelBase implements IChannel, Observable {
|
||||
this.productType = ProductType.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Queue<Transaction> getTransactions()
|
||||
{
|
||||
return this.transactions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Queue<Requirement> getCurrentRequirements()
|
||||
{
|
||||
return this.requirements;
|
||||
@ -47,7 +45,6 @@ public abstract class ChannelBase implements IChannel, Observable {
|
||||
* Adds new requirement to the requirement Queue
|
||||
* @param requirement requirement
|
||||
*/
|
||||
@Override
|
||||
public void addRequirement(Requirement requirement)
|
||||
{
|
||||
this.requirements.add(requirement);
|
||||
@ -73,7 +70,6 @@ public abstract class ChannelBase implements IChannel, Observable {
|
||||
* Adds new transaction to the transaction Queue
|
||||
* @param transaction transaction
|
||||
*/
|
||||
@Override
|
||||
public void addTransaction(Transaction transaction)
|
||||
{
|
||||
this.transactions.add(transaction);
|
||||
@ -86,4 +82,8 @@ public abstract class ChannelBase implements IChannel, Observable {
|
||||
{
|
||||
this.requirements.clear();
|
||||
}
|
||||
|
||||
public ProductType getProductType() {
|
||||
return productType;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.channel;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
public interface IChannel
|
||||
{
|
||||
//TODO Daniel
|
||||
|
||||
//Transaction getNextTransaction();
|
||||
Queue<Transaction> getTransactions();
|
||||
|
||||
//public Requirement getNextRequirement();
|
||||
Queue<Requirement> getCurrentRequirements();
|
||||
|
||||
void addRequirement(Requirement requirement);
|
||||
|
||||
void addTransaction(Transaction transaction);
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.*;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
||||
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface INode {
|
||||
void sendTransaction(Product product, INode node);
|
||||
|
||||
void sendTransaction(MonetaryAmount amount, INode node);
|
||||
|
||||
void receiveTransaction(ProductTransaction transaction);
|
||||
|
||||
void receiveTransaction(FinancialTransaction transaction);
|
||||
|
||||
void refuseTransaction(ProductTransaction transaction);
|
||||
|
||||
void refuseTransaction(FinancialTransaction transaction);
|
||||
|
||||
Transaction readNextTransaction(IChannel channel);
|
||||
|
||||
Requirement readNextRequirement(IChannel channel);
|
||||
|
||||
void acceptRequirement(Requirement requirement);
|
||||
|
||||
void subscribeToChannel(IChannel channel);
|
||||
|
||||
void unsubscribeFromChannel(IChannel channel);
|
||||
|
||||
void doAction(ProductOperationType action, Product product);
|
||||
|
||||
void doAction(ProductOperationType action);
|
||||
|
||||
void storeProduct(Product product);
|
||||
|
||||
void storeProducts(List<Product> products);
|
||||
|
||||
Product getProductFromStorage(String name, ProductType type);
|
||||
|
||||
Signature generateSignature(Transaction transaction);
|
||||
|
||||
boolean validateSignature(Signature signature);
|
||||
}
|
||||
@ -1,18 +1,19 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.node;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.ChannelBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.*;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.ProductType;
|
||||
import cz.cvut.fel.sit.omo.foodchain.requirement.Requirement;
|
||||
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||
|
||||
import javax.money.MonetaryAmount;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class NodeBase implements INode {
|
||||
private final List<IChannel> subscribedChannels;
|
||||
public class NodeBase {
|
||||
private final List<ChannelBase> subscribedChannels;
|
||||
private final List<Product> products;
|
||||
|
||||
public NodeBase(){
|
||||
@ -20,98 +21,97 @@ public class NodeBase implements INode {
|
||||
products = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTransaction(Product product, INode node) {
|
||||
Transaction transaction = new ProductTransaction(product, node);
|
||||
|
||||
public void sendTransaction(Product product, NodeBase node) {
|
||||
Transaction transaction = new ProductTransaction(this, node, TransactionType.SALE, product); //TODO wrong constructor
|
||||
|
||||
subscribedChannels.stream()
|
||||
.filter(ch -> ch.getProductType().equals(product.getType()))
|
||||
.filter(ch -> ch.getProductType().equals(product.getProductType()))
|
||||
.findAny().ifPresent(channel -> channel.addTransaction(transaction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTransaction(MonetaryAmount amount, INode node) {
|
||||
|
||||
public void sendTransaction(MonetaryAmount amount, NodeBase node) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void receiveTransaction(ProductTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void receiveTransaction(FinancialTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void refuseTransaction(ProductTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void refuseTransaction(FinancialTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
//TODO another way to read transaction
|
||||
|
||||
@Override
|
||||
public Transaction readNextTransaction(IChannel channel) {
|
||||
public Transaction readNextTransaction(ChannelBase channel) {
|
||||
return channel.getNextTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Requirement readNextRequirement(IChannel channel) {
|
||||
|
||||
public Requirement readNextRequirement(ChannelBase channel) {
|
||||
return channel.getNextRequirement();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void acceptRequirement(Requirement requirement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToChannel(IChannel channel) {
|
||||
|
||||
public void subscribeToChannel(ChannelBase channel) {
|
||||
subscribedChannels.add(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromChannel(IChannel channel) {
|
||||
|
||||
public void unsubscribeFromChannel(ChannelBase channel) {
|
||||
subscribedChannels.remove(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void doAction(ProductOperationType action, Product product) {
|
||||
//create new action
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void doAction(ProductOperationType action) {
|
||||
//create new action
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void storeProduct(Product product) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void storeProducts(List<Product> products) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Product getProductFromStorage(String name, ProductType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Signature generateSignature(Transaction transaction) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public boolean validateSignature(Signature signature) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
|
||||
public class Action extends OperationBase {
|
||||
|
||||
private final IOperation lastOperation;
|
||||
private final OperationBase lastOperation;
|
||||
private final Product product;
|
||||
private final ProductOperationType type;
|
||||
|
||||
Action(INode node, Product product) {
|
||||
Action(NodeBase node, Product product) {
|
||||
super(node);
|
||||
this.product = product;
|
||||
type = null;
|
||||
@ -23,7 +23,7 @@ public class Action extends OperationBase {
|
||||
product.setStateToAvailable();
|
||||
}
|
||||
|
||||
public IOperation getLastOperation() {
|
||||
public OperationBase getLastOperation() {
|
||||
return lastOperation;
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
|
||||
import javax.money.MonetaryAmount;
|
||||
|
||||
public class FinancialTransaction extends Transaction {
|
||||
|
||||
private final Float amount;
|
||||
private final MonetaryAmount amount;
|
||||
private final ProductTransaction transactionPaid;
|
||||
|
||||
FinancialTransaction(INode creator, INode receiver, TransactionType type, Float amount, ProductTransaction transactionPaid) {
|
||||
FinancialTransaction(NodeBase creator, NodeBase receiver, TransactionType type, MonetaryAmount amount, ProductTransaction transactionPaid) {
|
||||
super(creator, receiver, type);
|
||||
this.amount = amount;
|
||||
this.transactionPaid = transactionPaid;
|
||||
}
|
||||
|
||||
public Float getAmount() {
|
||||
public MonetaryAmount getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
public interface IOperation {
|
||||
//TODO Tomas Angelo
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -10,9 +9,9 @@ public class OperationBase {
|
||||
private final LocalDateTime timeStart;
|
||||
private LocalDateTime timeEnd;
|
||||
|
||||
private final INode nodeCreator;
|
||||
private final NodeBase nodeCreator;
|
||||
|
||||
OperationBase(INode node) {
|
||||
OperationBase(NodeBase node) {
|
||||
nodeCreator = node;
|
||||
timeStart = LocalDateTime.now();
|
||||
}
|
||||
@ -29,7 +28,7 @@ public class OperationBase {
|
||||
this.timeEnd = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public INode getNodeCreator() {
|
||||
public NodeBase getNodeCreator() {
|
||||
return nodeCreator;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.product.Product;
|
||||
|
||||
public class ProductTransaction extends Transaction {
|
||||
|
||||
private final IOperation lastOperation;
|
||||
private final OperationBase lastOperation;
|
||||
private final Product product;
|
||||
private final ProductOperationType type;
|
||||
|
||||
ProductTransaction(INode creator, INode receiver, TransactionType transactionType, Product product) {
|
||||
public ProductTransaction(NodeBase creator, NodeBase receiver, TransactionType transactionType, Product product) {
|
||||
super(creator, receiver, transactionType);
|
||||
this.product = product;
|
||||
type = null;
|
||||
@ -24,7 +24,7 @@ public class ProductTransaction extends Transaction {
|
||||
product.setStateToAvailable();
|
||||
}
|
||||
|
||||
public IOperation getLastOperation() {
|
||||
public OperationBase getLastOperation() {
|
||||
return lastOperation;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.operation;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.signature.Signature;
|
||||
import cz.cvut.fel.sit.omo.foodchain.signature.SignatureManager;
|
||||
|
||||
@ -8,9 +8,9 @@ public abstract class Transaction extends OperationBase {
|
||||
|
||||
private final TransactionType transactionType;
|
||||
private final Signature signature;
|
||||
private final INode nodeReceiver;
|
||||
private final NodeBase nodeReceiver;
|
||||
|
||||
Transaction(INode creator, INode receiver, TransactionType type) {
|
||||
Transaction(NodeBase creator, NodeBase receiver, TransactionType type) {
|
||||
super(creator);
|
||||
transactionType = type;
|
||||
nodeReceiver = receiver;
|
||||
@ -29,7 +29,7 @@ public abstract class Transaction extends OperationBase {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public INode getNodeReceiver() {
|
||||
public NodeBase getNodeReceiver() {
|
||||
return nodeReceiver;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.ChannelBase;
|
||||
|
||||
public class ChannelPool extends PoolListBase<IChannel> {
|
||||
public class ChannelPool extends PoolListBase<ChannelBase> {
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.pool;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
|
||||
public class NodePool extends PoolListBase<INode> {
|
||||
public class NodePool extends PoolListBase<NodeBase> {
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.product;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.IOperation;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.OperationBase;
|
||||
|
||||
public class Product
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
package cz.cvut.fel.sit.omo.foodchain.reporting;
|
||||
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.IChannel;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.INode;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.IOperation;
|
||||
import cz.cvut.fel.sit.omo.foodchain.channel.ChannelBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.node.NodeBase;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.OperationBase;
|
||||
|
||||
public class ReportTextFileVisitor {
|
||||
public void visit(INode node){
|
||||
public void visit(NodeBase node){
|
||||
|
||||
}
|
||||
|
||||
public void visit(IOperation operationBase){
|
||||
public void visit(OperationBase operationBase){
|
||||
|
||||
}
|
||||
|
||||
public void visit(IChannel channel){
|
||||
public void visit(ChannelBase channel){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user