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        setDisplayOptionalColumns(context.getDisplayOptionalColumns());
048        
049        setHierarchyElements(context.getHierarchyElements());
050    }
051    
052    /**
053     * Set the default locale for this context of extraction
054     * The default locale is used for export of localized values such as multilingual strings or contents.
055     * @param defaultLocale the default locale
056     */
057    public void setDefaultLocale(Locale defaultLocale)
058    {
059        _defaultLocale = defaultLocale;
060    }
061    
062    /**
063     * Get the default locale for this context of extraction
064     * @return the default locale. Can be null.
065     */
066    public Locale getDefaultLocale()
067    {
068        return _defaultLocale;
069    }
070
071    /**
072     * Retrieves the variables controlling display of optional columns
073     * @return The variables controlling display of optional columns
074     */
075    public Map<String, Boolean> getDisplayOptionalColumns()
076    {
077        return _displayOptionalColumns;
078    }
079    
080    /**
081     * Sets the variables controlling display of optional columns
082     * @param displayOptionalColumns The variables to set
083     */
084    public void setDisplayOptionalColumns(Map<String, Boolean> displayOptionalColumns)
085    {
086        _displayOptionalColumns = displayOptionalColumns;
087    }
088
089    /**
090     * Retrieves the variables to use in queries
091     * @return the variables to use in queries
092     */
093    public Map<String, List<String>> getClauseVariables()
094    {
095        return _clauseVariables;
096    }
097    
098    /**
099     * Sets the variables to use in queries
100     * @param clauseVariables the variables to set
101     */
102    public void setClauseVariables(Map<String, List<String>> clauseVariables)
103    {
104        _clauseVariables = clauseVariables;
105    }
106    
107    /**
108     * Retrieves the parents elements of the context
109     * @return the elements of the context
110     */
111    public List<ExtractionExecutionContextHierarchyElement> getHierarchyElements()
112    {
113        return _hierarchyElements;
114    }
115    
116    /**
117     * Sets the parents elements of the context
118     * @param hierarchyElements the hierarchy elements to set
119     */
120    public void setHierarchyElements(List<ExtractionExecutionContextHierarchyElement> hierarchyElements)
121    {
122        _hierarchyElements = hierarchyElements;
123    }
124    
125}