1 | package org.greenstone.gsdl3.gs3build.doctypes;
|
---|
2 |
|
---|
3 | import java.io.PrintWriter;
|
---|
4 |
|
---|
5 | import java.sql.*;
|
---|
6 |
|
---|
7 | import org.greenstone.gsdl3.gs3build.util.XMLTools;
|
---|
8 | import org.greenstone.gsdl3.gs3build.util.GS3SQLConnection;
|
---|
9 | import org.greenstone.gsdl3.gs3build.database.*;
|
---|
10 |
|
---|
11 | public class DocumentSQLWriter
|
---|
12 | {
|
---|
13 | public DocumentSQLWriter()
|
---|
14 | {
|
---|
15 | }
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Just write the document to the database, assuming that it is not already there
|
---|
19 | */
|
---|
20 | public boolean writeDocument(DocumentInterface document, GS3SQLConnection connection)
|
---|
21 | {
|
---|
22 | // TODO: output document in METS format, with Greenstone-specific metadata
|
---|
23 | // placed in a wrapper inside the descriptive metadata block
|
---|
24 |
|
---|
25 | // put the document into the database
|
---|
26 | try {
|
---|
27 | if (document.getID() != null)
|
---|
28 | { //tag = XMLTools.addAttribute(tag, "OBJID", document.getID().toString());
|
---|
29 | GS3SQLInsert insert = new GS3SQLInsert("document");
|
---|
30 | insert.addValue("DocID", document.getID().toString());
|
---|
31 |
|
---|
32 | System.out.println(insert.toString());
|
---|
33 | connection.execute(insert.toString());
|
---|
34 | }
|
---|
35 | } catch (Exception ex) {
|
---|
36 | System.out.println(ex);
|
---|
37 | }
|
---|
38 | // output.println(tag);
|
---|
39 |
|
---|
40 | // Write the structural metadata:
|
---|
41 | // if in "Create METS" mode:
|
---|
42 | // take all the documents as being in the one group, of the "physical"
|
---|
43 | // document; particular document plugins may extend this behaviour,
|
---|
44 | // which would suggest placing it in the AbstractDocument or similar
|
---|
45 | // class?!
|
---|
46 | document.getDocumentMetadata().writeSQL(document, connection);
|
---|
47 |
|
---|
48 | document.getDocumentFiles().writeSQL(document, connection);
|
---|
49 |
|
---|
50 | document.getDocumentStructure().writeSQL(document, connection);
|
---|
51 |
|
---|
52 | // Write the body information
|
---|
53 | // TODO: only output the document if there is some
|
---|
54 | // content/formatting change between the original and
|
---|
55 | // what greenstone actually does; if the original is
|
---|
56 | // good, then place a marker saying "get the document
|
---|
57 | // "from the original file"
|
---|
58 | return true;
|
---|
59 | }
|
---|
60 | }
|
---|