Coverage Report - fr.paris.lutece.plugins.releaser.business.Component
 
Classes in this File Line Coverage Branch Coverage Complexity
Component
21 %
17/79
0 %
0/16
1,16
 
 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.releaser.business;
 35  
 
 36  
 import java.util.List;
 37  
 
 38  
 import com.sun.jna.platform.win32.OaIdl.CURRENCY._CURRENCY;
 39  
 
 40  
 import fr.paris.lutece.plugins.releaser.util.ConstanteUtils;
 41  
 import fr.paris.lutece.plugins.releaser.util.version.Version;
 42  
 import fr.paris.lutece.portal.service.i18n.I18nService;
 43  
 
 44  
 /**
 45  
  * This is the business class for the object Component
 46  
  */
 47  2
 public class Component
 48  
 {
 49  
     // Variables declarations
 50  
     private String _strArtifactId;
 51  
     private String _strGroupId;
 52  
     private String _strType;
 53  
     private String _strCurrentVersion;
 54  
     private String _strTargetVersion;
 55  
     private String _strLastAvailableVersion;
 56  
     private String _strLastAvailableSnapshotVersion;
 57  
     private String _strNextSnapshotVersion;
 58  
     private String _strReleaseComment;
 59  
     private String _strDescription; 
 60  
     private boolean _bIsProject;
 61  
     private String _strJiraCode;
 62  
     private String _strJiraRoadmapUrl;
 63  
     private int _nJiraCurrentVersionClosedIssues;
 64  
     private int _nJiraCurrentVersionOpenedIssues;   
 65  
     private List<String> _listTargetVersions;
 66  
     private int _nTargetVersionIndex;
 67  
     private boolean _bDowngrade;
 68  
     private boolean _bUpgrade;
 69  
     private boolean _bErrorLastRelease;
 70  
     private String _strName;
 71  
     private String _strCloneUrl;
 72  
     private String _strFullName;
 73  
     
 74  
     
 75  
     
 76  
     
 77  
     private String _strScmDeveloperConnection;
 78  
    
 79  
     
 80  
         
 81  
 
 82  
     /**
 83  
      * Returns the ArtifactId
 84  
      * 
 85  
      * @return The ArtifactId
 86  
      */
 87  
     public String getArtifactId( )
 88  
     {
 89  2
         return _strArtifactId;
 90  
     }
 91  
 
 92  
     /**
 93  
      * Sets the ArtifactId
 94  
      * 
 95  
      * @param strArtifactId
 96  
      *            The ArtifactId
 97  
      */
 98  
     public void setArtifactId( String strArtifactId )
 99  
     {
 100  2
         _strArtifactId = strArtifactId;
 101  2
     }
 102  
 
 103  
     /**
 104  
      * Returns the GroupId
 105  
      * 
 106  
      * @return The GroupId
 107  
      */
 108  
     public String getGroupId( )
 109  
     {
 110  0
         return _strGroupId;
 111  
     }
 112  
 
 113  
     /**
 114  
      * Sets the GroupId
 115  
      * 
 116  
      * @param strGroupId
 117  
      *            The GroupId
 118  
      */
 119  
     public void setGroupId( String strGroupId )
 120  
     {
 121  1
         _strGroupId = strGroupId;
 122  1
     }
 123  
 
 124  
     /**
 125  
      * Returns the Type
 126  
      * 
 127  
      * @return The Type
 128  
      */
 129  
     public String getType( )
 130  
     {
 131  0
         return _strType;
 132  
     }
 133  
 
 134  
     /**
 135  
      * Sets the Type
 136  
      * 
 137  
      * @param strType
 138  
      *            The Type
 139  
      */
 140  
     public void setType( String strType )
 141  
     {
 142  0
         _strType = strType;
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Returns the CurrentVersion
 147  
      * 
 148  
      * @return The CurrentVersion
 149  
      */
 150  
     public String getCurrentVersion( )
 151  
     {
 152  1
         return _strCurrentVersion;
 153  
     }
 154  
 
 155  
     /**
 156  
      * Sets the CurrentVersion
 157  
      * 
 158  
      * @param strCurrentVersion
 159  
      *            The CurrentVersion
 160  
      */
 161  
     public void setCurrentVersion( String strCurrentVersion )
 162  
     {
 163  1
         _strCurrentVersion = strCurrentVersion;
 164  1
     }
 165  
 
 166  
     /**
 167  
      * Returns the TargetVersion
 168  
      * 
 169  
      * @return The TargetVersion
 170  
      */
 171  
     public String getTargetVersion( )
 172  
     {
 173  0
         return _strTargetVersion;
 174  
     }
 175  
 
 176  
     /**
 177  
      * Sets the TargetVersion
 178  
      * 
 179  
      * @param strTargetVersion
 180  
      *            The TargetVersion
 181  
      */
 182  
     public void setTargetVersion( String strTargetVersion )
 183  
     {
 184  1
         _strTargetVersion = strTargetVersion;
 185  1
     }
 186  
 
 187  
     /**
 188  
      * Returns the IsProject
 189  
      * 
 190  
      * @return The IsProject
 191  
      */
 192  
     public boolean isProject( )
 193  
     {
 194  0
         return _bIsProject;
 195  
     }
 196  
 
 197  
     /**
 198  
      * Sets the IsProject
 199  
      * 
 200  
      * @param bIsProject
 201  
      *            The IsProject
 202  
      */
 203  
     public void setIsProject( boolean bIsProject )
 204  
     {
 205  0
         _bIsProject = bIsProject;
 206  0
     }
 207  
 
 208  
     /**
 209  
      * Returns the LastAvailableVersion
 210  
      * 
 211  
      * @return The LastAvailableVersion
 212  
      */
 213  
     public String getLastAvailableVersion( )
 214  
     {
 215  0
         return _strLastAvailableVersion;
 216  
     }
 217  
 
 218  
     /**
 219  
      * Sets the LastAvailableVersion
 220  
      * 
 221  
      * @param strLastAvailableVersion
 222  
      *            The LastAvailableVersion
 223  
      */
 224  
     public void setLastAvailableVersion( String strLastAvailableVersion )
 225  
     {
 226  0
         _strLastAvailableVersion = strLastAvailableVersion;
 227  0
     }
 228  
 
 229  
     /**
 230  
      * Returns the NextSnapshotVersion
 231  
      * 
 232  
      * @return The NextSnapshotVersion
 233  
      */
 234  
     public String getNextSnapshotVersion( )
 235  
     {
 236  0
         return _strNextSnapshotVersion;
 237  
     }
 238  
 
 239  
     /**
 240  
      * Sets the NextSnapshotVersion
 241  
      * 
 242  
      * @param strNextSnapshotVersion
 243  
      *            The NextSnapshotVersion
 244  
      */
 245  
     public void setNextSnapshotVersion( String strNextSnapshotVersion )
 246  
     {
 247  1
         _strNextSnapshotVersion = strNextSnapshotVersion;
 248  1
     }
 249  
 
 250  
     /**
 251  
      * Returns the ReleaseComment
 252  
      * 
 253  
      * @return The ReleaseComment
 254  
      */
 255  
     public String getReleaseComment( )
 256  
     {
 257  0
         return _strReleaseComment;
 258  
     }
 259  
 
 260  
     /**
 261  
      * Sets the ReleaseComment
 262  
      * 
 263  
      * @param strReleaseComment
 264  
      *            The ReleaseComment
 265  
      */
 266  
     public void addReleaseComment( String strReleaseComment )
 267  
     {
 268  0
         if ( _strReleaseComment != null )
 269  
         {
 270  0
             _strReleaseComment = _strReleaseComment + "<br>\n" + strReleaseComment;
 271  
         }
 272  
         else
 273  
         {
 274  0
             _strReleaseComment = strReleaseComment;
 275  
         }
 276  0
     }
 277  
 
 278  
     /**
 279  
      * Reset comments
 280  
      */
 281  
     public void resetComments( )
 282  
     {
 283  0
         _strReleaseComment = null;
 284  0
     }
 285  
 
 286  
     /**
 287  
      * Returns the JiraCode
 288  
      * 
 289  
      * @return The JiraCode
 290  
      */
 291  
     public String getJiraCode( )
 292  
     {
 293  0
         return _strJiraCode;
 294  
     }
 295  
 
 296  
     /**
 297  
      * Sets the JiraCode
 298  
      * 
 299  
      * @param strJiraCode
 300  
      *            The JiraCode
 301  
      */
 302  
     public void setJiraCode( String strJiraCode )
 303  
     {
 304  0
         _strJiraCode = strJiraCode;
 305  0
     }
 306  
 
 307  
     /**
 308  
      * Returns the JiraRoadmapUrl
 309  
      * 
 310  
      * @return The JiraRoadmapUrl
 311  
      */
 312  
     public String getJiraRoadmapUrl( )
 313  
     {
 314  0
         return _strJiraRoadmapUrl;
 315  
     }
 316  
 
 317  
     /**
 318  
      * Sets the JiraRoadmapUrl
 319  
      * 
 320  
      * @param strJiraRoadmapUrl
 321  
      *            The JiraRoadmapUrl
 322  
      */
 323  
     public void setJiraRoadmapUrl( String strJiraRoadmapUrl )
 324  
     {
 325  0
         _strJiraRoadmapUrl = strJiraRoadmapUrl;
 326  0
     }
 327  
 
 328  
     /**
 329  
      * Returns the JiraCurrentVersionClosedIssues
 330  
      * 
 331  
      * @return The JiraCurrentVersionClosedIssues
 332  
      */
 333  
     public int getJiraCurrentVersionClosedIssues( )
 334  
     {
 335  0
         return _nJiraCurrentVersionClosedIssues;
 336  
     }
 337  
 
 338  
     /**
 339  
      * Sets the JiraCurrentVersionClosedIssues
 340  
      * 
 341  
      * @param nJiraCurrentVersionClosedIssues
 342  
      *            The JiraCurrentVersionClosedIssues
 343  
      */
 344  
     public void setJiraCurrentVersionClosedIssues( int nJiraCurrentVersionClosedIssues )
 345  
     {
 346  0
         _nJiraCurrentVersionClosedIssues = nJiraCurrentVersionClosedIssues;
 347  0
     }
 348  
 
 349  
     /**
 350  
      * Returns the JiraCurrentVersionOpenedIssues
 351  
      * 
 352  
      * @return The JiraCurrentVersionOpenedIssues
 353  
      */
 354  
     public int getJiraCurrentVersionOpenedIssues( )
 355  
     {
 356  0
         return _nJiraCurrentVersionOpenedIssues;
 357  
     }
 358  
 
 359  
     /**
 360  
      * Sets the JiraCurrentVersionOpenedIssues
 361  
      * 
 362  
      * @param nJiraCurrentVersionOpenedIssues
 363  
      *            The JiraCurrentVersionOpenedIssues
 364  
      */
 365  
     public void setJiraCurrentVersionOpenedIssues( int nJiraCurrentVersionOpenedIssues )
 366  
     {
 367  0
         _nJiraCurrentVersionOpenedIssues = nJiraCurrentVersionOpenedIssues;
 368  0
     }
 369  
     
 370  
     /**
 371  
      * Set target versions list
 372  
      * @param listTargetVersions The target versions list 
 373  
      */
 374  
     public void setTargetVersions( List<String> listTargetVersions )
 375  
     {
 376  0
         _listTargetVersions = listTargetVersions;
 377  0
     }
 378  
     
 379  
     /**
 380  
      * Gets the target versions list
 381  
      * @return the target versions list
 382  
      */
 383  
     public List<String> getTargetVersions()
 384  
     {
 385  0
         return _listTargetVersions;
 386  
     }
 387  
     
 388  
     /**
 389  
      * Set the target version index
 390  
      * @param nIndex the target version index
 391  
      */
 392  
     public void setTargetVersionIndex( int nIndex )
 393  
     {
 394  0
         _nTargetVersionIndex = nIndex;
 395  0
     }
 396  
     
 397  
     /**
 398  
      * Get the target version index
 399  
      * @return the target version index 
 400  
      */
 401  
     public int getTargetVersionIndex()
 402  
     {
 403  0
         return _nTargetVersionIndex;
 404  
     }
 405  
     
 406  
     /**
 407  
      * Returns the IsProject
 408  
      * 
 409  
      * @return True if should be released
 410  
      */
 411  
     public boolean shouldBeReleased( )
 412  
     {
 413  
 
 414  0
         if(this.isProject( ) && this.isSnapshotVersion( ) && !this.isTheme( ) && !this.isDowngrade( ) &&  this.getCurrentVersion( ).equals( this.getLastAvailableSnapshotVersion( ) ))
 415  
         {
 416  0
              return true;   
 417  
         }
 418  0
         return false;
 419  
    }
 420  
 
 421  
 
 422  
 
 423  
     
 424  
     /**
 425  
      * 
 426  
      * @return scm developer connection url
 427  
      */
 428  
     public String getScmDeveloperConnection( )
 429  
     {
 430  3
         return _strScmDeveloperConnection;
 431  
     }
 432  
     /**
 433  
      * 
 434  
      * @param _strScmDeveloperConnection scm developer connection url
 435  
      */
 436  
     public void setScmDeveloperConnection( String _strScmDeveloperConnection )
 437  
     {
 438  2
         this._strScmDeveloperConnection = _strScmDeveloperConnection;
 439  2
     }
 440  
     
 441  
     /**
 442  
      * 
 443  
      * @return
 444  
      */
 445  
     public boolean isSnapshotVersion()
 446  
     {
 447  0
          return  Version.isSnapshot(getCurrentVersion( ));
 448  
     }
 449  
     
 450  
     
 451  
     public boolean isUpgrade( )
 452  
     {
 453  0
         return _bUpgrade;
 454  
     }
 455  
 
 456  
     public void setUpgrade( boolean _bUpgrade )
 457  
     {
 458  0
         this._bUpgrade = _bUpgrade;
 459  0
     }
 460  
 
 461  
     public boolean isDowngrade( )
 462  
     {
 463  0
         return _bDowngrade;
 464  
     }
 465  
 
 466  
     public void setDowngrade( boolean _bDowngrade )
 467  
     {
 468  0
         this._bDowngrade = _bDowngrade;
 469  0
     }
 470  
 
 471  
  
 472  
     public boolean isTheme( )
 473  
     {
 474  0
         return getType( )!=null && ConstanteUtils.CONSTANTE_TYPE_LUTECE_SITE.equals( getType( ) );
 475  
     }
 476  
 
 477  
     public String getLastAvailableSnapshotVersion( )
 478  
     {
 479  1
         return _strLastAvailableSnapshotVersion;
 480  
     }
 481  
 
 482  
     public void setLastAvailableSnapshotVersion( String _strLastAvailableSnapshotVersion )
 483  
     {
 484  0
         this._strLastAvailableSnapshotVersion = _strLastAvailableSnapshotVersion;
 485  0
     }
 486  
 
 487  
     public boolean isErrorLastRelease( )
 488  
     {
 489  0
         return _bErrorLastRelease;
 490  
     }
 491  
 
 492  
     public void setErrorLastRelease( boolean _bErrorLastRelease )
 493  
     {
 494  0
         this._bErrorLastRelease = _bErrorLastRelease;
 495  0
     }
 496  
 
 497  
     public String getName( )
 498  
     {
 499  0
         return _strName;
 500  
     }
 501  
 
 502  
     public void setName( String _strName )
 503  
     {
 504  0
         this._strName = _strName;
 505  0
     }
 506  
 
 507  
     public String getCloneUrl( )
 508  
     {
 509  0
         return _strCloneUrl;
 510  
     }
 511  
 
 512  
     public void setCloneUrl( String _strCloneUrl )
 513  
     {
 514  0
         this._strCloneUrl = _strCloneUrl;
 515  0
     }
 516  
 
 517  
     public String getFullName( )
 518  
     {
 519  0
         return _strFullName;
 520  
     }
 521  
 
 522  
     public void setFullName( String strFullName )
 523  
     {
 524  0
         this._strFullName = strFullName;
 525  0
     }
 526  
 
 527  
             
 528  
 }