Skip to content

Commit

Permalink
reestablish node names
Browse files Browse the repository at this point in the history
  • Loading branch information
Al Niessner authored and Al Niessner committed Jul 13, 2024
1 parent 0c2b7db commit 7f00cd7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/main/java/gov/nasa/pds/harvest/cfg/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
Expand All @@ -17,6 +18,20 @@
*/
public class ConfigManager
{
private static HashMap<String,String> indexNodeMap = new HashMap<String,String>();
static {
indexNodeMap.put("pds-atm-registry", "PDS_ATM");
indexNodeMap.put("pds-eng-registry", "PDS_ENG");
indexNodeMap.put("pds-geo-registry", "PDS_GEO");
indexNodeMap.put("pds-img-registry", "PDS_IMG");
indexNodeMap.put("pds-naif-registry", "PDS_NAIF");
indexNodeMap.put("pds-ppi-registry", "PDS_PPI");
indexNodeMap.put("pds-rms-registry", "PDS_RMS");
indexNodeMap.put("pds-sbn-registry", "pds_SBN");
indexNodeMap.put("psa-registry", "PSA");
indexNodeMap.put("jaxa-registry", "JAXA");
indexNodeMap.put("roscosmos", "ROSCOSMOS");
}
static public List<FileRefRule> exchangeFileRef (List<FileRefType> xml2beans) {
ArrayList<FileRefRule> beans = new ArrayList<FileRefRule>();
FileRefRule rule;
Expand All @@ -42,6 +57,11 @@ static public List<String> exchangeLidvids (List<CollectionType> ids) {
}
return lidvids;
}
static public String exchangeIndexForNode (String indexName) {
if (indexNodeMap.containsKey (indexName)) return indexNodeMap.get(indexName);
if (0 < indexName.indexOf("-registry")) return indexName.substring(0, indexName.indexOf("-registry"));
return "development";
}
static public ConnectionFactory exchangeRegistry (RegistryType xml) throws Exception {
return EstablishConnectionFactory.from (xml.getValue(), xml.getAuth());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void onBundle(File file) throws Exception
private void processMetadata(File file, Document doc) throws Exception
{
Metadata meta = basicExtractor.extract(file, doc);
meta.setNodeName("fixme or delete me");
meta.setNodeName(ConfigManager.exchangeIndexForNode(RegistryManager.getInstance().getIndexName()));

if(!bundleCfg.getVersions().equalsIgnoreCase("all") && !bundleCfg.getVersions().contains(meta.strVid)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void onCollection(File file, BundleType bCfg) throws Exception
private void processMetadata(File file, Document doc, BundleType bCfg) throws Exception
{
Metadata meta = basicExtractor.extract(file, doc);
meta.setNodeName("fixme or delete me");
meta.setNodeName(ConfigManager.exchangeIndexForNode(RegistryManager.getInstance().getIndexName()));

// Collection filter
List<String> lids = ConfigManager.exchangeLids (bCfg.getCollection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void processMetadata(File file, Document doc) throws Exception
{
// Extract basic metadata
Metadata meta = basicExtractor.extract(file, doc);
meta.setNodeName("fixme or delete me");
meta.setNodeName(ConfigManager.exchangeIndexForNode(RegistryManager.getInstance().getIndexName()));

log.info("Processing " + file.getAbsolutePath());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void processMetadata(File file, Document doc) throws Exception

// Extract basic metadata
Metadata meta = basicExtractor.extract(file, doc);
meta.setNodeName("fixme or delete me");
meta.setNodeName(ConfigManager.exchangeIndexForNode(RegistryManager.getInstance().getIndexName()));

// Only process primary products from collection inventory
LidVidCache cache = RefsCache.getInstance().getProdRefsCache();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gov/nasa/pds/harvest/dao/RegistryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,7 @@ public Counter getCounter()
{
return counter;
}
public String getIndexName() {
return this.conFact.getIndexName();
}
}

0 comments on commit 7f00cd7

Please sign in to comment.