mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.2 to HEAD (QNames)
7624: QName Refactor Merge 1 of 9 7625: QName Refactor Merge 2 of 9 7626: QName Refactor Merge 3 of 9 7627: QName Refactor Merge 4 of 9 7628: QName Refactor Merge 5 of 9 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8436 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
|
||||
<hibernate-mapping package="org.alfresco.repo.avm">
|
||||
|
||||
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName"/>
|
||||
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName" />
|
||||
|
||||
<!-- AVMNodeBean is the abstract base for filesystem like objects.
|
||||
We're using the one table per class hierarchy strategy to implement
|
||||
@@ -48,17 +48,17 @@
|
||||
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
|
||||
<set name="aspects" fetch="join" lazy="false" table="avm_aspects_new" cascade="all" optimistic-lock="true">
|
||||
<cache usage="read-write"/>
|
||||
<key column="id"/>
|
||||
<element type="QName" not-null="true" column="name" length="200"/>
|
||||
<key column="id" not-null="true" foreign-key="fk_avm_asp_n"/>
|
||||
<element column="qname_id" type="long" not-null="true"/>
|
||||
</set>
|
||||
<map name="properties" fetch="join" lazy="false" table="avm_node_properties_new" cascade="all" optimistic-lock="true">
|
||||
<cache usage="read-write"/>
|
||||
<key column="node_id" not-null="true"/>
|
||||
<map-key type="QName" length="200" column="qname"/>
|
||||
<key column="node_id" not-null="true" foreign-key="fk_avm_np_n"/>
|
||||
<map-key column="qname_id" type="long" />
|
||||
<composite-element class="org.alfresco.repo.domain.PropertyValue">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
@@ -141,6 +141,33 @@
|
||||
column="current_root_id" cascade="save-update" foreign-key="fk_avm_s_root">
|
||||
</many-to-one>
|
||||
</class>
|
||||
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
|
||||
<many-to-one
|
||||
name="name"
|
||||
class="org.alfresco.repo.domain.hibernate.QNameEntityImpl"
|
||||
column="qname_id"
|
||||
foreign-key="fk_avm_sp_qname"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
unique="false"
|
||||
not-null="true"
|
||||
cascade="none" />
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
<property name="doubleValue" column="double_value" type="double" />
|
||||
<property name="stringValue" column="string_value" type="string" length="1024"/>
|
||||
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
||||
</component>
|
||||
</class>
|
||||
<class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
|
||||
<cache usage="read-write"/>
|
||||
<id name="id" column="id" type="long">
|
||||
@@ -185,6 +212,20 @@
|
||||
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto" foreign-key="fk_avm_ml_to"/>
|
||||
</composite-id>
|
||||
</class>
|
||||
<!-- When a snapshot is created we stow away all of the layered
|
||||
nodes that were frozen by the snapshot so that subsequent
|
||||
snapshots can find them and force copies. -->
|
||||
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
|
||||
table="avm_version_layered_node_entry">
|
||||
<composite-id>
|
||||
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id" foreign-key="fk_avm_vlne_vr"/>
|
||||
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
|
||||
</composite-id>
|
||||
<property name="path" type="string" length="512" column="path"/>
|
||||
</class>
|
||||
|
||||
<!-- DEPRECATED START -->
|
||||
<!-- These are kept so that the AVMPropertiesPatch and AVMAspectsPatch -->
|
||||
<class name="AVMNodePropertyImpl" proxy="AVMNodeProperty" table="avm_node_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
@@ -192,27 +233,9 @@
|
||||
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_np_node"/>
|
||||
<property name="name" column="qname" type="QName" length="200" index="idx_avm_np_name"/>
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
<property name="doubleValue" column="double_value" type="double" />
|
||||
<property name="stringValue" column="string_value" type="string" length="1024"/>
|
||||
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
||||
</component>
|
||||
</class>
|
||||
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
|
||||
<property name="name" column="qname" type="QName" length="200" index="idx_avm_sp_name"/>
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
@@ -229,17 +252,8 @@
|
||||
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_asp_node"/>
|
||||
<property name="name" column="qname" type="QName" length="200"/>
|
||||
</class>
|
||||
<!-- When a snapshot is created we stow away all of the layered
|
||||
nodes that were frozen by the snapshot so that subsequent
|
||||
snapshots can find them and force copies. -->
|
||||
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
|
||||
table="avm_version_layered_node_entry">
|
||||
<composite-id>
|
||||
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id"/>
|
||||
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
|
||||
</composite-id>
|
||||
<property name="path" type="string" length="512" column="path"/>
|
||||
</class>
|
||||
<!-- DEPRECATED END -->
|
||||
|
||||
<class name="IssuerIDImpl" proxy="IssuerID" table="avm_issuer_ids" optimistic-lock="version" lazy="false">
|
||||
<id name="issuer" type="string" length="32" column="issuer"/>
|
||||
<version name="version" column="version" type="long"/>
|
||||
|
@@ -28,6 +28,8 @@ import java.util.List;
|
||||
import org.alfresco.repo.avm.AVMStore;
|
||||
import org.alfresco.repo.avm.AVMStoreProperty;
|
||||
import org.alfresco.repo.avm.AVMStorePropertyDAO;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
@@ -38,6 +40,16 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
*/
|
||||
class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMStorePropertyDAO
|
||||
{
|
||||
private QNameDAO qnameDAO;
|
||||
|
||||
/**
|
||||
* Set the DAO for accessing QName entities
|
||||
*/
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a property.
|
||||
* @param prop The AVMStoreProperty to persist.
|
||||
@@ -55,11 +67,25 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
*/
|
||||
public AVMStoreProperty get(AVMStore store, QName name)
|
||||
{
|
||||
Query query =
|
||||
getSession().createQuery("from AVMStorePropertyImpl asp where asp.store = :store and asp.name = :name");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", name);
|
||||
return (AVMStoreProperty)query.uniqueResult();
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(name);
|
||||
if (qnameEntity == null)
|
||||
{
|
||||
// No such QName
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where " +
|
||||
"asp.store = :store and " +
|
||||
"asp.name = :name");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", qnameEntity);
|
||||
return (AVMStoreProperty)query.uniqueResult();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,12 +111,30 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<AVMStoreProperty> queryByKeyPattern(AVMStore store, QName keyPattern)
|
||||
{
|
||||
// Get the URI and LocalName parts
|
||||
String uri = keyPattern.getNamespaceURI();
|
||||
if (uri == null || uri.length() == 0)
|
||||
{
|
||||
uri = "%";
|
||||
}
|
||||
String localName = keyPattern.getLocalName();
|
||||
if (localName == null || localName.length() == 0)
|
||||
{
|
||||
localName = "%";
|
||||
}
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name like :name");
|
||||
"join asp.name name " +
|
||||
"join name.namespace namespace " +
|
||||
"where " +
|
||||
"asp.store = :store and " +
|
||||
"namespace.uri like :uri and " +
|
||||
"name.localName like :localName");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", keyPattern);
|
||||
query.setParameter("uri", uri);
|
||||
query.setParameter("localName", localName);
|
||||
return (List<AVMStoreProperty>)query.list();
|
||||
}
|
||||
|
||||
@@ -102,11 +146,28 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<AVMStoreProperty> queryByKeyPattern(QName keyPattern)
|
||||
{
|
||||
// Get the URI and LocalName parts
|
||||
String uri = keyPattern.getNamespaceURI();
|
||||
if (uri == null || uri.length() == 0)
|
||||
{
|
||||
uri = "%";
|
||||
}
|
||||
String localName = keyPattern.getLocalName();
|
||||
if (localName == null || localName.length() == 0)
|
||||
{
|
||||
localName = "%";
|
||||
}
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where asp.name like :name");
|
||||
query.setParameter("name", keyPattern);
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"join asp.name name " +
|
||||
"join name.namespace namespace " +
|
||||
"where " +
|
||||
"namespace.uri like :uri and " +
|
||||
"name.localName like :localName");
|
||||
query.setParameter("uri", uri);
|
||||
query.setParameter("localName", localName);
|
||||
return (List<AVMStoreProperty>)query.list();
|
||||
}
|
||||
|
||||
@@ -126,12 +187,16 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
*/
|
||||
public void delete(AVMStore store, QName name)
|
||||
{
|
||||
Query delete =
|
||||
getSession().createQuery("delete from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name = :name");
|
||||
delete.setEntity("store", store);
|
||||
delete.setParameter("name", name);
|
||||
delete.executeUpdate();
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(name);
|
||||
if (qnameEntity != null)
|
||||
{
|
||||
Query delete =
|
||||
getSession().createQuery("delete from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name = :name");
|
||||
delete.setEntity("store", store);
|
||||
delete.setParameter("name", qnameEntity);
|
||||
delete.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user