ListAttribute seems to be mostly working, though I had to tweak hibernate-cfg.properties to

make it suck back generated primary keys.
Restructured ListEntry so that most most gets are via Session.get() rather than by query.
Added new methods to AttributeService to handle ListAttribute specific operations.
Added a little more testing for AttributeService.
I'm praying that the build will be repaired, since my efforts having been doing
so much lately.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5553 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park 2007-04-26 00:31:33 +00:00
parent 602440a983
commit d3aae2a9b7
18 changed files with 404 additions and 164 deletions

View File

@ -12,4 +12,5 @@ hibernate.cache.use_second_level_cache=true
hibernate.default_batch_fetch_size=1
hibernate.jdbc.batch_size=32
hibernate.connection.release_mode=auto
hibernate.connection.isolation=2
hibernate.connection.isolation=2
hibernate.jdbc.use_get_generated_keys=true

View File

@ -915,6 +915,7 @@
<list>
<value>setAttribute</value>
<value>removeAttribute</value>
<value>addAttribute</value>
</list>
</property>
</bean>

View File

@ -272,4 +272,11 @@ public interface Attribute extends Serializable, Iterable<Attribute>
* @param index The entry to remove.
*/
public void remove(int index);
/**
* Set an attribute in a list.
* @param index The index to set.
* @param value The attribute to set.
*/
public void set(int index, Attribute value);
}

View File

@ -395,4 +395,12 @@ public abstract class AttributeImpl implements Attribute
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#set(int, org.alfresco.repo.attributes.Attribute)
*/
public void set(int index, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
}

View File

@ -186,25 +186,12 @@ public class AttributeServiceImpl implements AttributeService
{
throw new AVMBadArgumentException("Bad Attribute Path List.");
}
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
return null;
}
Attribute current = entry.getAttribute();
for (int i = 1; i < keys.size(); i++)
{
if (current.getType() != Type.MAP)
{
return null;
}
current = current.get(keys.get(i));
if (current == null)
{
return null;
}
}
return fAttributeConverter.toValue(current);
return fAttributeConverter.toValue(found);
}
/* (non-Javadoc)
@ -220,29 +207,16 @@ public class AttributeServiceImpl implements AttributeService
{
return fGlobalAttributeEntryDAO.getKeys();
}
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(0));
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
Attribute current = entry.getAttribute();
if (current.getType() != Type.MAP)
if (found.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(0));
throw new AVMWrongTypeException("Not a Map: " + keys.get(keys.size() - 1));
}
for (int i = 1; i < keys.size(); i++)
{
current = current.get(keys.get(i));
if (current == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
}
}
return new ArrayList<String>(current.keySet());
return new ArrayList<String>(found.keySet());
}
/* (non-Javadoc)
@ -254,9 +228,9 @@ public class AttributeServiceImpl implements AttributeService
{
throw new AVMBadArgumentException("Null argument.");
}
Attribute toSave = fAttributeConverter.toPersistent(value);
if (keys.size() == 0)
{
Attribute toSave = fAttributeConverter.toPersistent(value);
GlobalAttributeEntry found = fGlobalAttributeEntryDAO.get(name);
if (found == null)
{
@ -267,30 +241,16 @@ public class AttributeServiceImpl implements AttributeService
found.setAttribute(toSave);
return;
}
GlobalAttributeEntry gEntry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (gEntry == null)
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Global Attribute Not Found: " + keys.get(0));
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
Attribute current = gEntry.getAttribute();
if (current.getType() != Type.MAP)
if (found.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Global Attribute Not Map: " + keys.get(0));
throw new AVMWrongTypeException("Not a Map: " + keys);
}
for (int i = 1; i < keys.size(); i++)
{
Attribute child = current.get(keys.get(i));
if (child == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (child.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
}
current = child;
}
current.put(name, toSave);
found.put(name, fAttributeConverter.toPersistent(value));
}
/* (non-Javadoc)
@ -306,30 +266,17 @@ public class AttributeServiceImpl implements AttributeService
{
throw new AVMBadArgumentException("Cannot query top level Attributes.");
}
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(0));
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
Attribute current = entry.getAttribute();
if (current.getType() != Type.MAP)
if (found.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(0));
}
for (int i = 1; i < keys.size(); i++)
{
current = current.get(keys.get(i));
if (current == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
}
throw new AVMWrongTypeException("Not a Map: " + keys);
}
List<Pair<String, Attribute>> rawResult =
fAttributeDAO.find((MapAttribute)current, query);
fAttributeDAO.find((MapAttribute)found, query);
List<Pair<String, Attribute>> result =
new ArrayList<Pair<String, Attribute>>();
for (Pair<String, Attribute> raw : rawResult)
@ -354,29 +301,160 @@ public class AttributeServiceImpl implements AttributeService
fGlobalAttributeEntryDAO.delete(name);
return;
}
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
if (found.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys);
}
found.remove(name);
}
private Attribute getAttributeFromPath(List<String> keys)
{
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
if (entry == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(0));
return null;
}
Attribute current = entry.getAttribute();
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(0));
}
for (int i = 1; i < keys.size(); i++)
{
current = current.get(keys.get(i));
if (current.getType() == Type.MAP)
{
current = current.get(keys.get(i));
}
else if (current.getType() == Type.LIST)
{
current = current.get(Integer.parseInt(keys.get(i)));
}
else
{
throw new AVMWrongTypeException("Not a Map or List: " + keys.get(i - 1));
}
if (current == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys.get(i));
}
if (current.getType() != Type.MAP)
{
throw new AVMWrongTypeException("Attribute Not Map: " + keys.get(i));
return null;
}
}
current.remove(name);
return current;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#addAttribute(java.util.List, org.alfresco.repo.attributes.Attribute)
*/
public void addAttribute(List<String> keys, Attribute value)
{
if (keys == null || value == null)
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
if (keys.size() < 1)
{
throw new AVMBadArgumentException("Path too short: " + keys);
}
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
if (found.getType() != Type.LIST)
{
throw new AVMWrongTypeException("Attribute Not List: " + keys);
}
found.add(fAttributeConverter.toPersistent(value));
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#addAttribute(java.lang.String, org.alfresco.repo.attributes.Attribute)
*/
public void addAttribute(String path, Attribute value)
{
if (path == null || value == null)
{
throw new AVMBadArgumentException("Illegal null arguments.");
}
List<String> keys = parsePath(path);
addAttribute(keys, value);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.util.List, int)
*/
public void removeAttribute(List<String> keys, int index)
{
if (keys == null)
{
throw new AVMBadArgumentException("Illegal Null Keys.");
}
if (keys.size() < 1)
{
throw new AVMBadArgumentException("Keys too short: " + keys);
}
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
if (found.getType() != Type.LIST)
{
throw new AVMWrongTypeException("Attribute Not List: " + keys);
}
found.remove(index);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#removeAttribute(java.lang.String, int)
*/
public void removeAttribute(String path, int index)
{
if (path == null)
{
throw new AVMBadArgumentException("Illegal null path.");
}
List<String> keys = parsePath(path);
removeAttribute(keys, index);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.util.List, int, org.alfresco.repo.attributes.Attribute)
*/
public void setAttribute(List<String> keys, int index, Attribute value)
{
if (keys == null || value == null)
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
if (keys.size() < 1)
{
throw new AVMBadArgumentException("Keys too short.");
}
Attribute found = getAttributeFromPath(keys);
if (found == null)
{
throw new AVMNotFoundException("Attribute Not Found: " + keys);
}
if (found.getType() != Type.LIST)
{
throw new AVMWrongTypeException("Attribute Not List: " + keys);
}
found.set(index, fAttributeConverter.toPersistent(value));
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.attributes.AttributeService#setAttribute(java.lang.String, int, org.alfresco.repo.attributes.Attribute)
*/
public void setAttribute(String path, int index, Attribute value)
{
if (path == null || value == null)
{
throw new AVMBadArgumentException("Illegal null argument.");
}
List<String> keys = parsePath(path);
setAttribute(keys, index, value);
}
}

View File

@ -111,6 +111,8 @@ public class AttributeServiceTest extends TestCase
{
System.out.println(key + " => " + fService.getAttribute(key));
}
fService.setAttribute("", "string", new StringAttributeValue("This is another string."));
assertEquals("This is another string.", fService.getAttribute("string").getStringValue());
}
catch (Exception e)
{
@ -294,6 +296,16 @@ public class AttributeServiceTest extends TestCase
Attribute found = fService.getAttribute("dummy");
assertNotNull(found);
assertEquals(5, found.size());
Attribute add = new IntAttributeValue(6);
fService.addAttribute("dummy", add);
assertEquals(6, fService.getAttribute("dummy").size());
fService.removeAttribute("dummy", 2);
found = fService.getAttribute("dummy");
assertEquals(5, found.size());
assertEquals(3, found.get(2).getIntValue());
Attribute replace = new StringAttributeValue("String");
fService.setAttribute("dummy", 2, replace);
assertEquals("String", fService.getAttribute("dummy/2").getStringValue());
}
catch (Exception e)
{

View File

@ -335,4 +335,12 @@ public abstract class AttributeValue implements Attribute
{
throw new AttributeMethodNotImplemented("Not a List.");
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.Attribute#set(int, org.alfresco.repo.attributes.Attribute)
*/
public void set(int index, Attribute value)
{
throw new AttributeMethodNotImplemented("Not a List.");
}
}

View File

@ -47,6 +47,7 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
public ListAttributeImpl(ListAttribute other)
{
super(other.getAcl());
int index = 0;
AVMDAOs.Instance().fAttributeDAO.save(this);
for (Attribute entry : other)
@ -114,7 +115,8 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + entry.getType());
}
}
ListEntry listEntry = new ListEntryImpl(this, index++, newEntry);
ListEntryKey key = new ListEntryKey(this, index++);
ListEntry listEntry = new ListEntryImpl(key, newEntry);
AVMDAOs.Instance().fListEntryDAO.save(listEntry);
}
}
@ -134,7 +136,8 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
public void add(Attribute attr)
{
int size = AVMDAOs.Instance().fListEntryDAO.size(this);
ListEntry entry = new ListEntryImpl(this, size, attr);
ListEntryKey key = new ListEntryKey(this, size);
ListEntry entry = new ListEntryImpl(key, attr);
AVMDAOs.Instance().fListEntryDAO.save(entry);
}
@ -152,12 +155,15 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
}
for (int i = size; i > index; i--)
{
ListEntry entry = dao.get(this, i - 1);
ListEntry newEntry = new ListEntryImpl(this, i, entry.getAttribute());
ListEntryKey key = new ListEntryKey(this, i - 1);
ListEntry entry = dao.get(key);
key = new ListEntryKey(this, i);
ListEntry newEntry = new ListEntryImpl(key, entry.getAttribute());
dao.delete(entry);
dao.save(newEntry);
}
ListEntry newEntry = new ListEntryImpl(this, index, attr);
ListEntryKey key = new ListEntryKey(this, index);
ListEntry newEntry = new ListEntryImpl(key, attr);
dao.save(newEntry);
}
@ -176,7 +182,8 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
@Override
public Attribute get(int index)
{
ListEntry entry = AVMDAOs.Instance().fListEntryDAO.get(this, index);
ListEntryKey key = new ListEntryKey(this, index);
ListEntry entry = AVMDAOs.Instance().fListEntryDAO.get(key);
if (entry == null)
{
return null;
@ -215,7 +222,8 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
public void remove(int index)
{
ListEntryDAO dao = AVMDAOs.Instance().fListEntryDAO;
ListEntry entry = dao.get(this, index);
ListEntryKey key = new ListEntryKey(this, index);
ListEntry entry = dao.get(key);
if (entry == null)
{
throw new AVMBadArgumentException("Index out of bounds: " + index);
@ -225,8 +233,10 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
AVMDAOs.Instance().fAttributeDAO.delete(entry.getAttribute());
for (int i = index; i < size - 1; i++)
{
entry = dao.get(this, i + 1);
ListEntry newEntry = new ListEntryImpl(this, i, entry.getAttribute());
key = new ListEntryKey(this, i + 1);
entry = dao.get(key);
key = new ListEntryKey(this, i);
ListEntry newEntry = new ListEntryImpl(key, entry.getAttribute());
dao.delete(entry);
dao.save(newEntry);
}
@ -248,4 +258,21 @@ public class ListAttributeImpl extends AttributeImpl implements ListAttribute
builder.append(']');
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeImpl#set(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void set(int index, Attribute value)
{
ListEntryKey key = new ListEntryKey(this, index);
ListEntry entry = AVMDAOs.Instance().fListEntryDAO.get(key);
if (entry == null)
{
throw new AVMBadArgumentException("Index out of bounds: " + index);
}
Attribute oldAttr = entry.getAttribute();
entry.setAttribute(value);
AVMDAOs.Instance().fAttributeDAO.delete(oldAttr);
}
}

View File

@ -195,4 +195,13 @@ public class ListAttributeValue extends AttributeValue implements ListAttribute
builder.append(']');
return builder.toString();
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.AttributeValue#set(int, org.alfresco.repo.attributes.Attribute)
*/
@Override
public void set(int index, Attribute value)
{
fData.set(index, value);
}
}

View File

@ -34,20 +34,20 @@ import java.io.Serializable;
public interface ListEntry extends Serializable
{
/**
* Get the List this is an entry for.
* @return The ListAttribute.
* Get the key.
* @return The key.
*/
public ListAttribute getList();
/**
* Get the index of this entry in the ListAttribute.
* @return The index.
*/
public int getIndex();
public ListEntryKey getKey();
/**
* Get the Attribute for this entry.
* @return The Attribute
*/
public Attribute getAttribute();
/**
* Set the Attribute.
* @param attr The attribute to set.
*/
public void setAttribute(Attribute attr);
}

View File

@ -45,7 +45,7 @@ public interface ListEntryDAO
* @param index The index.
* @return The ListEntry.
*/
public ListEntry get(ListAttribute list, int index);
public ListEntry get(ListEntryKey key);
/**
* Get all entries for a given list.

View File

@ -33,11 +33,7 @@ public class ListEntryImpl implements ListEntry
{
private static final long serialVersionUID = 1573391734169157835L;
private long fID;
private ListAttribute fList;
private int fIndex;
private ListEntryKey fKey;
private Attribute fAttribute;
@ -48,21 +44,20 @@ public class ListEntryImpl implements ListEntry
{
}
public ListEntryImpl(ListAttribute list, int index, Attribute attr)
public ListEntryImpl(ListEntryKey key, Attribute attr)
{
fList = list;
fIndex = index;
fKey = key;
fAttribute = attr;
}
public void setId(long id)
public void setKey(ListEntryKey key)
{
fID = id;
fKey = key;
}
public long getId()
public ListEntryKey getKey()
{
return fID;
return fKey;
}
/* (non-Javadoc)
@ -77,30 +72,4 @@ public class ListEntryImpl implements ListEntry
{
fAttribute = attr;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.ListEntry#getIndex()
*/
public int getIndex()
{
return fIndex;
}
public void setIndex(int index)
{
fIndex = index;
}
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.ListEntry#getList()
*/
public ListAttribute getList()
{
return fList;
}
public void setList(ListAttribute list)
{
fList = list;
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.repo.attributes;
import java.io.Serializable;
/**
* Key class for the ListEntry entity.
* @author britt
*/
public class ListEntryKey implements Serializable
{
private ListAttribute fList;
private int fIndex;
public ListEntryKey()
{
}
public ListEntryKey(ListAttribute list, int index)
{
fList = list;
fIndex = index;
}
/**
* @return the Index
*/
public int getIndex()
{
return fIndex;
}
/**
* @param index the fIndex to set
*/
public void setIndex(int index)
{
fIndex = index;
}
/**
* @return the fList
*/
public ListAttribute getList()
{
return fList;
}
/**
* @param list the fList to set
*/
public void setList(ListAttribute list)
{
fList = list;
}
}

View File

@ -90,13 +90,10 @@
</class>
<class name="ListEntryImpl" proxy="ListEntry" lazy="false" table="alf_list_attribute_entries">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<natural-id>
<many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
<property name="index" type="int" column="mindex" index="list_index_index"/>
</natural-id>
<composite-id name="key" class="ListEntryKey">
<key-many-to-one class="ListAttributeImpl" name="list" column="list_id"/>
<key-property name="index" type="int" column="mindex"/>
</composite-id>
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
</class>
</hibernate-mapping>

View File

@ -30,6 +30,8 @@ import java.util.List;
import org.alfresco.repo.attributes.ListAttribute;
import org.alfresco.repo.attributes.ListEntry;
import org.alfresco.repo.attributes.ListEntryDAO;
import org.alfresco.repo.attributes.ListEntryImpl;
import org.alfresco.repo.attributes.ListEntryKey;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@ -53,7 +55,7 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
*/
public void delete(ListAttribute list)
{
Query query = getSession().createQuery("delete from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("delete from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
query.executeUpdate();
}
@ -61,12 +63,9 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
/* (non-Javadoc)
* @see org.alfresco.repo.attributes.ListEntryDAO#get(org.alfresco.repo.attributes.ListAttribute, int)
*/
public ListEntry get(ListAttribute list, int index)
public ListEntry get(ListEntryKey key)
{
Query query = getSession().createQuery("from ListEntryImpl le where le.list = :list and le.index = :index");
query.setEntity("list", list);
query.setInteger("index", index);
return (ListEntry)query.uniqueResult();
return (ListEntry)getSession().get(ListEntryImpl.class, key);
}
/* (non-Javadoc)
@ -75,7 +74,7 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
@SuppressWarnings("unchecked")
public List<ListEntry> get(ListAttribute list)
{
Query query = getSession().createQuery("from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
return (List<ListEntry>)query.list();
}
@ -93,8 +92,8 @@ public class ListEntryDAOHibernate extends HibernateDaoSupport implements
*/
public int size(ListAttribute list)
{
Query query = getSession().createQuery("select count() from ListEntryImpl le where le.list = :list");
Query query = getSession().createQuery("select count(*) from ListEntryImpl le where le.key.list = :list");
query.setEntity("list", list);
return (Integer)query.uniqueResult();
return ((Long)query.uniqueResult()).intValue();
}
}

View File

@ -93,8 +93,8 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
*/
public int size(MapAttribute mapAttr)
{
Query query = getSession().createQuery("select count() from MapEntryImpl me where me.map = :map");
Query query = getSession().createQuery("select count(me) from MapEntryImpl me where me.map = :map");
query.setEntity("map", mapAttr);
return (Integer)query.uniqueResult();
return ((Long)query.uniqueResult()).intValue();
}
}

View File

@ -65,6 +65,36 @@ public interface AttributeService
*/
public void setAttribute(List<String> keys, String name, Attribute value);
/**
* Set an attribute in a list.
* @param path The path to the list.
* @param index The list index.
* @param value The Attribute to set.
*/
public void setAttribute(String path, int index, Attribute value);
/**
* Set an attribute in a list.
* @param keys The path components to the list.
* @param index The list index.
* @param value The Attribute to set.
*/
public void setAttribute(List<String> keys, int index, Attribute value);
/**
* Add an attribute to a List Attribute
* @param path The path to the list.
* @param value The Attribute to add.
*/
public void addAttribute(String path, Attribute value);
/**
* Add an attribute to a List Attribute.
* @param keys The path components to the list.
* @param value The Attribute to add.
*/
public void addAttribute(List<String> keys, Attribute value);
/**
* Remove an Attribute.
* @param name The name of the Attribute.
@ -77,7 +107,21 @@ public interface AttributeService
* @param name The name of the attribute to remove.
*/
public void removeAttribute(List<String> keys, String name);
/**
* Remove an attribute from a list.
* @param path The path to the list.
* @param index The index to remove.
*/
public void removeAttribute(String path, int index);
/**
* Remove an attribute from a list.
* @param keys The components of the path to the list.
* @param index The index to remove.
*/
public void removeAttribute(List<String> keys, int index);
/**
* Query for a list of attributes which are contained in the map
* defined by the given path and meet the query criteria.

View File

@ -1170,7 +1170,6 @@ public interface AVMService
* @throws AVMNotFoundException
*/
public AVMNodeDescriptor forceCopy(String path);
/**
* Perform a non-virtual (heavy-weight), and potentially recursive