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


Java RdfDataUnitUtils类代码示例

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


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

示例1: loadRdfIntoObject

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
private <TYPE> void loadRdfIntoObject(RepositoryConnection connection, IRI resourceClass, TYPE object)
        throws DataUnitException, RepositoryException, SerializationFailure, SerializationRdfFailure {
    final List<RDFDataUnit.Entry> etries = DataUnitUtils.getEntries(sourceDataUnit,
            RDFDataUnit.Entry.class);
    final IRI [] graphs = RdfDataUnitUtils.asGraphs(etries);
    // Load subjects.
    final List<Resource> resources = getConfigurationSubject(resourceClass, graphs);
    if (resources.isEmpty()) {
        // No configuration resource.
        LOG.debug("No configuration object found.");
        return;
    }
    if (resources.size() > 1) {
        LOG.info("Loading from multiple instances.");
    }
    // For each subject load data.
    for (Resource resource : resources) {
        serialization.convert(connection, resource, etries, object, null);
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:21,代码来源:RdfConfiguration.java

示例2: checkParamsFromMapAreInOutput

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
@Test
public void checkParamsFromMapAreInOutput() throws Exception {
    addFileToInput("valid.xml");

    // Prepare configuration.
    final WritableRDFDataUnit configRdf = env.createRdfInput("config", false);
    InputOutputUtils.extractFromFile(new File(getClass().getClassLoader().getResource("config.ttl").toURI()), RDFFormat.TURTLE, configRdf,
            RdfDataUnitUtils.addGraph(configRdf, "main-config"));

    // configure DPU
    XSLTConfig_V1 config = new XSLTConfig_V1();
    config.setXslTemplate(resourceAsString("output-params.xslt"));
    dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

    // run DPU
    env.run(dpu);

    // check output for parameters
    List<FilesDataUnit.Entry> outputList = new ArrayList<>(FilesHelper.getFiles(output));
    Iterator<FilesDataUnit.Entry> outputIterator = outputList.iterator();

    while (outputIterator.hasNext()) {
        String outputContents = IOUtils.toString(java.net.URI.create(outputIterator.next().getFileURIString()), "UTF-8");

        // verify result
        assertTrue("Output contents should contain string '1'", outputContents.contains("1"));
        assertTrue("Output contents should contain string '2'", outputContents.contains("2"));
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:30,代码来源:XsltTest.java

示例3: RemoteRdfDataUnit

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
RemoteRdfDataUnit(ExecContext<?> execContext, String endpointUrl, IRI... graphs)
        throws ExternalError {
    this.execContext = execContext;
    this.repository = new SPARQLRepository(endpointUrl);
    try {
        this.repository.initialize();
    } catch (RepositoryException ex) {
        throw new ExternalError("Can't create remote HTTP repository.", ex);
    }
    // Initialize entries.
    entries = new ArrayList<>(graphs.length);
    for (IRI uri : graphs) {
        entries.add(new RdfDataUnitUtils.InMemoryEntry(uri, "remote: " + endpointUrl));
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:16,代码来源:RemoteRdfDataUnit.java

示例4: asGraph

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
/**
 * Convert {@link RDFDataUnit.Entry} to {@link IRI}
 * 
 * @param faultTolerance
 * @param entry
 * @return
 * @throws DPUException 
 */
public static IRI asGraph(FaultTolerance faultTolerance, final RDFDataUnit.Entry entry)
        throws DPUException {
    return faultTolerance.execute(new FaultTolerance.ActionReturn<IRI>() {

        @Override
        public IRI action() throws Exception {
            return RdfDataUnitUtils.asGraph(entry);
        }
    });
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:19,代码来源:FaultToleranceUtils.java

示例5: convert

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
@Override
public void convert(RepositoryConnection connection, Resource rootResource,
        List<RDFDataUnit.Entry> context, Object object, Configuration config)
        throws SerializationFailure, SerializationRdfFailure, DataUnitException, RepositoryException {
    if (config == null) {
        config = SerializationUtils.createConfiguration(object.getClass());
    }
    // Get read graphs.
    final IRI[] graphs = RdfDataUnitUtils.asGraphs(context);
    // Load object.
    loadIntoObject(new Context(connection, graphs, config), rootResource, object);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:13,代码来源:SerializationRdfSimple.java

示例6: prepareDataset

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
/**
 * @return Null if no dataset should be used.
 */
protected static Dataset prepareDataset(List<RDFDataUnit.Entry> source, RDFDataUnit.Entry target)
        throws DataUnitException {
    final SimpleDataset dataset = new SimpleDataset();
    // Add read graphs.
    for (IRI uri : RdfDataUnitUtils.asGraphs(source)) {
        dataset.addDefaultGraph(uri);
    }
    // Add write graph.
    if (target != null) {
        dataset.setDefaultInsertGraph(target.getDataGraphURI());
        dataset.addDefaultRemoveGraph(target.getDataGraphURI());
    }
    return dataset;
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:18,代码来源:SparqlUtils.java

示例7: getMetadataEntries

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
/**
 * Provide access to metadata in same form as to any other graph. As a symbolic name fixed value is used.
 * Do not write into input metadata graphs as it would corrupt data for other DPUs.
 *
 * @param dataUnit
 * @return
 */
public static List<RDFDataUnit.Entry> getMetadataEntries(MetadataDataUnit dataUnit)
        throws DataUnitException {
    final List<RDFDataUnit.Entry> result = new LinkedList<>();
    for (IRI graphName : dataUnit.getMetadataGraphnames()) {
        result.add(new RdfDataUnitUtils.InMemoryEntry(graphName, METADATA_GRAPH_SYMBOLIC_NAME));
    }
    return result;
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:16,代码来源:DataUnitUtils.java

示例8: innerExecute

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
@Override
protected void innerExecute() throws DPUException {
    // Prepare tabular convertor.
    final TableToRdf tableToRdf = new TableToRdf(
            config.getTableToRdfConfig(),
            rdfTableWrap,
            rdfTableWrap.getValueFactory());
    // Prepare parser based on type.
    final Parser parser;
    switch (config.getTableType()) {
        case CSV:
            parser = new ParserCsv(config.getParserCsvConfig(), tableToRdf, ctx);
            break;
        case DBF:
            parser = new ParserDbf(config.getParserDbfConfig(), tableToRdf, ctx);
            break;
        case XLS:
            parser = new ParserXls(config.getParserXlsConfig(), tableToRdf, ctx);
            break;
        default:
            throw ContextUtils.dpuException(this.ctx, "execution.errors.table.unknown", this.config.getXlsSheetName());
    }
    // Get files to process.
    final List<FilesDataUnit.Entry> files = FaultToleranceUtils.getEntries(faultTolerance, inFilesTable,
            FilesDataUnit.Entry.class);

    for (final FilesDataUnit.Entry entry : files) {
        if (ctx.canceled()) {
            throw ContextUtils.dpuExceptionCancelled(ctx);
        }
        // Set output graph.
        final RDFDataUnit.Entry entryOutput = faultTolerance.execute(new FaultTolerance.ActionReturn<RDFDataUnit.Entry>() {

            @Override
            public RDFDataUnit.Entry action() throws Exception {
                return RdfDataUnitUtils.addGraph(outRdfTables, entry.getSymbolicName());
            }
        });
        rdfTableWrap.setOutput(entryOutput);
        final String symbolicName = faultTolerance.execute(new FaultTolerance.ActionReturn<String>() {

            @Override
            public String action() throws Exception {
                return entry.getSymbolicName();
            }
        });

        ContextUtils.sendShortInfo(this.ctx, "dpu.execution.file.processing", symbolicName);
        // Output data.
        try {
            // If set add subject for the whole table.
            if (config.isUseTableSubject()) {
                // Prepare subject for table.
                // TODO: We can use better subject here!
                final IRI tableURI = faultTolerance.execute(new FaultTolerance.ActionReturn<IRI>() {

                    @Override
                    public IRI action() throws Exception {
                        return rdfTableWrap.getValueFactory().createIRI(entry.getFileURIString());
                    }
                });
                // Set as a table subject.
                tableToRdf.setTableSubject(tableURI);
                // Add metadata (symbolic name) to table subject.
                faultTolerance.execute(new FaultTolerance.Action() {

                    @Override
                    public void action() throws Exception {
                        rdfTableWrap.add(tableURI, TabularOntology.TABLE_SYMBOLIC_NAME,
                                rdfTableWrap.getValueFactory().createLiteral(entry.getSymbolicName()));
                    }
                });
            }
            // Parse file.
            parser.parse(FaultToleranceUtils.asFile(faultTolerance, entry));
        } catch (ParseFailed ex) {
            throw ContextUtils.dpuException(this.ctx, ex, "dpu.execution.errors.conversion.failed", entry);
        }
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:81,代码来源:Tabular.java

示例9: innerExecute

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
@Override
protected void innerExecute() throws DPUException {
    // Get list of input graphs.
    final List<RDFDataUnit.Entry> inputEntries = FaultToleranceUtils.getEntries(faultTolerance, rdfInput,
            RDFDataUnit.Entry.class);
    // Prepare output graph.
    final RDFDataUnit.Entry outputEntry = faultTolerance.execute(new FaultTolerance.ActionReturn<RDFDataUnit.Entry>() {

        @Override
        public RDFDataUnit.Entry action() throws Exception {
            return RdfDataUnitUtils.addGraph(rdfOutput, generateOutputSymbolicName());
        }
    });
    // Per-graph execution.
    int counter = 0;
    for (final RDFDataUnit.Entry entry : inputEntries) {
        LOG.info("Processing {}/{}", ++counter, inputEntries.size());
        faultTolerance.execute(rdfInput, new FaultTolerance.ConnectionAction() {

            @Override
            public void action(RepositoryConnection connection) throws Exception {
                final SparqlUtils.SparqlUpdateObject update =
                        SparqlUtils.createInsert(COPY_QUERY, Arrays.asList(entry), outputEntry);
                // Copy statementes.
                SparqlUtils.execute(connection, update);
            }
        });
    }
    faultTolerance.execute(new FaultTolerance.ActionReturn<Boolean>() {

        @Override
        public Boolean action() throws Exception {
            Resource resource = ResourceHelpers.getResource(rdfOutput, outputEntry.getSymbolicName());
            Date now = new Date();
            resource.setLast_modified(now);
            resource.setCreated(now);
            ResourceHelpers.setResource(rdfOutput, outputEntry.getSymbolicName(), resource);
            if (config.getVirtualGraph() != null) {
                VirtualGraphHelpers.setVirtualGraph(rdfOutput, outputEntry.getSymbolicName(), config.getVirtualGraph().toString());
            }
            return Boolean.TRUE;
        }
    });
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:45,代码来源:RdfGraphMerger.java

示例10: getWritableMetadataEntry

import eu.unifiedviews.helpers.dataunit.rdf.RdfDataUnitUtils; //导入依赖的package包/类
/**
 * Provide access to metadata in the same form as to any other graph. This graph can be used to write
 * operation but it should be used with caution.
 *
 * @param dataUnit
 * @return
 * @throws DataUnitException
 */
public static RDFDataUnit.Entry getWritableMetadataEntry(WritableMetadataDataUnit dataUnit) 
        throws DataUnitException {
    return new RdfDataUnitUtils.InMemoryEntry(dataUnit.getMetadataWriteGraphname(),
            WRITABLE_METADATA_GRAPH_SYMBOLIC_NAME);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:14,代码来源:DataUnitUtils.java


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