All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.nasa.pds.citool.ri.RIChecker Maven / Gradle / Ivy

Go to download

The Legacy Catalog Tool provides functionality for ingesting PDS3 catalog files into the PDS4 infrastructure including the Registry Service.

There is a newer version: 3.1.0
Show newest version
package gov.nasa.pds.citool.ri;

import gov.nasa.pds.tools.LabelParserException;
import gov.nasa.pds.tools.label.AttributeStatement;
import gov.nasa.pds.tools.label.Label;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Base class for Referential Integrity checking.
 *
 * @author mcayanan
 *
 */
public abstract class RIChecker {
    protected URL supportFile = null;
    private List problems =
        new ArrayList();

    public Map getUnmatchedValues(
            List parents,
            List children) {
        ValueMatcher matcher = new ValueMatcher(parents);
        return matcher.getUnmatched(children);
    }

    public Map getUnmatchedValues(
            Map> parents,
            Map> children) {
        Map result =
            new LinkedHashMap();

        for(String identifier : children.keySet()) {
            result.putAll(getUnmatchedValues(parents.get(identifier),
                    children.get(identifier)));
        }
        return result;
    }

    public void setSupportFile(URL url) {
        supportFile = url;
    }

    public void addProblem(LabelParserException problem) {
        problems.add(problem);
    }

    public void addProblems(List problems) {
        this.problems.addAll(problems);
    }

    public List getProblems() {
        return problems;
    }

    public boolean hasProblems() {
        if (problems.isEmpty()) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * Determine if the supplied list of catalog files has
     * referential integrity.
     *
     * @param parents A list of parent labels.
     * @param children A list of child labels.
     *
     */
    abstract public void performCheck(List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy