001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.extraction.execution.pipeline;
017
018import java.io.OutputStream;
019import java.util.List;
020import java.util.Map;
021
022import org.ametys.plugins.extraction.execution.ExtractionExecutor;
023import org.ametys.plugins.extraction.execution.PathResolver;
024import org.ametys.runtime.i18n.I18nizableText;
025
026/**
027 * A descriptor which can provide a {@link Pipeline} with {@link #newPipeline(OutputStream) newPipeline} method.
028 */
029public interface PipelineDescriptor
030{
031    /**
032     * Gets the label
033     * @return the label
034     */
035    I18nizableText getLabel();
036    
037    /**
038     * Gets the XSLT file names to chain
039     * @return the XSLT file names to chain
040     */
041    List<String> getStylesheets();
042    
043    /**
044     * Gets the {@link PipelineSerializerModel serializer model}
045     * @return the {@link PipelineSerializerModel serializer model}
046     */
047    PipelineSerializerModel getSerializerModel();
048    
049    /**
050     * Gets the result subfolder (or file). 
051     * <br>Can contain variables (see {@link PathResolver}), resolved against the extraction results.
052     * <br>If it returns
053     * <ul>
054     * <li>a file path without variable, then all extraction results will be in this file;</li>
055     * <li>a file path with variables, then extraction results will be dispatched in the resolved file paths;</li>
056     * <li>
057     * a folder path without variable, then all extraction results will be in one file under this folder 
058     * (the file name will be the one provided in <code>defaultResultFileName</code> parameter 
059     * of {@link ExtractionExecutor#execute(String, String, String, java.util.Map, PipelineDescriptor) ExtractionExecutor#execute method});
060     * </li>
061     * <li>
062     * a folder path with variables, then each first level content extraction result will be dispatched in one file under the resolved folders
063     * (the file name will be the <b>title</b> of the content, and the extension is the return of {@link #getDefaultExtension()});
064     * </li>
065     * </ul>
066     * @return the result subfolder (or file)
067     */
068    String getResultSubfolder();
069    
070    /**
071     * Gets the default extension of the file result(s)
072     * <br>The default extension is used when {@link #getResultSubfolder()} is a folder and not a file.
073     * @return the default extension of the file result(s)
074     */
075    String getDefaultExtension();
076    
077    /**
078     * Provides a new {@link Pipeline}
079     * @param out the output stream to write on
080     * @return the built {@link Pipeline}
081     */
082    Pipeline newPipeline(OutputStream out);
083    
084    /**
085     * Get the output parameters to add some specific features in each serializer.
086     * @return The output parameters
087     */
088    Map<String, String> getOutputParameters();
089}