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.odfsync.cdmfr.components;
017
018import java.io.InputStream;
019import java.util.List;
020import java.util.Map;
021import java.util.Set;
022
023import org.apache.cocoon.ProcessingException;
024import org.slf4j.Logger;
025
026import org.ametys.plugins.repository.query.expression.Expression;
027
028/**
029 * Interface for component to import a CDM-fr input stream.
030 */
031public interface ImportCDMFrComponent
032{
033    /** Avalon Role */
034    public static final String ROLE = ImportCDMFrComponent.class.getName();
035
036    /**
037     * Return the metadata identifier for CDM-fr synchronization.
038     * @return The metadata name (cdmfrSyncCode)
039     */
040    public String getIdField();
041
042    /**
043     * Get the path of tri-state fields (with local and external values)
044     * @param additionalParameters Additional parameters
045     * @return the synchronized fields
046     */
047    public Set<String> getLocalAndExternalFields(Map<String, Object> additionalParameters);
048    
049
050    /**
051     * Handle the CDM-fr input stream to import all the programs and its dependencies containing into it.
052     * @param input The CDM-fr input stream
053     * @param parameters The parameters useful for the operation
054     * @param logger The logger
055     * @return The list of imported/synchronized programs
056     * @throws ProcessingException If an error occurs
057     */
058    public Map<String, Object> handleInputStream(InputStream input, Map<String, Object> parameters, Logger logger) throws ProcessingException;
059
060    /**
061     * Construct the query to retrieve the content.
062     * @param lang Lang
063     * @param idValue Synchronization value
064     * @param contentType Content type
065     * @param catalog The catalog
066     * @return The {@link List} of {@link Expression}
067     */
068    public List<Expression> getExpressionsList(String lang, String idValue, String contentType, String catalog);
069}