maito.datacollecting
Class DataStorage
java.lang.Object
maito.datacollecting.DataStorage
public class DataStorage
- extends java.lang.Object
A class that takes care of storing the data it receives from a RecordParser.
The original raw data is stored into a file. The data is also transformed using a
Transformer implementation and then the transformed record is stored in the database.
- Author:
- Oskari Saarekas
- See Also:
Transformer
,
RecordParser
Constructor Summary |
DataStorage(java.lang.String sourceID,
java.sql.Connection conn,
java.io.File file,
Transformer transformer)
|
Method Summary |
boolean |
addRecord(Record record,
java.lang.String original)
Adds a new record to the file and to the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DataStorage
public DataStorage(java.lang.String sourceID,
java.sql.Connection conn,
java.io.File file,
Transformer transformer)
- Parameters:
sourceID
- ID of the datasource. The ID must exist in the DataSource table, or the
class will not work properly.conn
- Connection object to the database. The class will not work if the
object is invalid.file
- File object that indicates the file where the plaintext records are
stored. The class will not work properly if invalid object is passed.
addRecord
public boolean addRecord(Record record,
java.lang.String original)
- Adds a new record to the file and to the database.
- Parameters:
record
- The record to be added as a Record object.original
- The record in its original String form.
- Returns:
- True if the record is successfully added to the database
and the file seems to be writable, or an identical record
already exists in the database.