Project

General

Profile

« Previous | Next » 

Revision 6377

remove ORE mapping from system metadata

View differences:

src/xmltables-oracle.sql
422 422
		PRIMARY KEY (guid)
423 423
)
424 424

  
425
/*
426
 * Table used to store system metadata provenance information
427
 */
428
CREATE TABLE systemMetadataMap (
429
   guid   		VARCHAR2(2000),          -- the globally unique string identifier of the object that the system metadata describes
430
   target_guid	VARCHAR2(2000),          -- the globally unique string identifier of the other object
431
   CONSTRAINT systemMetadataMap_fk 
432
		FOREIGN KEY (guid) REFERENCES systemMetadata
433
);
434

  
435 425
CREATE TABLE systemMetadataReplicationPolicy (
436 426
	guid VARCHAR2(2000),	-- the globally unique string identifier of the object that the system metadata describes
437 427
	member_node VARCHAR(250),	 -- replication member node
src/upgrade-db-to-1.10.0-postgres.sql
16 16
	obsoleted_by   text,     -- the identifier of the record that replaces this record
17 17
	CONSTRAINT systemMetadata_pk PRIMARY KEY (guid)
18 18
);
19
/*
20
 * Table used to store system metadata map information
21
 */
22
CREATE TABLE systemMetadataMap (
23
   guid   		text,          -- the globally unique string identifier of the object that the system metadata describes
24
   relationship	VARCHAR(250),	 -- the provenance relationship defined between objects
25
   target_guid	text,          -- the globally unique string identifier of the other object
26
   CONSTRAINT systemMetadataMap_fk 
27
		FOREIGN KEY (guid) REFERENCES systemMetadata
28
);
29 19

  
30 20
CREATE TABLE systemMetadataReplicationPolicy (
31 21
	guid text,	-- the globally unique string identifier of the object that the system metadata describes
src/xmltables-postgres.sql
320 320
 * ALTER TABLE systemMetadata ADD COLUMN number_replicas INT8;
321 321
 */
322 322

  
323
/*
324
 * Table used to store system metadata ORE map information
325
 */
326
CREATE TABLE systemMetadataMap (
327
   guid   		text,          -- the globally unique string identifier of the object that the system metadata describes
328
   target_guid	text,          -- the globally unique string identifier of the other object
329
   CONSTRAINT systemMetadataMap_fk 
330
		FOREIGN KEY (guid) REFERENCES systemMetadata
331
);
332 323

  
333 324
CREATE TABLE systemMetadataReplicationPolicy (
334 325
	guid text,	-- the globally unique string identifier of the object that the system metadata describes
src/upgrade-db-to-1.10.0-oracle.sql
18 18
		PRIMARY KEY (guid)
19 19
)
20 20

  
21
/*
22
 * Table used to store system metadata map information
23
 */
24
CREATE TABLE systemMetadataMap (
25
   guid   		VARCHAR2(2000),          -- the globally unique string identifier of the object that the system metadata describes
26
   relationship	VARCHAR(250),	 -- the provenance relationship defined between objects
27
   target_guid	VARCHAR2(2000),          -- the globally unique string identifier of the other object
28
   CONSTRAINT systemMetadataMap_fk 
29
		FOREIGN KEY (guid) REFERENCES systemMetadata
30
);
31

  
32 21
CREATE TABLE systemMetadataReplicationPolicy (
33 22
	guid VARCHAR2(2000),	-- the globally unique string identifier of the object that the system metadata describes
34 23
	member_node VARCHAR(250),	 -- replication member node
src/edu/ucsb/nceas/metacat/IdentifierManager.java
337 337
            // Return database connection to the pool
338 338
            DBConnectionPool.returnDBConnection(dbConn, serialNumber);
339 339
        }
340
        
341
        // look up mapping information
342
        sysMeta.setResourceMapList((getSystemMetadataMap(sysMeta.getIdentifier().getValue())));
343
        
340

  
344 341
        // look up replication policy
345 342
        ReplicationPolicy replicationPolicy = new ReplicationPolicy();
346 343
        replicationPolicy.setBlockedMemberNodeList(getReplicationPolicy(guid, "blocked"));
......
360 357
        return sysMeta;
361 358
    }
362 359
    
363
    private List<Identifier> getSystemMetadataMap(String guid)
364
    	throws McdbDocNotFoundException {
365
    	
366
    	List<Identifier> identifiers = new ArrayList<Identifier>();
367
    	String sql = "select guid, target_guid " +
368
    		"from systemMetadataMap where guid = ?";
369
	    DBConnection dbConn = null;
370
	    int serialNumber = -1;
371
	    try {
372
	        // Get a database connection from the pool
373
	        dbConn = DBConnectionPool.getDBConnection("IdentifierManager.getSystemMetadataMap");
374
	        serialNumber = dbConn.getCheckOutSerialNumber();
375
	
376
	        // Execute the statement
377
	        PreparedStatement stmt = dbConn.prepareStatement(sql);
378
	        stmt.setString(1, guid);
379
	        ResultSet rs = stmt.executeQuery();
380
	        while (rs.next()) 
381
	        {
382
	            String targetGuid = rs.getString(3);
383
	            Identifier id = new Identifier();
384
	            id.setValue(targetGuid);
385
	            identifiers.add(id);
386
	        
387
	        } 
388
	        stmt.close();
389
	        
390
	    } 
391
	    catch (SQLException e) {
392
	        logMetacat.error("Error while getting system metadata map for guid " + guid, e);
393
	    } 
394
	    finally {
395
	        // Return database connection to the pool
396
	        DBConnectionPool.returnDBConnection(dbConn, serialNumber);
397
	    }
398
	    
399
	    return identifiers;
400
	}
401 360
    
402 361
    private List<NodeReference> getReplicationPolicy(String guid, String policy)
403 362
		throws McdbDocNotFoundException {
......
1068 1027
        }
1069 1028
    }
1070 1029
    
1071
    private void insertSystemMetadataMap(String guid, List<String> targetGuids)
1072
    {
1073
        DBConnection dbConn = null;
1074
        int serialNumber = -1;
1075
        
1076
        try {
1077
            // Get a database connection from the pool
1078
            dbConn = 
1079
                DBConnectionPool.getDBConnection("IdentifierManager.insertSystemMetadataMap");
1080
            serialNumber = dbConn.getCheckOutSerialNumber();
1081

  
1082
            // remove existing values first
1083
            String delete = "delete from systemMetadataMap " + 
1084
            "where guid = ?";
1085
	        PreparedStatement stmt = dbConn.prepareStatement(delete);
1086
	        //data values
1087
	        stmt.setString(1, guid);
1088
	        //execute
1089
	        int deletedCount = stmt.executeUpdate();
1090
	        stmt.close();
1091
            
1092
            for (String targetGuid: targetGuids) {
1093
	            // Execute the insert statement
1094
	            String insert = "insert into systemMetadataMap " + 
1095
	                "(guid, target_guid) " +
1096
	                "values (?, ?)";
1097
	            PreparedStatement insertStatement = dbConn.prepareStatement(insert);
1098
	            
1099
	            //data values
1100
	            insertStatement.setString(1, guid);
1101
	            insertStatement.setString(2, targetGuid);
1102
	            //execute
1103
	            int rows = insertStatement.executeUpdate();
1104
	            insertStatement.close();
1105
            }
1106
        } catch (SQLException e) {
1107
            logMetacat.error("SQL error while adding systemMetadataMap for: " + guid, e); 
1108
        } finally {
1109
            // Return database connection to the pool
1110
            DBConnectionPool.returnDBConnection(dbConn, serialNumber);
1111
        }
1112
    }
1113
    
1114 1030
    private void insertReplicationPolicy(String guid, String policy, List<String> memberNodes)
1115 1031
    {
1116 1032
        DBConnection dbConn = null;
......
1239 1155
                sm.getObsoletedBy() == null ? null: sm.getObsoletedBy().getValue());
1240 1156
        
1241 1157
        String guid = sm.getIdentifier().getValue();
1242
        // ORE map pointers
1243
        List<String> targetGuids = new ArrayList<String>();
1244
        if (sm.getResourceMapList() != null) {
1245
        	for (Identifier pid: sm.getResourceMapList()) {
1246
        		targetGuids.add(pid.getValue());
1247
        	}
1248
    		insertSystemMetadataMap(guid, targetGuids);
1249
        }
1250 1158
        
1251 1159
        // save replication policies
1252 1160
        if (replicationPolicy != null) {

Also available in: Unified diff