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


Java FilesDataUnit类代码示例

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


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

示例1: zipFiles

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
/**
 * Pack files in given iterator into zip file and add metadata.
 *
 * @param zipFile
 * @param filesIteration
 */
private void zipFiles(File zipFile, List<FilesDataUnit.Entry> filesIteration) throws DPUException {
    final byte[] buffer = new byte[8196];
    // Used to publish the error mesage only for the first time.
    boolean firstFailure = true;
    try (FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = new ZipOutputStream(fos)) {
        // Itarate over files and zip them.
        int counter = 0;
        for (FilesDataUnit.Entry entry : filesIteration) {
            LOG.info("Processing: {}/{}", counter++, filesIteration.size());
            if (ctx.canceled()) {
                break;
            }
            if (!addZipEntry(zos, buffer, entry)) {
                if (firstFailure) {
                    // TODO This needs rework, we fail but not instantly?
                    ContextUtils.sendError(ctx, "zipper.errors.zip.failed", "");
                }
                firstFailure = false;
            }
        }
    } catch (IOException ex) {
        throw new DPUException(ex);
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:31,代码来源:Zipper.java

示例2: assertInputOutputIdentical

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
private void assertInputOutputIdentical() throws Exception {
    List<FilesDataUnit.Entry> inputList = new ArrayList<FilesDataUnit.Entry>(FilesHelper.getFiles(input));
    List<FilesDataUnit.Entry> outputList = new ArrayList<FilesDataUnit.Entry>(FilesHelper.getFiles(outputValid));

    Collections.sort(inputList, new SymbolicNameComparator());
    Collections.sort(outputList, new SymbolicNameComparator());

    // iterate over files
    Iterator<FilesDataUnit.Entry> inputIterator = inputList.iterator();
    Iterator<FilesDataUnit.Entry> outputIterator = outputList.iterator();

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

        // verify result
        assertEquals(inputContents, outputContents);
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:20,代码来源:FilterValidXmlTest.java

示例3: checkCorrectOutputFileExtension

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void checkCorrectOutputFileExtension() throws Exception {
    addFileToInput("valid-for-xslt.xml");

    XSLTConfig_V1 config = new XSLTConfig_V1();
    config.setXslTemplate(resourceAsString("produce-list.xslt"));
    config.setOutputFileExtension(".extension");
    dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

    env.run(dpu);

    VirtualPathHelper helper = VirtualPathHelpers.create(output);
    List<FilesDataUnit.Entry> outputList = new ArrayList<>(FilesHelper.getFiles(output));
    Iterator<FilesDataUnit.Entry> outputIterator = outputList.iterator();

    while (outputIterator.hasNext()) {
        String symbolicName = outputIterator.next().getSymbolicName();
        assertEquals("symbolicName-test.extension", helper.getVirtualPath(symbolicName));
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:21,代码来源:XsltTest.java

示例4: getUpdateQueryString

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
private static String getUpdateQueryString() {
    StringBuilder sb = new StringBuilder();
    sb.append("DELETE ");
    sb.append("{ ");
    sb.append("?s <" + FilesDataUnit.PREDICATE_FILE_URI + "> ?o ");
    sb.append("} ");
    sb.append("INSERT ");
    sb.append("{ ");
    sb.append("?s <" + RDFDataUnit.PREDICATE_DATAGRAPH_URI + "> ?" + DATA_GRAPH_BINDING + " ");
    sb.append("} ");
    sb.append("WHERE ");
    sb.append("{");
    sb.append("?s <" + MetadataDataUnit.PREDICATE_SYMBOLIC_NAME + "> ?" + SYMBOLIC_NAME_BINDING + " . ");
    sb.append("?s <" + FilesDataUnit.PREDICATE_FILE_URI + "> ?o ");
    sb.append("}");
    return sb.toString();
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:18,代码来源:FilesToRDF.java

示例5: prepareInputFiles

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
private File prepareInputFiles() {
    File filesToProcessList = null;
    FileWriter writer = null;
    try {
        filesToProcessList = new File(new File(URI.create(filesOutput.getBaseFileURIString())), "filesList.txt");
        writer = new FileWriter(filesToProcessList, true);
        FilesDataUnit.Iteration iteration = filesInput.getIteration();
        while (iteration.hasNext()) {
            File inpF = FilesDataUnitUtils.asFile(iteration.next());
            writer.write(inpF.getAbsolutePath() + "\n");
        }
    } catch (DataUnitException | IOException ex) {
        LOG.error("Error preparing input files.", ex);
    } finally {
        IOUtils.closeQuietly(writer);
    }
    return filesToProcessList;
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:ExecuteShellScript.java

示例6: GETRequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void GETRequestTest() throws Exception {
    HttpRequestConfig_V1 config = createGetRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(GET_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例7: DELETERequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void DELETERequestTest() throws Exception {
    HttpRequestConfig_V1 config = createDeleteRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(DELETE_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例8: rawPOSTRequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void rawPOSTRequestTest() throws Exception {
    HttpRequestConfig_V1 config = createPostRawRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(POST_RAW_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例9: rawPUTRequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void rawPUTRequestTest() throws Exception {
    HttpRequestConfig_V1 config = createPutRawRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(POST_RAW_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例10: multipartPOSTRequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void multipartPOSTRequestTest() throws Exception {
    HttpRequestConfig_V1 config = createPostMultipartRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(POST_MULTIPART_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例11: multipartPUTRequestTest

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Test
public void multipartPUTRequestTest() throws Exception {
    HttpRequestConfig_V1 config = createPutMultipartRequestConfig();

    URI sentResponse = this.getClass().getClassLoader().getResource(POST_MULTIPART_RESPONSE_FILE).toURI();
    String sentResponseContent = readFile(new File(sentResponse));

    this.dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());
    HttpRequestExecutor executor = mockHttpExecutorWithResponses(config);
    this.dpu.setRequestExecutor(executor);
    this.env.run(this.dpu);

    FilesDataUnit.Entry entry = this.output.getIteration().next();
    File receivedResponse = new File(URI.create(entry.getFileURIString()));
    String receivedResponseContent = readFile(receivedResponse);

    assertEquals(sentResponseContent, receivedResponseContent);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:19,代码来源:HttpRequestTest.java

示例12: generateGraphFile

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
/**
 * Check if file graph should be generated and if so, then generate new graph file.
 * 
 * @param rdfFile
 * @param graphName
 *            Name of the graph, that will be written into .graph file.
 * @throws DPUException
 */
private void generateGraphFile(final FilesDataUnit.Entry rdfFile, String graphName) throws DPUException {
    final FilesDataUnit.Entry graphFileEntry = faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

        @Override
        public FilesDataUnit.Entry action() throws Exception {
            final String rdfFilePath = MetadataUtils.get(inRdfData, rdfFile, FilesVocabulary.UV_VIRTUAL_PATH);
            return FilesDataUnitUtils.createFile(outFilesData, rdfFilePath + ".graph");
        }
    });
    try {
        FileUtils.writeStringToFile(FaultToleranceUtils.asFile(faultTolerance, graphFileEntry), graphName);
    } catch (IOException ex) {
        throw ContextUtils.dpuException(ctx, ex, "rdfToFiles.error.graphFile");
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:24,代码来源:RdfToFiles.java

示例13: innerExecute

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
@Override
protected void innerExecute() throws DPUException {

    ContextUtils.sendShortInfo(ctx, "ExcelToCsv.message");

    try {
        sheetNameSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); // case-insensitive sheet names
        String sheetNames = config.getSheetNames();
        if (sheetNames != null && sheetNames.length() > 0) {
            sheetNameSet.addAll(Arrays.asList(sheetNames.split(Pattern.quote(":"))));
        }

        Set<FilesDataUnit.Entry> entries = FilesHelper.getFiles(input);
        for (FilesDataUnit.Entry entry : entries) {
            excelToCsv(entry);
        }
    } catch (DataUnitException | EncryptedDocumentException | InvalidFormatException | IOException ex) {
        throw ContextUtils.dpuException(ctx, ex, "ExcelToCsv.dpuFailed");
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:21,代码来源:ExcelToCsv.java

示例14: getFilesMap

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
/**
 * Gets file entries from the given {@link eu.unifiedviews.dataunit.files.FilesDataUnit}.
 * This method internally iterates over entries in the {@link eu.unifiedviews.dataunit.files.FilesDataUnit} and stores the entries into one {@link Map} of
 * entries.
 * Only suitable for ~10000 of entries (files) in the given {@link eu.unifiedviews.dataunit.files.FilesDataUnit}, because all entries are stored into a
 * {@link Set}. For bigger amounts of files, it is better to directly use {@link eu.unifiedviews.dataunit.files.FilesDataUnit.Iteration} to iterate over the
 * files and directly process them.
 * 
 * @param filesDataUnit
 *            data unit from which the entries are fetched
 * @return {@link Map} containing all entries in the given data unit, keys are symbolic names
 * @throws DataUnitException
 */
public static Map<String, FilesDataUnit.Entry> getFilesMap(FilesDataUnit filesDataUnit) throws DataUnitException {
    if (filesDataUnit == null) {
        return new LinkedHashMap<>();
    }
    FilesDataUnit.Iteration iteration = filesDataUnit.getIteration();
    Map<String, FilesDataUnit.Entry> resultSet = new LinkedHashMap<>();
    try {
        while (iteration.hasNext()) {
            FilesDataUnit.Entry entry = iteration.next();
            resultSet.put(entry.getSymbolicName(), entry);
        }
    } finally {
        iteration.close();
    }
    return resultSet;
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:30,代码来源:FilesHelper.java

示例15: getFiles

import eu.unifiedviews.dataunit.files.FilesDataUnit; //导入依赖的package包/类
/**
 * Gets file entries from the given {@link eu.unifiedviews.dataunit.files.FilesDataUnit}.
 * This method internally iterates over entries in the {@link eu.unifiedviews.dataunit.files.FilesDataUnit} and stores the entries into one {@link Set} of
 * entries.
 * Only suitable for ~10000 of entries (files) in the given {@link eu.unifiedviews.dataunit.files.FilesDataUnit}, because all entries are stored into a
 * {@link Set}. For bigger amounts of files, it is better to directly use {@link eu.unifiedviews.dataunit.files.FilesDataUnit.Iteration} to iterate over the
 * files and directly process them.
 * 
 * @param filesDataUnit
 *            data unit from which the entries are fetched
 * @return {@link Set} containing all entries in the given data unit
 * @throws DataUnitException
 */
public static Set<FilesDataUnit.Entry> getFiles(FilesDataUnit filesDataUnit) throws DataUnitException {
    if (filesDataUnit == null) {
        return new LinkedHashSet<>();
    }
    FilesDataUnit.Iteration iteration = filesDataUnit.getIteration();
    Set<FilesDataUnit.Entry> resultSet = new LinkedHashSet<>();
    try {
        while (iteration.hasNext()) {
            FilesDataUnit.Entry entry = iteration.next();
            resultSet.add(entry);
        }
    } finally {
        iteration.close();
    }
    return resultSet;
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:30,代码来源:FilesHelper.java


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