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.impl; 017 018import java.io.OutputStream; 019import java.util.Collections; 020import java.util.List; 021import java.util.Map; 022 023import org.ametys.plugins.extraction.ExtractionConstants; 024import org.ametys.plugins.extraction.execution.pipeline.ExtractionMatcher; 025import org.ametys.plugins.extraction.execution.pipeline.Pipeline; 026import org.ametys.plugins.extraction.execution.pipeline.PipelineDescriptor; 027import org.ametys.plugins.extraction.execution.pipeline.PipelineSerializerModel; 028import org.ametys.runtime.i18n.I18nizableText; 029 030/** 031 * Basic implementation of {@link PipelineDescriptor}, with no XSLT and a XML serializer. 032 */ 033public class NoOpPipelineDescriptor implements PipelineDescriptor 034{ 035 private PipelineSerializerModel _xmlSerializer; 036 037 /** 038 * Default constructor 039 * @param xmlSerializer The XML descriptor serializer for the pipelines 040 */ 041 public NoOpPipelineDescriptor(PipelineSerializerModel xmlSerializer) 042 { 043 _xmlSerializer = xmlSerializer; 044 } 045 046 @Override 047 public I18nizableText getLabel() 048 { 049 return new I18nizableText(ExtractionConstants.PLUGIN_NAME, "PLUGINS_EXTRACTION_EXECUTE_EXTRACTION_DEFAULT_PIPELINE_LABEL"); 050 } 051 052 @Override 053 public ExtractionMatcher getExtractionMatcher() 054 { 055 return new AllExtractionMatcher(); 056 } 057 058 @Override 059 public List<String> getStylesheets() 060 { 061 return Collections.emptyList(); 062 } 063 064 @Override 065 public PipelineSerializerModel getSerializerModel() 066 { 067 return _xmlSerializer; 068 } 069 070 @Override 071 public String getResultSubfolder() 072 { 073 return ""; // root folder 074 } 075 076 @Override 077 public String getDefaultExtension() 078 { 079 return _xmlSerializer.getDefaultFileExtension(); 080 } 081 082 @Override 083 public Pipeline newPipeline(OutputStream out) 084 { 085 return new PipelineImpl(this, out, null/*we can pass null as xslt list is empty*/); 086 } 087 088 @Override 089 public Map<String, String> getOutputParameters() 090 { 091 return Collections.emptyMap(); 092 } 093}