1 package org.apache.maven.scm.provider.synergy.command.changelog;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
41
42
43
44 public class SynergyChangeLogCommand
45 extends AbstractChangeLogCommand
46 implements SynergyCommand
47 {
48
49
50 protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
51 Date startDate, Date endDate, ScmBranch branch,
52 String datePattern )
53 throws ScmException
54 {
55 if ( getLogger().isDebugEnabled() )
56 {
57 getLogger().debug( "executing changelog command..." );
58 }
59
60 SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
61
62 if ( getLogger().isDebugEnabled() )
63 {
64 getLogger().debug( "basedir: " + fileSet.getBasedir() );
65 }
66
67 String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );
68
69 List<ChangeSet> csList = new ArrayList<ChangeSet>();
70
71 try
72 {
73 String projectSpec =
74 SynergyUtil.getWorkingProject( getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr );
75 if ( projectSpec == null )
76 {
77 throw new ScmException( "You should checkout a working project first" );
78 }
79 List<SynergyTask> tasks =
80 SynergyUtil.getCompletedTasks( getLogger(), projectSpec, startDate, endDate, ccmAddr );
81 for ( SynergyTask t : tasks )
82 {
83 ChangeSet cs = new ChangeSet();
84 cs.setAuthor( t.getUsername() );
85 cs.setComment( "Task " + t.getNumber() + ": " + t.getComment() );
86 cs.setDate( t.getModifiedTime() );
87 cs.setFiles( SynergyUtil.getModifiedObjects( getLogger(), t.getNumber(), ccmAddr ) );
88 csList.add( cs );
89 }
90 }
91 finally
92 {
93 SynergyUtil.stop( getLogger(), ccmAddr );
94 }
95
96 return new ChangeLogScmResult( "ccm query ...", new ChangeLogSet( csList, startDate, endDate ) );
97 }
98
99 }