当前位置: 首页>>代码示例>>Java>>正文


Java ResultCollector类代码示例

本文整理汇总了Java中dk.statsbiblioteket.medieplatform.autonomous.ResultCollector的典型用法代码示例。如果您正苦于以下问题:Java ResultCollector类的具体用法?Java ResultCollector怎么用?Java ResultCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResultCollector类属于dk.statsbiblioteket.medieplatform.autonomous包,在下文中一共展示了ResultCollector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-ninestars-QA-suite,代码行数:27,代码来源:NinestarsBatchQA.java

示例2: runTool

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
private void runTool(Tool tool, Batch batch, ResultCollector resultCollector) throws
                                                                              IOException,
                                                                              InterruptedException,
                                                                              TransformerException {
    //create the input as a file on the cluster
    Configuration conf = new Configuration();
    getProperties().setProperty(ConfigConstants.ITERATOR_USE_FILESYSTEM, "False");
    propertiesToHadoopConfiguration(conf, getProperties());

    conf.set(ConfigConstants.BATCH_ID, batch.getFullID());

    String user = conf.get(ConfigConstants.HADOOP_USER, "newspapr");
    conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);


    FileSystem fs = FileSystem.get(FileSystem.getDefaultUri(conf), conf, user);
    long time = System.currentTimeMillis();
    String jobFolder = getProperties().getProperty(ConfigConstants.JOB_FOLDER);
    Path inputFile = createInputFile(batch, fs, time, jobFolder);
    Path outDir = new Path(
            jobFolder, "output_" + batch.getFullID() + "_" + time);


    runJob(tool, batch, resultCollector, conf, inputFile, outDir, user);

}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-event-framework,代码行数:27,代码来源:AbstractHadoopRunnableComponent.java

示例3: getMetadataChecksFactory

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
protected MetadataChecksFactory getMetadataChecksFactory(Batch batch, ResultCollector resultCollector,
                                                       Document batchXmlStructure) {
    boolean atNinestars =
            Boolean.parseBoolean(getProperties().getProperty(ConfigConstants.AT_NINESTARS, Boolean.FALSE.toString()));
    MetadataChecksFactory metadataChecksFactory;

    if (atNinestars) {
        String jpylyzerPath = getProperties().getProperty(ConfigConstants.JPYLYZER_PATH);
        String batchFolder = getProperties().getProperty(ConfigConstants.ITERATOR_FILESYSTEM_BATCHES_FOLDER);
        metadataChecksFactory = new MetadataChecksFactory(resultCollector,
                                                          true,
                                                          batchFolder,
                                                          jpylyzerPath,
                mfPakDAO, batch, batchXmlStructure,disabledChecks);
    } else {
        metadataChecksFactory = new MetadataChecksFactory(resultCollector, mfPakDAO, batch, batchXmlStructure,disabledChecks);
    }
    return metadataChecksFactory;
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:20,代码来源:MetadataCheckerComponent.java

示例4: MetadataChecksFactory

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Initialise the MetadataChecksFactory with a result collector to collect errors in.
 * @param resultCollector The result collector to collect errors in.
 * @param mfPakDAO        a DAO object from which one can read relevant external properties of a batch.
 * @param batch           a batch object representing the batch being analysed.
 * @param disabledChecks  a set of enums detailing the checks to be disabled
 */
public MetadataChecksFactory(ResultCollector resultCollector, MfPakDAO mfPakDAO, Batch batch,
                             Document batchXmlStructure, Set<Checks> disabledChecks) {
    this.resultCollector = resultCollector;
    this.batchXmlStructure = batchXmlStructure;
    if (disabledChecks == null){
        disabledChecks = new HashSet<>();
    }
    this.disabledChecks = disabledChecks;
    try {
        this.batchContext = BatchContextUtils.buildBatchContext(mfPakDAO, batch);
    } catch (SQLException e) {
        throw new RuntimeException("Failed to obtain required information from database. "
                + "Check database connection, and try again", e);
    }
    
    //FIXME Introduce checks on batch context
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:25,代码来源:MetadataChecksFactory.java

示例5: testCreateEventHandlers

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
@Test
public void testCreateEventHandlers() throws Exception {
    MetadataChecksFactory factoryForAll = new MetadataChecksFactory(new ResultCollector("sdfsd", "sdfds"),
            true,
            "batchFolder",
            "jpylyzerPath", MFPakMocker.getMFPak(),
            new Batch("4000"),
            null,
            null);
    final List<TreeEventHandler> eventHandlers = factoryForAll.createEventHandlers();
    Assert.assertEquals(eventHandlers.size(), 11);
    int i = 0;
    Assert.assertTrue(eventHandlers.get(i++) instanceof ChecksumCheckEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof JpylyzingEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchemaValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchematronValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof ModsXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoMixCrossCheckEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof EditionModsEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof FilmXmlChecker);
    Assert.assertTrue(eventHandlers.get(i++) instanceof MixXmlFileChecker);
    Assert.assertTrue(eventHandlers.get(i++) instanceof MixFilmCrossCheckEventHandler);

}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:26,代码来源:MetadataChecksFactoryTest.java

示例6: testCreateEventHandlersWithDisabled

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
@Test
public void testCreateEventHandlersWithDisabled() throws Exception {
    Set<MetadataChecksFactory.Checks> disabled = new HashSet<>();
    disabled.add(MetadataChecksFactory.Checks.CHECKSUM);
    disabled.add(MetadataChecksFactory.Checks.MIX_FILM);
    MetadataChecksFactory factoryForAll = new MetadataChecksFactory(new ResultCollector("sdfsd", "sdfds"),
            true,
            "batchFolder",
            "jpylyzerPath", MFPakMocker.getMFPak(),
            new Batch("4000"),
            null,
            disabled);
    final List<TreeEventHandler> eventHandlers = factoryForAll.createEventHandlers();
    Assert.assertEquals(eventHandlers.size(), 9);
    int i = 0;
    Assert.assertTrue(eventHandlers.get(i++) instanceof JpylyzingEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchemaValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchematronValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof ModsXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoMixCrossCheckEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof EditionModsEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof FilmXmlChecker);
    Assert.assertTrue(eventHandlers.get(i++) instanceof MixXmlFileChecker);
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:26,代码来源:MetadataChecksFactoryTest.java

示例7: testCreateEventHandlersWithDisabledNotAtNinestars

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
public void testCreateEventHandlersWithDisabledNotAtNinestars() throws Exception {
    Set<MetadataChecksFactory.Checks> disabled = new HashSet<>();
    disabled.add(MetadataChecksFactory.Checks.CHECKSUM);
    disabled.add(MetadataChecksFactory.Checks.MIX_FILM);
    MetadataChecksFactory factoryForAll = new MetadataChecksFactory(new ResultCollector("sdfsd", "sdfds"),
            false,
            "batchFolder",
            "jpylyzerPath", MFPakMocker.getMFPak(),
            new Batch("4000"),
            null,
            disabled);
    final List<TreeEventHandler> eventHandlers = factoryForAll.createEventHandlers();
    Assert.assertEquals(eventHandlers.size(), 8);
    int i = 0;
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchemaValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof SchematronValidatorEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof ModsXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoXPathEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof AltoMixCrossCheckEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof EditionModsEventHandler);
    Assert.assertTrue(eventHandlers.get(i++) instanceof FilmXmlChecker);
    Assert.assertTrue(eventHandlers.get(i++) instanceof MixXmlFileChecker);
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:24,代码来源:MetadataChecksFactoryTest.java

示例8: 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

示例9: testGood2J3

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Test success for 2J3 - filepath in alto file matches actual file path
 */
@Test
public void testGood2J3() {
    DocumentCache documentCache = new DocumentCache();
    ResultCollector resultCollector = new ResultCollector("foo", "bar");
    Batch batch = new Batch();
    batch.setBatchID("400022028241");
    batch.setRoundTripNumber(10);
    MfPakDAO dao = mock(MfPakDAO.class);
    AltoXPathEventHandler handler = new AltoXPathEventHandler(resultCollector, documentCache);
    AttributeParsingEvent altoEvent = new AttributeParsingEvent("B400022028241-RT2/400022028241-14/1795-06-15-01/AdresseContoirsEfterretninger-1795-06-15-01-0012B.alto.xml") {
        @Override
        public InputStream getData() throws IOException {
            return Thread.currentThread().getContextClassLoader().getResourceAsStream("goodData/good.alto.xml");

        }

        @Override
        public String getChecksum() throws IOException {
            return null;  //To change body of implemented methods use File | Settings | File Templates.
        }
    } ;
    handler.handleAttribute(altoEvent);
    assertTrue(resultCollector.isSuccess(), "Unexpected failure: " + resultCollector.toReport());
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:28,代码来源:AltoValidationTest.java

示例10: testBad2J3

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Test failure for 2J3 - filepath in alto file matches actual file path
 */
@Test
public void testBad2J3() {
    DocumentCache documentCache = new DocumentCache();
    ResultCollector resultCollector = new ResultCollector("foo", "bar");
    Batch batch = new Batch();
    batch.setBatchID("400022028241");
    batch.setRoundTripNumber(10);
    MfPakDAO dao = mock(MfPakDAO.class);
    AltoXPathEventHandler handler = new AltoXPathEventHandler(resultCollector, documentCache);
    AttributeParsingEvent altoEvent = new AttributeParsingEvent("B400022028241-RT2/400022028241-14/1795-06-15-01/AdresseContoirsEfterretninger-1795-06-15-01-0012B.alto.xml") {
        @Override
        public InputStream getData() throws IOException {
            return Thread.currentThread().getContextClassLoader().getResourceAsStream("badData/bad1.alto.xml");
        }

        @Override
        public String getChecksum() throws IOException {
            return null;  //To change body of implemented methods use File | Settings | File Templates.
        }
    } ;
    handler.handleAttribute(altoEvent);
    assertFalse("Unexpected success: " + resultCollector.toReport(), resultCollector.isSuccess());
    assertTrue(resultCollector.toReport().contains("2J-3"));
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:28,代码来源:AltoValidationTest.java

示例11: handleTestEvent

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
private void handleTestEvent(final String input, ResultCollector resultCollector) {
    DocumentCache documentCache = new DocumentCache();
    SchematronValidatorEventHandler handler = new SchematronValidatorEventHandler(resultCollector, documentCache,attributeConfigs);
    AttributeParsingEvent event = new AttributeParsingEvent("test.alto.xml") {
        @Override
        public InputStream getData() throws IOException {
            return new ByteArrayInputStream(input.getBytes("UTF-8"));
        }

        @Override
        public String getChecksum() throws IOException {
            return null;
        }
    };
    handler.handleAttribute(event);
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:17,代码来源:AltoValidationTest.java

示例12: testPageModsGoodSch

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Test that we can validate a valid page mods file.
 */
@Test
public void testPageModsGoodSch() {
    DocumentCache documentCache = new DocumentCache();
    ResultCollector resultCollector = new ResultCollector("foo", "bar");
    SchematronValidatorEventHandler handler = new SchematronValidatorEventHandler(resultCollector, documentCache,attributeConfigs);
    AttributeParsingEvent modsEvent = new AttributeParsingEvent("B400022028241-RT1/400022028241-14/1795-06-15-01/AdresseContoirsEfterretninger-1795-06-15-01-0010B.mods.xml") {
        @Override
        public InputStream getData() throws IOException {
            return Thread.currentThread().getContextClassLoader().getResourceAsStream("goodData/goodpagemods.mods.xml");
        }

        @Override
        public String getChecksum() throws IOException {
            return null;
        }
    };
    handler.handleAttribute(modsEvent);

    assertTrue(resultCollector.isSuccess(),resultCollector.toReport());
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:24,代码来源:PageModsTest.java

示例13: testPageModsBad1Sch

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Test that we test an invalid page mods file.
 */
@Test
public void testPageModsBad1Sch() {
    DocumentCache documentCache = new DocumentCache();
    ResultCollector resultCollector = new ResultCollector("foo", "bar");
    SchematronValidatorEventHandler handler = new SchematronValidatorEventHandler(resultCollector, documentCache,attributeConfigs);
    AttributeParsingEvent modsEvent = new AttributeParsingEvent("AdresseContoirsEfterretninger-1795-06-15-01-0010B.mods.xml") {
        @Override
        public InputStream getData() throws IOException {
            return Thread.currentThread().getContextClassLoader().getResourceAsStream("badData/bad1.mods.xml");
        }

        @Override
        public String getChecksum() throws IOException {
            return null;
        }
    };
    handler.handleAttribute(modsEvent);
    String report = resultCollector.toReport();
    assertTrue(report.contains("2C-3:"),report);
    assertTrue(report.contains("2C-4:"),report);
    assertTrue(report.contains("2C-6:"),report);
    assertTrue(report.contains("2C-9:"),report);
    assertTrue(report.contains("2C-10:"), report);
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:28,代码来源:PageModsTest.java

示例14: testPageModsBad2Sch

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
/**
 * Test that we test an invalid page mods file.
 */
@Test
public void testPageModsBad2Sch() {
    DocumentCache documentCache = new DocumentCache();
    ResultCollector resultCollector = new ResultCollector("foo", "bar");
    SchematronValidatorEventHandler handler = new SchematronValidatorEventHandler(resultCollector, documentCache,attributeConfigs);
    AttributeParsingEvent modsEvent = new AttributeParsingEvent("AdresseContoirsEfterretninger-1795-06-15-01-0003B.mods.xml") {
        @Override
        public InputStream getData() throws IOException {
            return Thread.currentThread().getContextClassLoader().getResourceAsStream("badData/bad2.mods.xml");
        }

        @Override
        public String getChecksum() throws IOException {
            return null;
        }
    };
    handler.handleAttribute(modsEvent);

    String report = resultCollector.toReport();
    assertTrue(report.contains("2C-4:"), report);
    assertTrue(report.contains("2C-6:"), report);
    assertTrue(report.contains("2C-9:"), report);
    assertTrue(report.contains("2C-10:"), report);

}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:29,代码来源:PageModsTest.java

示例15: iterateDataDir

import dk.statsbiblioteket.medieplatform.autonomous.ResultCollector; //导入依赖的package包/类
private void iterateDataDir(String dataDirS, ResultCollector resultCollector) throws FileNotFoundException, SQLException {
    Batch batch = new Batch();
    DocumentCache documentCache = new DocumentCache();
    batch.setBatchID("400022028241");
    batch.setRoundTripNumber(1);
    File dataDir = new File(Thread.currentThread().getContextClassLoader().getResource(dataDirS).getPath());
    String editionNodeName = "B400022028241-RT1/400022028241-1/1795-06-15-02";
    Document batchStructure = DOM.streamToDOM(new FileInputStream(new File(dataDir, "structure.xml")));
    MfPakDAO dao = getMockMfPakDAO(batch, true);
    BatchContext context = BatchContextUtils.buildBatchContext(dao, batch);
    ModsXPathEventHandler handler = new ModsXPathEventHandler(resultCollector, context, batchStructure, documentCache);
    File fileDir = new File(dataDir, "1795-06-15-02");
    handler.handleNodeBegin(new NodeBeginsParsingEvent(editionNodeName));
    for (File attributeFile: fileDir.listFiles()) {
        final String name = editionNodeName + "/" + attributeFile.getName();
        if (attributeFile.getName().contains("mods")) {
            FileAttributeParsingEvent modsEvent = new FileAttributeParsingEvent(name, attributeFile);
            handler.handleAttribute(modsEvent);
        }
    }
    handler.handleNodeEnd(new NodeEndParsingEvent(editionNodeName));
}
 
开发者ID:statsbiblioteket,项目名称:newspaper-batch-metadata-checker,代码行数:23,代码来源:PageModsTest.java


注:本文中的dk.statsbiblioteket.medieplatform.autonomous.ResultCollector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。