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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user