001/*
002 *  Copyright 2017 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;
017
018import java.util.ArrayList;
019import java.util.HashMap;
020import java.util.List;
021import java.util.Locale;
022import java.util.Map;
023
024/**
025 * Context of extraction components execution
026 */
027public class ExtractionExecutionContext
028{
029    private Map<String, Boolean> _displayOptionalColumns = new HashMap<>();
030    private Map<String, List<String>> _clauseVariables = new HashMap<>();
031    private List<ExtractionExecutionContextHierarchyElement> _hierarchyElements = new ArrayList<>();
032    private Locale _defaultLocale;
033    
034    /**
035     * Default constructor
036     */
037    public ExtractionExecutionContext()
038    {
039    }
040    
041    /**
042     * Creates a context by copy
043     * @param context context to copy
044     */
045    public ExtractionExecutionContext(ExtractionExecutionContext context)
046    {
047        setDefaultLocale(context.getDefaultLocale());
048        setDisplayOptionalColumns(context.getDisplayOptionalColumns());
049        setClauseVariables(context.getClauseVariables());
050        setHierarchyElements(context.getHierarchyElements());
051    }
052    
053    /**
054     * Set the default locale for this context of extraction
055     * The default locale is used for export of localized values such as multilingual strings or contents.
056     * @param defaultLocale the default locale
057     */
058    public void setDefaultLocale(Locale defaultLocale)
059    {
060        _defaultLocale = defaultLocale;
061    }
062    
063    /**
064     * Get the default locale for this context of extraction
065     * @return the default locale. Can be null.
066     */
067    public Locale getDefaultLocale()
068    {
069        return _defaultLocale;
070    }
071
072    /**
073     * Retrieves the variables controlling display of optional columns
074     * @return The variables controlling display of optional columns
075     */
076    public Map<String, Boolean> getDisplayOptionalColumns()
077    {
078        return _displayOptionalColumns;
079    }
080    
081    /**
082     * Sets the variables controlling display of optional columns
083     * @param displayOptionalColumns The variables to set
084     */
085    public void setDisplayOptionalColumns(Map<String, Boolean> displayOptionalColumns)
086    {
087        _displayOptionalColumns = displayOptionalColumns;
088    }
089
090    /**
091     * Retrieves the variables to use in queries
092     * @return the variables to use in queries
093     */
094    public Map<String, List<String>> getClauseVariables()
095    {
096        return _clauseVariables;
097    }
098    
099    /**
100     * Sets the variables to use in queries
101     * @param clauseVariables the variables to set
102     */
103    public void setClauseVariables(Map<String, List<String>> clauseVariables)
104    {
105        _clauseVariables = clauseVariables;
106    }
107    
108    /**
109     * Retrieves the parents elements of the context
110     * @return the elements of the context
111     */
112    public List<ExtractionExecutionContextHierarchyElement> getHierarchyElements()
113    {
114        return _hierarchyElements;
115    }
116    
117    /**
118     * Sets the parents elements of the context
119     * @param hierarchyElements the hierarchy elements to set
120     */
121    public void setHierarchyElements(List<ExtractionExecutionContextHierarchyElement> hierarchyElements)
122    {
123        _hierarchyElements = hierarchyElements;
124    }
125    
126}