Group Project

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

WIF3003 Group Project Sem.

2, 2021/2022

Title: i-Farm, the Organic Farm Activity Logging Application

The purpose of this competition is to assess the students’ ability to apply adequate concurrent
programming skills and use appropriate constructs in the Java language to solve a real life
farming community problem.

Context:

The organic farm certifying body forms a group of inspectors to conduct inspections on the
organic farms on a timely basis, to enable the produce to meet all the requirements and criteria
for organic plant products. This allows the certifying body to identify and eliminate potential
frauds, for example some farms may mix organic and inorganic products together for
certification to increase the price of inorganic products.

Problem:

Traditionally, during the organic farm inspection, the inspectors will check the farm’s activity
logs, which consist of all farming activities carried out by the farmers on their plantation.
Activity logs come with different formats in different farms, some in hand-written format and
some in the Excel format. The inspectors then review the activity logs and consolidate the logs
into a standard format. Finally, they perform quantitative and qualitative analysis and prepare an
inspection report for certification.

The certifying body has engaged a team of software developers to help the farmers and
inspectors digitalize the activity logging and inspection process into a paperless solution. The
certifying body also concerns about the software system’s scalability to process the growing
amount of data concurrently when there are more farmers using the system in the future.

How do we simulate the huge amount of farming data entries and process the data concurrently
without compromising system reliability such as ensuring data loss and data inconsistency?

Forces:

- You form a team of 5 developers working on the application.


- You must build the application in Java.
- You must build the application as a console application, focusing on functionality instead
of UI/UX.
- You must build the application into a scalable, highly-available and fault tolerant system
- The application must be easy to understand and modify.
- You must do proper exception handling.
- You must ensure the atomicity of data. The data processing must be all-or-nothing.

CTK Page 1 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Solution:

Design and develop a Java console-line application to implement a concurrent programming-


based system that is:

- Highly maintainable: Properly commented, easy to understand and develop


- Loosely coupled: Enable a team to work independently on their respective modules
without impacting other modules.
- Highly available: If a thread fails / dies, the other threads are not interrupted
- Atomic: If a transaction of data fails in the middle, roll back the previous commits.
- Fault tolerance: If a thread fails / dies, the system works around with an alternative
solution to continue providing the service.
- Scalable: Able to cater for a large volume of data entry, and spawn more threads when
the usage increases.

System Scope:

A. Dummy Data Generation

Refer to Appendix 1: Entity-Relationship Diagram for the database schema; Appendix 2:


Sample Data for the sample data for each table; and Appendix 3: Data Constraints and
Definitions for rules of data.

Generate the data into text files with minimum number of records for each data as follows, and
load into your application:

No. Table Name Minimum Number of Data Required

1 Farms 10

2 Plants 100

3 Fertilizers 100

4 Pesticides 100

CTK Page 2 of 14
WIF3003 Group Project Sem. 2, 2021/2022

B. Dummy Farmers Simulation

Simulate farmers (users) activity logging in multiple threads. Farmers are part of the Users data
schema.

Refer to Appendix 1: Entity-Relationship Diagram for the database schema; Appendix 2:


Sample Data for the sample data for each table; and Appendix 3: Data Constraints and
Definitions for rules of data.

1. Implement the class FarmerSimulator that implements the interface below:

interface FarmerSimulatorInterface {
[]Farmer generateFarmers(int numberOfFarmers);
}

2. Implement the class Farmer that extends Thread or implements Runnable. In the run()
method, the Farmer object generates at least 1000 activities of random activity types for
a single random farm. For example, Farmer A generates 1234 activities of random types
for Farm A.

3. Write the farmers’ sent operations and success operations into log file(s). Make sure that
the correctness of your application is traceable and clearly shown as logs.

C. Concurrent Programming Logic

Apply your knowledge in concurrent programming to enable the system to handle data entry
from at least 100 farmers efficiently and effectively.

You are required to record and compare the duration spent to process the farmers’ data entry
before implementing concurrent programming logic and after implementing concurrent
programming logic. Justify the differences.

D. Disaster Simulation

Simulate disasters where farmer operations fail in the middle. Implement a workaround to
recover your failed threads. Justify how you attempt to resolve the disasters to allow farmers to
continue operations from the point where they failed. Ensure the atomicity of data.

CTK Page 3 of 14
WIF3003 Group Project Sem. 2, 2021/2022

E. Data Visualization

Identify which plant / fertilizer / pesticide is used in the activity. Check the unitType attribute
of the plant / fertilizer / pesticide. Process all activities into their respective standard units.

The standard units for mass, pack and volume unit types are as follows:

- mass -> kg
- pack -> pack (1000g)
- volume -> ℓ

After all activities have been successfully processed, allow the user to type in commands to
visualize the activities data in different ways:

1. Display all activity logs for a target farm


2. Display all activity logs for a target farmer
3. Display all activity logs for a target farm and plant / fertilizer / pesticide
4. Display all activity logs for a target farm and plant / fertilizer / pesticide between date A
and date B (inclusive)
5. Display summarized logs by plants, fertilizers and pesticides for a target farm and plant /
fertilizer / pesticide between date A and date B (inclusive) for selected field and row
number. For example, if the activity logs are:

Sowing Broccoli Field 1 Row 1 1 kg 2022-03-03


Sowing Broccoli Field 1 Row 1 1.5 kg 2022-03-04
Fertilizer Bone Meal Field 1 Row 1 1 kg 2022-03-04

The expected output is:

Sowing Broccoli Field 1 Row 1 2.5 kg


Fertilizer Bone Meal Field 1 Row 1 1 kg

F. [Plus Point] Improved Concurrent Programming Design

Design and implement the i-Farm application in your own way with concurrent programming
concepts that you have learnt. Test with more farms and farmers and provide a performance test
result of how many farms and farmers can be handled by your improved application. Justify why
you think your way can be a better solution. Back your justifications with proper diagrams.

CTK Page 4 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Report and Video Presentation:

Week 6:

Introduction: Describe the problem statement and justify how concurrent programming can
tackle the problem.

Methodology: Discuss at least 3 different methodologies that you have learnt to apply concurrent
programming concepts. Discuss why the methodology can / cannot solve the problem.

Roles and Responsibilities: Discuss the roles and responsibilities and work schedule for your
team.

System Design: Draw a diagram to illustrate the application design.

Submission due: 12pm, Friday 22 April 2022

Week 13:

System Implementation: Screenshot the source code for the key features implemented in your
application. Highlight your additional work (plus points).

Discussion: Screenshot the application, improvements after implementing concurrent


programming logic, drawbacks and other aspects that show your understanding towards your
application outcome.

Testimony: Describe testimony on responsibility, work done and lessons learnt. May attach with
Git commit logs as a proof of contributions.

Conclusion: Conclude how you have attempted to solve the concurrent programming problem
and your learning points in summary.

Submission due: 12pm, Friday 17 June 2022

CTK Page 5 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Assessments:

Criteria Excellent Good Average Poor Very


Poor
Week 6 (Report - 10%)

Project Planning 2 1.5 1.0 0.5 0

Members and responsibilities 2 1.5 1.0 0.5 0

Methodology 3 2.5 2 1 0

Problem solving 3 2.5 2 1 0


Week 6 (Presentation - 10%)
Teamwork 2 1.5 1.0 0.5 0

Language and presentation 2 1.5 1.0 0.5 0

Methodology 3 2.5 2 1 0

Problem solving 3 2.5 2 1 0

Criteria Excellent Good Average Poor Very


Poor
Week 13 (Report and Implementation - 20%)

Programming style, including code 2 1.5 1.0 0.5 0


organization, readability, descriptive
variables, clear comments, etc.

Dummy data generation 2 1.5 1 0.5 0

Dummy farmers simulation 2 1.5 1 0.5 0

Concurrent programming logic 3 2.5 2 1 0

Disaster simulation 2 1.5 1 0.5 0

Data visualization 3 2.5 2 1 0

Improved concurrent programming 3 2.5 2 1 0


design

Discussion 3 2.5 2 1 0
Week 13 (Presentation - 10%)
Teamwork 2 1.5 1.0 0.5 0

CTK Page 6 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Language and presentation 2 1.5 1.0 0.5 0

Understanding of Concurrent 3 2.5 2 1 0


Programming

Individual member’s testimony 3 2.5 2 1 0

Late submission
If for some good reason you are unable to submit your deliverables by the deadline, email me to
seek for a late submission. This should be done prior to the deadline. Late submission without
prior approval will have your marks deducted (5% per day overdue), or zero marks be assigned 3
days after the deadline.

Penalties
If you plagiarize someone else’ work, one or more of the following penalties may be imposed:

• Loss of all or partial marks for the assessment items;


• Downgrading the final grade in the course;
• Imposing a grade of failure in the course.

CTK Page 7 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Appendix 1: Entity-Relationship Diagram

CTK Page 8 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Business Rules:

1. Each user must be associated with at least 1 farm and each farm can be associated with 0
or more users.
2. Each user can create multiple activities and each activity must be created by one and only
one user.
3. Each farm must be associated with at least 1 plant and each plant can be associated with 0
or more farms.
4. Each farm must be associated with at least 1 fertilizer and each fertilizer can be
associated with 0 or more farms.
5. Each farm must be associated with at least 1 pesticide and each pesticide can be
associated with 0 or more farms.
6. Each farm must be associated with at least 1 activity and each activity must be associated
with 1 farm.

CTK Page 9 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Appendix 2: Sample Data

Farms

_id name address plants fertilizers pesticides


Oak Wood ["1","2","4","5","6",
1 Farm 838, Dayton Point "7","8"] ["3","4","6"] ["1","6"]

2 Pinewood Farm 1285, Roosevelt Street ["1","3","5","6","7"] ["1","2"] ["1","3",”7”]

Users

_id name email password phoneNumber farms

1 Vail Cussons vcussons1@gmail.com RLqRFf053akr 012-2045723 [“1”, ”2”]

2 Amalee Carthur amcarthur2@gmail.com 5ixWqjMrGW 011-10237932 [“2”]

3 Richard Reagus rtreagus3@gmail.com sHrfiUwOQljl 017-59298049 [“1”]

4 Whitby Flintiff wscrine4@gmail.com OiWxfJeaeZU 012-74350295 [“1”]

Plants

_id name unitType


1 Pansies mass
2 Winter melon mass
3 Welsh onion mass
4 Pumkin mass
5 Mizuna mass
6 Fennel mass
7 Leek mass
8 Radish mass

Fertilizers

CTK Page 10 of 14
WIF3003 Group Project Sem. 2, 2021/2022

_id name unitType


1 GROBEL NPK 4-3-3+1MgO pack
2 Activit 4-3-2 pack
3 Fertiplus 4-2-10 pack
4 Nutri Smart Active Eco-Fertilizer pack
5 BG Soil pack
6 Grobel NPK 4-3-3 +1 MgO pack
7 Greenferti 4-3-3-1 pack
8 MixO’Plus pack

Pesticides

_id name unitType


1 XenTari mass

2 Enspray 99 mass

3 Trilogy mass

4 Evergreen Pyrethrum Concentrate mass


5 Agree® WG Biological Insecticide mass

6 BIOBAC Y1336 WP mass

7 Kingbo Matrine mass

Activities

_id date action type unit quantity field row farmId userId
1 2021-12-22 sowing fennel kg 3 1 1 2 2

2 2021-12-31 harvest winter melon g 500 2 1 1 3

3 2022-01-03 pesticide Enspray 99 ml 2000 1 1 2 2

4 2022-01-05 fertilizer Activit 4-3-2 pack (500g) 2 1 2 1 4

5 2022-01-06 sales winter melon kg 10 2 1 1 3

Appendix 3: Data Constraints and Definitions

*All columns in all tables are not nullable.

Farms
CTK Page 11 of 14
WIF3003 Group Project Sem. 2, 2021/2022

Attribute Data Constraints and Definitions

_id ● The unique identifier for each row.


● Start from 1 and increment by 1 for the subsequent rows.
● Stored as String.

name The name of the farm.

address The address of the farm.

plants ● The _ids of the plants that the farm has.


● Should not contain an id that does not exist in the Plants table.
● Should have at least one element.

fertilizers ● The _ids of the fertilizers that the farm has.


● Should not contain an id that does not exist in the Fertilizers table.
● Should have at least one element.

pesticides ● The _ids of the pesticides that the farm has.


● Should not contain an id that does not exist in the Pesticides table.
● Should have at least one element.

Users

Attribute Data Constraints and Definitions

_id ● The unique identifier for each row.


● Start from 1 and increment by 1 for the subsequent rows.
● Stored as String.

CTK Page 12 of 14
WIF3003 Group Project Sem. 2, 2021/2022

name The name of the user.

email The email of the user.

password The password of the user.

phoneNumber The phone number of the user.

farms ● The farms that the user belongs to.


● Should not contain an id that does not exist in the Farms table.
● Should have at least one element.

Plants, Fertilizers & Pesticides

Attribute Data Constraints and Definitions

_id ● The unique identifier for each row.


● Start from 1 and increment by 1 for the subsequent rows.
● Stored as String.

name The name of the plant/fertilizer/pesticide.

unitType ● The type of unit used to indicate the amount of the


plant/fertilizer/pesticide.
● The value can be mass, pack, or volume.

Activities

Attribute Data Constraints and Definitions

_id ● The unique identifier for each row.


● Start from 1 and increment by 1 for the subsequent rows.
● Stored as String.

date ● The date when the activity took place.


● The format should be YYYY-MM-DD.

CTK Page 13 of 14
WIF3003 Group Project Sem. 2, 2021/2022

action ● The type of the activity.


● The value can be sowing, fertilizers, pesticides, harvest, or
sales.

type ● If the action is sowing/harvest/sales, store the plant’s name.


● If the action is fertilizers, store the fertilizer’s name.
● If the action is pesticides, store the pesticide’s name.

unit ● The unit of the type attribute.


● If the unitType of the item in parent table is:
○ mass -> kg/g
○ pack -> pack (500g)/ pack (1000g)
○ volume -> ℓ/m ℓ

quantity The amount of the type attribute.

field The field number in the farm where the activity took place.

row The row number in the field where the activity took place.

farmId The id of the farm where the activity took place.

userId The id of the user who records the activity.

CTK Page 14 of 14

You might also like