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


Java TransformContext类代码示例

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


TransformContext类属于at.punkt.lodms.spi.transform包,在下文中一共展示了TransformContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTransformers

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
private void runTransformers(String runId, URI pipelineId, Map<String, Object> customData) {
    for (Transformer transformer : transformers) {
        if (transformer instanceof Disableable && ((Disableable) transformer).isDisabled()) {
            continue;
        }
        TransformContext context = new TransformContext(runId, customData);
        context.setPipeline(this);
        try {
            long start = System.currentTimeMillis();
            transformer.transform(repository, pipelineId, context);
            context.setDuration(System.currentTimeMillis() - start);
            eventPublisher.publishEvent(new TransformCompletedEvent(transformer, context, this));
        } catch (TransformException ex) {
            eventPublisher.publishEvent(new TransformFailedEvent(ex, transformer, context, this));
        }
        if (cancelAllowed && context.isCancelPipeline()) {
            eventPublisher.publishEvent(new PipelineAbortedEvent(context.getCancelMessage(), this, runId, transformer));
            return;
        }
    }
}
 
开发者ID:lodms,项目名称:lodms-core,代码行数:22,代码来源:ETLPipelineImpl.java

示例2: transformShouldDeleteAllOldStatements

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Test
public void transformShouldDeleteAllOldStatements() throws RepositoryException {
    Repository repository = new SailRepository(new MemoryStore());
    repository.initialize();
    RepositoryConnection con = repository.getConnection();
    try {
        loadRDFInStore("example_themes.n3", con);
        List<Statement> statements = Iterations.asList(con.getStatements(null, new URIImpl("http://www.w3.org/ns/dcat#theme"), null, false, DEFAULT_GRAPH));
        ODSValueMapper mapper = new ODSValueMapper();
        ODSValueMapperConfig config = new ODSValueMapperConfig();
        config.setMappings(getMappingList());
        config.setMappedPredicate(new MappedPredicate(ODSVoc.DCAT_DATASET, "http://www.w3.org/ns/dcat#theme", "theme"));
        mapper.configure(config);
        mapper.transform(repository, DEFAULT_GRAPH, new TransformContext("myid", new HashMap<String, Object>()));
        for (Statement s : statements) {
            Assert.assertFalse("should not have statement with " + s.getSubject().stringValue(), con.hasStatement(s, false, DEFAULT_GRAPH));
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        Assert.fail(e.getMessage());
    } finally {
        con.close();
    }
    repository.shutDown();
}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:26,代码来源:ODSValueMapperTest.java

示例3: transformShouldInsertNewStatements

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Test
public void transformShouldInsertNewStatements() throws RepositoryException {
    Repository repository = new SailRepository(new MemoryStore());
    repository.initialize();
    RepositoryConnection con = repository.getConnection();
    try {
        loadRDFInStore("example_themes.n3", con);
        List<Statement> statements = Iterations.asList(con.getStatements(null, new URIImpl("http://www.w3.org/ns/dcat#theme"), null, false, DEFAULT_GRAPH));
        ODSValueMapper mapper = new ODSValueMapper();
        ODSValueMapperConfig config = new ODSValueMapperConfig();
        config.setMappedPredicate(new MappedPredicate(ODSVoc.DCAT_DATASET, "http://www.w3.org/ns/dcat#theme", "theme"));
        config.setMappings(getMappingList());
        mapper.configure(config);
        mapper.transform(repository, DEFAULT_GRAPH, new TransformContext("myid", new HashMap<String, Object>()));
        for (Statement s : statements) {
            Statement newStatement = new StatementImpl(s.getSubject(), s.getPredicate(), MAPPINGS.get(s.getObject().stringValue()));
            Assert.assertTrue(con.hasStatement(newStatement, false, DEFAULT_GRAPH));
        }
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    } finally {
        con.close();
    }
    repository.shutDown();

}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:27,代码来源:ODSValueMapperTest.java

示例4: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
  try {
    TranslationApi api = config.getProvider();
    api.setClientId(config.getProviderClientID());
    api.setClientSecret(config.getProviderClientSecret());
    Collection<Statement> toBeTranslated = getStatementsToTranslate(repository, graph);
    logger.info(toBeTranslated.size() + " candidate literals to be translated");
    TranslationCache cache = new TranslationCache(repository, new URIImpl(config.getTranslationCache()));
    List<TranslatedStatement> translatedStatements = buildTranslationsFromCache(toBeTranslated, cache);
    logger.info(translatedStatements.size() + " translations generated from cache");
    logger.info(toBeTranslated.size() + " new literals to be translated");
    Collection<TranslatedStatement> newTranslations = api.translateStatements(toBeTranslated);
    context.getWarnings().addAll(api.getWarnings());
    cache.addTranslations(newTranslations);
    translatedStatements.addAll(newTranslations);
    insertTranslatedStatements(repository, graph, translatedStatements);
  } catch (Exception e) {
    throw new TransformException(e);
  }
}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:22,代码来源:WebTranslator.java

示例5: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        URI currentGraph = (URI) context.getCustomData().get("virtuosoExtractorGraph");
        URI previousGraph = valueFactory.createURI(currentGraph.stringValue() + "previous");
        List<Statement> statements = generateDateStaments(repository, currentGraph, previousGraph, graph);
        RepositoryConnection con = repository.getConnection();
        try {
            con.add(statements, graph);
            con.commit();
        } finally {
            con.close();
        }
    } catch (Exception e) {
        throw new TransformException(e.getMessage(), e);
    }

}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:19,代码来源:ODSModificationDetector.java

示例6: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        RepositoryConnection con = repository.getConnection();
        try {
            con.setAutoCommit(false);
            Update update = con.prepareUpdate(QueryLanguage.SPARQL, config.getQuery());
            DatasetImpl dataset = new DatasetImpl();
            dataset.setDefaultInsertGraph(graph);
            update.setDataset(dataset);
            update.execute();
            con.commit();
        } finally {
            con.close();
        }
    } catch (Exception ex) {
        throw new TransformException(ex);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:20,代码来源:SPARQLUpdateTransformer.java

示例7: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, final URI graph, TransformContext context) throws TransformException {
    try {
        final RepositoryConnection con = repository.getConnection();
        if (config.getValueType() == ValueType.LITERAL) {
            try {
                transformLiteral(con, graph);
            } finally {
                con.close();
            }
        } else if (config.getValueType() == ValueType.URI) {
            try {
                transformUri(con, graph);
            } finally {
                con.close();
            }
        }

    } catch (Exception ex) {
        throw new TransformException(ex);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:23,代码来源:RegexTransformer.java

示例8: testRunTransformContext

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Test
public void testRunTransformContext() {
    MockApplicationEventPublisher eventPublisher = new MockApplicationEventPublisher();
    ETLPipelineImpl instance = new ETLPipelineImpl(id, eventPublisher, repository);

    instance.setTransformers(getMockTransformers(1));
    instance.run();

    TransformCompletedEvent completedEvent = eventPublisher.getPublishedEventsOfType(TransformCompletedEvent.class).get(0);
    TransformContext context = completedEvent.getTransformContext();
    Assert.assertEquals(instance, context.getPipeline());
    Assert.assertNotNull(context.getId());
    Assert.assertTrue(context.getDuration() >= 0);
}
 
开发者ID:lodms,项目名称:lodms-core,代码行数:15,代码来源:ETLPipelineImplTest.java

示例9: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
/**
 * Transforms the cached RDF data in the repository.
 *
 * @param repository The repository where the RDF data is cached that should be transformed
 * @param graph      The graph that contains the RDF data which was extracted
 * @param context    The context containing meta information about this transformation process
 * @throws at.punkt.lodms.spi.transform.TransformException
 *          If the transformation fails, this exception has to be thrown
 */
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        RepositoryConnection connection = repository.getConnection();
        performUpdateQueries(config.getQueries(), connection, context.getWarnings(), graph);
        connection.close();
    } catch (RepositoryException e) {
        logger.error(e.getMessage());
        logger.error(e.getStackTrace());
        throw new TransformException(e.getMessage(), e);
    }
}
 
开发者ID:nvdk,项目名称:ods-lodms-plugins,代码行数:22,代码来源:MultipleSparqlUpdateTransformer.java

示例10: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {

        PPTApi api = new PPTApi(config.getApiConfig().getServer(), config.getApiConfig().getAuthentication());
        api.annotate(config, repository, graph, context);

    } catch (Exception ex) {
        throw new TransformException(ex);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:12,代码来源:PPXTransformer.java

示例11: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
/**
 * Transforms the cached RDF data in the repository.
 *
 * @param repository The repository where the RDF data is cached that should be transformed
 * @param graph      The graph that contains the RDF data which was extracted
 * @param context    The context containing meta information about this transformation process
 * @throws at.punkt.lodms.spi.transform.TransformException
 *          If the transformation fails, this exception has to be thrown
 */
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        WKDLawHandler wkdLawHandler = new WKDLawHandler(repository);
        org.openrdf.model.Resource documentResource = wkdLawHandler.getDocumentResource(graph);
        String suggestionURI = documentResource + "?Suggestions";
        context.getCustomData().put("wkdspotlighttagger.documenturi",suggestionURI);
        QueryResult<BindingSet> result = wkdLawHandler.getTextValues(graph);
        RepositoryConnection connection = repository.getConnection();
        try {
            connection.clear(graph);
            connection.add(ValueFactoryImpl.getInstance().createURI(suggestionURI),rdfType, pebblesSuggestion,graph);
            while (result.hasNext()) {
                BindingSet bSet = result.next();
                Value text = bSet.getValue("value");
                URI fragment = (URI) bSet.getValue("fragment");
                if (!text.stringValue().isEmpty()) {
                    String nif = getTagsForText(fragment,text.stringValue());
                    connection.add(new ByteArrayInputStream(nif.getBytes("ISO-8859-1")),fragment.stringValue(), RDFFormat.RDFXML,graph);
                }
            }
        }
        finally {
            result.close();
            connection.close();
        }
    }
    catch (Exception e) {
        throw new TransformException(e.getMessage(),e);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:41,代码来源:WkdSpotlightNifTagger.java

示例12: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
/**
 * Transforms the cached RDF data in the repository.
 *
 * @param repository The repository where the RDF data is cached that should be transformed
 * @param graph      The graph that contains the RDF data which was extracted
 * @param context    The context containing meta information about this transformation process
 * @throws at.punkt.lodms.spi.transform.TransformException
 *          If the transformation fails, this exception has to be thrown
 */
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        WKDLawHandler wkdLawHandler = new WKDLawHandler(repository);
        org.openrdf.model.Resource documentResource = wkdLawHandler.getDocumentResource(graph);
        String suggestionURI = documentResource + "?Suggestions";
        context.getCustomData().put("wkdspotlighttagger.documenturi",suggestionURI);
        List<SpotlightAnnotation> annotationList = getAnnotations(repository, graph, context);
        RepositoryConnection connection = repository.getConnection();
        connection.clear(graph);
        connection.commit();
        URI suggestionGraph = valueFactory.createURI(suggestionURI);
        connection.add(suggestionGraph,rdfType, pebblesSuggestion,graph);
        try {
            for (SpotlightAnnotation annotation : annotationList) {
                URI fragmentURI = annotation.getFragmentURI();
                for (SpotlightResource resource : annotation.getResources()) {
                    URI relatedConcept = valueFactory.createURI(resource.getURI());
                    connection.add(documentResource,skosRelated,relatedConcept,graph);
                    connection.add(fragmentURI,skosRelated,relatedConcept,graph);
                }
            }
            connection.commit();
        }
        finally {
            connection.close();
        }
    }
    catch (Exception e) {
        throw new TransformException(e.getMessage(),e);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:42,代码来源:WkdSpotlightTagger.java

示例13: getAnnotations

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
private List<SpotlightAnnotation> getAnnotations(Repository repository, URI graph, TransformContext context) throws RepositoryException, QueryEvaluationException, TransformException {
    List<SpotlightAnnotation> annotations = new ArrayList<SpotlightAnnotation>();
    WKDLawHandler wkdLawHandler = new WKDLawHandler(repository);
    QueryResult<BindingSet> result = wkdLawHandler.getTextValues(graph);
    while (result.hasNext()) {
        BindingSet bSet = result.next();
        Value text = bSet.getValue("value");
        URI fragment = (URI) bSet.getValue("fragment");
        SpotlightAnnotation annotation = getTagsFor(fragment,text.stringValue());
        annotations.add(annotation);
    }
    return  annotations;
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:14,代码来源:WkdSpotlightTagger.java

示例14: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        RepositoryConnection con = repository.getConnection();
        Set<Statement> toRemove = new HashSet<Statement>();
        Set<Statement> toAdd = new HashSet<Statement>();
        try {
            ArrayList<Statement> replaceStmts = new ArrayList<Statement>();
            for (URI triggerProp : config.getTriggerProperties()) {
                replaceStmts.clear();
                RepositoryResult<Statement> result = con.getStatements(null, triggerProp, null, true, graph);
                result.addTo(replaceStmts);
                result.close();
                for (Statement replace : replaceStmts) {
                    if (config.getObjectType().isAssignableFrom(replace.getObject().getClass())) {
                        toRemove.add(replace);
                        toAdd.add(factory.createStatement(replace.getSubject(), replace.getPredicate(), transformValue(replace.getObject())));
                    }
                }
            }
            con.remove(toRemove, graph);
            con.add(toAdd, graph);
            con.commit();
        } finally {
            con.close();
        }
    } catch (RepositoryException ex) {
        throw new TransformException(ex);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:31,代码来源:SimpleReplaceTransformer.java

示例15: transform

import at.punkt.lodms.spi.transform.TransformContext; //导入依赖的package包/类
@Override
public void transform(Repository repository, URI graph, TransformContext context) throws TransformException {
    try {
        final RepositoryConnection con = repository.getConnection();
        try {
            transformLiteral(con, graph);
        } finally {
            con.close();
        }

    } catch (Exception ex) {
        throw new TransformException(ex);
    }
}
 
开发者ID:lodms,项目名称:lodms-plugins,代码行数:15,代码来源:HtmlTransformer.java


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