diff --git a/src/main/java/gov/nasa/pds/citool/CIToolIngester.java b/src/main/java/gov/nasa/pds/citool/CIToolIngester.java index 3c016e8..a6b6ade 100644 --- a/src/main/java/gov/nasa/pds/citool/CIToolIngester.java +++ b/src/main/java/gov/nasa/pds/citool/CIToolIngester.java @@ -1,5 +1,13 @@ package gov.nasa.pds.citool; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; import gov.nasa.pds.citool.comparator.CatalogComparator; import gov.nasa.pds.citool.ingestor.CatalogObject; import gov.nasa.pds.citool.ingestor.CatalogVolumeIngester; @@ -9,22 +17,12 @@ import gov.nasa.pds.citool.util.ReferenceUtils; import gov.nasa.pds.citool.util.References; import gov.nasa.pds.citool.util.RegistryObjectCache; - import gov.nasa.pds.tools.LabelParserException; import gov.nasa.pds.tools.constants.Constants.ProblemType; import gov.nasa.pds.tools.label.Label; import gov.nasa.pds.tools.label.ManualPathResolver; import gov.nasa.pds.tools.label.parser.DefaultLabelParser; -import java.net.URI; -import java.net.URL; -import java.net.URISyntaxException; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.logging.Logger; -import java.io.IOException; - public class CIToolIngester { diff --git a/src/main/java/gov/nasa/pds/citool/ingestor/Constants.java b/src/main/java/gov/nasa/pds/citool/ingestor/Constants.java index 42c3a1b..0dc35b1 100644 --- a/src/main/java/gov/nasa/pds/citool/ingestor/Constants.java +++ b/src/main/java/gov/nasa/pds/citool/ingestor/Constants.java @@ -1,7 +1,7 @@ package gov.nasa.pds.citool.ingestor; -import java.util.Map; import java.util.HashMap; +import java.util.Map; /** * Class that holds constants used in ingest. * @@ -12,6 +12,8 @@ public class Constants { public static final String LID_PREFIX = "urn:nasa:pds:context_pds3:"; + public static final String RESOURCE_LID_SUFFIX = "_resource_info"; + public static final String TARGET_PROD = "Product_Target_PDS3"; public static final String MISSION_PROD = "Product_Mission_PDS3"; @@ -25,7 +27,7 @@ public class Constants { public static final String GUEST_PROD = "Product_PDS_Guest"; public static final String AFFIL_PROD = "Product_PDS_Affiliate"; - + // or Collection_Volume_Set_PDS3 ???? public static final String VOLUME_PROD = "Product_Volume_PDS3"; @@ -65,11 +67,11 @@ public class Constants { public static final String HAS_TARGET = "target_ref"; public static final String HAS_RESOURCE = "resource_ref"; - + public static final String HAS_FILE = "file_ref"; public static final String HAS_NODE = "node_ref"; - + public static final String PRODUCT_VERSION = "version_id"; @@ -94,4 +96,22 @@ public class Constants { pds3ToPds4Map.put("MISSION_ALIAS_NAME", "alternate_title"); pds3ToPds4Map.put("RESOURCE_LINK", "resource_url"); } + + /** Mapping of PDS3 to PDS4 names */ + public static final Map nodeValueToIdMap = new HashMap(); + + static { + nodeValueToIdMap.put("atmos", "planetary atmospheres"); + nodeValueToIdMap.put("geoscience", "geosciences"); + nodeValueToIdMap.put("isas/jaxa", "jaxa"); + nodeValueToIdMap.put("naif", "navigation and ancillary information facility"); + nodeValueToIdMap.put("ppi", "planetary plasma interactions"); + nodeValueToIdMap.put("ppi-ucla", "planetary plasma interactions"); + nodeValueToIdMap.put("rings", "planetary rings"); + nodeValueToIdMap.put("sbn", "small bodies"); + nodeValueToIdMap.put("esa", "planetary science archive"); + nodeValueToIdMap.put("rs", "radio science"); + nodeValueToIdMap.put("rad", "radio science"); + nodeValueToIdMap.put("imaging-jpl", "imaging"); + } } diff --git a/src/main/java/gov/nasa/pds/citool/ingestor/ProductFactory.java b/src/main/java/gov/nasa/pds/citool/ingestor/ProductFactory.java index 394488f..b26075e 100644 --- a/src/main/java/gov/nasa/pds/citool/ingestor/ProductFactory.java +++ b/src/main/java/gov/nasa/pds/citool/ingestor/ProductFactory.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.Map.Entry; - +import java.util.Set; +import java.util.logging.Logger; import gov.nasa.pds.citool.file.FileObject; import gov.nasa.pds.citool.registry.model.FileInfo; import gov.nasa.pds.citool.registry.model.Metadata; @@ -20,6 +20,9 @@ public class ProductFactory { + + private static Logger log = Logger.getLogger(ProductFactory.class.getName()); + /** * Create an extrinsic object * @@ -27,7 +30,7 @@ public class ProductFactory * @return an extrinsic object * */ - public static RegistryObject createProduct(CatalogObject catObj, CatalogVolumeIngester ingester) + public static RegistryObject createProduct(CatalogObject catObj, CatalogVolumeIngester ingester) throws Exception { RegistryObject product = new RegistryObject(); @@ -167,7 +170,31 @@ else if (objType.equalsIgnoreCase(Constants.VOLUME_OBJ) && key.equals("VOLUME_ID slots.put("name", product.getName()); slots.put(getKey("product_class"), Constants.VOLUME_PROD); - } + } else if (objType.equalsIgnoreCase(Constants.HK_OBJ) + && key.equals("CURATING_NODE_ID")) { + + String dsId = md.getMetadata("DATA_SET_ID"); + String productLid = dsId + Constants.RESOURCE_LID_SUFFIX; + productLid = Utility.collapse(productLid); + productLid = Utility.replaceChars(productLid); + productLid = Constants.LID_PREFIX + "resource:resource." + productLid.toLowerCase(); + + product.setLid(productLid); + slots.put("lid", productLid); + + product.setObjectType(Constants.RESOURCE_PROD); + slots.put("objectType", product.getObjectType()); + + slots.put(getKey("product_class"), Constants.RESOURCE_PROD); + + String node_id = md.getMetadata("CURATING_NODE_ID"); + node_id = Utility.collapse(node_id); + slots.put("node_id", getNodeId(node_id.toLowerCase())); + + slots.put("resource_name", md.getAllMetadata("RESOURCE_NAME")); + slots.put("resource_url", md.getAllMetadata("RESOURCE_LINK")); + + } if (objType.equalsIgnoreCase(Constants.DATASET_OBJ) && ingester.getArchiveStatus() !=null) { @@ -356,4 +383,11 @@ private static String getKey(String key) return key.toLowerCase(); } + private static String getNodeId(String value) { + if (Constants.nodeValueToIdMap.containsKey(value)) { + return Constants.nodeValueToIdMap.get(value); + } + return value; + } + } diff --git a/src/main/java/gov/nasa/pds/citool/util/ReferenceUtils.java b/src/main/java/gov/nasa/pds/citool/util/ReferenceUtils.java index 744ba1f..6d844e7 100644 --- a/src/main/java/gov/nasa/pds/citool/util/ReferenceUtils.java +++ b/src/main/java/gov/nasa/pds/citool/util/ReferenceUtils.java @@ -6,8 +6,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; - -import gov.nasa.pds.citool.CIToolIngester; import gov.nasa.pds.citool.ingestor.CatalogObject; import gov.nasa.pds.citool.ingestor.CatalogVolumeIngester; import gov.nasa.pds.citool.ingestor.Constants; @@ -302,57 +300,14 @@ private static void handleResourceRefs(Map> refs, CatalogOb values = new ArrayList(); } - String dsId = pdsLbl.get("DATA_SET_ID").getValue().toString(); - String key = "RESOURCE_ID"; - if (md.containsKey(key)) { - if (md.isMultiValued(key)) { - List tmpValues = md.getAllMetadata(key); - for (String aVal: tmpValues) { - lidValue = dsId + "__" + aVal; - lidValue = Utility.collapse(lidValue); - lidValue = Utility.replaceChars(lidValue); - lidValue = lidValue.toLowerCase(); - if (!Utility.valueExists(Constants.LID_PREFIX+"resource:resource."+lidValue, values)) - values.add(Constants.LID_PREFIX+"resource:resource."+lidValue); - } - } - else { - lidValue = md.getMetadata(key); - lidValue = dsId + "__" + lidValue; - lidValue = Utility.collapse(lidValue); - lidValue = Utility.replaceChars(lidValue); - lidValue = lidValue.toLowerCase(); - if (!Utility.valueExists(Constants.LID_PREFIX+"resource:resource."+lidValue, values)) - values.add(Constants.LID_PREFIX+"resource:resource."+lidValue); - } - refs.put(Constants.HAS_RESOURCE, values); - } - - key = "CURATING_NODE_ID"; - if (md.containsKey(key)) { - if (refs.get(Constants.HAS_NODE) != null) { - values = refs.get(Constants.HAS_NODE); - } else { - values = new ArrayList(); - } - if (md.isMultiValued(key)) { - List tmpValues = md.getAllMetadata(key); - for (String aVal : tmpValues) { - lidValue = aVal; - lidValue = Utility.collapse(lidValue); - lidValue = lidValue.toLowerCase(); - if (!Utility.valueExists(Constants.LID_PREFIX + "node:node." + lidValue, values)) - values.add(Constants.LID_PREFIX + "node:node." + lidValue); - } - } else { - lidValue = md.getMetadata(key); - lidValue = Utility.collapse(lidValue); - lidValue = lidValue.toLowerCase(); - if (!Utility.valueExists(Constants.LID_PREFIX + "node:node." + lidValue, values)) - values.add(Constants.LID_PREFIX + "node:node." + lidValue); - } - refs.put(Constants.HAS_NODE, values); - } + lidValue = pdsLbl.get("DATA_SET_ID").getValue().toString() + Constants.RESOURCE_LID_SUFFIX; + lidValue = Utility.collapse(lidValue); + lidValue = Utility.replaceChars(lidValue); + lidValue = lidValue.toLowerCase(); + if (!Utility.valueExists(Constants.LID_PREFIX + "resource:resource." + lidValue, values)) + values.add(Constants.LID_PREFIX + "resource:resource." + lidValue); + + refs.put(Constants.HAS_RESOURCE, values); } diff --git a/src/main/resources/search-conf/defaults/pds/dataset.xml b/src/main/resources/search-conf/defaults/pds/dataset.xml index 4f9e9fb..f3bc40e 100644 --- a/src/main/resources/search-conf/defaults/pds/dataset.xml +++ b/src/main/resources/search-conf/defaults/pds/dataset.xml @@ -108,11 +108,14 @@ target_ref.target_type - - resource_ref + + resource_ref.resource_url + + + resource_ref.resource_name - node_ref.node_name + resource_ref.node_id