Project

General

Profile

« Previous | Next » 

Revision 5452

Added by berkley over 14 years ago

fixed identifier manager problem with getting guid for systememtadaa doc

View differences:

test/edu/ucsb/nceas/metacat/util/MetacatPopulatorTest.java
100 100
            MetacatPopulator mp = new MetacatPopulator(
101 101
                    "http://knb.ecoinformatics.org/knb", 
102 102
                    "http://knb-mn.ecoinformatics.org/knb", 
103
                    "grass", "uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org", "kepler");
103
                    "parasitism", "uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org", "kepler");
104 104
            mp.populate();
105 105
        }
106 106
        catch(Exception e)
test/edu/ucsb/nceas/metacattest/IdentifierManagerTest.java
58 58
    }
59 59
    
60 60
    /**
61
     * test getting a guid from the systemmetadata table
62
     */
63
    public void testGetGUID()
64
    {
65
        try
66
        {
67
            IdentifierManager im = IdentifierManager.getInstance();
68
            Date d1 = new Date();
69
            String guid1 = "guid:" + d1.getTime();
70

  
71
            String docid = insertTestDocument();
72
            im.createSystemMetadataMapping(guid1, docid);
73
            docid = docid.substring(0, docid.lastIndexOf("."));
74
            
75
            String gotGuid = im.getGUID(docid, 1);
76
            assertTrue(gotGuid.equals(guid1));
77
        }
78
        catch(Exception e)
79
        {
80
            fail("Unexpected exception in testGetGUID: " + e.getMessage());
81
        }
82
    }
83
    
84
    /**
61 85
     * test getting a list of all local ids
62 86
     */
63 87
    public void testGetAllLocalIds()
src/edu/ucsb/nceas/metacat/util/MetacatPopulator.java
218 218
        SystemMetadata sm = new SystemMetadata();
219 219
        //set the id
220 220
        Identifier id = new Identifier();
221
        id.setValue(doc.docid);
221
        id.setValue(doc.docid.trim());
222 222
        sm.setIdentifier(id);
223 223
        
224 224
        //set the object format
......
533 533
        
534 534
        public Document(String docid, String doctype, String createDate, String updateDate)
535 535
        {
536
            this.docid = docid;
537
            this.doctype = doctype;
538
            this.createDate = createDate;
539
            this.updateDate = updateDate;
536
            this.docid = docid.trim();
537
            this.doctype = doctype.trim();
538
            this.createDate = createDate.trim();
539
            this.updateDate = updateDate.trim();
540 540
        }
541 541
    }
542 542
}
src/edu/ucsb/nceas/metacat/IdentifierManager.java
392 392
    
393 393
    /**
394 394
     * given a local identifer, look up the guid.  Throw McdbDocNotFoundException
395
     * if the docid, rev is not found in the identifiers table
395
     * if the docid, rev is not found in the identifiers or systemmetadata tables
396 396
     *
397 397
     * @param docid the docid to look up
398 398
     * @param rev the revision of the docid to look up
......
428 428
                stmt = dbConn.prepareStatement(query);
429 429
                stmt.setString(1, docid);
430 430
                stmt.setInt(2, rev);
431
                rs = stmt.executeQuery();
431 432
                if(rs.next())
432 433
                {
433 434
                    guid = rs.getString(1);

Also available in: Unified diff