Coverage Report - org.apache.maven.scm.provider.synergy.command.changelog.SynergyChangeLogCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
SynergyChangeLogCommand
0 %
0/23
0 %
0/8
6
 
 1  
 package org.apache.maven.scm.provider.synergy.command.changelog;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  * http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.Date;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.maven.scm.ChangeSet;
 27  
 import org.apache.maven.scm.ScmBranch;
 28  
 import org.apache.maven.scm.ScmException;
 29  
 import org.apache.maven.scm.ScmFileSet;
 30  
 import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
 31  
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 32  
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
 33  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 34  
 import org.apache.maven.scm.provider.synergy.command.SynergyCommand;
 35  
 import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository;
 36  
 import org.apache.maven.scm.provider.synergy.util.SynergyTask;
 37  
 import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
 38  
 
 39  
 /**
 40  
  * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
 41  
  * @author Olivier Lamy
 42  
  * @version $Id: SynergyChangeLogCommand.java 1067549 2011-02-05 23:13:10Z olamy $
 43  
  */
 44  0
 public class SynergyChangeLogCommand
 45  
     extends AbstractChangeLogCommand
 46  
     implements SynergyCommand
 47  
 {
 48  
 
 49  
     /** {@inheritDoc} */
 50  
     protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
 51  
                                                           Date startDate, Date endDate, ScmBranch branch,
 52  
                                                           String datePattern )
 53  
         throws ScmException
 54  
     {
 55  0
         if ( getLogger().isDebugEnabled() )
 56  
         {
 57  0
             getLogger().debug( "executing changelog command..." );
 58  
         }
 59  
 
 60  0
         SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
 61  
 
 62  0
         if ( getLogger().isDebugEnabled() )
 63  
         {
 64  0
             getLogger().debug( "basedir: " + fileSet.getBasedir() );
 65  
         }
 66  
 
 67  0
         String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );
 68  
 
 69  0
         List<ChangeSet> csList = new ArrayList<ChangeSet>();
 70  
 
 71  
         try
 72  
         {
 73  0
             String projectSpec =
 74  
                 SynergyUtil.getWorkingProject( getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr );
 75  0
             if ( projectSpec == null )
 76  
             {
 77  0
                 throw new ScmException( "You should checkout a working project first" );
 78  
             }
 79  0
             List<SynergyTask> tasks = SynergyUtil.getCompletedTasks( getLogger(), projectSpec, startDate, endDate, ccmAddr );
 80  0
             for (SynergyTask t : tasks )
 81  
             {
 82  0
                 ChangeSet cs = new ChangeSet();
 83  0
                 cs.setAuthor( t.getUsername() );
 84  0
                 cs.setComment( "Task " + t.getNumber() + ": " + t.getComment() );
 85  0
                 cs.setDate( t.getModifiedTime() );
 86  0
                 cs.setFiles( SynergyUtil.getModifiedObjects( getLogger(), t.getNumber(), ccmAddr ) );
 87  0
                 csList.add( cs );
 88  0
             }
 89  
         }
 90  
         finally
 91  
         {
 92  0
             SynergyUtil.stop( getLogger(), ccmAddr );
 93  0
         }
 94  
 
 95  0
         return new ChangeLogScmResult( "ccm query ...", new ChangeLogSet( csList, startDate, endDate ) );
 96  
     }
 97  
 
 98  
 }