added properties to changesets

This commit is contained in:
Sebastian Sdorra
2011-04-18 21:33:28 +02:00
parent 22084dacb9
commit 240d42df24
3 changed files with 260 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ package sonia.scm.repository;
import sonia.scm.Validateable;
import sonia.scm.util.Util;
import sonia.scm.util.ValidationUtil;
import sonia.scm.xml.XmlMapStringAdapter;
//~--- JDK imports ------------------------------------------------------------
@@ -45,12 +46,15 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
@@ -321,6 +325,22 @@ public class Changeset implements Validateable, Cloneable, Serializable
return modifications;
}
/**
* Method description
*
*
* @return
*/
public Map<String, String> getProperties()
{
if (properties == null)
{
properties = new HashMap<String, String>();
}
return properties;
}
/**
* Method description
*
@@ -418,6 +438,17 @@ public class Changeset implements Validateable, Cloneable, Serializable
this.modifications = modifications;
}
/**
* Method description
*
*
* @param properties
*/
public void setProperties(Map<String, String> properties)
{
this.properties = properties;
}
/**
* Method description
*
@@ -450,6 +481,10 @@ public class Changeset implements Validateable, Cloneable, Serializable
@XmlElement(name = "modifications")
private Modifications modifications;
/** changeset properties */
@XmlJavaTypeAdapter(XmlMapStringAdapter.class)
private Map<String, String> properties;
/** The name of the branches on which the changeset was committed. */
private List<String> tags;
}

View File

@@ -0,0 +1,100 @@
/**
* 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.xml;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
*
* @author Sebastian Sdorra
*/
public class XmlMapStringAdapter
extends XmlAdapter<Set<XmlMapStringElement>, Map<String, String>>
{
/**
* Method description
*
*
* @param map
*
* @return
*
* @throws Exception
*/
@Override
public Set<XmlMapStringElement> marshal(Map<String, String> map)
throws Exception
{
Set<XmlMapStringElement> set = new HashSet<XmlMapStringElement>();
for (Map.Entry<String, String> e : map.entrySet())
{
set.add(new XmlMapStringElement(e.getKey(), e.getValue()));
}
return set;
}
/**
* Method description
*
*
* @param set
*
* @return
*
* @throws Exception
*/
@Override
public Map<String, String> unmarshal(Set<XmlMapStringElement> set)
throws Exception
{
Map<String, String> map = new HashMap<String, String>();
for (XmlMapStringElement e : set)
{
map.put(e.getKey(), e.getValue());
}
return map;
}
}

View File

@@ -0,0 +1,125 @@
/**
* 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.xml;
//~--- JDK imports ------------------------------------------------------------
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "element")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlMapStringElement
{
/**
* Constructs ...
*
*/
public XmlMapStringElement() {}
/**
* Constructs ...
*
*
* @param key
* @param value
*/
public XmlMapStringElement(String key, String value)
{
this.key = key;
this.value = value;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getKey()
{
return key;
}
/**
* Method description
*
*
* @return
*/
public String getValue()
{
return value;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param key
*/
public void setKey(String key)
{
this.key = key;
}
/**
* Method description
*
*
* @param value
*/
public void setValue(String value)
{
this.value = value;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String key;
/** Field description */
private String value;
}