Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright 2009, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government sponsorship acknowledged.
// Any commercial use must be negotiated with the Office of Technology Transfer
// at the California Institute of Technology.
//
// This software is subject to U. S. export control laws and regulations
// (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software
// is subject to U.S. export control laws and regulations, the recipient has
// the responsibility to obtain export licenses or other export authority as
// may be required before exporting such information to foreign countries or
// providing access to foreign nationals.
//
// $Id$
package gov.nasa.pds.citool;
import gov.nasa.pds.citool.report.NewStandardValuesReport;
import gov.nasa.pds.citool.report.ReferentialIntegrityReport;
import gov.nasa.pds.citool.report.Report;
import gov.nasa.pds.citool.ri.NewValidValueFinder;
import gov.nasa.pds.citool.ri.RIType;
import gov.nasa.pds.citool.ri.ReferentialIntegrityValidator;
import gov.nasa.pds.citool.target.Target;
import gov.nasa.pds.citool.util.Utility;
import gov.nasa.pds.citool.validate.ReferenceFinderValidator;
import gov.nasa.pds.citool.validate.ReferenceValidator;
import gov.nasa.pds.tools.LabelParserException;
import gov.nasa.pds.tools.constants.Constants.ProblemType;
import gov.nasa.pds.tools.dict.Dictionary;
import gov.nasa.pds.tools.dict.parser.DictionaryParser;
import gov.nasa.pds.tools.label.AttributeStatement;
import gov.nasa.pds.tools.label.IncludePointer;
import gov.nasa.pds.tools.label.Label;
import gov.nasa.pds.tools.label.ManualPathResolver;
import gov.nasa.pds.tools.label.ObjectStatement;
import gov.nasa.pds.tools.label.PointerStatement;
import gov.nasa.pds.tools.label.Statement;
import gov.nasa.pds.tools.label.parser.DefaultLabelParser;
import gov.nasa.pds.tools.label.validate.Validator;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class CIToolValidator {
private ManualPathResolver resolver;
private DefaultLabelParser parser;
private Report report;
private URL allrefs;
public CIToolValidator(Report report) {
this(report, new ArrayList());
}
public CIToolValidator(Report report, List includePaths) {
this.report = report;
this.allrefs = null;
resolver = new ManualPathResolver();
if (!includePaths.isEmpty()) {
resolver.setIncludePaths(includePaths);
}
parser = new DefaultLabelParser(true, true, true, resolver);
}
public Dictionary parseDictionary(List dictionaries,
boolean aliasing)
throws URISyntaxException, CIToolValidatorException {
Dictionary dictionary = null;
boolean dictionaryPassed = true;
URL url = null;
Iterator i = dictionaries.iterator();
try {
url = Utility.toURL(i.next());
dictionary = DictionaryParser.parse(url, aliasing, true);
report.addConfiguration(" Dictionary version "
+ dictionary.getVersion());
if (dictionary.getProblems().size() != 0) {
dictionaryPassed = false;
report.record(dictionary.getDictionaryURI(),
dictionary.getProblems());
}
while (i.hasNext()) {
url = Utility.toURL(i.next());
Dictionary mergedDictionary = DictionaryParser.parse(url,
aliasing, true);
dictionary.merge(mergedDictionary);
report.addConfiguration(" Dictionary version "
+ mergedDictionary.getVersion());
if (mergedDictionary.getProblems().size() != 0) {
dictionaryPassed = false;
report.record(mergedDictionary.getDictionaryURI(),
mergedDictionary.getProblems());
}
}
} catch (LabelParserException le) {
List problems =
new ArrayList();
problems.add(le);
report.record(url.toURI(), problems);
dictionaryPassed = false;
} catch (IOException io) {
report.recordSkip(url.toURI(), io);
dictionaryPassed = false;
}
if (!dictionaryPassed) {
throw new CIToolValidatorException("Dictionary did not pass");
}
return dictionary;
}
public void setAllrefs(URL url) {
this.allrefs = url;
}
public Report doReferentialIntegrity(List