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.Map;
022
023import org.ametys.core.user.UserIdentity;
024import org.ametys.plugins.extraction.component.ExtractionComponent;
025
026/**
027 * Object representing the extraction definition file content
028 */
029public class Extraction
030{    
031    /**
032     * Rights profiles
033     */
034    public enum ExtractionProfile
035    {
036        /** Read access */
037        READ_ACCESS,
038        /** Write access */
039        WRITE_ACCESS,
040        /** Right access */
041        RIGHT_ACCESS;
042        
043        @Override
044        public String toString()
045        {
046            return name().toLowerCase();
047        }
048        
049    }
050    
051    private String _descriptionId;
052    private List<ExtractionComponent> _extractionComponents;
053    private List<String> _displayOptionalColumnsNames;
054    private Map<String, String> _queryVariablesNamesAndContentTypes;
055    private UserIdentity _author;
056    
057    /**
058     * Retrieves the identifier of the extraction's description
059     * @return the identifier of the extraction's description
060     */
061    public String getDescriptionId()
062    {
063        return _descriptionId;
064    }
065    
066    /**
067     * Set the identifier of the extraction's description
068     * @param descriptionId the identifier to set
069     */
070    public void setDescriptionId(String descriptionId)
071    {
072        _descriptionId = descriptionId;
073    }
074    
075    /**
076     * Retrieves the list of the extraction components
077     * @return The extraction components 
078     */
079    public List<ExtractionComponent> getExtractionComponents()
080    {
081        return null != _extractionComponents ? _extractionComponents : new ArrayList<>();
082    }
083    
084    /**
085     * Add an extraction component 
086     * @param extractionComponent The extraction component to add
087     */
088    public void addExtractionComponent(ExtractionComponent extractionComponent)
089    {
090        if (null == _extractionComponents)
091        {
092            _extractionComponents = new ArrayList<>();
093        }
094        _extractionComponents.add(extractionComponent);
095    }
096    
097    /**
098     * Retrieves the list of variables names controlling display of optional columns
099     * @return The variables names
100     */
101    public List<String> getDisplayOptionalColumnsNames()
102    {
103        return null != _displayOptionalColumnsNames ? _displayOptionalColumnsNames : new ArrayList<>();
104    }
105    
106    /**
107     * Set variables names controlling display of optional columns
108     * @param displayOptionalColumnsNames the variables for the optional columns to set
109     */
110    public void setDisplayOptionalColumnsNames(List<String> displayOptionalColumnsNames)
111    {
112        _displayOptionalColumnsNames = displayOptionalColumnsNames;
113    }
114    
115    /**
116     * Retrieves the list of variables names and content type to use in queries
117     * @return A Map containing variables names and content types
118     */
119    public Map<String, String> getQueryVariablesNamesAndContentTypes()
120    {
121        return null != _queryVariablesNamesAndContentTypes ? _queryVariablesNamesAndContentTypes : new HashMap<>();
122    }
123    
124    /**
125     * Set variables names and content types to use in queries
126     * @param queryVariablesNamesAndContentTypes A Map containing variables names and content types to set
127     */
128    public void setQueryVariablesNamesAndContentTypes(Map<String, String> queryVariablesNamesAndContentTypes)
129    {
130        _queryVariablesNamesAndContentTypes = queryVariablesNamesAndContentTypes;
131    }
132
133    /**
134     * Get the author of the extraction
135     * @return The author
136     */
137    public UserIdentity getAuthor ()
138    {
139        return _author;
140    }
141    
142    /**
143     * Set the author of this extraction.
144     * @param author the author
145     */
146    public void setAuthor(UserIdentity author)
147    {
148        _author = author;
149    }
150}