Revision 2031
Added by Duane Costa about 20 years ago
HarvestDetailLog.java | ||
---|---|---|
6 | 6 |
|
7 | 7 |
package edu.ucsb.nceas.metacat.harvesterClient; |
8 | 8 |
|
9 |
import java.sql.Connection; |
|
10 |
import java.sql.SQLException; |
|
11 |
import java.sql.Statement; |
|
12 |
|
|
9 | 13 |
/** |
10 | 14 |
* HarvestDetailLog manages data and operations corresponding to the |
11 | 15 |
* HARVEST_DETAIL_LOG table. It records errors encountered while attempting |
12 |
* to harvest a particular document. |
|
16 |
* to harvest a particular EML document.
|
|
13 | 17 |
* |
14 | 18 |
* @author costa |
15 | 19 |
*/ |
16 | 20 |
public class HarvestDetailLog { |
17 | 21 |
|
22 |
private Harvester harvester; // The parent Harvester object |
|
18 | 23 |
private int detailLogID; |
24 |
private int harvestLogID; |
|
25 |
private HarvestDocument harvestDocument; // The associated HarvestDocument |
|
19 | 26 |
private String errorMessage; |
20 |
private Object harvestDocument; |
|
21 |
private int harvestLogID; |
|
22 | 27 |
|
23 | 28 |
|
24 | 29 |
/** |
25 |
* Creates a new instance of HarvestDetailLog. |
|
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 |
|
26 | 37 |
*/ |
27 |
public HarvestDetailLog() { |
|
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; |
|
28 | 48 |
} |
49 |
|
|
29 | 50 |
|
30 |
|
|
31 | 51 |
/** |
32 | 52 |
* Inserts a new entry into the HARVEST_DETAIL_LOG table, based on the |
33 |
* contents of this HarvestDetailLog object. Not yet implemented.
|
|
53 |
* contents of this HarvestDetailLog object. |
|
34 | 54 |
*/ |
35 |
public void dnInsertHarvestDetailLogEntry() { |
|
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 |
} |
|
36 | 83 |
} |
37 |
|
|
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 |
|
|
38 | 95 |
} |
Also available in: Unified diff
Additional development of Harvester implementation