ManageFarmers: R6 Class for adding farmer information in OFPE database.

ManageFarmersR Documentation

R6 Class for adding farmer information in OFPE database.

Description

R6 class that takes a list with a vector of farmer names and a database connection object. Adds a unique ID field for each farmer that is used for internal relationships. If a farmer is already present in the database, it will be skipped. This follows the ManageDB interface and includes a setup and execute method that is called from the ManageDB class.

Public fields

dbCon

Database connection object connected to an OFPE formatted database, see DBCon class.

farmers

Vector of farmer names to add to the database.

Methods

Public methods


Method new()

Create an ManageFarmers object. The database connection and a vector of farmer names are used to upload farmer information to the database. Instantiates the class for running the setup and execute methods.

Usage
ManageFarmers$new(dbCon, action_item)
Arguments
dbCon

Database connection object connected to an OFPE formatted database, see DBCon class.

action_item

List of inputs to the ManageFarmers method, from the list passed into the ManageDB class. This includes a vector of farmer names to add to the 'all_farms.farmers' table of an OFPE formatted database.

Returns

A new initialized 'ManageFarmers' object.


Method setup()

No setup needed for the ManageFarmers class. However is still present to abide by the ManageDB interface consisting of setup and execute methods.

Usage
ManageFarmers$setup()

Method execute()

Executes the upload of prepared farmer information to the database in the 'all_farms' schema and the 'farmers' table. If a farmer is already present with the same name and ID, it will be skipped.

Usage
ManageFarmers$execute()
Arguments
None

No arguments needed because they are provided during class initialization.

Returns

Farmer data uploaded into 'all_farms.farmers' table in the database.


Method .uploadFarmers()

Uploads a farmer to the database. Takes the farmer name and adds it to the 'all_farms.farmers' table. Makes sure there is no conflict defined in the .buildTables method of the BuildDB class. A farmeridx is automatically generated upon upload by PostgreSQL. The dot indicates that this function would be private if not for documentations sake.

Usage
ManageFarmers$.uploadFarmers(farmer, db)
Arguments
farmer

Name of a farmer for upload into 'all_farms.farmers'.

db

Database connection.

Returns

Farmer upload into database.


Method clone()

The objects of this class are cloneable with this method.

Usage
ManageFarmers$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

DBCon for database connection class, ManageDB for the class that calls this class to manage the database.


paulhegedus/OFPE documentation built on Nov. 23, 2022, 5:09 a.m.