Merge branch 'develop' into feature/text_report_impl
# Conflicts: # src/main/java/cz/cvut/fel/sit/omo/foodchain/FoodChain.java
This commit is contained in:
commit
172075612b
@ -23,10 +23,20 @@ public class FoodChain
|
|||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
parseChannels();
|
if(args.length < 4)
|
||||||
parseNodes();
|
{
|
||||||
parseProducts();
|
parseChannels("conf/channels.xml");
|
||||||
parseScenarios();
|
parseNodes("conf/nodes.xml");
|
||||||
|
parseProducts("conf/products.xml");
|
||||||
|
parseScenarios("conf/scenarios.xml");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parseChannels(args[1]);
|
||||||
|
parseNodes(args[2]);
|
||||||
|
parseProducts(args[3]);
|
||||||
|
parseScenarios(args[4]);
|
||||||
|
}
|
||||||
|
|
||||||
// getFactoryManager().getPoolDatabaseInstance().getChannelPoolInstance().findAll().stream().forEach(ch -> System.out.println(ch.getProductType()));
|
// getFactoryManager().getPoolDatabaseInstance().getChannelPoolInstance().findAll().stream().forEach(ch -> System.out.println(ch.getProductType()));
|
||||||
// getFactoryManager().getPoolDatabaseInstance().getNodePoolInstance().findAll().stream().forEach(ch -> System.out.println(ch));
|
// getFactoryManager().getPoolDatabaseInstance().getNodePoolInstance().findAll().stream().forEach(ch -> System.out.println(ch));
|
||||||
@ -34,7 +44,10 @@ public class FoodChain
|
|||||||
// getFactoryManager().getPoolDatabaseInstance().getScenarioPoolInstance().findAll().stream().forEach(ch -> ch.getSteps().stream().forEach(s -> System.out.println(s)));
|
// getFactoryManager().getPoolDatabaseInstance().getScenarioPoolInstance().findAll().stream().forEach(ch -> ch.getSteps().stream().forEach(s -> System.out.println(s)));
|
||||||
|
|
||||||
Ticker.start();
|
Ticker.start();
|
||||||
while (Ticker.getTimer().isRunning());
|
while (Ticker.getTimer().isRunning())
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
ReportingManager reportingManager = new ReportingManager();
|
ReportingManager reportingManager = new ReportingManager();
|
||||||
|
|
||||||
@ -46,87 +59,61 @@ public class FoodChain
|
|||||||
return factoryManager;
|
return factoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseChannels()
|
public static ParserResult parseDocument(String path, String rootElementTag)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// parse channel configuration
|
ConfigurationParser.parseDocument(path);
|
||||||
ConfigurationParser.parseDocument("conf/channels.xml");
|
}
|
||||||
ParserResult parserResult = ConfigurationParser.getElements("channel");
|
catch (ParserConfigurationException | SAXException | IOException e)
|
||||||
|
{
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConfigurationParser.getElements(rootElementTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void parseChannels(String path)
|
||||||
|
{
|
||||||
|
ParserResult parserResult = parseDocument(path, "channel");
|
||||||
List<ParserResultElement> elements = parserResult.getElements();
|
List<ParserResultElement> elements = parserResult.getElements();
|
||||||
for (ParserResultElement el : elements)
|
for (ParserResultElement el : elements)
|
||||||
{
|
{
|
||||||
ChannelBase res = getFactoryManager().getChannelFactoryInstance().makeChannel(el);
|
ChannelBase res = getFactoryManager().getChannelFactoryInstance().makeChannel(el);
|
||||||
getFactoryManager().getPoolDatabaseInstance().getChannelPoolInstance().add(res);
|
getFactoryManager().getPoolDatabaseInstance().getChannelPoolInstance().add(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (ParserConfigurationException | SAXException | IOException e)
|
|
||||||
{
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseNodes()
|
public static void parseNodes(String path)
|
||||||
{
|
{
|
||||||
try
|
ParserResult parserResult = parseDocument(path, "node");
|
||||||
{
|
|
||||||
// parse channel configuration
|
|
||||||
ConfigurationParser.parseDocument("conf/nodes.xml");
|
|
||||||
ParserResult parserResult = ConfigurationParser.getElements("node");
|
|
||||||
List<ParserResultElement> elements = parserResult.getElements();
|
List<ParserResultElement> elements = parserResult.getElements();
|
||||||
for (ParserResultElement el : elements)
|
for (ParserResultElement el : elements)
|
||||||
{
|
{
|
||||||
NodeBase res = getFactoryManager().getNodeFactoryInstance().makeNode(el);
|
NodeBase res = getFactoryManager().getNodeFactoryInstance().makeNode(el);
|
||||||
getFactoryManager().getPoolDatabaseInstance().getNodePoolInstance().add(res);
|
getFactoryManager().getPoolDatabaseInstance().getNodePoolInstance().add(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (ParserConfigurationException | SAXException | IOException e)
|
|
||||||
{
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseProducts()
|
public static void parseProducts(String path)
|
||||||
{
|
{
|
||||||
try
|
ParserResult parserResult = parseDocument(path, "product");
|
||||||
{
|
|
||||||
// parse channel configuration
|
|
||||||
ConfigurationParser.parseDocument("conf/products.xml");
|
|
||||||
ParserResult parserResult = ConfigurationParser.getElements("product");
|
|
||||||
List<ParserResultElement> elements = parserResult.getElements();
|
List<ParserResultElement> elements = parserResult.getElements();
|
||||||
for (ParserResultElement el : elements)
|
for (ParserResultElement el : elements)
|
||||||
{
|
{
|
||||||
Product res = getFactoryManager().getProductFactoryInstance().makeProduct(el);
|
Product res = getFactoryManager().getProductFactoryInstance().makeProduct(el);
|
||||||
getFactoryManager().getPoolDatabaseInstance().getProductPoolInstance().add(res);
|
getFactoryManager().getPoolDatabaseInstance().getProductPoolInstance().add(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (ParserConfigurationException | SAXException | IOException e)
|
|
||||||
{
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseScenarios()
|
public static void parseScenarios(String path)
|
||||||
{
|
{
|
||||||
try
|
ParserResult parserResult = parseDocument(path, "scenario");
|
||||||
{
|
|
||||||
// parse channel configuration
|
|
||||||
ConfigurationParser.parseDocument("conf/scenarios.xml");
|
|
||||||
ParserResult parserResult = ConfigurationParser.getElements("scenario");
|
|
||||||
List<ParserResultElement> elements = parserResult.getElements();
|
List<ParserResultElement> elements = parserResult.getElements();
|
||||||
for (ParserResultElement el : elements)
|
for (ParserResultElement el : elements)
|
||||||
{
|
{
|
||||||
Scenario res = getFactoryManager().getScenarioFactoryInstance().makeScenario(el);
|
Scenario res = getFactoryManager().getScenarioFactoryInstance().makeScenario(el);
|
||||||
getFactoryManager().getPoolDatabaseInstance().getScenarioPoolInstance().add(res);
|
getFactoryManager().getPoolDatabaseInstance().getScenarioPoolInstance().add(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (ParserConfigurationException | SAXException | IOException e)
|
|
||||||
{
|
|
||||||
System.err.println(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user