View Javadoc

1   package org.apache.maven.scm.provider.accurev;
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.Collection;
23  import java.util.Date;
24  import java.util.HashSet;
25  
26  public class Transaction
27  {
28  
29      public class Version
30      {
31  
32          private String realSpec;
33  
34          private String virtualSpec;
35  
36          private String ancestorSpec;
37  
38          private Long elementId;
39  
40          private String elementName;
41  
42          private Version( Long id, String elementName, String virtualSpec, String realSpec, String ancestor )
43          {
44              this.elementId = id;
45              this.virtualSpec = virtualSpec;
46              this.realSpec = realSpec;
47              this.ancestorSpec = ancestor;
48              this.elementName = elementName;
49          }
50  
51          public String getVirtualSpec()
52          {
53              return virtualSpec;
54          }
55  
56          public void setVirtualSpec( String virtualSpec )
57          {
58              this.virtualSpec = virtualSpec;
59          }
60  
61          public String getAncestorSpec()
62          {
63              return ancestorSpec;
64          }
65  
66          public void setAncestorSpec( String ancestorSpec )
67          {
68              this.ancestorSpec = ancestorSpec;
69          }
70  
71          public void setRealSpec( String realSpec )
72          {
73              this.realSpec = realSpec;
74          }
75  
76          public void setElementId( Long elementId )
77          {
78              this.elementId = elementId;
79          }
80  
81          public String getRealSpec()
82          {
83              return realSpec;
84          }
85  
86          public Long getElementId()
87          {
88              return elementId;
89          }
90  
91          public Transaction getTransaction()
92          {
93              return getOuterTransaction();
94          }
95  
96          public String getElementName()
97          {
98              return elementName;
99          }
100 
101         @Override
102         public String toString()
103         {
104             return String.format( "Version: %s (%d) %s (%s) anc=%s", elementName, elementId, virtualSpec, realSpec,
105                                   ancestorSpec );
106         }
107 
108     }
109 
110     private Collection<Version> versions = new HashSet<Version>();
111 
112     private long id;
113 
114     public Transaction( Long id, Date when, String tranType, String user )
115     {
116         this.id = id;
117         this.tranType = tranType;
118         this.when = when;
119         this.author = user;
120     }
121 
122     public long getId()
123     {
124         return id;
125     }
126 
127     public String getTranType()
128     {
129         return tranType;
130     }
131 
132     public String getComment()
133     {
134         return comment;
135     }
136 
137     public void setComment( String comment )
138     {
139         this.comment = comment;
140     }
141 
142     private Date when;
143 
144     private String tranType;
145 
146     private String author;
147 
148     private String comment;
149 
150     public long getTranId()
151     {
152         return id;
153     }
154 
155     private Transaction getOuterTransaction()
156     {
157         return this;
158     }
159 
160     public Collection<Version> getVersions()
161     {
162         return versions;
163     }
164 
165     public Date getWhen()
166     {
167         return when;
168     }
169 
170     public String getType()
171     {
172         return tranType;
173     }
174 
175     public String getAuthor()
176     {
177         return author;
178     }
179 
180     public void addVersion( Long id, String name, String virtualSpec, String realSpec, String ancestor )
181     {
182         Transaction.Version v = new Version( id, name, virtualSpec, realSpec, ancestor );
183         versions.add( v );
184 
185     }
186 
187     public String toString()
188     {
189         return String.format( "Transaction: %d, %s at %tc by %s -'%s'", this.getId(), this.getTranType(),
190                               this.getWhen(), this.getAuthor(), this.getComment() );
191     }
192 }