[Draft] Work on visitors (need some renovation)

This commit is contained in:
Nikita Iryupin 2020-12-27 19:01:40 +01:00
parent 3118f91a42
commit fadc4732a9
4 changed files with 24 additions and 15 deletions

View File

@ -18,7 +18,6 @@ pass
<scenario type="Farmer"> <scenario type="Farmer">
<steps> <steps>
generate generate
pass
sell FRUIT jablko sell FRUIT jablko
</steps> </steps>
</scenario> </scenario>

View File

@ -7,6 +7,7 @@ import cz.cvut.fel.sit.omo.foodchain.parser.ConfigurationParser;
import cz.cvut.fel.sit.omo.foodchain.parser.ParserResult; import cz.cvut.fel.sit.omo.foodchain.parser.ParserResult;
import cz.cvut.fel.sit.omo.foodchain.parser.ParserResultElement; import cz.cvut.fel.sit.omo.foodchain.parser.ParserResultElement;
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.reporting.ReportingManager;
import cz.cvut.fel.sit.omo.foodchain.scenario.Scenario; import cz.cvut.fel.sit.omo.foodchain.scenario.Scenario;
import cz.cvut.fel.sit.omo.foodchain.util.Ticker; import cz.cvut.fel.sit.omo.foodchain.util.Ticker;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -34,6 +35,10 @@ public class FoodChain
Ticker.start(); Ticker.start();
while (Ticker.getTimer().isRunning()); while (Ticker.getTimer().isRunning());
ReportingManager reportingManager = new ReportingManager();
System.out.println(reportingManager.acceptAllObjects());
} }
public static FactoryManager getFactoryManager() public static FactoryManager getFactoryManager()

View File

@ -205,6 +205,10 @@ public class NodeBase implements ChannelObserver {
return money; return money;
} }
public NodeType getNodeType() {
return nodeType;
}
public Map<ChannelBase, ChannelSubscriptionType> getSubscribedChannels() { public Map<ChannelBase, ChannelSubscriptionType> getSubscribedChannels() {
return subscribedChannels; return subscribedChannels;
} }

View File

@ -13,30 +13,31 @@ public class ReportTextVisitor {
public String visit(NodeBase node) { public String visit(NodeBase node) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
result.append("Node info: ").append(ln) result.append("Node type: ").append(node.getNodeType()).append(ln)
.append("Allowed seller: ").append(node.getAllowedSeller()).append(ln) .append("Allowed seller: ").append(node.getAllowedSeller()).append(ln)
.append("Allowed purchaser: ").append(node.getAllowedPurchaser()).append(ln) .append("Allowed purchaser: ").append(node.getAllowedPurchaser()).append(ln)
.append("Money: ").append(node.getMoney()).append(ln) .append("Money: ").append(node.getMoney()).append(ln)
.append("Refused transactions: "); .append("Refused transactions: ");
node.getRefusedTransactions().forEach(tr -> result.append(tr.accept(this))); node.getRefusedTransactions().forEach(tr -> result.append(tr.accept(this)));
result.append(ln).append(ln);
return result.toString(); return result.toString();
} }
public String visit(ChannelBase channel) { public String visit(ChannelBase channel) {
return null; return "";
} }
public String visit(Product product) { public String visit(Product product) {
return null; return "";
} }
public String visit(ProductTransaction transaction) { public String visit(ProductTransaction transaction) {
return null; return "";
} }
public String visit(FinancialTransaction transaction) { public String visit(FinancialTransaction transaction) {
return null; return "";
} }
} }