1
|
/*
|
2
|
* HarvestDetailLog.java
|
3
|
*
|
4
|
* Created on January 14, 2004, 4:59 PM
|
5
|
*/
|
6
|
|
7
|
package edu.ucsb.nceas.metacat.harvesterClient;
|
8
|
|
9
|
import java.sql.Connection;
|
10
|
import java.sql.SQLException;
|
11
|
import java.sql.Statement;
|
12
|
|
13
|
/**
|
14
|
* HarvestDetailLog manages data and operations corresponding to the
|
15
|
* HARVEST_DETAIL_LOG table. It records errors encountered while attempting
|
16
|
* to harvest a particular EML document.
|
17
|
*
|
18
|
* @author costa
|
19
|
*/
|
20
|
public class HarvestDetailLog {
|
21
|
|
22
|
private Harvester harvester; // The parent Harvester object
|
23
|
private int detailLogID;
|
24
|
private int harvestLogID;
|
25
|
private HarvestDocument harvestDocument; // The associated HarvestDocument
|
26
|
private String errorMessage;
|
27
|
|
28
|
|
29
|
/**
|
30
|
* Creates a new instance of HarvestDetailLog and inserts the data into
|
31
|
* the HARVEST_DETAIL_LOG table.
|
32
|
*
|
33
|
* @param harvester the Harvester parent object
|
34
|
* @param harvestLogID foreign key value matching the HARVEST_LOG table
|
35
|
* @param harvestDocument HarvestDocument object that generated an error
|
36
|
* @param errorMessage text of the error message
|
37
|
*/
|
38
|
public HarvestDetailLog(Harvester harvester,
|
39
|
int harvestLogID,
|
40
|
HarvestDocument harvestDocument,
|
41
|
String errorMessage
|
42
|
) {
|
43
|
this.harvester = harvester;
|
44
|
this.detailLogID = harvester.getDetailLogID(); // Primary key for record
|
45
|
this.harvestLogID = harvestLogID;
|
46
|
this.harvestDocument = harvestDocument;
|
47
|
this.errorMessage = errorMessage;
|
48
|
}
|
49
|
|
50
|
|
51
|
/**
|
52
|
* Inserts a new entry into the HARVEST_DETAIL_LOG table, based on the
|
53
|
* contents of this HarvestDetailLog object.
|
54
|
*/
|
55
|
void dbInsertHarvestDetailLogEntry() {
|
56
|
String insertString;
|
57
|
Statement stmt;
|
58
|
|
59
|
// Set the value of the HARVEST_LOG_ID to the current time in UTC seconds
|
60
|
insertString = "INSERT INTO HARVEST_DETAIL_LOG " +
|
61
|
"(DETAIL_LOG_ID, HARVEST_LOG_ID, SCOPE," +
|
62
|
" IDENTIFIER, REVISION," +
|
63
|
" DOCUMENT_URL, ERROR_MESSAGE, DOCUMENT_TYPE) " +
|
64
|
"values(" +
|
65
|
detailLogID + ", " +
|
66
|
harvestLogID + ", " +
|
67
|
"'" + harvestDocument.scope + "', " +
|
68
|
harvestDocument.identifier + ", " +
|
69
|
harvestDocument.revision + ", " +
|
70
|
"'" + harvestDocument.documentURL + "', " +
|
71
|
"'" + errorMessage + "'," +
|
72
|
"'" + harvestDocument.documentType + "'" +
|
73
|
")";
|
74
|
|
75
|
try {
|
76
|
stmt = harvester.conn.createStatement();
|
77
|
stmt.executeUpdate(insertString);
|
78
|
stmt.close();
|
79
|
}
|
80
|
catch(SQLException e) {
|
81
|
System.out.println("SQLException: " + e.getMessage());
|
82
|
}
|
83
|
}
|
84
|
|
85
|
|
86
|
/**
|
87
|
* Prints the contents of this HarvestLog object. Used in generating reports.
|
88
|
*/
|
89
|
void printOutput() {
|
90
|
System.out.println("detailLogID: " + detailLogID);
|
91
|
System.out.println("errorMessage: " + errorMessage);
|
92
|
harvestDocument.printOutput();
|
93
|
}
|
94
|
|
95
|
}
|