mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Interim checkin for ListAttribute support.
Should fix build breakage also. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5551 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,7 @@ package org.alfresco.repo.attributes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -36,7 +37,7 @@ import org.alfresco.repo.domain.DbAccessControlList;
|
||||
* Interface for polymorphic attributes.
|
||||
* @author britt
|
||||
*/
|
||||
public interface Attribute extends Serializable
|
||||
public interface Attribute extends Serializable, Iterable<Attribute>
|
||||
{
|
||||
public static enum Type implements Serializable
|
||||
{
|
||||
@@ -49,7 +50,8 @@ public interface Attribute extends Serializable
|
||||
DOUBLE,
|
||||
STRING,
|
||||
SERIALIZABLE,
|
||||
MAP
|
||||
MAP,
|
||||
LIST
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -232,4 +234,42 @@ public interface Attribute extends Serializable
|
||||
* @return The values.
|
||||
*/
|
||||
public Collection<Attribute> values();
|
||||
|
||||
/**
|
||||
* Add an attribute to a list attribute.
|
||||
* @param attr
|
||||
*/
|
||||
public void add(Attribute attr);
|
||||
|
||||
/**
|
||||
* Add an attribute to a list attribute at a given position.
|
||||
* @param index The offset.
|
||||
* @param attr The attribute.
|
||||
*/
|
||||
public void add(int index, Attribute attr);
|
||||
|
||||
/**
|
||||
* Get the size of a List of a Map.
|
||||
* @return
|
||||
*/
|
||||
public int size();
|
||||
|
||||
/**
|
||||
* Get an iterator over a list's entries.
|
||||
* @return
|
||||
*/
|
||||
public Iterator<Attribute> iterator();
|
||||
|
||||
/**
|
||||
* Get an Attribute from a List.
|
||||
* @param index The offset.
|
||||
* @return The Attribute or null.
|
||||
*/
|
||||
public Attribute get(int index);
|
||||
|
||||
/**
|
||||
* Remove an entry from a list.
|
||||
* @param index The entry to remove.
|
||||
*/
|
||||
public void remove(int index);
|
||||
}
|
||||
|
@@ -83,6 +83,10 @@ public class AttributeConverter
|
||||
{
|
||||
return new MapAttributeImpl((MapAttribute)from);
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
return new ListAttributeImpl((ListAttribute)from);
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
|
||||
@@ -134,6 +138,10 @@ public class AttributeConverter
|
||||
{
|
||||
return new MapAttributeValue((MapAttribute)from);
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
return new ListAttributeValue((ListAttribute)from);
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Invalid Attribute Type: " + from.getType());
|
||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.attributes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -110,7 +111,7 @@ public abstract class AttributeImpl implements Attribute
|
||||
*/
|
||||
public Attribute get(String key)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not MapValue");
|
||||
throw new AttributeMethodNotImplemented("Not Map or List");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -174,7 +175,7 @@ public abstract class AttributeImpl implements Attribute
|
||||
*/
|
||||
public void put(String key, Attribute value)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not MapValue");
|
||||
throw new AttributeMethodNotImplemented("Not Map or List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -346,4 +347,52 @@ public abstract class AttributeImpl implements Attribute
|
||||
{
|
||||
fACL = acl;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#add(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
public void add(Attribute attr)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#add(int, org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
public void add(int index, Attribute attr)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#iterator()
|
||||
*/
|
||||
public Iterator<Attribute> iterator()
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List or Map.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#get(int)
|
||||
*/
|
||||
public Attribute get(int index)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#remove(int)
|
||||
*/
|
||||
public void remove(int index)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,8 @@ public class AttributeServiceTest extends TestCase
|
||||
assertNotNull(fService.getAttribute("boolean"));
|
||||
assertEquals(42, (int)fService.getAttribute("short").getShortValue());
|
||||
assertEquals("I sneeze.", fService.getAttribute("map/funky").getStringValue());
|
||||
assertEquals(10, fService.getKeys("").size());
|
||||
// This is 11 because of the AVMLockingService.
|
||||
assertEquals(11, fService.getKeys("").size());
|
||||
assertEquals(5, fService.getKeys("map").size());
|
||||
List<String> keys = fService.getKeys("");
|
||||
for (String key : keys)
|
||||
@@ -276,4 +277,28 @@ public class AttributeServiceTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ListAttributes
|
||||
*/
|
||||
public void testList()
|
||||
{
|
||||
try
|
||||
{
|
||||
ListAttribute list = new ListAttributeValue();
|
||||
list.add(new IntAttributeValue(0));
|
||||
list.add(new IntAttributeValue(1));
|
||||
list.add(new IntAttributeValue(2));
|
||||
list.add(new IntAttributeValue(3));
|
||||
list.add(new IntAttributeValue(4));
|
||||
fService.setAttribute("", "dummy", list);
|
||||
Attribute found = fService.getAttribute("dummy");
|
||||
assertNotNull(found);
|
||||
assertEquals(5, found.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.attributes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -286,4 +287,52 @@ public abstract class AttributeValue implements Attribute
|
||||
{
|
||||
fACL = acl;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#add(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
public void add(Attribute attr)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#add(int, org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
public void add(int index, Attribute attr)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#iterator()
|
||||
*/
|
||||
public Iterator<Attribute> iterator()
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List or Map.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#get(int)
|
||||
*/
|
||||
public Attribute get(int index)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#remove(int)
|
||||
*/
|
||||
public void remove(int index)
|
||||
{
|
||||
throw new AttributeMethodNotImplemented("Not a List.");
|
||||
}
|
||||
}
|
||||
|
34
source/java/org/alfresco/repo/attributes/ListAttribute.java
Normal file
34
source/java/org/alfresco/repo/attributes/ListAttribute.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* List Attribute dummy interface.
|
||||
* @author britt
|
||||
*/
|
||||
public interface ListAttribute extends Attribute
|
||||
{
|
||||
}
|
251
source/java/org/alfresco/repo/attributes/ListAttributeImpl.java
Normal file
251
source/java/org/alfresco/repo/attributes/ListAttributeImpl.java
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.avm.AVMDAOs;
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
|
||||
/**
|
||||
* Persistent implementation of a list attribute.
|
||||
* @author britt
|
||||
*/
|
||||
public class ListAttributeImpl extends AttributeImpl implements ListAttribute
|
||||
{
|
||||
private static final long serialVersionUID = -394553378173857035L;
|
||||
|
||||
public ListAttributeImpl()
|
||||
{
|
||||
}
|
||||
|
||||
public ListAttributeImpl(ListAttribute other)
|
||||
{
|
||||
int index = 0;
|
||||
AVMDAOs.Instance().fAttributeDAO.save(this);
|
||||
for (Attribute entry : other)
|
||||
{
|
||||
Attribute newEntry = null;
|
||||
switch (entry.getType())
|
||||
{
|
||||
case BOOLEAN :
|
||||
{
|
||||
newEntry = new BooleanAttributeImpl((BooleanAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case BYTE :
|
||||
{
|
||||
newEntry = new ByteAttributeImpl((ByteAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case SHORT :
|
||||
{
|
||||
newEntry = new ShortAttributeImpl((ShortAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case INT :
|
||||
{
|
||||
newEntry = new IntAttributeImpl((IntAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case LONG :
|
||||
{
|
||||
newEntry = new LongAttributeImpl((LongAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case FLOAT :
|
||||
{
|
||||
newEntry = new FloatAttributeImpl((FloatAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case DOUBLE :
|
||||
{
|
||||
newEntry = new DoubleAttributeImpl((DoubleAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case STRING :
|
||||
{
|
||||
newEntry = new StringAttributeImpl((StringAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case SERIALIZABLE :
|
||||
{
|
||||
newEntry = new SerializableAttributeImpl((SerializableAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case MAP :
|
||||
{
|
||||
newEntry = new MapAttributeImpl((MapAttribute)entry);
|
||||
break;
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
newEntry = new ListAttributeImpl((ListAttribute)entry);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + entry.getType());
|
||||
}
|
||||
}
|
||||
ListEntry listEntry = new ListEntryImpl(this, index++, newEntry);
|
||||
AVMDAOs.Instance().fListEntryDAO.save(listEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
||||
*/
|
||||
public Type getType()
|
||||
{
|
||||
return Type.LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#add(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@Override
|
||||
public void add(Attribute attr)
|
||||
{
|
||||
int size = AVMDAOs.Instance().fListEntryDAO.size(this);
|
||||
ListEntry entry = new ListEntryImpl(this, size, attr);
|
||||
AVMDAOs.Instance().fListEntryDAO.save(entry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#add(int, org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, Attribute attr)
|
||||
{
|
||||
ListEntryDAO dao = AVMDAOs.Instance().fListEntryDAO;
|
||||
int size = dao.size(this);
|
||||
if (index > size || index < 0)
|
||||
{
|
||||
throw new AVMBadArgumentException("Index out of bounds: " + index);
|
||||
}
|
||||
for (int i = size; i > index; i--)
|
||||
{
|
||||
ListEntry entry = dao.get(this, i - 1);
|
||||
ListEntry newEntry = new ListEntryImpl(this, i, entry.getAttribute());
|
||||
dao.delete(entry);
|
||||
dao.save(newEntry);
|
||||
}
|
||||
ListEntry newEntry = new ListEntryImpl(this, index, attr);
|
||||
dao.save(newEntry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#clear()
|
||||
*/
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
AVMDAOs.Instance().fListEntryDAO.delete(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#get(int)
|
||||
*/
|
||||
@Override
|
||||
public Attribute get(int index)
|
||||
{
|
||||
ListEntry entry = AVMDAOs.Instance().fListEntryDAO.get(this, index);
|
||||
if (entry == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return entry.getAttribute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#iterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Attribute> iterator()
|
||||
{
|
||||
List<ListEntry> entries = AVMDAOs.Instance().fListEntryDAO.get(this);
|
||||
List<Attribute> attrList = new ArrayList<Attribute>();
|
||||
for (ListEntry entry : entries)
|
||||
{
|
||||
attrList.add(entry.getAttribute());
|
||||
}
|
||||
return attrList.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#size()
|
||||
*/
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return AVMDAOs.Instance().fListEntryDAO.size(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#remove(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void remove(int index)
|
||||
{
|
||||
ListEntryDAO dao = AVMDAOs.Instance().fListEntryDAO;
|
||||
ListEntry entry = dao.get(this, index);
|
||||
if (entry == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Index out of bounds: " + index);
|
||||
}
|
||||
int size = dao.size(this);
|
||||
dao.delete(entry);
|
||||
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());
|
||||
dao.delete(entry);
|
||||
dao.save(newEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('[');
|
||||
for (Attribute child : this)
|
||||
{
|
||||
builder.append(child.toString());
|
||||
builder.append(' ');
|
||||
}
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
198
source/java/org/alfresco/repo/attributes/ListAttributeValue.java
Normal file
198
source/java/org/alfresco/repo/attributes/ListAttributeValue.java
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* 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.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* Value based implementation of a list attribute.
|
||||
* @author britt
|
||||
*/
|
||||
public class ListAttributeValue extends AttributeValue implements ListAttribute
|
||||
{
|
||||
private static final long serialVersionUID = 791121577967727000L;
|
||||
|
||||
private List<Attribute> fData;
|
||||
|
||||
public ListAttributeValue()
|
||||
{
|
||||
fData = new ArrayList<Attribute>();
|
||||
}
|
||||
|
||||
public ListAttributeValue(ListAttribute attr)
|
||||
{
|
||||
this();
|
||||
for (Attribute child : attr)
|
||||
{
|
||||
Attribute newAttr = null;
|
||||
switch (child.getType())
|
||||
{
|
||||
case BOOLEAN :
|
||||
{
|
||||
newAttr = new BooleanAttributeValue((BooleanAttribute)child);
|
||||
break;
|
||||
}
|
||||
case BYTE :
|
||||
{
|
||||
newAttr = new ByteAttributeValue((ByteAttribute)child);
|
||||
break;
|
||||
}
|
||||
case SHORT :
|
||||
{
|
||||
newAttr = new ShortAttributeValue((ShortAttribute)child);
|
||||
break;
|
||||
}
|
||||
case INT :
|
||||
{
|
||||
newAttr = new IntAttributeValue((IntAttribute)child);
|
||||
break;
|
||||
}
|
||||
case LONG :
|
||||
{
|
||||
newAttr = new LongAttributeValue((LongAttribute)child);
|
||||
break;
|
||||
}
|
||||
case FLOAT :
|
||||
{
|
||||
newAttr = new FloatAttributeValue((FloatAttribute)child);
|
||||
break;
|
||||
}
|
||||
case DOUBLE :
|
||||
{
|
||||
newAttr = new DoubleAttributeValue((DoubleAttribute)child);
|
||||
break;
|
||||
}
|
||||
case STRING :
|
||||
{
|
||||
newAttr = new StringAttributeValue((StringAttribute)child);
|
||||
break;
|
||||
}
|
||||
case SERIALIZABLE :
|
||||
{
|
||||
newAttr = new SerializableAttributeValue((SerializableAttribute)child);
|
||||
break;
|
||||
}
|
||||
case MAP :
|
||||
{
|
||||
newAttr = new MapAttributeValue((MapAttribute)child);
|
||||
break;
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
newAttr = new ListAttributeValue((ListAttribute)child);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + child.getType());
|
||||
}
|
||||
}
|
||||
fData.add(newAttr);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#get(int)
|
||||
*/
|
||||
public Attribute get(int index)
|
||||
{
|
||||
return fData.get(index);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.Attribute#getType()
|
||||
*/
|
||||
public Type getType()
|
||||
{
|
||||
return Type.LIST;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeValue#add(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@Override
|
||||
public void add(Attribute attr)
|
||||
{
|
||||
fData.add(attr);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeValue#add(int, org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@Override
|
||||
public void add(int index, Attribute attr)
|
||||
{
|
||||
fData.add(index, attr);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeValue#iterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Attribute> iterator()
|
||||
{
|
||||
return fData.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeValue#size()
|
||||
*/
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return fData.size();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeValue#remove(int)
|
||||
*/
|
||||
@Override
|
||||
public void remove(int index)
|
||||
{
|
||||
fData.remove(index);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('[');
|
||||
for (Attribute child : fData)
|
||||
{
|
||||
builder.append(child.toString());
|
||||
builder.append(' ');
|
||||
}
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
53
source/java/org/alfresco/repo/attributes/ListEntry.java
Normal file
53
source/java/org/alfresco/repo/attributes/ListEntry.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Interface for list entries.
|
||||
* @author britt
|
||||
*/
|
||||
public interface ListEntry extends Serializable
|
||||
{
|
||||
/**
|
||||
* Get the List this is an entry for.
|
||||
* @return The ListAttribute.
|
||||
*/
|
||||
public ListAttribute getList();
|
||||
|
||||
/**
|
||||
* Get the index of this entry in the ListAttribute.
|
||||
* @return The index.
|
||||
*/
|
||||
public int getIndex();
|
||||
|
||||
/**
|
||||
* Get the Attribute for this entry.
|
||||
* @return The Attribute
|
||||
*/
|
||||
public Attribute getAttribute();
|
||||
}
|
75
source/java/org/alfresco/repo/attributes/ListEntryDAO.java
Normal file
75
source/java/org/alfresco/repo/attributes/ListEntryDAO.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.util.List;
|
||||
|
||||
/**
|
||||
* DAO interface for ListEntries.
|
||||
* @author britt
|
||||
*/
|
||||
public interface ListEntryDAO
|
||||
{
|
||||
/**
|
||||
* Save a new Entry.
|
||||
* @param entry
|
||||
*/
|
||||
public void save(ListEntry entry);
|
||||
|
||||
/**
|
||||
* Get the entry for the give list and index.
|
||||
* @param list The ListAttribute.
|
||||
* @param index The index.
|
||||
* @return The ListEntry.
|
||||
*/
|
||||
public ListEntry get(ListAttribute list, int index);
|
||||
|
||||
/**
|
||||
* Get all entries for a given list.
|
||||
* @param list The ListAttribute.
|
||||
* @return The entries.
|
||||
*/
|
||||
public List<ListEntry> get(ListAttribute list);
|
||||
|
||||
/**
|
||||
* Delete a list entry.
|
||||
* @param entry
|
||||
*/
|
||||
public void delete(ListEntry entry);
|
||||
|
||||
/**
|
||||
* Delete all entries from a list.
|
||||
* @param list
|
||||
*/
|
||||
public void delete(ListAttribute list);
|
||||
|
||||
/**
|
||||
* Get the size of the entries.
|
||||
* @param list The list.
|
||||
* @return The count of entries.
|
||||
*/
|
||||
public int size(ListAttribute list);
|
||||
}
|
106
source/java/org/alfresco/repo/attributes/ListEntryImpl.java
Normal file
106
source/java/org/alfresco/repo/attributes/ListEntryImpl.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Implementation of ListEntry
|
||||
* @author britt
|
||||
*/
|
||||
public class ListEntryImpl implements ListEntry
|
||||
{
|
||||
private static final long serialVersionUID = 1573391734169157835L;
|
||||
|
||||
private long fID;
|
||||
|
||||
private ListAttribute fList;
|
||||
|
||||
private int fIndex;
|
||||
|
||||
private Attribute fAttribute;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public ListEntryImpl()
|
||||
{
|
||||
}
|
||||
|
||||
public ListEntryImpl(ListAttribute list, int index, Attribute attr)
|
||||
{
|
||||
fList = list;
|
||||
fIndex = index;
|
||||
fAttribute = attr;
|
||||
}
|
||||
|
||||
public void setId(long id)
|
||||
{
|
||||
fID = id;
|
||||
}
|
||||
|
||||
public long getId()
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntry#getAttribute()
|
||||
*/
|
||||
public Attribute getAttribute()
|
||||
{
|
||||
return fAttribute;
|
||||
}
|
||||
|
||||
public void setAttribute(Attribute attr)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@@ -110,6 +110,11 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
||||
newAttr = new MapAttributeImpl((MapAttribute)value);
|
||||
break;
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
newAttr = new ListAttributeImpl((ListAttribute)value);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
|
||||
@@ -248,4 +253,13 @@ public class MapAttributeImpl extends AttributeImpl implements MapAttribute
|
||||
builder.append('}');
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeImpl#size()
|
||||
*/
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return AVMDAOs.Instance().fMapEntryDAO.size(this);
|
||||
}
|
||||
}
|
||||
|
@@ -108,6 +108,11 @@ public class MapAttributeValue extends AttributeValue implements MapAttribute
|
||||
newAttr = new MapAttributeValue((MapAttribute)value);
|
||||
break;
|
||||
}
|
||||
case LIST :
|
||||
{
|
||||
newAttr = new ListAttributeValue((ListAttribute)value);
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unknown Attribute Type: " + value.getType());
|
||||
|
@@ -40,4 +40,11 @@ public interface MapEntryDAO
|
||||
* @return A List of all entries in the given map.
|
||||
*/
|
||||
public List<MapEntry> get(MapAttribute mapAttr);
|
||||
|
||||
/**
|
||||
* Get the number of entries in a MapAttribute.
|
||||
* @param mapAttr The MapAttribute/
|
||||
* @return The number of entries.
|
||||
*/
|
||||
public int size(MapAttribute mapAttr);
|
||||
}
|
||||
|
@@ -33,6 +33,8 @@ import java.util.Map;
|
||||
import org.alfresco.repo.attributes.AttrQueryHelperImpl;
|
||||
import org.alfresco.repo.attributes.Attribute;
|
||||
import org.alfresco.repo.attributes.AttributeDAO;
|
||||
import org.alfresco.repo.attributes.ListAttribute;
|
||||
import org.alfresco.repo.attributes.ListEntryDAO;
|
||||
import org.alfresco.repo.attributes.MapAttribute;
|
||||
import org.alfresco.repo.attributes.MapEntry;
|
||||
import org.alfresco.repo.attributes.MapEntryDAO;
|
||||
@@ -52,6 +54,8 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
{
|
||||
private MapEntryDAO fMapEntryDAO;
|
||||
|
||||
private ListEntryDAO fListEntryDAO;
|
||||
|
||||
public AttributeDAOHibernate()
|
||||
{
|
||||
}
|
||||
@@ -61,6 +65,11 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
fMapEntryDAO = dao;
|
||||
}
|
||||
|
||||
public void setListEntryDao(ListEntryDAO dao)
|
||||
{
|
||||
fListEntryDAO = dao;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeDAO#delete(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@@ -76,6 +85,19 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
delete(subAttr);
|
||||
}
|
||||
}
|
||||
if (attr.getType() == Type.LIST)
|
||||
{
|
||||
List<Attribute> children = new ArrayList<Attribute>();
|
||||
for (Attribute child : attr)
|
||||
{
|
||||
children.add(child);
|
||||
}
|
||||
fListEntryDAO.delete((ListAttribute)attr);
|
||||
for (Attribute child : children)
|
||||
{
|
||||
delete(child);
|
||||
}
|
||||
}
|
||||
getSession().delete(attr);
|
||||
}
|
||||
|
||||
|
@@ -67,6 +67,10 @@
|
||||
<subclass name="MapAttributeImpl" proxy="MapAttribute" lazy="true"
|
||||
discriminator-value="M">
|
||||
</subclass>
|
||||
<!-- A List class -->
|
||||
<subclass name="ListAttributeImpl" proxy="ListAttribute" lazy="true"
|
||||
discriminator-value="T">
|
||||
</subclass>
|
||||
</class>
|
||||
<class name="GlobalAttributeEntryImpl" proxy="GlobalAttributeEntry" table="alf_global_attributes">
|
||||
<cache usage="read-write"/>
|
||||
@@ -83,5 +87,16 @@
|
||||
<property name="key" type="string" length="160" column="mkey" index="map_key_index"/>
|
||||
</natural-id>
|
||||
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
|
||||
</class>
|
||||
</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>
|
||||
<many-to-one class="AttributeImpl" name="attribute" column="attribute_id"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.attributes.ListAttribute;
|
||||
import org.alfresco.repo.attributes.ListEntry;
|
||||
import org.alfresco.repo.attributes.ListEntryDAO;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
/**
|
||||
* @author britt
|
||||
*
|
||||
*/
|
||||
public class ListEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
ListEntryDAO
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#delete(org.alfresco.repo.attributes.ListEntry)
|
||||
*/
|
||||
public void delete(ListEntry entry)
|
||||
{
|
||||
getSession().delete(entry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#delete(org.alfresco.repo.attributes.ListAttribute)
|
||||
*/
|
||||
public void delete(ListAttribute list)
|
||||
{
|
||||
Query query = getSession().createQuery("delete from ListEntryImpl le where le.list = :list");
|
||||
query.setEntity("list", list);
|
||||
query.executeUpdate();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#get(org.alfresco.repo.attributes.ListAttribute, int)
|
||||
*/
|
||||
public ListEntry get(ListAttribute list, int index)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#get(org.alfresco.repo.attributes.ListAttribute)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ListEntry> get(ListAttribute list)
|
||||
{
|
||||
Query query = getSession().createQuery("from ListEntryImpl le where le.list = :list");
|
||||
query.setEntity("list", list);
|
||||
return (List<ListEntry>)query.list();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#save(org.alfresco.repo.attributes.ListEntry)
|
||||
*/
|
||||
public void save(ListEntry entry)
|
||||
{
|
||||
getSession().save(entry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.ListEntryDAO#size(org.alfresco.repo.attributes.ListAttribute)
|
||||
*/
|
||||
public int size(ListAttribute list)
|
||||
{
|
||||
Query query = getSession().createQuery("select count() from ListEntryImpl le where le.list = :list");
|
||||
query.setEntity("list", list);
|
||||
return (Integer)query.uniqueResult();
|
||||
}
|
||||
}
|
@@ -87,4 +87,14 @@ public class MapEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
{
|
||||
getSession().save(entry);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.MapEntryDAO#size(org.alfresco.repo.attributes.MapAttribute)
|
||||
*/
|
||||
public int size(MapAttribute mapAttr)
|
||||
{
|
||||
Query query = getSession().createQuery("select count() from MapEntryImpl me where me.map = :map");
|
||||
query.setEntity("map", mapAttr);
|
||||
return (Integer)query.uniqueResult();
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.repo.attributes.AttributeDAO;
|
||||
import org.alfresco.repo.attributes.GlobalAttributeEntryDAO;
|
||||
import org.alfresco.repo.attributes.ListEntryDAO;
|
||||
import org.alfresco.repo.attributes.MapEntryDAO;
|
||||
|
||||
/**
|
||||
@@ -89,6 +90,8 @@ public class AVMDAOs
|
||||
|
||||
public GlobalAttributeEntryDAO fGlobalAttributeEntryDAO;
|
||||
|
||||
public ListEntryDAO fListEntryDAO;
|
||||
|
||||
/**
|
||||
* @param nodeDAO the fAVMNodeDAO to set
|
||||
*/
|
||||
@@ -174,4 +177,9 @@ public class AVMDAOs
|
||||
{
|
||||
fGlobalAttributeEntryDAO = dao;
|
||||
}
|
||||
|
||||
public void setListEntryDAO(ListEntryDAO dao)
|
||||
{
|
||||
fListEntryDAO = dao;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.avm.locking;
|
||||
|
||||
import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* Bootstrap for AVM Locking Service.
|
||||
* @author britt
|
||||
*/
|
||||
public class AVMLockingBootstrap extends AbstractLifecycleBean
|
||||
{
|
||||
private AVMLockingServiceImpl fLockingService;
|
||||
|
||||
public void setAvmLockingService(AVMLockingServiceImpl service)
|
||||
{
|
||||
fLockingService = service;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
fLockingService.init();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
@@ -50,7 +50,6 @@ public interface AttributeService
|
||||
*/
|
||||
public Attribute getAttribute(List<String> keys);
|
||||
|
||||
|
||||
/**
|
||||
* Set an attribute. Overwrites if it exists.
|
||||
* @param name The name of the Attribute.
|
||||
|
Reference in New Issue
Block a user