diff --git a/EAR diagrams/FoodChain.ldb b/EAR diagrams/FoodChain.ldb
new file mode 100644
index 0000000..534325f
Binary files /dev/null and b/EAR diagrams/FoodChain.ldb differ
diff --git a/FoodChain.iml b/FoodChain.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/FoodChain.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..3d4b7a9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,16 @@
+
+
+ 4.0.0
+
+ cz.cvut.fel.sit.omo.foodchain
+ FoodChain
+ 1.0-SNAPSHOT
+
+
+ 12
+ 12
+
+
+
\ No newline at end of file
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ChannelFactory.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ChannelFactory.java
new file mode 100644
index 0000000..bdf9c73
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ChannelFactory.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+public class ChannelFactory {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/FactoryManager.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/FactoryManager.java
new file mode 100644
index 0000000..6b384a5
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/FactoryManager.java
@@ -0,0 +1,49 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+public class FactoryManager {
+
+ public NodeFactory getNodeFactoryInstance(){
+ try {
+ return Singleton.getInstance(NodeFactory.class);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public ChannelFactory getChannelFactoryInstance(){
+ try {
+ return Singleton.getInstance(ChannelFactory.class);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public ScenarioFactory getScenarioFactoryInstance(){
+ try {
+ return Singleton.getInstance(ScenarioFactory.class);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public ProductFactory getProductFactoryInstance(){
+ try {
+ return Singleton.getInstance(ProductFactory.class);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
+
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java
new file mode 100644
index 0000000..0e9286b
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/NodeFactory.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+public class NodeFactory {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ProductFactory.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ProductFactory.java
new file mode 100644
index 0000000..c2c7a8e
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ProductFactory.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+public class ProductFactory {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ScenarioFactory.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ScenarioFactory.java
new file mode 100644
index 0000000..1a04f18
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/ScenarioFactory.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+public class ScenarioFactory {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/Singleton.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/Singleton.java
new file mode 100644
index 0000000..15af48f
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/factory/Singleton.java
@@ -0,0 +1,24 @@
+package cz.cvut.fel.sit.omo.foodchain.factory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Singleton {
+
+ private static final Singleton instance = new Singleton();
+
+ @SuppressWarnings("rawtypes")
+ private final Map mapHolder = new HashMap();
+
+ private Singleton() {
+ }
+
+ public static T getInstance(Class tClass) throws IllegalAccessException, InstantiationException {
+ if (!instance.mapHolder.containsKey(tClass)) {
+ T obj = tClass.newInstance();
+ instance.mapHolder.put(tClass, obj);
+ }
+
+ return (T) instance.mapHolder.get(tClass);
+ }
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/BuyerNodeBase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/BuyerNodeBase.java
new file mode 100644
index 0000000..0011253
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/BuyerNodeBase.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.node;
+
+public class BuyerNodeBase implements NodeInterface {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeInterface.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeInterface.java
new file mode 100644
index 0000000..15d58ae
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/NodeInterface.java
@@ -0,0 +1,25 @@
+package cz.cvut.fel.sit.omo.foodchain.node;
+
+public interface NodeInterface {
+ void sendTransaction(Product product, NodeInterface node);
+ void receiveTransaction(Transaction transaction);
+ void refuseTransaction(Transaction transaction);
+ Transaction readNextTransaction(ChannelInterface channel);
+
+ Requirement readNextRequirement(ChannelInterface channel);
+ void acceptRequirement(Requirement requirement);
+
+ void subscribeToChannel(ChannelInterface channel);
+ void unsubscribeFromChannel(ChannelInterface channel);
+
+ void doAction(Action action, Product product);
+ void doAction(Action action);
+
+ void storeProduct(Product product);
+ void storeProducts(List products);
+
+ Product getProductFromStorage(String name, ProductType type);
+
+ Signature generateSignature(Transaction transaction);
+ boolean validateSignature(Signature signature);
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/SellerNodeBase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/SellerNodeBase.java
new file mode 100644
index 0000000..8ad5718
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/node/SellerNodeBase.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.node;
+
+public class SellerNodeBase implements NodeInterface {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/NodePool.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/NodePool.java
new file mode 100644
index 0000000..65594d1
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/NodePool.java
@@ -0,0 +1,6 @@
+package cz.cvut.fel.sit.omo.foodchain.pool;
+
+import cz.cvut.fel.sit.omo.foodchain.node.NodeInterface;
+
+public class NodePool extends PoolListBase {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolDatabase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolDatabase.java
new file mode 100644
index 0000000..7b34fda
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolDatabase.java
@@ -0,0 +1,4 @@
+package cz.cvut.fel.sit.omo.foodchain.pool;
+
+public class PoolDatabase {
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolInterface.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolInterface.java
new file mode 100644
index 0000000..7eb13b5
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolInterface.java
@@ -0,0 +1,13 @@
+package cz.cvut.fel.sit.omo.foodchain.pool;
+
+import java.util.Collection;
+
+public interface PoolInterface {
+ Collection findAll();
+
+ void add(T element);
+ void remove(T element);
+
+ void clear();
+ boolean contains(T element);
+}
diff --git a/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolListBase.java b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolListBase.java
new file mode 100644
index 0000000..f654fc9
--- /dev/null
+++ b/src/main/java/cz/cvut/fel/sit/omo/foodchain/pool/PoolListBase.java
@@ -0,0 +1,31 @@
+package cz.cvut.fel.sit.omo.foodchain.pool;
+
+import java.util.*;
+
+public abstract class PoolListBase implements PoolInterface {
+ List pool;
+
+ public PoolListBase() {
+ pool = new LinkedList();
+ }
+
+ public Collection findAll() {
+ return pool;
+ }
+
+ public void add(T element) {
+ pool.add(element);
+ }
+
+ public void remove(T element) {
+ pool.remove(element);
+ }
+
+ public void clear() {
+ pool.clear();
+ }
+
+ public boolean contains(T element) {
+ return pool.contains(element);
+ }
+}