1 /* 2 * Copyright (c) 2002-2017, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.plugins.updatercatalog.business; 35 36 import java.util.ArrayList; 37 import java.util.List; 38 39 40 /** 41 * This is the business class for the object PluginRelease 42 */ 43 public class PluginRelease implements Comparable 44 { 45 // Variables declarations 46 private int _nIdRelease; 47 private String _strPluginName; 48 private String _strPluginVersion; 49 private String _strUrlDownload; 50 private String _strCoreVersionMin; 51 private String _strCoreVersionMax; 52 private List<ReleaseUpgrade> _listUpgrades = new ArrayList<ReleaseUpgrade>( ); 53 54 /** 55 * Returns the IdRelease 56 * @return The IdRelease 57 */ 58 public int getId( ) 59 { 60 return _nIdRelease; 61 } 62 63 /** 64 * Sets the IdRelease 65 * @param nIdRelease The IdRelease 66 */ 67 public void setId( int nIdRelease ) 68 { 69 _nIdRelease = nIdRelease; 70 } 71 72 /** 73 * Returns the PluginName 74 * @return The PluginName 75 */ 76 public String getPluginName( ) 77 { 78 return _strPluginName; 79 } 80 81 /** 82 * Sets the PluginName 83 * @param strPluginName The PluginName 84 */ 85 public void setPluginName( String strPluginName ) 86 { 87 _strPluginName = strPluginName; 88 } 89 90 /** 91 * Returns the PluginVersion 92 * @return The PluginVersion 93 */ 94 public String getPluginVersion( ) 95 { 96 return _strPluginVersion; 97 } 98 99 /** 100 * Sets the PluginVersion 101 * @param strPluginVersion The PluginVersion 102 */ 103 public void setPluginVersion( String strPluginVersion ) 104 { 105 _strPluginVersion = strPluginVersion; 106 } 107 108 /** 109 * Returns the UrlDownload 110 * @return The UrlDownload 111 */ 112 public String getUrlDownload( ) 113 { 114 return _strUrlDownload; 115 } 116 117 /** 118 * Sets the UrlDownload 119 * @param strUrlDownload The UrlDownload 120 */ 121 public void setUrlDownload( String strUrlDownload ) 122 { 123 _strUrlDownload = strUrlDownload; 124 } 125 126 /** 127 * Returns the CoreVersionMin 128 * @return The CoreVersionMin 129 */ 130 public String getCoreVersionMin( ) 131 { 132 return _strCoreVersionMin; 133 } 134 135 /** 136 * Sets the CoreVersionMin 137 * @param strCoreVersionMin The CoreVersionMin 138 */ 139 public void setCoreVersionMin( String strCoreVersionMin ) 140 { 141 _strCoreVersionMin = strCoreVersionMin; 142 } 143 144 /** 145 * Returns the CoreVersionMax 146 * @return The CoreVersionMax 147 */ 148 public String getCoreVersionMax( ) 149 { 150 return _strCoreVersionMax; 151 } 152 153 /** 154 * Sets the CoreVersionMax 155 * @param strCoreVersionMax The CoreVersionMax 156 */ 157 public void setCoreVersionMax( String strCoreVersionMax ) 158 { 159 _strCoreVersionMax = strCoreVersionMax; 160 } 161 162 /** 163 * Add an upgrade to the release 164 * @param upgrade The upgrade to add 165 */ 166 void addUpgrade( ReleaseUpgrade upgrade ) 167 { 168 _listUpgrades.add( upgrade ); 169 } 170 171 /** 172 * Gets upgrades from the release 173 * @return The list of upgrades 174 */ 175 public List<ReleaseUpgrade> getUpgrades( ) 176 { 177 return _listUpgrades; 178 } 179 180 /** 181 * Compare deux plugins releases in order to sort them 182 * @param o The Plugin to compare 183 * @return The comparaison 184 */ 185 public int compareTo( Object o ) 186 { 187 PluginRelease plugin = (PluginRelease) o; 188 189 int nCompare = getPluginName( ).compareTo( plugin.getPluginName( ) ); 190 191 if ( nCompare == 0 ) 192 { 193 nCompare = getPluginVersion( ).compareTo( plugin.getPluginVersion( ) ); 194 } 195 196 return nCompare; 197 } 198 }