當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。