001 package org.apache.maven.scm.provider.accurev;
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
022 import java.util.Collection;
023 import java.util.Date;
024 import java.util.HashSet;
025
026 public class Transaction
027 {
028
029 public class Version
030 {
031
032 private String realSpec;
033
034 private String virtualSpec;
035
036 private String ancestorSpec;
037
038 private Long elementId;
039
040 private String elementName;
041
042 private Version( Long id, String elementName, String virtualSpec, String realSpec, String ancestor )
043 {
044 this.elementId = id;
045 this.virtualSpec = virtualSpec;
046 this.realSpec = realSpec;
047 this.ancestorSpec = ancestor;
048 this.elementName = elementName;
049 }
050
051 public String getVirtualSpec()
052 {
053 return virtualSpec;
054 }
055
056 public void setVirtualSpec( String virtualSpec )
057 {
058 this.virtualSpec = virtualSpec;
059 }
060
061 public String getAncestorSpec()
062 {
063 return ancestorSpec;
064 }
065
066 public void setAncestorSpec( String ancestorSpec )
067 {
068 this.ancestorSpec = ancestorSpec;
069 }
070
071 public void setRealSpec( String realSpec )
072 {
073 this.realSpec = realSpec;
074 }
075
076 public void setElementId( Long elementId )
077 {
078 this.elementId = elementId;
079 }
080
081 public String getRealSpec()
082 {
083 return realSpec;
084 }
085
086 public Long getElementId()
087 {
088 return elementId;
089 }
090
091 public Transaction getTransaction()
092 {
093 return getOuterTransaction();
094 }
095
096 public String getElementName()
097 {
098 return elementName;
099 }
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 }