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.version; 017 018import java.time.Instant; 019import java.util.Map; 020 021import org.ametys.core.migration.action.data.ActionData; 022 023/** 024 * Representation of a version 025 * Each upgrade create a new version 026 */ 027public interface Version 028{ 029 /** 030 * Get the version handler ID of this version 031 * @return The version handler ID of this version 032 */ 033 public String getVersionHandlerId(); 034 035 /** 036 * Get the component id 037 * @return The component id 038 */ 039 public String getComponentId(); 040 041 /** 042 * Get the number of the version (null means that initialization is needed) 043 * @return The number of the version 044 */ 045 public String getVersionNumber(); 046 047 /** 048 * Set the number of the version 049 * Should only be used in initialization actions, so the version contains the version to reach, not the version to start (which should be null in the case of initialization) 050 * @param number number to set for this version 051 */ 052 public void setVersionNumber(String number); 053 054 /** 055 * Get the time when the version was created 056 * @return The time when the version was created 057 */ 058 public Instant getExecutionInstant(); 059 060 /** 061 * Set the execution date of this version (only to be used when creating a new version after cloning an old version) 062 * @param executionInstant instant to set 063 */ 064 public void setExecutionInstant(Instant executionInstant); 065 066 /** 067 * Get the comment about this version 068 * @return The comment about this version 069 */ 070 public String getComment(); 071 072 /** 073 * Change the comment of the version 074 * @param comment comment to set 075 */ 076 public void setComment(String comment); 077 078 /** 079 * Copy the {@link Version} object but only specific fields and componentId 080 * @param actionData The action data which inside there is the version to copy and the data to keep 081 * @return A copy of the {@link Version} object 082 */ 083 public Version copyFromActionData(ActionData actionData); 084 085 /** 086 * Add a parameter that will be replaced in the script with the value 087 * @param key key to replace 088 * @param value value that will be inserted 089 * @return the previous value associated with key, or null if there was no mapping for key. 090 */ 091 public Object addAdditionalValue(String key, Object value); 092 093 /** 094 * Get the map of values to replace in the script 095 * @return the map of keys to replace in the script 096 */ 097 public Map<String, Object> getAdditionalValues(); 098}