Implemented ScurityReport and TransactionReport

This commit is contained in:
Tomáš Musil 2021-01-05 22:25:05 +01:00
parent 6c11f188ee
commit af9d2796c3
11 changed files with 645 additions and 23 deletions

View File

@ -36,3 +36,6 @@
- Diagramy jsou ve složce resources v souboru FoodChain.eap.
- Javadoc je ve složce resources v souboru FoodChain.html.
***
Pro spuštění aplikace s jiným scénářem napište jeho cestu (tedy např. conf/double-spending-scenario.xml) jako první parametr při spuštění programu.
Druhá varianta je vypsání cest ke všem scénářům jako argumenty programu v pořadí: kanály, nody, produkty, scénáře.
***

583
reports.txt Normal file
View File

@ -0,0 +1,583 @@
--------------
PARTIES REPORT
--------------
------NODE------
Node type: Farmer
Current balance: USD 233.00
Allowed seller: None
Allowed purchaser: Processor
Applied margin: 1.2
Product sold and purchased, action provided:
-----Product: jablko-----
Sell jablko
Presence of product on Node (in ticks): 0
-----Product: hruška-----
Sell hruška
Presence of product on Node (in ticks): 0
-----Product: banán-----
Sell banán
Presence of product on Node (in ticks): 0
-----Product: okurka-----
Sell okurka
Presence of product on Node (in ticks): 0
-----Product: paprika-----
Sell paprika
Presence of product on Node (in ticks): 0
-----Product: rajče-----
Sell rajče
Presence of product on Node (in ticks): 0
-----Product: vepřové-----
Sell vepřové
Presence of product on Node (in ticks): 0
-----Product: hovězí-----
Sell hovězí
Presence of product on Node (in ticks): 0
-----Product: kuřecí-----
Sell kuřecí
Presence of product on Node (in ticks): 0
------NODE------
Node type: Processor
Current balance: USD 239.90
Allowed seller: Farmer
Allowed purchaser: Seller
Applied margin: 1.3
Product sold and purchased, action provided:
-----Product: jablko-----
Get jablko
Action DRY_FRUIT was done with jablko
Sell jablko
Presence of product on Node (in ticks): 8
-----Product: hruška-----
Get hruška
Sell hruška
Presence of product on Node (in ticks): 3
-----Product: banán-----
Get banán
Sell banán
Presence of product on Node (in ticks): 3
-----Product: okurka-----
Get okurka
Sell okurka
Presence of product on Node (in ticks): 3
-----Product: paprika-----
Get paprika
Action STORE_VEGETABLE was done with paprika
Sell paprika
Presence of product on Node (in ticks): 7
-----Product: rajče-----
Get rajče
Action STORE_VEGETABLE was done with rajče
Sell rajče
Presence of product on Node (in ticks): 8
-----Product: vepřové-----
Get vepřové
Action BOIL_MEAT was done with vepřové
Sell vepřové
Presence of product on Node (in ticks): 8
-----Product: hovězí-----
Get hovězí
Action GRILL_MEAT was done with hovězí
Sell hovězí
Presence of product on Node (in ticks): 9
-----Product: kuřecí-----
Get kuřecí
Sell kuřecí
Presence of product on Node (in ticks): 7
------NODE------
Node type: Seller
Current balance: USD 1580.60
Allowed seller: Processor
Allowed purchaser: Distributor
Applied margin: 1.5
Product sold and purchased, action provided:
-----Product: jablko-----
Get jablko
Action WRAP_INTO_GIFT_PACKAGE was done with jablko
Sell jablko
Presence of product on Node (in ticks): 4
-----Product: hruška-----
Get hruška
Action STORE_FRUIT was done with hruška
Sell hruška
Presence of product on Node (in ticks): 7
-----Product: banán-----
Get banán
Action WRAP_INTO_GIFT_PACKAGE was done with banán
Sell banán
Presence of product on Node (in ticks): 4
-----Product: okurka-----
Get okurka
Sell okurka
Presence of product on Node (in ticks): 2
-----Product: paprika-----
Get paprika
Action WRAP_INTO_GIFT_PACKAGE was done with paprika
Sell paprika
Presence of product on Node (in ticks): 3
-----Product: rajče-----
Get rajče
Presence of product on Node (in ticks): 10
-----Product: vepřové-----
Get vepřové
Sell vepřové
Presence of product on Node (in ticks): 2
-----Product: hovězí-----
Get hovězí
Sell hovězí
Presence of product on Node (in ticks): 2
-----Product: kuřecí-----
Get kuřecí
Action WRAP_INTO_GIFT_PACKAGE was done with kuřecí
Sell kuřecí
Presence of product on Node (in ticks): 4
------NODE------
Node type: Distributor
Current balance: USD 1050.70
Allowed seller: Seller
Allowed purchaser: Customer
Applied margin: 1.2
Product sold and purchased, action provided:
-----Product: jablko-----
Get jablko
Sell jablko
Presence of product on Node (in ticks): 1
-----Product: hruška-----
Get hruška
Sell hruška
Presence of product on Node (in ticks): 1
-----Product: banán-----
Get banán
Sell banán
Presence of product on Node (in ticks): 1
-----Product: okurka-----
Get okurka
Sell okurka
Presence of product on Node (in ticks): 1
-----Product: paprika-----
Get paprika
Sell paprika
Presence of product on Node (in ticks): 1
-----Product: vepřové-----
Get vepřové
Sell vepřové
Presence of product on Node (in ticks): 1
-----Product: hovězí-----
Get hovězí
Sell hovězí
Presence of product on Node (in ticks): 1
-----Product: kuřecí-----
Get kuřecí
Sell kuřecí
Presence of product on Node (in ticks): 1
------NODE------
Node type: Customer
Current balance: USD 445.80
Allowed seller: Distributor
Allowed purchaser: None
Applied margin: 1.0
Product sold and purchased, action provided:
-----Product: jablko-----
Get jablko
Presence of product on Node (in ticks): 2
-----Product: hruška-----
Get hruška
Presence of product on Node (in ticks): 4
-----Product: banán-----
Get banán
Presence of product on Node (in ticks): 2
-----Product: okurka-----
Get okurka
Presence of product on Node (in ticks): 2
-----Product: paprika-----
Get paprika
Presence of product on Node (in ticks): 4
-----Product: vepřové-----
Get vepřové
Presence of product on Node (in ticks): 4
-----Product: hovězí-----
Get hovězí
Presence of product on Node (in ticks): 1
-----Product: kuřecí-----
Get kuřecí
Presence of product on Node (in ticks): 2
-----------------
FOOD CHAIN REPORT
-----------------
-----PRODUCT-----
Name: jablko
Type: FRUIT
Started price: USD 5.00
Final price: USD 11.70
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Action DRY_FRUIT was done on Processor -> Moves product from Processor to Seller -> Action WRAP_INTO_GIFT_PACKAGE was done on Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: hruška
Type: FRUIT
Started price: USD 7.00
Final price: USD 16.38
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Moves product from Processor to Seller -> Action STORE_FRUIT was done on Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: banán
Type: FRUIT
Started price: USD 10.00
Final price: USD 23.40
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Moves product from Processor to Seller -> Action WRAP_INTO_GIFT_PACKAGE was done on Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: okurka
Type: VEGETABLE
Started price: USD 3.00
Final price: USD 7.02
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Moves product from Processor to Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: paprika
Type: VEGETABLE
Started price: USD 5.00
Final price: USD 11.70
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Action STORE_VEGETABLE was done on Processor -> Moves product from Processor to Seller -> Action WRAP_INTO_GIFT_PACKAGE was done on Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: rajče
Type: VEGETABLE
Started price: USD 3.00
Final price: USD 5.85
Road map:
Product pool -> Farmer -> Processor -> Seller
Things that happened to this product:
Moves product from Farmer to Processor -> Action STORE_VEGETABLE was done on Processor -> Moves product from Processor to Seller -> Reported
-----PRODUCT-----
Name: vepřové
Type: MEAT
Started price: USD 20.00
Final price: USD 46.80
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Action BOIL_MEAT was done on Processor -> Moves product from Processor to Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: hovězí
Type: MEAT
Started price: USD 50.00
Final price: USD 117.00
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Action GRILL_MEAT was done on Processor -> Moves product from Processor to Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
-----PRODUCT-----
Name: kuřecí
Type: MEAT
Started price: USD 30.00
Final price: USD 70.20
Road map:
Product pool -> Farmer -> Processor -> Seller -> Distributor -> Customer
Things that happened to this product:
Moves product from Farmer to Processor -> Moves product from Processor to Seller -> Action WRAP_INTO_GIFT_PACKAGE was done on Seller -> Moves product from Seller to Distributor -> Moves product from Distributor to Customer -> Reported
---------------
SECURITY REPORT
---------------
------NODE------
Node type: Farmer
Refused transactions:
No refused transactions
Refused requirements:
No refused requirements
------NODE------
Node type: Processor
Refused transactions:
No refused transactions
Refused requirements:
No refused requirements
------NODE------
Node type: Seller
Refused transactions:
No refused transactions
Refused requirements:
No refused requirements
------NODE------
Node type: Distributor
Refused transactions:
No refused transactions
Refused requirements:
No refused requirements
------NODE------
Node type: Customer
Refused transactions:
No refused transactions
Refused requirements:
No refused requirements
------------------
TRANSACTION REPORT
------------------
-----tick-----
Requirement{id=0, creator=Farmer, transactionType=SALE, productName='jablko', TTL=5}
-----tick-----
Processor accepted Requirement{id=0, creator=Farmer, transactionType=SALE, productName='jablko', TTL=4}
Requirement{id=1, creator=Processor, transactionType=PURCHASE, productName='jablko', TTL=5}
Farmer accepted Requirement{id=1, creator=Processor, transactionType=PURCHASE, productName='jablko', TTL=5}
ProductTransaction{product=jablko, creator=Farmer, receiver=Processor}
FinancialTransaction{amount=5, transactionPaid=ProductTransaction{product=jablko, creator=Farmer, receiver=Processor}}
Requirement{id=2, creator=Farmer, transactionType=SALE, productName='hruška', TTL=5}
-----tick-----
Processor accepted Requirement{id=2, creator=Farmer, transactionType=SALE, productName='hruška', TTL=4}
Requirement{id=3, creator=Processor, transactionType=PURCHASE, productName='hruška', TTL=5}
Farmer accepted Requirement{id=3, creator=Processor, transactionType=PURCHASE, productName='hruška', TTL=5}
ProductTransaction{product=hruška, creator=Farmer, receiver=Processor}
FinancialTransaction{amount=7, transactionPaid=ProductTransaction{product=hruška, creator=Farmer, receiver=Processor}}
Requirement{id=4, creator=Farmer, transactionType=SALE, productName='banán', TTL=5}
Action{product=jablko, type=DRY_FRUIT, duration=4, temperature=45}
-----tick-----
Processor accepted Requirement{id=4, creator=Farmer, transactionType=SALE, productName='banán', TTL=4}
Requirement{id=5, creator=Processor, transactionType=PURCHASE, productName='banán', TTL=5}
Farmer accepted Requirement{id=5, creator=Processor, transactionType=PURCHASE, productName='banán', TTL=5}
ProductTransaction{product=banán, creator=Farmer, receiver=Processor}
FinancialTransaction{amount=1E+1, transactionPaid=ProductTransaction{product=banán, creator=Farmer, receiver=Processor}}
Requirement{id=6, creator=Farmer, transactionType=SALE, productName='okurka', TTL=5}
Requirement{id=7, creator=Processor, transactionType=SALE, productName='hruška', TTL=5}
-----tick-----
Processor accepted Requirement{id=6, creator=Farmer, transactionType=SALE, productName='okurka', TTL=4}
Requirement{id=8, creator=Processor, transactionType=PURCHASE, productName='okurka', TTL=5}
Farmer accepted Requirement{id=8, creator=Processor, transactionType=PURCHASE, productName='okurka', TTL=5}
ProductTransaction{product=okurka, creator=Farmer, receiver=Processor}
Seller accepted Requirement{id=7, creator=Processor, transactionType=SALE, productName='hruška', TTL=4}
Requirement{id=9, creator=Seller, transactionType=PURCHASE, productName='hruška', TTL=5}
FinancialTransaction{amount=3, transactionPaid=ProductTransaction{product=okurka, creator=Farmer, receiver=Processor}}
Requirement{id=10, creator=Farmer, transactionType=SALE, productName='paprika', TTL=5}
Requirement{id=11, creator=Processor, transactionType=SALE, productName='banán', TTL=5}
-----tick-----
Processor accepted Requirement{id=10, creator=Farmer, transactionType=SALE, productName='paprika', TTL=4}
Requirement{id=12, creator=Processor, transactionType=PURCHASE, productName='paprika', TTL=5}
Farmer accepted Requirement{id=12, creator=Processor, transactionType=PURCHASE, productName='paprika', TTL=5}
ProductTransaction{product=paprika, creator=Farmer, receiver=Processor}
Processor accepted Requirement{id=9, creator=Seller, transactionType=PURCHASE, productName='hruška', TTL=4}
ProductTransaction{product=hruška, creator=Processor, receiver=Seller}
Seller accepted Requirement{id=11, creator=Processor, transactionType=SALE, productName='banán', TTL=4}
Requirement{id=13, creator=Seller, transactionType=PURCHASE, productName='banán', TTL=5}
FinancialTransaction{amount=5, transactionPaid=ProductTransaction{product=paprika, creator=Farmer, receiver=Processor}}
FinancialTransaction{amount=9.1, transactionPaid=ProductTransaction{product=hruška, creator=Processor, receiver=Seller}}
Requirement{id=14, creator=Farmer, transactionType=SALE, productName='rajče', TTL=5}
Requirement{id=15, creator=Processor, transactionType=SALE, productName='okurka', TTL=5}
Action{product=hruška, type=STORE_FRUIT, duration=3, temperature=2}
-----tick-----
Processor accepted Requirement{id=14, creator=Farmer, transactionType=SALE, productName='rajče', TTL=4}
Requirement{id=16, creator=Processor, transactionType=PURCHASE, productName='rajče', TTL=5}
Seller accepted Requirement{id=15, creator=Processor, transactionType=SALE, productName='okurka', TTL=4}
Requirement{id=17, creator=Seller, transactionType=PURCHASE, productName='okurka', TTL=5}
Farmer accepted Requirement{id=16, creator=Processor, transactionType=PURCHASE, productName='rajče', TTL=5}
ProductTransaction{product=rajče, creator=Farmer, receiver=Processor}
Processor accepted Requirement{id=13, creator=Seller, transactionType=PURCHASE, productName='banán', TTL=4}
ProductTransaction{product=banán, creator=Processor, receiver=Seller}
FinancialTransaction{amount=3, transactionPaid=ProductTransaction{product=rajče, creator=Farmer, receiver=Processor}}
FinancialTransaction{amount=13, transactionPaid=ProductTransaction{product=banán, creator=Processor, receiver=Seller}}
Requirement{id=18, creator=Farmer, transactionType=SALE, productName='vepřové', TTL=5}
Action{product=paprika, type=STORE_VEGETABLE, duration=3, temperature=2}
Action{product=banán, type=WRAP_INTO_GIFT_PACKAGE, duration=1, temperature=21}
-----tick-----
Processor accepted Requirement{id=18, creator=Farmer, transactionType=SALE, productName='vepřové', TTL=4}
Requirement{id=19, creator=Processor, transactionType=PURCHASE, productName='vepřové', TTL=5}
Farmer accepted Requirement{id=19, creator=Processor, transactionType=PURCHASE, productName='vepřové', TTL=5}
ProductTransaction{product=vepřové, creator=Farmer, receiver=Processor}
Processor accepted Requirement{id=17, creator=Seller, transactionType=PURCHASE, productName='okurka', TTL=4}
ProductTransaction{product=okurka, creator=Processor, receiver=Seller}
FinancialTransaction{amount=2E+1, transactionPaid=ProductTransaction{product=vepřové, creator=Farmer, receiver=Processor}}
FinancialTransaction{amount=3.9, transactionPaid=ProductTransaction{product=okurka, creator=Processor, receiver=Seller}}
Requirement{id=20, creator=Farmer, transactionType=SALE, productName='hovězí', TTL=5}
Requirement{id=21, creator=Processor, transactionType=SALE, productName='jablko', TTL=5}
Requirement{id=22, creator=Seller, transactionType=SALE, productName='okurka', TTL=5}
-----tick-----
Processor accepted Requirement{id=20, creator=Farmer, transactionType=SALE, productName='hovězí', TTL=4}
Requirement{id=23, creator=Processor, transactionType=PURCHASE, productName='hovězí', TTL=5}
Farmer accepted Requirement{id=23, creator=Processor, transactionType=PURCHASE, productName='hovězí', TTL=5}
ProductTransaction{product=hovězí, creator=Farmer, receiver=Processor}
Distributor accepted Requirement{id=22, creator=Seller, transactionType=SALE, productName='okurka', TTL=4}
Requirement{id=24, creator=Distributor, transactionType=PURCHASE, productName='okurka', TTL=5}
Seller accepted Requirement{id=21, creator=Processor, transactionType=SALE, productName='jablko', TTL=4}
Requirement{id=25, creator=Seller, transactionType=PURCHASE, productName='jablko', TTL=5}
FinancialTransaction{amount=5E+1, transactionPaid=ProductTransaction{product=hovězí, creator=Farmer, receiver=Processor}}
Requirement{id=26, creator=Farmer, transactionType=SALE, productName='kuřecí', TTL=5}
Action{product=rajče, type=STORE_VEGETABLE, duration=3, temperature=2}
Requirement{id=27, creator=Seller, transactionType=SALE, productName='banán', TTL=5}
-----tick-----
Processor accepted Requirement{id=26, creator=Farmer, transactionType=SALE, productName='kuřecí', TTL=4}
Requirement{id=28, creator=Processor, transactionType=PURCHASE, productName='kuřecí', TTL=5}
Farmer accepted Requirement{id=28, creator=Processor, transactionType=PURCHASE, productName='kuřecí', TTL=5}
ProductTransaction{product=kuřecí, creator=Farmer, receiver=Processor}
Seller accepted Requirement{id=24, creator=Distributor, transactionType=PURCHASE, productName='okurka', TTL=4}
ProductTransaction{product=okurka, creator=Seller, receiver=Distributor}
Processor accepted Requirement{id=25, creator=Seller, transactionType=PURCHASE, productName='jablko', TTL=4}
ProductTransaction{product=jablko, creator=Processor, receiver=Seller}
Distributor accepted Requirement{id=27, creator=Seller, transactionType=SALE, productName='banán', TTL=4}
Requirement{id=29, creator=Distributor, transactionType=PURCHASE, productName='banán', TTL=5}
FinancialTransaction{amount=3E+1, transactionPaid=ProductTransaction{product=kuřecí, creator=Farmer, receiver=Processor}}
FinancialTransaction{amount=6.5, transactionPaid=ProductTransaction{product=jablko, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=5.85, transactionPaid=ProductTransaction{product=okurka, creator=Seller, receiver=Distributor}}
Action{product=vepřové, type=BOIL_MEAT, duration=2, temperature=100}
Action{product=jablko, type=WRAP_INTO_GIFT_PACKAGE, duration=1, temperature=21}
Requirement{id=30, creator=Distributor, transactionType=SALE, productName='okurka', TTL=5}
-----tick-----
Customer accepted Requirement{id=30, creator=Distributor, transactionType=SALE, productName='okurka', TTL=4}
Requirement{id=31, creator=Customer, transactionType=PURCHASE, productName='okurka', TTL=5}
Distributor accepted Requirement{id=31, creator=Customer, transactionType=PURCHASE, productName='okurka', TTL=5}
ProductTransaction{product=okurka, creator=Distributor, receiver=Customer}
Seller accepted Requirement{id=29, creator=Distributor, transactionType=PURCHASE, productName='banán', TTL=4}
ProductTransaction{product=banán, creator=Seller, receiver=Distributor}
FinancialTransaction{amount=19.5, transactionPaid=ProductTransaction{product=banán, creator=Seller, receiver=Distributor}}
FinancialTransaction{amount=7.02, transactionPaid=ProductTransaction{product=okurka, creator=Distributor, receiver=Customer}}
Requirement{id=32, creator=Processor, transactionType=SALE, productName='paprika', TTL=5}
Requirement{id=33, creator=Seller, transactionType=SALE, productName='hruška', TTL=5}
Requirement{id=34, creator=Distributor, transactionType=SALE, productName='banán', TTL=5}
-----tick-----
Seller accepted Requirement{id=32, creator=Processor, transactionType=SALE, productName='paprika', TTL=4}
Requirement{id=35, creator=Seller, transactionType=PURCHASE, productName='paprika', TTL=5}
Customer accepted Requirement{id=34, creator=Distributor, transactionType=SALE, productName='banán', TTL=4}
Requirement{id=36, creator=Customer, transactionType=PURCHASE, productName='banán', TTL=5}
Distributor accepted Requirement{id=33, creator=Seller, transactionType=SALE, productName='hruška', TTL=4}
Requirement{id=37, creator=Distributor, transactionType=PURCHASE, productName='hruška', TTL=5}
Distributor accepted Requirement{id=36, creator=Customer, transactionType=PURCHASE, productName='banán', TTL=5}
ProductTransaction{product=banán, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=23.4, transactionPaid=ProductTransaction{product=banán, creator=Distributor, receiver=Customer}}
Action{product=hovězí, type=GRILL_MEAT, duration=2, temperature=200}
Requirement{id=38, creator=Seller, transactionType=SALE, productName='jablko', TTL=5}
Customer consumed okurka VEGETABLE
-----tick-----
Processor accepted Requirement{id=35, creator=Seller, transactionType=PURCHASE, productName='paprika', TTL=4}
ProductTransaction{product=paprika, creator=Processor, receiver=Seller}
Seller accepted Requirement{id=37, creator=Distributor, transactionType=PURCHASE, productName='hruška', TTL=4}
ProductTransaction{product=hruška, creator=Seller, receiver=Distributor}
Distributor accepted Requirement{id=38, creator=Seller, transactionType=SALE, productName='jablko', TTL=4}
Requirement{id=39, creator=Distributor, transactionType=PURCHASE, productName='jablko', TTL=5}
FinancialTransaction{amount=6.5, transactionPaid=ProductTransaction{product=paprika, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=13.65, transactionPaid=ProductTransaction{product=hruška, creator=Seller, receiver=Distributor}}
Requirement{id=40, creator=Processor, transactionType=SALE, productName='rajče', TTL=5}
Action{product=paprika, type=WRAP_INTO_GIFT_PACKAGE, duration=1, temperature=21}
Requirement{id=41, creator=Distributor, transactionType=SALE, productName='hruška', TTL=5}
Customer consumed banán FRUIT
-----tick-----
Seller accepted Requirement{id=40, creator=Processor, transactionType=SALE, productName='rajče', TTL=4}
Requirement{id=42, creator=Seller, transactionType=PURCHASE, productName='rajče', TTL=5}
Customer accepted Requirement{id=41, creator=Distributor, transactionType=SALE, productName='hruška', TTL=4}
Requirement{id=43, creator=Customer, transactionType=PURCHASE, productName='hruška', TTL=5}
Seller accepted Requirement{id=39, creator=Distributor, transactionType=PURCHASE, productName='jablko', TTL=4}
ProductTransaction{product=jablko, creator=Seller, receiver=Distributor}
Distributor accepted Requirement{id=43, creator=Customer, transactionType=PURCHASE, productName='hruška', TTL=5}
ProductTransaction{product=hruška, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=9.75, transactionPaid=ProductTransaction{product=jablko, creator=Seller, receiver=Distributor}}
FinancialTransaction{amount=16.38, transactionPaid=ProductTransaction{product=hruška, creator=Distributor, receiver=Customer}}
Requirement{id=44, creator=Processor, transactionType=SALE, productName='vepřové', TTL=5}
Requirement{id=45, creator=Seller, transactionType=SALE, productName='paprika', TTL=5}
Requirement{id=46, creator=Distributor, transactionType=SALE, productName='jablko', TTL=5}
-----tick-----
Seller accepted Requirement{id=44, creator=Processor, transactionType=SALE, productName='vepřové', TTL=4}
Requirement{id=47, creator=Seller, transactionType=PURCHASE, productName='vepřové', TTL=5}
Processor accepted Requirement{id=42, creator=Seller, transactionType=PURCHASE, productName='rajče', TTL=4}
ProductTransaction{product=rajče, creator=Processor, receiver=Seller}
Distributor accepted Requirement{id=45, creator=Seller, transactionType=SALE, productName='paprika', TTL=4}
Requirement{id=48, creator=Distributor, transactionType=PURCHASE, productName='paprika', TTL=5}
Customer accepted Requirement{id=46, creator=Distributor, transactionType=SALE, productName='jablko', TTL=4}
Requirement{id=49, creator=Customer, transactionType=PURCHASE, productName='jablko', TTL=5}
Distributor accepted Requirement{id=49, creator=Customer, transactionType=PURCHASE, productName='jablko', TTL=5}
ProductTransaction{product=jablko, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=3.9, transactionPaid=ProductTransaction{product=rajče, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=11.7, transactionPaid=ProductTransaction{product=jablko, creator=Distributor, receiver=Customer}}
Requirement{id=50, creator=Processor, transactionType=SALE, productName='kuřecí', TTL=5}
-----tick-----
Processor accepted Requirement{id=47, creator=Seller, transactionType=PURCHASE, productName='vepřové', TTL=4}
ProductTransaction{product=vepřové, creator=Processor, receiver=Seller}
Seller accepted Requirement{id=50, creator=Processor, transactionType=SALE, productName='kuřecí', TTL=4}
Requirement{id=51, creator=Seller, transactionType=PURCHASE, productName='kuřecí', TTL=5}
Seller accepted Requirement{id=48, creator=Distributor, transactionType=PURCHASE, productName='paprika', TTL=4}
ProductTransaction{product=paprika, creator=Seller, receiver=Distributor}
FinancialTransaction{amount=26, transactionPaid=ProductTransaction{product=vepřové, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=9.75, transactionPaid=ProductTransaction{product=paprika, creator=Seller, receiver=Distributor}}
Requirement{id=52, creator=Processor, transactionType=SALE, productName='hovězí', TTL=5}
Requirement{id=53, creator=Seller, transactionType=SALE, productName='vepřové', TTL=5}
Requirement{id=54, creator=Distributor, transactionType=SALE, productName='paprika', TTL=5}
Customer consumed jablko FRUIT
-----tick-----
Processor accepted Requirement{id=51, creator=Seller, transactionType=PURCHASE, productName='kuřecí', TTL=4}
ProductTransaction{product=kuřecí, creator=Processor, receiver=Seller}
Seller accepted Requirement{id=52, creator=Processor, transactionType=SALE, productName='hovězí', TTL=4}
Requirement{id=55, creator=Seller, transactionType=PURCHASE, productName='hovězí', TTL=5}
Distributor accepted Requirement{id=53, creator=Seller, transactionType=SALE, productName='vepřové', TTL=4}
Requirement{id=56, creator=Distributor, transactionType=PURCHASE, productName='vepřové', TTL=5}
Customer accepted Requirement{id=54, creator=Distributor, transactionType=SALE, productName='paprika', TTL=4}
Requirement{id=57, creator=Customer, transactionType=PURCHASE, productName='paprika', TTL=5}
Distributor accepted Requirement{id=57, creator=Customer, transactionType=PURCHASE, productName='paprika', TTL=5}
ProductTransaction{product=paprika, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=39, transactionPaid=ProductTransaction{product=kuřecí, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=11.7, transactionPaid=ProductTransaction{product=paprika, creator=Distributor, receiver=Customer}}
Action{product=kuřecí, type=WRAP_INTO_GIFT_PACKAGE, duration=1, temperature=21}
Customer consumed hruška FRUIT
-----tick-----
Processor accepted Requirement{id=55, creator=Seller, transactionType=PURCHASE, productName='hovězí', TTL=4}
ProductTransaction{product=hovězí, creator=Processor, receiver=Seller}
Seller accepted Requirement{id=56, creator=Distributor, transactionType=PURCHASE, productName='vepřové', TTL=4}
ProductTransaction{product=vepřové, creator=Seller, receiver=Distributor}
FinancialTransaction{amount=65, transactionPaid=ProductTransaction{product=hovězí, creator=Processor, receiver=Seller}}
FinancialTransaction{amount=39, transactionPaid=ProductTransaction{product=vepřové, creator=Seller, receiver=Distributor}}
Requirement{id=58, creator=Seller, transactionType=SALE, productName='hovězí', TTL=5}
Requirement{id=59, creator=Distributor, transactionType=SALE, productName='vepřové', TTL=5}
-----tick-----
Customer accepted Requirement{id=59, creator=Distributor, transactionType=SALE, productName='vepřové', TTL=4}
Requirement{id=60, creator=Customer, transactionType=PURCHASE, productName='vepřové', TTL=5}
Distributor accepted Requirement{id=58, creator=Seller, transactionType=SALE, productName='hovězí', TTL=4}
Requirement{id=61, creator=Distributor, transactionType=PURCHASE, productName='hovězí', TTL=5}
Distributor accepted Requirement{id=60, creator=Customer, transactionType=PURCHASE, productName='vepřové', TTL=5}
ProductTransaction{product=vepřové, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=46.8, transactionPaid=ProductTransaction{product=vepřové, creator=Distributor, receiver=Customer}}
Requirement{id=62, creator=Seller, transactionType=SALE, productName='kuřecí', TTL=5}
-----tick-----
Seller accepted Requirement{id=61, creator=Distributor, transactionType=PURCHASE, productName='hovězí', TTL=4}
ProductTransaction{product=hovězí, creator=Seller, receiver=Distributor}
Distributor accepted Requirement{id=62, creator=Seller, transactionType=SALE, productName='kuřecí', TTL=4}
Requirement{id=63, creator=Distributor, transactionType=PURCHASE, productName='kuřecí', TTL=5}
FinancialTransaction{amount=97.5, transactionPaid=ProductTransaction{product=hovězí, creator=Seller, receiver=Distributor}}
Requirement{id=64, creator=Distributor, transactionType=SALE, productName='hovězí', TTL=5}
Customer consumed paprika VEGETABLE
-----tick-----
Customer accepted Requirement{id=64, creator=Distributor, transactionType=SALE, productName='hovězí', TTL=4}
Requirement{id=65, creator=Customer, transactionType=PURCHASE, productName='hovězí', TTL=5}
Seller accepted Requirement{id=63, creator=Distributor, transactionType=PURCHASE, productName='kuřecí', TTL=4}
ProductTransaction{product=kuřecí, creator=Seller, receiver=Distributor}
Distributor accepted Requirement{id=65, creator=Customer, transactionType=PURCHASE, productName='hovězí', TTL=5}
ProductTransaction{product=hovězí, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=58.5, transactionPaid=ProductTransaction{product=kuřecí, creator=Seller, receiver=Distributor}}
FinancialTransaction{amount=117, transactionPaid=ProductTransaction{product=hovězí, creator=Distributor, receiver=Customer}}
Requirement{id=66, creator=Distributor, transactionType=SALE, productName='kuřecí', TTL=5}
Customer consumed hovězí MEAT
-----tick-----
Customer accepted Requirement{id=66, creator=Distributor, transactionType=SALE, productName='kuřecí', TTL=4}
Requirement{id=67, creator=Customer, transactionType=PURCHASE, productName='kuřecí', TTL=5}
Distributor accepted Requirement{id=67, creator=Customer, transactionType=PURCHASE, productName='kuřecí', TTL=5}
ProductTransaction{product=kuřecí, creator=Distributor, receiver=Customer}
FinancialTransaction{amount=70.2, transactionPaid=ProductTransaction{product=kuřecí, creator=Distributor, receiver=Customer}}
Customer consumed vepřové MEAT
-----tick-----
Customer consumed kuřecí MEAT
-----tick-----

View File

@ -46,7 +46,7 @@ public class FoodChain
parseProducts("conf/products.xml");
parseScenarios("conf/scenarios.xml");
rootLogger.log(Level.INFO,"Parsed default scenarios");
// rootLogger.log(Level.INFO,"Parsed default scenarios");
}
else if (args.length < 2)
{
@ -55,7 +55,7 @@ public class FoodChain
parseProducts("conf/products.xml");
parseScenarios(args[0]);
rootLogger.log(Level.INFO,"Parsed non-default scenarios");
// rootLogger.log(Level.INFO,"Parsed non-default scenarios");
}
else
{
@ -64,7 +64,7 @@ public class FoodChain
parseProducts(args[3]);
parseScenarios(args[4]);
rootLogger.log(Level.INFO,"Parsed non-default scenarios");
// rootLogger.log(Level.INFO,"Parsed non-default scenarios");
}
Ticker.start();
@ -72,7 +72,7 @@ public class FoodChain
ReportingManager reportingManager = new ReportingManager();
System.out.println(reportingManager.generateReport());
reportingManager.createFileTextReport("reports.txt");
}
public static FactoryManager getFactoryManager() { return factoryManager; }

View File

@ -271,6 +271,8 @@ public class NodeBase implements ChannelObserver {
return refusedTransactions;
}
public List<RefusedRequirement> getRefusedRequirements() { return refusedRequirements; }
public NodeType getAllowedSeller() {
return allowedSeller;
}

View File

@ -26,4 +26,14 @@ public class RefusedRequirement {
public String getProductName() { return productName; }
public MonetaryAmount getPrice() { return price; }
@Override
public String toString() {
return "RefusedRequirement{" +
"transactionType=" + transactionType +
", productType=" + productType +
", productName='" + productName + '\'' +
", price=" + price +
'}';
}
}

View File

@ -28,7 +28,7 @@ public class FoodChainReportVisitor implements ReportTextVisitor {
.forEach(n -> builder.append(" -> ").append(n.accept(this)));
builder.append(ln);
builder.append("Things happened to this product: ").append(ln);
builder.append("Things that happened to this product: ").append(ln);
product.getListOfOperations().forEach(o -> builder.append(o.accept(this)).append(" -> "));
builder.append("Reported").append(ln);

View File

@ -16,6 +16,7 @@ public class PartiesReportVisitor implements ReportTextVisitor {
builder.append("------NODE------").append(ln)
.append("Node type: ").append(node.getNodeType()).append(ln)
.append("Current balance: ").append(node.getMoney()).append(ln)
.append("Allowed seller: ").append(node.getAllowedSeller()).append(ln)
.append("Allowed purchaser: ").append(node.getAllowedPurchaser()).append(ln)
.append("Applied margin: ").append(node.getMargin()).append(ln)

View File

@ -2,6 +2,7 @@ package cz.cvut.fel.sit.omo.foodchain.reporting;
import cz.cvut.fel.sit.omo.foodchain.FoodChain;
import cz.cvut.fel.sit.omo.foodchain.pool.PoolDatabase;
import cz.cvut.fel.sit.omo.foodchain.util.ReportLogger;
public class ReportBuilder {
private final StringBuilder report;
@ -22,7 +23,7 @@ public class ReportBuilder {
.append("--------------").append(ln).append(ln);
db.getNodePoolInstance().findAll().forEach(n -> report.append(n.accept(reportVisitor)));
report.append(ln);
report.append(ln).append(ln);
return this;
}
@ -30,12 +31,12 @@ public class ReportBuilder {
public ReportBuilder addFoodChainReport() {
ReportTextVisitor reportVisitor = new FoodChainReportVisitor();
report.append("------------------").append(ln)
report.append("-----------------").append(ln)
.append("FOOD CHAIN REPORT").append(ln)
.append("------------------").append(ln).append(ln);
.append("-----------------").append(ln).append(ln);
db.getProductPoolInstance().findAll().forEach(p -> report.append(p.accept(reportVisitor)));
report.append(ln);
report.append(ln).append(ln);
return this;
}
@ -43,17 +44,20 @@ public class ReportBuilder {
public ReportBuilder addSecurityReport() {
ReportTextVisitor reportVisitor = new SecurityReportVisitor();
report.append("----------------").append(ln)
report.append("---------------").append(ln)
.append("SECURITY REPORT").append(ln)
.append("----------------").append(ln).append(ln);
.append("---------------").append(ln).append(ln);
db.getNodePoolInstance().findAll().forEach(n -> report.append(n.accept(reportVisitor)));
report.append(ln).append(ln);
return this;
}
public ReportBuilder addTransactionReport() {
//TODO
report.append("------------------").append(ln)
.append("TRANSACTION REPORT").append(ln)
.append("------------------").append(ln).append(ln)
.append(ReportLogger.getSb().toString());
return this;
}

View File

@ -11,10 +11,8 @@ public class ReportingManager {
File reportFile = new File(pathname);
try {
FileWriter fileWriter = new FileWriter(reportFile);
if (!reportFile.createNewFile()) {
throw new FileAlreadyExistsException(pathname);
}
fileWriter.write(generateReport());
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -7,7 +7,23 @@ import cz.cvut.fel.sit.omo.foodchain.product.Product;
public class SecurityReportVisitor implements ReportTextVisitor {
@Override
public String visit(NodeBase node) { return null; }
public String visit(NodeBase node) {
StringBuilder builder = new StringBuilder();
builder.append("------NODE------").append(ln)
.append("Node type: ").append(node.getNodeType()).append(ln)
.append("Refused transactions:").append(ln);
if (node.getRefusedTransactions().isEmpty()) builder.append("No refused transactions").append(ln);
else node.getRefusedTransactions().forEach(t -> builder.append(t).append(ln));
builder.append("Refused requirements:").append(ln);
if (node.getRefusedRequirements().isEmpty()) builder.append("No refused requirements").append(ln);
else node.getRefusedRequirements().forEach(r -> builder.append(r).append(ln));
return builder.toString();
}
@Override
public String visit(Product product) {

View File

@ -16,25 +16,26 @@ import java.util.logging.LogRecord;
*/
public class ReportLogger extends Handler
{
private static final StringBuilder sb = new StringBuilder();
/**
* Logs message and prints it out.
* @param record message to be printed
*/
@Override
public void publish(LogRecord record) {
StringBuilder sb = new StringBuilder();
sb.append(record.getMessage());
// Blocking Money logs because spams "Using default formatter toString()." after printing MonetaryAmount in reports
if(record.getSourceClassName().equals(Money.class.getName()))return;
if(record.getSourceClassName().equals(Money.class.getName()) || record.getMessage().contains("MathContext"))return;
sb.append(record.getMessage()).append(System.lineSeparator());
if(record.getLevel().equals(Level.WARNING) || record.getLevel().equals(Level.SEVERE))
{
System.err.println(sb.toString());
System.err.println(record.getMessage());
}
else
{
System.out.println(sb.toString());
System.out.println(record.getMessage());
}
}
@ -45,4 +46,8 @@ public class ReportLogger extends Handler
@Override
public void close() throws SecurityException {
}
public static StringBuilder getSb() {
return sb;
}
}