001package org.apache.maven.scm.command.changelog; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.CommandParameter; 023import org.apache.maven.scm.ScmBranch; 024import org.apache.maven.scm.ScmException; 025import org.apache.maven.scm.ScmFileSet; 026import org.apache.maven.scm.ScmRequest; 027import org.apache.maven.scm.ScmVersion; 028import org.apache.maven.scm.repository.ScmRepository; 029 030import java.util.Date; 031 032/** 033 * @author Petr Kozelka 034 * @since 1.8 035 */ 036public class ChangeLogScmRequest 037 extends ScmRequest 038{ 039 private static final long serialVersionUID = 20120620L; 040 041 public ChangeLogScmRequest( ScmRepository scmRepository, ScmFileSet scmFileSet ) 042 { 043 super( scmRepository, scmFileSet ); 044 } 045 046 public ScmBranch getScmBranch() 047 throws ScmException 048 { 049 return (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null ); 050 } 051 052 public void setScmBranch( ScmBranch scmBranch ) 053 throws ScmException 054 { 055 parameters.setScmVersion( CommandParameter.BRANCH, scmBranch ); 056 } 057 058 public Date getStartDate() 059 throws ScmException 060 { 061 return parameters.getDate( CommandParameter.START_DATE ); 062 } 063 064 /** 065 * @param startDate the start date of the period 066 */ 067 public void setStartDate( Date startDate ) 068 throws ScmException 069 { 070 parameters.setDate( CommandParameter.START_DATE, startDate ); 071 } 072 073 public Date getEndDate() 074 throws ScmException 075 { 076 return parameters.getDate( CommandParameter.END_DATE ); 077 } 078 079 /** 080 * @param endDate the end date of the period 081 */ 082 public void setEndDate( Date endDate ) 083 throws ScmException 084 { 085 parameters.setDate( CommandParameter.END_DATE, endDate ); 086 } 087 088 public int getNumDays() 089 throws ScmException 090 { 091 return parameters.getInt( CommandParameter.START_DATE ); 092 } 093 094 /** 095 * @param numDays the number days before the current time if startdate and enddate are null 096 */ 097 public void setNumDays( int numDays ) 098 throws ScmException 099 { 100 parameters.setInt( CommandParameter.NUM_DAYS, numDays ); 101 } 102 103 public ScmVersion getStartRevision() 104 throws ScmException 105 { 106 return parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); 107 } 108 109 /** 110 * @param startRevision the start branch/tag/revision 111 */ 112 public void setStartRevision( ScmVersion startRevision ) 113 throws ScmException 114 { 115 parameters.setScmVersion( CommandParameter.START_SCM_VERSION, startRevision ); 116 } 117 118 public ScmVersion getEndRevision() 119 throws ScmException 120 { 121 return parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); 122 } 123 124 /** 125 * @param endRevision the end branch/tag/revision 126 */ 127 public void setEndRevision( ScmVersion endRevision ) 128 throws ScmException 129 { 130 parameters.setScmVersion( CommandParameter.END_SCM_VERSION, endRevision ); 131 } 132 133 public String getDatePattern() 134 throws ScmException 135 { 136 return parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null ); 137 } 138 139 /** 140 * @param datePattern the date pattern used in changelog output returned by scm tool 141 */ 142 public void setDatePattern( String datePattern ) 143 throws ScmException 144 { 145 parameters.setString( CommandParameter.CHANGELOG_DATE_PATTERN, datePattern ); 146 } 147 148 public Integer getLimit() 149 throws ScmException 150 { 151 final int limit = parameters.getInt( CommandParameter.LIMIT, -1 ); 152 return limit > 0 ? limit : null; 153 } 154 155 /** 156 * @param limit the maximal count of returned changesets 157 */ 158 public void setLimit( Integer limit ) 159 throws ScmException 160 { 161 if ( limit != null ) 162 { 163 parameters.setInt( CommandParameter.LIMIT, limit ); 164 } 165 else 166 { 167 parameters.remove( CommandParameter.LIMIT ); 168 } 169 } 170 171 public void setDateRange( Date startDate, Date endDate ) 172 throws ScmException 173 { 174 setStartDate( startDate ); 175 setEndDate( endDate ); 176 } 177 178}