improve ChangesetViewer api

This commit is contained in:
Sebastian Sdorra
2011-04-16 17:17:50 +02:00
parent 5bff5bbd17
commit a93cded116
3 changed files with 429 additions and 4 deletions

View File

@@ -43,9 +43,11 @@ import sonia.scm.util.Util;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
@@ -130,6 +132,12 @@ public class Changeset implements Validateable, Cloneable, Serializable
return false;
}
if ((this.branches != other.branches)
&& ((this.branches == null) ||!this.branches.equals(other.branches)))
{
return false;
}
if ((this.date != other.date)
&& ((this.date == null) ||!this.date.equals(other.date)))
{
@@ -150,6 +158,19 @@ public class Changeset implements Validateable, Cloneable, Serializable
return false;
}
if ((this.modifications != other.modifications)
&& ((this.modifications == null)
||!this.modifications.equals(other.modifications)))
{
return false;
}
if ((this.tags != other.tags)
&& ((this.tags == null) ||!this.tags.equals(other.tags)))
{
return false;
}
return true;
}
@@ -164,18 +185,27 @@ public class Changeset implements Validateable, Cloneable, Serializable
{
int hash = 7;
hash = 71 * hash + ((this.author != null)
hash = 47 * hash + ((this.author != null)
? this.author.hashCode()
: 0);
hash = 71 * hash + ((this.date != null)
hash = 47 * hash + ((this.branches != null)
? this.branches.hashCode()
: 0);
hash = 47 * hash + ((this.date != null)
? this.date.hashCode()
: 0);
hash = 71 * hash + ((this.description != null)
hash = 47 * hash + ((this.description != null)
? this.description.hashCode()
: 0);
hash = 71 * hash + ((this.id != null)
hash = 47 * hash + ((this.id != null)
? this.id.hashCode()
: 0);
hash = 47 * hash + ((this.modifications != null)
? this.modifications.hashCode()
: 0);
hash = 47 * hash + ((this.tags != null)
? this.tags.hashCode()
: 0);
return hash;
}
@@ -200,6 +230,13 @@ public class Changeset implements Validateable, Cloneable, Serializable
}
out.append("desc:").append(description).append("\n");
out.append("branches: ").append(Util.toString(branches)).append("\n");
out.append("tags: ").append(Util.toString(tags)).append("\n");
if (modifications != null)
{
out.append("modifications: \n").append(modifications);
}
return out.toString();
}
@@ -217,6 +254,17 @@ public class Changeset implements Validateable, Cloneable, Serializable
return author;
}
/**
* Method description
*
*
* @return
*/
public List<String> getBranches()
{
return branches;
}
/**
* Method description
*
@@ -250,6 +298,28 @@ public class Changeset implements Validateable, Cloneable, Serializable
return id;
}
/**
* Method description
*
*
* @return
*/
public Modifications getModifications()
{
return modifications;
}
/**
* Method description
*
*
* @return
*/
public List<String> getTags()
{
return tags;
}
/**
* Method description
*
@@ -275,6 +345,17 @@ public class Changeset implements Validateable, Cloneable, Serializable
this.author = author;
}
/**
* Method description
*
*
* @param branches
*/
public void setBranches(List<String> branches)
{
this.branches = branches;
}
/**
* Method description
*
@@ -308,11 +389,36 @@ public class Changeset implements Validateable, Cloneable, Serializable
this.id = id;
}
/**
* Method description
*
*
* @param modifications
*/
public void setModifications(Modifications modifications)
{
this.modifications = modifications;
}
/**
* Method description
*
*
* @param tags
*/
public void setTags(List<String> tags)
{
this.tags = tags;
}
//~--- fields ---------------------------------------------------------------
/** The author of the changeset */
private String author;
/** The tags associated with the changeset */
private List<String> branches;
/** The date when the changeset was committed */
private Long date;
@@ -321,4 +427,11 @@ public class Changeset implements Validateable, Cloneable, Serializable
/** The changeset identification string */
private String id;
/** List of files changed by this changeset */
@XmlElement(name = "modifications")
private Modifications modifications;
/** The name of the branches on which the changeset was committed. */
private List<String> tags;
}

View File

@@ -0,0 +1,278 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "modifications")
public class Modifications
{
/**
* Constructs ...
*
*/
public Modifications() {}
/**
* Constructs ...
*
*
* @param added
*/
public Modifications(List<String> added)
{
this(added, null, null);
}
/**
* Constructs ...
*
*
* @param added
* @param modified
*/
public Modifications(List<String> added, List<String> modified)
{
this(added, modified, null);
}
/**
* Constructs ...
*
*
* @param added
* @param modified
* @param removed
*/
public Modifications(List<String> added, List<String> modified,
List<String> removed)
{
this.added = added;
this.modified = modified;
this.removed = removed;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Modifications other = (Modifications) obj;
if ((this.added != other.added)
&& ((this.added == null) ||!this.added.equals(other.added)))
{
return false;
}
if ((this.modified != other.modified)
&& ((this.modified == null) ||!this.modified.equals(other.modified)))
{
return false;
}
if ((this.removed != other.removed)
&& ((this.removed == null) ||!this.removed.equals(other.removed)))
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 7;
hash = 41 * hash + ((this.added != null)
? this.added.hashCode()
: 0);
hash = 41 * hash + ((this.modified != null)
? this.modified.hashCode()
: 0);
hash = 41 * hash + ((this.removed != null)
? this.removed.hashCode()
: 0);
return hash;
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
StringBuilder out = new StringBuilder();
out.append("added:").append(Util.toString(added)).append("\n");
out.append("modified:").append(Util.toString(modified)).append("\n");
out.append("removed:").append(Util.toString(removed)).append("\n");
return out.toString();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<String> getAdded()
{
return added;
}
/**
* Method description
*
*
* @return
*/
public List<String> getModified()
{
return modified;
}
/**
* Method description
*
*
* @return
*/
public List<String> getRemoved()
{
return removed;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param added
*/
public void setAdded(List<String> added)
{
this.added = added;
}
/**
* Method description
*
*
* @param modified
*/
public void setModified(List<String> modified)
{
this.modified = modified;
}
/**
* Method description
*
*
* @param removed
*/
public void setRemoved(List<String> removed)
{
this.removed = removed;
}
//~--- fields ---------------------------------------------------------------
/** list of added files */
@XmlElement(name = "file")
@XmlElementWrapper(name = "added")
public List<String> added;
/** list of modified files */
@XmlElement(name = "file")
@XmlElementWrapper(name = "modified")
public List<String> modified;
/** list of removed files */
@XmlElement(name = "file")
@XmlElementWrapper(name = "removed")
public List<String> removed;
}

View File

@@ -40,6 +40,7 @@ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.TimeZone;
/**
@@ -52,6 +53,9 @@ public class Util
/** Field description */
public static final String DATE_PATTERN = "yyyy-MM-dd HH-mm-ss";
/** Field description */
public static final String EMPTY_STRING = "";
//~--- methods --------------------------------------------------------------
/**
@@ -260,6 +264,36 @@ public class Util
return parseDate(dateString, null);
}
/**
* Method description
*
*
* @param collection
*
* @return
*/
public static String toString(Collection<? extends Object> collection)
{
StringBuilder sb = new StringBuilder();
if (collection != null)
{
Iterator<? extends Object> it = collection.iterator();
while (it.hasNext())
{
sb.append(it.next());
if (it.hasNext())
{
sb.append(", ");
}
}
}
return sb.toString();
}
/**
* Method description
*