Project

General

Profile

« Previous | Next » 

Revision 8200

only attempt to generate OREs for objects that we know not to have them already. https://projects.ecoinformatics.org/ecoinfo/issues/6061

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
1622 1622
				// this is probably okay for many sci meta data docs
1623 1623
				logMetacat.warn("No potential ORE map found for: " + potentialOreIdentifier.getValue());
1624 1624
				// try the SOLR index
1625
				List<Identifier> potentialOreIdentifiers = this.lookupOreFor(originalIdentifier);
1625
				List<Identifier> potentialOreIdentifiers = this.lookupOreFor(originalIdentifier, false);
1626 1626
				if (potentialOreIdentifiers != null) {
1627 1627
					potentialOreIdentifier = potentialOreIdentifiers.get(0);
1628 1628
					try {
......
1722 1722
	 * @param guid of the EML/packaging object
1723 1723
	 * @return list of resource map identifiers for the given pid
1724 1724
	 */
1725
	public List<Identifier> lookupOreFor(Identifier guid) {
1725
	public List<Identifier> lookupOreFor(Identifier guid, boolean includeObsolete) {
1726 1726
		// Search for the ORE if we can find it
1727 1727
		String pid = guid.getValue();
1728 1728
		List<Identifier> retList = null;
1729 1729
		try {
1730
			MockHttpServletRequest request = new MockHttpServletRequest(null, null, null);
1731
			String query = "fl=id,resourceMap&wt=xml&q=formatType:METADATA+-obsoletedBy:*+resourceMap:*+id:\"" + pid + "\"";
1730
			String query = "fl=id,resourceMap&wt=xml&q=-obsoletedBy:*+resourceMap:*+id:\"" + pid + "\"";;
1731
			if (includeObsolete) {
1732
				query = "fl=id,resourceMap&wt=xml&q=resourceMap:*+id:\"" + pid + "\"";
1733
			}
1734
			
1732 1735
			InputStream results = this.query("solr", query);
1733 1736
			org.w3c.dom.Node rootNode = XMLUtilities.getXMLReaderAsDOMTreeRootNode(new InputStreamReader(results, "UTF-8"));
1734 1737
			//String resultString = XMLUtilities.getDOMTreeAsString(rootNode);
src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java
613 613
	 */
614 614
    public static boolean oreExistsFor(Identifier identifier) {
615 615
    	MockHttpServletRequest request = new MockHttpServletRequest(null, null, null);
616
		List<Identifier> ids = MNodeService.getInstance(request).lookupOreFor(identifier);
616
		List<Identifier> ids = MNodeService.getInstance(request).lookupOreFor(identifier, true);
617 617
		return (ids != null && ids.size() > 0);
618 618
	}
619 619

  
src/edu/ucsb/nceas/metacat/admin/upgrade/dataone/GenerateORE.java
87 87
            List<String> idList = null;
88 88
            
89 89
            idList = DBUtil.getAllDocidsByType(DocumentImpl.EML2_0_0NAMESPACE, true, serverLocation);
90
            filterOutExisting(idList);
90 91
            Collections.sort(idList);
91 92
            SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData);
92 93
            
93 94
            idList = DBUtil.getAllDocidsByType(DocumentImpl.EML2_0_1NAMESPACE, true, serverLocation);
95
            filterOutExisting(idList);
94 96
            Collections.sort(idList);
95 97
            SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData);
96 98
            
97 99
            idList = DBUtil.getAllDocidsByType(DocumentImpl.EML2_1_0NAMESPACE, true, serverLocation);
100
            filterOutExisting(idList);
98 101
            Collections.sort(idList);
99 102
            SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData);
100 103
            
101 104
            idList = DBUtil.getAllDocidsByType(DocumentImpl.EML2_1_1NAMESPACE, true, serverLocation);
105
            filterOutExisting(idList);
102 106
            Collections.sort(idList);
103 107
            SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData);
104 108
            
......
111 115
    	return success;
112 116
    }
113 117
    
118
    private List<String> filterOutExisting(List<String> idList) {
119
    	List<String> toRemove = new ArrayList<String>();
120
    	for (String id: idList) {
121
    		Identifier identifier = new Identifier();
122
    		identifier.setValue(id);
123
			boolean exists = SystemMetadataFactory.oreExistsFor(identifier);
124
			if (exists) {
125
				toRemove.add(id);
126
			}
127
    	}
128
    	for (String id: toRemove) {
129
    		idList.remove(id);
130
    	}
131
    	return idList;
132
    }
133
    
114 134
    public int getServerLocation() {
115 135
		return serverLocation;
116 136
	}

Also available in: Unified diff