Project

General

Profile

« Previous | Next » 

Revision 168

Added by Matt Jones about 24 years ago

documentation cleanup

View differences:

src/edu/ucsb/nceas/metacat/DBSAXHandler.java
1 1
/**
2
 *        Name: DBSAXHandler.java
3
 *     Purpose: A Class that handles the SAX XML events as they
4
 *              are generated from XML documents
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: DBSAXHandler.java
3
 *   Purpose: A Class that handles the SAX XML events as they
4
 *            are generated from XML documents
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBValidate.java
1
/**
2
 *      Name: GenericXMLValidate.java
3
 *   Purpose: A Class that validates XML documents
4
 *            This class is designed to be 'parser independent
5
 *            i.e. it uses only org.xml.sax classes
6
 *            It is tied to SAX 1.0 methods
7
 * Copyright: 2000 Regents of the University of California and the
8
 *            National Center for Ecological Analysis and Synthesis
9
 *   Authors: Dan Higgins
10
 * 
11
 *   Version: '$Id$'
12
 */
1 13
package edu.ucsb.nceas.metacat;
2 14

  
3 15

  
src/edu/ucsb/nceas/metacat/ElementNode.java
1 1
/**
2
 *        Name: ElementNode.java
3
 *     Purpose: A Class that represents an XML element and its contents,
4
 *              and can build itself from a database connection
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: ElementNode.java
3
 *   Purpose: A Class that represents an XML element and its contents,
4
 *            and can build itself from a database connection
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBSAXDocument.java
1 1
/**
2
 *        Name: DBSAXDocument.java
3
 *     Purpose: A Class that writes an XML document main data
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Jivka Bojilova
2
 *      Name: DBSAXDocument.java
3
 *   Purpose: A Class that writes an XML document main data
4
 * Copyright: 2000 Regents of the University of California and the
5
 *            National Center for Ecological Analysis and Synthesis
6
 *   Authors: Jivka Bojilova
7 7
 *
8
 *     Version: '$Id$'
8
 *   Version: '$Id$'
9 9
 */
10 10

  
11 11
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBEntityResolver.java
1 1
/**
2 2
 *      Name: DBEntityResolver.java
3 3
 *   Purpose: A Class that implements org.xml.sax.EntityResolver interface
4
 *              for resolving external entities
4
 *            for resolving external entities
5 5
 * Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
6
 *            National Center for Ecological Analysis and Synthesis
7 7
 *   Authors: Jivka Bojilova
8 8
 *
9 9
 *   Version: '$Id$'
src/edu/ucsb/nceas/metacat/DBSAXNode.java
1 1
/**
2
 *        Name: DBSAXNode.java
3
 *     Purpose: A Class that represents an XML node and its contents
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Matt Jones
2
 *      Name: DBSAXNode.java
3
 *   Purpose: A Class that represents an XML node and its contents
4
 * Copyright: 2000 Regents of the University of California and the
5
 *            National Center for Ecological Analysis and Synthesis
6
 *   Authors: Matt Jones
7 7
 *
8
 *     Version: '$Id$'
8
 *   Version: '$Id$'
9 9
 */
10 10

  
11 11
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/GenericXMLValidate.java
1
/**
2
 *      Name: GenericXMLValidate.java
3
 *   Purpose: A Class that validates XML documents
4
 *            This class is designed to be 'parser independent
5
 *            i.e. it uses only org.xml.sax classes
6
 *            It is tied to SAX 1.0 methods
7
 * Copyright: 2000 Regents of the University of California and the
8
 *            National Center for Ecological Analysis and Synthesis
9
 *   Authors: Dan Higgins
10
 * 
11
 *   Version: '$Id$'
12
 */
1 13
package edu.ucsb.nceas.metacat;
2 14

  
3 15

  
src/edu/ucsb/nceas/metacat/DBReader.java
1 1
/**
2
 *        Name: DBReader.java
3
 *     Purpose: A Class that creates an XML text document
4
 *              from a query to a relational DB containing a DOM representation
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: DBReader.java
3
 *   Purpose: A Class that creates an XML text document
4
 *            from a query to a relational DB containing a DOM representation
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/XMLValidate.java
1
/**
2
 *      Name: XMLValidate.java
3
 *   Purpose: A Class that validates XML documents
4
 *            This class is uses a specific parser
5
 *            and calls the GenericXMLValidate class
6
 *            to do the actual validation
7
 * Copyright: 2000 Regents of the University of California and the
8
 *            National Center for Ecological Analysis and Synthesis
9
 *   Authors: Dan Higgins 
10
 * 
11
 *   Version: '$Id$'
12
 */
1 13
package edu.ucsb.nceas.metacat;
2 14

  
3 15
import org.w3c.dom.*;
src/edu/ucsb/nceas/metacat/MetaCatUtil.java
1 1
/**
2
 *        Name: MetaCatUtil.java
3
 *     Purpose: A Class that implements utility methods for a metadata catalog
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Matt Jones
2
 *      Name: MetaCatUtil.java
3
 *   Purpose: A Class that implements utility methods for a metadata catalog
4
 * Copyright: 2000 Regents of the University of California and the
5
 *            National Center for Ecological Analysis and Synthesis
6
 *   Authors: Matt Jones
7 7
 * 
8
 *     Version: '$Id$'
8
 *   Version: '$Id$'
9 9
 */
10 10

  
11 11
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBDTDHandler.java
1 1
/**
2
 *        Name: DBDTDHandler.java
3
 *     Purpose: A Class that implements org.xml.sax.DTDHandler interface
4
 *              for resolving external entities
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Jivka Bojilova
2
 *      Name: DBDTDHandler.java
3
 *   Purpose: A Class that implements org.xml.sax.DTDHandler interface
4
 *            for resolving external entities
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Jivka Bojilova
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/AccessionNumber.java
1 1
/**
2
 *        Name: AccessionNumber.java
3
 *     Purpose: A class that gets Accession Number, check for uniqueness
4
 *              and register it into db
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Jivka Bojilova
2
 *      Name: AccessionNumber.java
3
 *   Purpose: A class that gets Accession Number, check for uniqueness
4
 *            and register it into db
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Jivka Bojilova
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
......
22 22
public class AccessionNumber  {
23 23
    
24 24
    public static String generate (String accNumber, String action) 
25
        throws ClassNotFoundException, StringIndexOutOfBoundsException, SQLException
25
        throws ClassNotFoundException, StringIndexOutOfBoundsException, 
26
               SQLException
26 27
    {
27 28
        
28 29
        String globalName = null;
......
35 36
        String defaultDB = (String)options.handleGetObject("defaultDB");
36 37
        String user = (String)options.handleGetObject("user");
37 38
        String password = (String)options.handleGetObject("password");
38
        String defaultGlobalName = (String)options.handleGetObject("defaultGlobalName");
39
        String defaultGlobalName = 
40
               (String)options.handleGetObject("defaultGlobalName");
39 41
        String sep = (String)options.handleGetObject("accNumberSeparator");
40 42

  
41 43

  
42 44
        try {
43 45
            // Open a new connection to the database
44
            Connection conn = MetaCatUtil.openDBConnection(dbDriver, defaultDB, user, password);
46
            Connection conn = MetaCatUtil.openDBConnection(dbDriver, 
47
                              defaultDB, user, password);
45 48
            conn.setAutoCommit(true);
46 49

  
47 50
            // split the acc # in 2 parts - global name & local id
......
58 61
                    return put(conn, globalName, localId, sep);
59 62

  
60 63
        } catch (SQLException e) {
61
            System.out.println("Error on AccessionNumber.genAccessionNumber(): " + e.getMessage());
64
            System.out.println(
65
                       "Error on AccessionNumber.genAccessionNumber(): " + 
66
                       e.getMessage());
62 67
            throw e;
63 68
        }    
64 69
        
65 70
        return null;        
66 71
    }    
67 72

  
68
    private static String put (Connection conn, String globalName, String localId, String sep) 
73
    private static String put (Connection conn, String globalName, 
74
                String localId, String sep) 
69 75
                throws SQLException
70 76
    {
71 77
        
......
80 86

  
81 87
            // insert globalName & l
82 88
            PreparedStatement pstmt;
83
            pstmt = conn.prepareStatement("INSERT INTO xml_acc_numbers (global_name, local_id) " + 
84
                                          "VALUES (?, ?)");
89
            pstmt = conn.prepareStatement(
90
                    "INSERT INTO xml_acc_numbers (global_name, local_id) " + 
91
                    "VALUES (?, ?)");
85 92
            pstmt.setString(1,globalName);
86 93
            pstmt.setString(2,l.toString());
87 94
            pstmt.execute();
88 95
            
89 96
        } catch (SQLException e) {
90
            System.out.println("Error on AccessionNumber.put(conn, globalName, localId): " + e.getMessage());
97
            System.out.println(
98
                   "Error on AccessionNumber.put(conn, globalName, localId): " 
99
                   + e.getMessage());
91 100
            throw e;
92 101
        }    
93 102
        return globalName + sep + l;
94 103
    }
95 104

  
96 105
    /** check for existance of Accesssion Number */
97
    private static boolean unique (Connection conn, String globalName, String localId)
98
                throws SQLException
106
    private static boolean unique (Connection conn, String globalName, 
107
                String localId) throws SQLException
99 108
    {
100 109
        
101 110
        boolean hasAccNumber = false;
102 111
        
103 112
        try {
104 113
            PreparedStatement pstmt;
105
            pstmt = conn.prepareStatement("SELECT 'x' FROM xml_acc_numbers " + 
106
                                         "WHERE global_name LIKE ? AND local_id = ?");
114
            pstmt = conn.prepareStatement(
115
                    "SELECT 'x' FROM xml_acc_numbers " + 
116
                    "WHERE global_name LIKE ? AND local_id = ?");
107 117
            pstmt.setString(1,globalName);
108 118
            pstmt.setString(2,localId);
109 119
            pstmt.execute();
......
112 122
            pstmt.close();
113 123
            
114 124
        } catch (SQLException e) {
115
            System.out.println("Error on AccessionNumber.unique(globalName, localId): " + e.getMessage());
125
            System.out.println("Error on AccessionNumber.unique(globalName, 
126
                               localId): " + e.getMessage());
116 127
            throw e;
117 128
        }    
118 129
        
......
125 136
    {
126 137
        try {
127 138
            PreparedStatement pstmt;
128
            pstmt = conn.prepareStatement("SELECT max(local_id) FROM xml_acc_numbers " + 
129
                                         "WHERE global_name LIKE ?");
139
            pstmt = conn.prepareStatement(
140
                    "SELECT max(local_id) FROM xml_acc_numbers " + 
141
                    "WHERE global_name LIKE ?");
130 142
            pstmt.setString(1,globalName);
131 143
            pstmt.execute();
132 144
            ResultSet rs = pstmt.getResultSet();
......
137 149

  
138 150
            pstmt.close();
139 151
        } catch (SQLException e) {
140
            System.out.println("Error on AccessionNumber.get(): " + e.getMessage());
152
            System.out.println(
153
                   "Error on AccessionNumber.get(): " + e.getMessage());
141 154
            throw e;
142 155
        }    
143 156
        
src/edu/ucsb/nceas/metacat/DBTransform.java
1 1
/**
2
 *        Name: DBTransform.java
3
 *     Purpose: A Class that transforms an XML text document
4
 *              into a another type using XSL
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: DBTransform.java
3
 *   Purpose: A Class that transforms an XML text document
4
 *            into a another type using XSL
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBWriter.java
1 1
/**
2
 *        Name: DBWriter.java
3
 *     Purpose: A Class that reads in an XML text document and
4
 *              write its contents to a database connection using SAX
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: DBWriter.java
3
 *   Purpose: A Class that reads in an XML text document and
4
 *            write its contents to a database connection using SAX
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/DBSimpleQuery.java
1 1
/**
2
 *        Name: DBSimpleQuery.java
3
 *     Purpose: A Class that searches a relational DB for elements and 
4
 *              attributes that have free text matches to the query string.  
5
 *              It returns a result set consisting of the root nodeid for 
6
 *              each document that satisfies the query
7
 *   Copyright: 2000 Regents of the University of California and the
8
 *              National Center for Ecological Analysis and Synthesis
9
 *     Authors: Matt Jones
2
 *      Name: DBSimpleQuery.java
3
 *   Purpose: A Class that searches a relational DB for elements and 
4
 *            attributes that have free text matches to the query string.  
5
 *            It returns a result set consisting of the root nodeid for 
6
 *            each document that satisfies the query
7
 * Copyright: 2000 Regents of the University of California and the
8
 *            National Center for Ecological Analysis and Synthesis
9
 *   Authors: Matt Jones
10 10
 *
11
 *     Version: '$Id$'
11
 *   Version: '$Id$'
12 12
 */
13 13

  
14 14
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/BasicNode.java
1 1
/**
2
 *        Name: BasicNode.java
3
 *     Purpose: A Class that represents an XML node and its contents
4
 *   Copyright: 2000 Regents of the University of California and the
5
 *              National Center for Ecological Analysis and Synthesis
6
 *     Authors: Matt Jones
2
 *      Name: BasicNode.java
3
 *   Purpose: A Class that represents an XML node and its contents
4
 * Copyright: 2000 Regents of the University of California and the
5
 *            National Center for Ecological Analysis and Synthesis
6
 *   Authors: Matt Jones
7 7
 *
8
 *     Version: '$Id$'
8
 *   Version: '$Id$'
9 9
 */
10 10

  
11 11
package edu.ucsb.nceas.metacat;
src/edu/ucsb/nceas/metacat/TextNode.java
1 1
/**
2
 *        Name: TextNode.java
3
 *     Purpose: A Class that represents an XML Text node and its contents,
4
 *              and can build itself from a database connection
5
 *   Copyright: 2000 Regents of the University of California and the
6
 *              National Center for Ecological Analysis and Synthesis
7
 *     Authors: Matt Jones
2
 *      Name: TextNode.java
3
 *   Purpose: A Class that represents an XML Text node and its contents,
4
 *            and can build itself from a database connection
5
 * Copyright: 2000 Regents of the University of California and the
6
 *            National Center for Ecological Analysis and Synthesis
7
 *   Authors: Matt Jones
8 8
 *
9
 *     Version: '$Id$'
9
 *   Version: '$Id$'
10 10
 */
11 11

  
12 12
package edu.ucsb.nceas.metacat;

Also available in: Unified diff