Merge branch 'feature/node_impl' into develop
This commit is contained in:
commit
371b47ac31
@ -1,21 +1,26 @@
|
||||
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.Action;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||
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.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public interface INode {
|
||||
void sendTransaction(Product product, INode INode);
|
||||
void sendTransaction(Product product, INode node);
|
||||
|
||||
void receiveTransaction(Transaction transaction);
|
||||
void sendTransaction(MonetaryAmount amount, INode node);
|
||||
|
||||
void refuseTransaction(Transaction transaction);
|
||||
void receiveTransaction(ProductTransaction transaction);
|
||||
|
||||
void receiveTransaction(FinancialTransaction transaction);
|
||||
|
||||
void refuseTransaction(ProductTransaction transaction);
|
||||
|
||||
void refuseTransaction(FinancialTransaction transaction);
|
||||
|
||||
Transaction readNextTransaction(IChannel channel);
|
||||
|
||||
@ -27,13 +32,13 @@ public interface INode {
|
||||
|
||||
void unsubscribeFromChannel(IChannel channel);
|
||||
|
||||
void doAction(Action action, Product product);
|
||||
void doAction(ProductOperationType action, Product product);
|
||||
|
||||
void doAction(Action action);
|
||||
void doAction(ProductOperationType action);
|
||||
|
||||
void storeProduct(Product product);
|
||||
|
||||
void storeProducts(List products);
|
||||
void storeProducts(List<Product> products);
|
||||
|
||||
Product getProductFromStorage(String name, ProductType type);
|
||||
|
||||
|
||||
@ -1,39 +1,68 @@
|
||||
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.Action;
|
||||
import cz.cvut.fel.sit.omo.foodchain.operation.Transaction;
|
||||
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.awt.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class NodeBase implements INode {
|
||||
private final List<IChannel> subscribedChannels;
|
||||
private final List<Product> products;
|
||||
|
||||
public NodeBase(){
|
||||
subscribedChannels = new LinkedList<>();
|
||||
products = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTransaction(Product product, INode node) {
|
||||
Transaction transaction = new ProductTransaction(product, node);
|
||||
|
||||
subscribedChannels.stream()
|
||||
.filter(ch -> ch.getProductType().equals(product.getType()))
|
||||
.findAny().ifPresent(channel -> channel.addTransaction(transaction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTransaction(MonetaryAmount amount, INode node) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveTransaction(Transaction transaction) {
|
||||
public void receiveTransaction(ProductTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refuseTransaction(Transaction transaction) {
|
||||
public void receiveTransaction(FinancialTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refuseTransaction(ProductTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refuseTransaction(FinancialTransaction transaction) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Transaction readNextTransaction(IChannel channel) {
|
||||
return null;
|
||||
return channel.getNextTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Requirement readNextRequirement(IChannel channel) {
|
||||
return null;
|
||||
return channel.getNextRequirement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,31 +72,32 @@ public class NodeBase implements INode {
|
||||
|
||||
@Override
|
||||
public void subscribeToChannel(IChannel channel) {
|
||||
|
||||
subscribedChannels.add(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromChannel(IChannel channel) {
|
||||
|
||||
subscribedChannels.remove(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(Action action, Product product) {
|
||||
|
||||
public void doAction(ProductOperationType action, Product product) {
|
||||
//create new action
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(Action action) {
|
||||
|
||||
public void doAction(ProductOperationType action) {
|
||||
//create new action
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void storeProduct(Product product) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeProducts(List products) {
|
||||
public void storeProducts(List<Product> products) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user