本文整理汇总了Java中dk.statsbiblioteket.medieplatform.autonomous.ResultCollector.addFailure方法的典型用法代码示例。如果您正苦于以下问题:Java ResultCollector.addFailure方法的具体用法?Java ResultCollector.addFailure怎么用?Java ResultCollector.addFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dk.statsbiblioteket.medieplatform.autonomous.ResultCollector
的用法示例。
在下文中一共展示了ResultCollector.addFailure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWork
import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入方法依赖的package包/类
/**
* Call the doWork method on the runnable component, and add a failure to the result collector is the
* method throws
*
* @param batch the batch to work on
* @param component the component doing the work
* @param resultCollector the result collector
*
* @return the resultcollector
* @throws WorkException if the component threw an exception
*/
protected static ResultCollector doWork(Batch batch, RunnableComponent component,
ResultCollector resultCollector) throws WorkException {
try {
component.doWorkOnItem(batch, resultCollector);
} catch (Exception e) {
log.error("Failed to do work on component {}", component.getComponentName(), e);
resultCollector.addFailure(batch.getFullID(),
"exception",
component.getClass().getSimpleName(),
"Unexpected error in component: " + e.toString(),
Strings.getStackTrace(e));
throw new WorkException(e);
}
return resultCollector;
}
示例2: verify
import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入方法依赖的package包/类
/**
* Compare the alto sizes and the mix sizes, if both are > 0. If less than 0, we assume that they have not been
* set (ie. there was no alto file or something)
*
* @param sizes the store of sizes
* @param resultCollector the result collector
*/
private void verify(SizeSet sizes, ResultCollector resultCollector) {
if (!sizes.getMixSize()
.equalWidth(sizes.getAltoSize())) {
resultCollector.addFailure(
sizes.getFolder(),
"metadata",
getClass().getSimpleName(),
"2J-7: The file '" + sizes.getFolder() + ".mix.xml' and file '" + sizes.getFolder() + ".alto.xml' should agree on height");
}
if (!sizes.getMixSize()
.equalHeight(sizes.getAltoSize())) {
resultCollector.addFailure(
sizes.getFolder(),
"metadata",
getClass().getSimpleName(),
"2J-7: The file '" + sizes.getFolder() + ".mix.xml' and file '" + sizes.getFolder() + ".alto.xml' should agree on width");
}
}
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:27,代码来源:AltoMixCrossCheckEventHandler.java
示例3: testConvert
import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入方法依赖的package包/类
/**
* Test the conversion from a resultCollector to a ninestars QA report
*/
@Test
public void testConvert() {
ResultCollector resultCollector = new ResultCollector("batch", "0.1");
String reference = "reference";
String type = "type";
resultCollector.addFailure(reference, type, "component", "description", "details1\n", "details2\n");
final Batch batch = new Batch("4000213213", 3);
final HashSet<MetadataChecksFactory.Checks> disabledChecks = new HashSet<>();
String converted = NinestarsUtils.convertResult(resultCollector, batch.getFullID(), disabledChecks);
//System.out.println(converted);
URL schemaFile = Thread.currentThread().getContextClassLoader().getResource("xsd/qaresult.xsd");
try {
checkSchema(converted, schemaFile);
} catch (SAXException | IOException e) {
Assert.fail();
}
Document convertedAsDom = DOM.stringToDOM(converted, true);
XPathSelector xpath = DOM.createXPathSelector("qa", "http://schemas.statsbiblioteket.dk/qaresult/");
String batchID = xpath.selectString(convertedAsDom, "/qa:qaresult/@batchID");
Assert.assertEquals(batchID, batch.getFullID());
String disabledChecksResult = xpath.selectString(convertedAsDom, "/qa:qaresult/@disabledChecks");
Assert.assertEquals(disabledChecksResult,"");
String typeSelected = xpath.selectString(convertedAsDom,
"/qa:qaresult/qa:qafailures/qa:qafailure[qa:filereference = '"
+ reference + "']/qa:type");
Assert.assertEquals(typeSelected, type);
}
示例4: testConvertWithDisabledChecks
import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入方法依赖的package包/类
/**
* Test the conversion from a resultCollector to a ninestars QA report
*/
@Test
public void testConvertWithDisabledChecks() {
ResultCollector resultCollector = new ResultCollector("batch", "0.1");
String reference = "reference";
String type = "type";
resultCollector.addFailure(reference, type, "component", "description", "details1\n", "details2\n");
final HashSet<MetadataChecksFactory.Checks> disabledChecks = new HashSet<>();
disabledChecks.add(MetadataChecksFactory.Checks.CHECKSUM);
disabledChecks.add(MetadataChecksFactory.Checks.JPYLYZER);
final Batch batch = new Batch("4000213213", 3);
String converted = NinestarsUtils.convertResult(resultCollector, batch.getFullID(), disabledChecks);
//System.out.println(converted);
URL schemaFile = Thread.currentThread().getContextClassLoader().getResource("xsd/qaresult.xsd");
try {
checkSchema(converted, schemaFile);
} catch (SAXException | IOException e) {
Assert.fail();
}
Document convertedAsDom = DOM.stringToDOM(converted, true);
XPathSelector xpath = DOM.createXPathSelector("qa", "http://schemas.statsbiblioteket.dk/qaresult/");
String batchID = xpath.selectString(convertedAsDom,
"/qa:qaresult/@batchID");
Assert.assertEquals(batchID, batch.getFullID());
String disabledChecksResult = xpath.selectString(convertedAsDom, "/qa:qaresult/@disabledChecks");
String[] disabledChecksSplit = disabledChecksResult.split(",");
Assert.assertEquals(disabledChecks.size(),disabledChecksSplit.length);
for (String check : disabledChecksSplit) {
Assert.assertTrue(disabledChecks.contains(MetadataChecksFactory.Checks.valueOf(check)));
}
String typeSelected = xpath.selectString(convertedAsDom,
"/qa:qaresult/qa:qafailures/qa:qafailure[qa:filereference = '" + reference + "']/qa:type");
Assert.assertEquals(typeSelected, type);
}
示例5: runValidation
import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入方法依赖的package包/类
protected static int runValidation(File file, String jpylyzerPath) throws
FileNotFoundException {
DocumentCache documentCache = new DocumentCache();
ResultCollector resultCollector = new ResultCollector("file", NinestarsUtils.getVersion());
JpylyzingEventHandler jpylyzingEventHandler = new JpylyzingEventHandler(resultCollector,
file.getParentFile().getAbsolutePath(),
jpylyzerPath);
Map<String, AttributeSpec> metadataChecksConfig = MetadataChecksFactory.getAttributeValidationConfig();
DefaultTreeEventHandler schemaValidatorEventHandler = new SchemaValidatorEventHandler(resultCollector,
documentCache,metadataChecksConfig);
DefaultTreeEventHandler schematronValidatorEventHandler = new SchematronValidatorEventHandler(resultCollector,
documentCache,metadataChecksConfig);
EventRunner runner = new EventRunner(null,
Arrays.asList((TreeEventHandler) jpylyzingEventHandler,
schemaValidatorEventHandler,
schematronValidatorEventHandler),
resultCollector);
runner.handleNodeBegins(new DataFileNodeBeginsParsingEvent(file.getName()));
//simulate a tree iteration
try {
runner.handleAttribute(new FileAttributeParsingEvent(file.getName() + JpylyzingEventHandler.CONTENTS,
file));
} catch (RuntimeException e) {
resultCollector.addFailure(file.getName(),
"exception",
JpylyzingEventHandler.class.getSimpleName(),
"Unexpected error: " + e.getMessage(),
Strings.getStackTrace(e));
}
// Only run the validations if jpylyzer succeeds it's run.
if (resultCollector.isSuccess()) {
AttributeParsingEvent parsingEvent = runner.popInjectedEvent();
runner.handleAttribute(parsingEvent);
runner.handleNodeEnd(new DataFileNodeEndsParsingEvent(file.getName()));
runner.handleFinish();
}
String result = NinestarsUtils.convertResult(resultCollector, file.getName(), new HashSet<MetadataChecksFactory.Checks>());
System.out.println(result);
if (!resultCollector.isSuccess()) {
return 1;
}
return 0;
}