gov.nasa.pds.registry.common.connection.es.GetAltIdsParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of registry-common Show documentation
Show all versions of registry-common Show documentation
Common code used by Harvest and Registry Manager.
The newest version!
package gov.nasa.pds.registry.common.connection.es;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
class GetAltIdsParser implements SearchResponseParser.Callback
{
private Map> map;
GetAltIdsParser()
{
map = new TreeMap<>();
}
public Map> getIdMap()
{
return map;
}
@Override
public void onRecord(String id, Object rec)
{
if(rec instanceof Map, ?>)
{
Object obj = ((Map, ?>)rec).get("alternate_ids");
if(obj == null) return;
// Multiple values
if(obj instanceof List>)
{
Set altIds = new TreeSet<>();
for(Object item: (List>)obj)
{
altIds.add(item.toString());
}
map.put(id, altIds);
}
// Single value
else if(obj instanceof String)
{
Set altIds = new TreeSet<>();
altIds.add((String)obj);
map.put(id, altIds);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy