001/*
002 *  Copyright 2020 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.core.migration.action.data.impl;
017
018import org.apache.avalon.framework.configuration.Configuration;
019import org.apache.avalon.framework.configuration.ConfigurationException;
020
021import org.ametys.core.migration.version.Version;
022
023/**
024 * Data for upgrade done by initialization
025 */
026public class SqlInitializationActionData extends SqlUpgradeActionData
027{
028    /**
029     * Table to check to verify if the upgrade is needed
030     */
031    protected String _tableToCheck;
032    
033    /**
034     * Same constructor as {@link AbstractActionData}
035     * @param versionNumber version number of the version
036     * @param version version concerned by this upgrade
037     * @param comment Comment about this action
038     * @param from if this actions is the equivalent of multiple actions, this is the version id just before the 1st action impacted by this action
039     * @param type type of action
040     * @param pluginName name of the plugin
041     * @param configuration configuration of the initialization
042     * @param restartRequired true if a restart is required after the action
043     * @throws ConfigurationException id or type missing
044     */
045    public SqlInitializationActionData(String versionNumber, Version version, String comment, String from, String type, String pluginName, Configuration configuration, boolean restartRequired) throws ConfigurationException
046    {
047        super(versionNumber, version, comment, from, type, pluginName, configuration, restartRequired);
048        _tableToCheck = configuration.getAttribute("table", null);
049    }
050    
051    /**
052     * Get the table that will need to be tested before the initialization is executed
053     * @return The table that will need to be tested before the initialization is executed
054     */
055    public String getTable()
056    {
057        return _tableToCheck;
058    }
059}