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