source: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentSQLWriter.java@ 5800

Last change on this file since 5800 was 5800, checked in by cs025, 20 years ago

Adding gs3build

  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1package org.greenstone.gsdl3.gs3build.doctypes;
2
3import java.io.PrintWriter;
4
5import java.sql.*;
6
7import org.greenstone.gsdl3.gs3build.util.XMLTools;
8import org.greenstone.gsdl3.gs3build.util.GS3SQLConnection;
9import org.greenstone.gsdl3.gs3build.database.*;
10
11public 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}
Note: See TracBrowser for help on using the repository browser.