mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added QName indexed properties to AVMRepositories.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3376 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -157,6 +157,12 @@
|
|||||||
<ref bean="sessionFactory"/>
|
<ref bean="sessionFactory"/>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="avmStorePropertyDAO" class="org.alfresco.repo.avm.hibernate.AVMStorePropertyDAOHibernate">
|
||||||
|
<property name="sessionFactory">
|
||||||
|
<ref bean="sessionFactory"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
|
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
|
||||||
<property name="issuerDAO">
|
<property name="issuerDAO">
|
||||||
@@ -192,6 +198,9 @@
|
|||||||
<property name="avmNodePropertyDAO">
|
<property name="avmNodePropertyDAO">
|
||||||
<ref bean="avmNodePropertyDAO"/>
|
<ref bean="avmNodePropertyDAO"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="avmStorePropertyDAO">
|
||||||
|
<ref bean="avmStorePropertyDAO"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- The HibernateTransactionManager -->
|
<!-- The HibernateTransactionManager -->
|
||||||
|
@@ -130,6 +130,12 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="avmStorePropertyDAO" class="org.alfresco.repo.avm.hibernate.AVMStorePropertyDAOHibernate">
|
||||||
|
<property name="sessionFactory">
|
||||||
|
<ref bean="sessionFactory"/>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
|
<bean id="avmContext" class="org.alfresco.repo.avm.AVMContext">
|
||||||
<property name="issuerDAO">
|
<property name="issuerDAO">
|
||||||
<ref bean="issuerDAO"/>
|
<ref bean="issuerDAO"/>
|
||||||
@@ -164,6 +170,9 @@
|
|||||||
<property name="avmNodePropertyDAO">
|
<property name="avmNodePropertyDAO">
|
||||||
<ref bean="avmNodePropertyDAO"/>
|
<ref bean="avmNodePropertyDAO"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="avmStorePropertyDAO">
|
||||||
|
<ref bean="avmStorePropertyDAO"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- The HibernateTransactionManager -->
|
<!-- The HibernateTransactionManager -->
|
||||||
|
@@ -75,6 +75,11 @@ public class AVMContext
|
|||||||
*/
|
*/
|
||||||
public AVMNodePropertyDAO fAVMNodePropertyDAO;
|
public AVMNodePropertyDAO fAVMNodePropertyDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AVMStorePropertyDAO
|
||||||
|
*/
|
||||||
|
public AVMStorePropertyDAO fAVMStorePropertyDAO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeDAO the fAVMNodeDAO to set
|
* @param nodeDAO the fAVMNodeDAO to set
|
||||||
*/
|
*/
|
||||||
@@ -159,4 +164,9 @@ public class AVMContext
|
|||||||
{
|
{
|
||||||
fAVMNodePropertyDAO = avmNodePropertyDAO;
|
fAVMNodePropertyDAO = avmNodePropertyDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAvmStorePropertyDAO(AVMStorePropertyDAO avmStorePropertyDAO)
|
||||||
|
{
|
||||||
|
fAVMStorePropertyDAO = avmStorePropertyDAO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -871,12 +871,12 @@ class AVMRepository
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @param value The value of the property.
|
* @param value The value of the property.
|
||||||
*/
|
*/
|
||||||
public void setProperty(String path, QName name, PropertyValue value)
|
public void setNodeProperty(String path, QName name, PropertyValue value)
|
||||||
{
|
{
|
||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts = SplitPath(path);
|
String [] pathParts = SplitPath(path);
|
||||||
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
||||||
store.setProperty(pathParts[1], name, value);
|
store.setNodeProperty(pathParts[1], name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -884,12 +884,12 @@ class AVMRepository
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param properties The Map of QNames to PropertyValues.
|
* @param properties The Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public void setProperties(String path, Map<QName, PropertyValue> properties)
|
public void setNodeProperties(String path, Map<QName, PropertyValue> properties)
|
||||||
{
|
{
|
||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts = SplitPath(path);
|
String [] pathParts = SplitPath(path);
|
||||||
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
||||||
store.setProperties(pathParts[1], properties);
|
store.setNodeProperties(pathParts[1], properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -899,12 +899,12 @@ class AVMRepository
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @return The PropertyValue or null if it does not exist.
|
* @return The PropertyValue or null if it does not exist.
|
||||||
*/
|
*/
|
||||||
public PropertyValue getProperty(int version, String path, QName name)
|
public PropertyValue getNodeProperty(int version, String path, QName name)
|
||||||
{
|
{
|
||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts = SplitPath(path);
|
String [] pathParts = SplitPath(path);
|
||||||
AVMStore store = getAVMStoreByName(pathParts[0], false);
|
AVMStore store = getAVMStoreByName(pathParts[0], false);
|
||||||
return store.getProperty(version, pathParts[1], name);
|
return store.getNodeProperty(version, pathParts[1], name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -913,12 +913,12 @@ class AVMRepository
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @return A Map of QNames to PropertyValues.
|
* @return A Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public Map<QName, PropertyValue> getProperties(int version, String path)
|
public Map<QName, PropertyValue> getNodeProperties(int version, String path)
|
||||||
{
|
{
|
||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts = SplitPath(path);
|
String [] pathParts = SplitPath(path);
|
||||||
AVMStore store = getAVMStoreByName(pathParts[0], false);
|
AVMStore store = getAVMStoreByName(pathParts[0], false);
|
||||||
return store.getProperties(version, pathParts[1]);
|
return store.getNodeProperties(version, pathParts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -926,12 +926,64 @@ class AVMRepository
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
*/
|
*/
|
||||||
public void deleteProperty(String path, QName name)
|
public void deleteNodeProperty(String path, QName name)
|
||||||
{
|
{
|
||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts = SplitPath(path);
|
String [] pathParts = SplitPath(path);
|
||||||
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
||||||
store.deleteProperty(pathParts[1], name);
|
store.deleteNodeProperty(pathParts[1], name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property on a store. Overwrites if property exists.
|
||||||
|
* @param store The AVMStore.
|
||||||
|
* @param name The QName.
|
||||||
|
* @param value The PropertyValue to set.
|
||||||
|
*/
|
||||||
|
public void setStoreProperty(String store, QName name, PropertyValue value)
|
||||||
|
{
|
||||||
|
getAVMStoreByName(store, true).setProperty(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a group of properties on a store. Overwrites any properties that exist.
|
||||||
|
* @param store The AVMStore.
|
||||||
|
* @param props The properties to set.
|
||||||
|
*/
|
||||||
|
public void setStoreProperties(String store, Map<QName, PropertyValue> props)
|
||||||
|
{
|
||||||
|
getAVMStoreByName(store, true).setProperties(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property from a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The property
|
||||||
|
* @return The property value or null if non-existent.
|
||||||
|
*/
|
||||||
|
public PropertyValue getStoreProperty(String store, QName name)
|
||||||
|
{
|
||||||
|
return getAVMStoreByName(store, false).getProperty(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties for a store.
|
||||||
|
* @param store The name of the Store.
|
||||||
|
* @return A Map of all the properties.
|
||||||
|
*/
|
||||||
|
public Map<QName, PropertyValue> getStoreProperties(String store)
|
||||||
|
{
|
||||||
|
return getAVMStoreByName(store, false).getProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property from a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The name of the property.
|
||||||
|
*/
|
||||||
|
public void deleteStoreProperty(String store, QName name)
|
||||||
|
{
|
||||||
|
getAVMStoreByName(store, true).deleteProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -317,14 +317,14 @@ public interface AVMService
|
|||||||
* @param name The QName of the property.
|
* @param name The QName of the property.
|
||||||
* @param value The property to set.
|
* @param value The property to set.
|
||||||
*/
|
*/
|
||||||
public void setProperty(String path, QName name, PropertyValue value);
|
public void setNodeProperty(String path, QName name, PropertyValue value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a collection of properties on a node.
|
* Set a collection of properties on a node.
|
||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param properties The Map of properties to set.
|
* @param properties The Map of properties to set.
|
||||||
*/
|
*/
|
||||||
public void setProperties(String path, Map<QName, PropertyValue> properties);
|
public void setNodeProperties(String path, Map<QName, PropertyValue> properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property of a node by QName.
|
* Get a property of a node by QName.
|
||||||
@@ -333,7 +333,7 @@ public interface AVMService
|
|||||||
* @param name The QName.
|
* @param name The QName.
|
||||||
* @return The PropertyValue or null if it doesn't exist.
|
* @return The PropertyValue or null if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
public PropertyValue getProperty(int version, String path, QName name);
|
public PropertyValue getNodeProperty(int version, String path, QName name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the properties associated with a node.
|
* Get all the properties associated with a node.
|
||||||
@@ -341,12 +341,49 @@ public interface AVMService
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @return A Map of QNames to PropertyValues.
|
* @return A Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public Map<QName, PropertyValue> getProperties(int version, String path);
|
public Map<QName, PropertyValue> getNodeProperties(int version, String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a property.
|
* Delete a property.
|
||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param name The QName of the property to delete.
|
* @param name The QName of the property to delete.
|
||||||
*/
|
*/
|
||||||
public void deleteProperty(String path, QName name);
|
public void deleteNodeProperty(String path, QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property on a store. If the property exists it will be overwritten.
|
||||||
|
* @param store The store to set the property on.
|
||||||
|
* @param name The name of the property.
|
||||||
|
* @param value The value of the property.
|
||||||
|
*/
|
||||||
|
public void setStoreProperty(String store, QName name, PropertyValue value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a group of properties on a store. Existing properties will be overwritten.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param props A Map of the properties to set.
|
||||||
|
*/
|
||||||
|
public void setStoreProperties(String store, Map<QName, PropertyValue> props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property from a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The name of the property.
|
||||||
|
* @return A PropertyValue or null if non-existent.
|
||||||
|
*/
|
||||||
|
public PropertyValue getStoreProperty(String store, QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @return A Map of the stores properties.
|
||||||
|
*/
|
||||||
|
public Map<QName, PropertyValue> getStoreProperties(String store);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property on a store by name.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The name of the property to delete.
|
||||||
|
*/
|
||||||
|
public void deleteStoreProperty(String store, QName name);
|
||||||
}
|
}
|
||||||
|
@@ -1037,7 +1037,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
* @param name The QName of the property.
|
* @param name The QName of the property.
|
||||||
* @param value The property to set.
|
* @param value The property to set.
|
||||||
*/
|
*/
|
||||||
public void setProperty(final String path, final QName name, final PropertyValue value)
|
public void setNodeProperty(final String path, final QName name, final PropertyValue value)
|
||||||
{
|
{
|
||||||
if (path == null || name == null || value == null)
|
if (path == null || name == null || value == null)
|
||||||
{
|
{
|
||||||
@@ -1047,7 +1047,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
{
|
{
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
fAVMRepository.setProperty(path, name, value);
|
fAVMRepository.setNodeProperty(path, name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TxnCallback doit = new TxnCallback();
|
TxnCallback doit = new TxnCallback();
|
||||||
@@ -1059,7 +1059,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param properties The Map of properties to set.
|
* @param properties The Map of properties to set.
|
||||||
*/
|
*/
|
||||||
public void setProperties(final String path, final Map<QName, PropertyValue> properties)
|
public void setNodeProperties(final String path, final Map<QName, PropertyValue> properties)
|
||||||
{
|
{
|
||||||
if (path == null || properties == null)
|
if (path == null || properties == null)
|
||||||
{
|
{
|
||||||
@@ -1069,7 +1069,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
{
|
{
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
fAVMRepository.setProperties(path, properties);
|
fAVMRepository.setNodeProperties(path, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TxnCallback doit = new TxnCallback();
|
TxnCallback doit = new TxnCallback();
|
||||||
@@ -1083,7 +1083,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
* @param name The QName.
|
* @param name The QName.
|
||||||
* @return The PropertyValue or null if it doesn't exist.
|
* @return The PropertyValue or null if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
public PropertyValue getProperty(final int version, final String path, final QName name)
|
public PropertyValue getNodeProperty(final int version, final String path, final QName name)
|
||||||
{
|
{
|
||||||
if (path == null || name == null)
|
if (path == null || name == null)
|
||||||
{
|
{
|
||||||
@@ -1095,7 +1095,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
|
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
value = fAVMRepository.getProperty(version, path, name);
|
value = fAVMRepository.getNodeProperty(version, path, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TxnCallback doit = new TxnCallback();
|
TxnCallback doit = new TxnCallback();
|
||||||
@@ -1109,7 +1109,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @return A List of AVMNodeProperties.
|
* @return A List of AVMNodeProperties.
|
||||||
*/
|
*/
|
||||||
public Map<QName, PropertyValue> getProperties(final int version, final String path)
|
public Map<QName, PropertyValue> getNodeProperties(final int version, final String path)
|
||||||
{
|
{
|
||||||
if (path == null)
|
if (path == null)
|
||||||
{
|
{
|
||||||
@@ -1121,7 +1121,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
|
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
properties = fAVMRepository.getProperties(version, path);
|
properties = fAVMRepository.getNodeProperties(version, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TxnCallback doit = new TxnCallback();
|
TxnCallback doit = new TxnCallback();
|
||||||
@@ -1134,7 +1134,7 @@ public class AVMServiceImpl implements AVMService
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param name The QName of the property to delete.
|
* @param name The QName of the property to delete.
|
||||||
*/
|
*/
|
||||||
public void deleteProperty(final String path, final QName name)
|
public void deleteNodeProperty(final String path, final QName name)
|
||||||
{
|
{
|
||||||
if (path == null || name == null)
|
if (path == null || name == null)
|
||||||
{
|
{
|
||||||
@@ -1144,7 +1144,125 @@ public class AVMServiceImpl implements AVMService
|
|||||||
{
|
{
|
||||||
public void perform()
|
public void perform()
|
||||||
{
|
{
|
||||||
fAVMRepository.deleteProperty(path, name);
|
fAVMRepository.deleteNodeProperty(path, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TxnCallback doit = new TxnCallback();
|
||||||
|
fTransaction.perform(doit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property on a store. If the property exists it will be overwritten.
|
||||||
|
* @param store The store to set the property on.
|
||||||
|
* @param name The name of the property.
|
||||||
|
* @param value The value of the property.
|
||||||
|
*/
|
||||||
|
public void setStoreProperty(final String store, final QName name, final PropertyValue value)
|
||||||
|
{
|
||||||
|
if (store == null || name == null || value == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Illegal null argument.");
|
||||||
|
}
|
||||||
|
class TxnCallback implements RetryingTransactionCallback
|
||||||
|
{
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
fAVMRepository.setStoreProperty(store, name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TxnCallback doit = new TxnCallback();
|
||||||
|
fTransaction.perform(doit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a group of properties on a store. Existing properties will be overwritten.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param props A Map of the properties to set.
|
||||||
|
*/
|
||||||
|
public void setStoreProperties(final String store, final Map<QName, PropertyValue> props)
|
||||||
|
{
|
||||||
|
if (store == null || props == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Illegal null argument.");
|
||||||
|
}
|
||||||
|
class TxnCallback implements RetryingTransactionCallback
|
||||||
|
{
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
fAVMRepository.setStoreProperties(store, props);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TxnCallback doit = new TxnCallback();
|
||||||
|
fTransaction.perform(doit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property from a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The name of the property.
|
||||||
|
* @return A PropertyValue or null if non-existent.
|
||||||
|
*/
|
||||||
|
public PropertyValue getStoreProperty(final String store, final QName name)
|
||||||
|
{
|
||||||
|
if (store == null || name == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Illegal null argument.");
|
||||||
|
}
|
||||||
|
class TxnCallback implements RetryingTransactionCallback
|
||||||
|
{
|
||||||
|
public PropertyValue value;
|
||||||
|
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
value = fAVMRepository.getStoreProperty(store, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TxnCallback doit = new TxnCallback();
|
||||||
|
fTransaction.perform(doit, false);
|
||||||
|
return doit.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with a store.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @return A Map of the stores properties.
|
||||||
|
*/
|
||||||
|
public Map<QName, PropertyValue> getStoreProperties(final String store)
|
||||||
|
{
|
||||||
|
if (store == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Null store name.");
|
||||||
|
}
|
||||||
|
class TxnCallback implements RetryingTransactionCallback
|
||||||
|
{
|
||||||
|
public Map<QName, PropertyValue> props;
|
||||||
|
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
props = fAVMRepository.getStoreProperties(store);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TxnCallback doit = new TxnCallback();
|
||||||
|
fTransaction.perform(doit, false);
|
||||||
|
return doit.props;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property on a store by name.
|
||||||
|
* @param store The name of the store.
|
||||||
|
* @param name The name of the property to delete.
|
||||||
|
*/
|
||||||
|
public void deleteStoreProperty(final String store, final QName name)
|
||||||
|
{
|
||||||
|
if (store == null || name == null)
|
||||||
|
{
|
||||||
|
throw new AVMBadArgumentException("Invalid null argument.");
|
||||||
|
}
|
||||||
|
class TxnCallback implements RetryingTransactionCallback
|
||||||
|
{
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
fAVMRepository.deleteStoreProperty(store, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TxnCallback doit = new TxnCallback();
|
TxnCallback doit = new TxnCallback();
|
||||||
|
@@ -2032,11 +2032,11 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
setupBasicTree();
|
setupBasicTree();
|
||||||
QName name = QName.createQName("silly.uri", "SillyProperty");
|
QName name = QName.createQName("silly.uri", "SillyProperty");
|
||||||
PropertyValue value = new PropertyValue(name, "Silly Property Value");
|
PropertyValue value = new PropertyValue(name, "Silly Property Value");
|
||||||
fService.setProperty("main:/a/b/c/foo", name, value);
|
fService.setNodeProperty("main:/a/b/c/foo", name, value);
|
||||||
fService.createSnapshot("main");
|
fService.createSnapshot("main");
|
||||||
PropertyValue returned = fService.getProperty(-1, "main:/a/b/c/foo", name);
|
PropertyValue returned = fService.getNodeProperty(-1, "main:/a/b/c/foo", name);
|
||||||
assertEquals(value.toString(), returned.toString());
|
assertEquals(value.toString(), returned.toString());
|
||||||
Map<QName, PropertyValue> props = fService.getProperties(-1, "main:/a/b/c/foo");
|
Map<QName, PropertyValue> props = fService.getNodeProperties(-1, "main:/a/b/c/foo");
|
||||||
assertEquals(1, props.size());
|
assertEquals(1, props.size());
|
||||||
assertEquals(value.toString(), props.get(name).toString());
|
assertEquals(value.toString(), props.get(name).toString());
|
||||||
props = new HashMap<QName, PropertyValue>();
|
props = new HashMap<QName, PropertyValue>();
|
||||||
@@ -2049,16 +2049,16 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
QName n3 = QName.createQName("silly.uri", "Prop3");
|
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||||
PropertyValue p3 = new PropertyValue(null, 42);
|
PropertyValue p3 = new PropertyValue(null, 42);
|
||||||
props.put(n3, p3);
|
props.put(n3, p3);
|
||||||
fService.setProperties("main:/a/b/c/bar", props);
|
fService.setNodeProperties("main:/a/b/c/bar", props);
|
||||||
fService.createSnapshot("main");
|
fService.createSnapshot("main");
|
||||||
props = fService.getProperties(-1, "main:/a/b/c/bar");
|
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||||
assertEquals(3, props.size());
|
assertEquals(3, props.size());
|
||||||
assertEquals(p1.toString(), props.get(n1).toString());
|
assertEquals(p1.toString(), props.get(n1).toString());
|
||||||
assertEquals(p2.toString(), props.get(n2).toString());
|
assertEquals(p2.toString(), props.get(n2).toString());
|
||||||
assertEquals(p3.toString(), props.get(n3).toString());
|
assertEquals(p3.toString(), props.get(n3).toString());
|
||||||
fService.deleteProperty("main:/a/b/c/bar", n1);
|
fService.deleteNodeProperty("main:/a/b/c/bar", n1);
|
||||||
fService.createSnapshot("main");
|
fService.createSnapshot("main");
|
||||||
props = fService.getProperties(-1, "main:/a/b/c/bar");
|
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||||
assertEquals(2, props.size());
|
assertEquals(2, props.size());
|
||||||
assertEquals(p2.toString(), props.get(n2).toString());
|
assertEquals(p2.toString(), props.get(n2).toString());
|
||||||
assertEquals(p3.toString(), props.get(n3).toString());
|
assertEquals(p3.toString(), props.get(n3).toString());
|
||||||
@@ -2068,4 +2068,43 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test properties on stores.
|
||||||
|
*/
|
||||||
|
public void testStoreProperties()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QName name = QName.createQName("silly.uri", "SillyProperty");
|
||||||
|
PropertyValue value = new PropertyValue(name, "Silly Property Value");
|
||||||
|
fService.setStoreProperty("main", name, value);
|
||||||
|
PropertyValue found = fService.getStoreProperty("main", name);
|
||||||
|
assertEquals(value.toString(), found.toString());
|
||||||
|
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
|
||||||
|
QName n1 = QName.createQName("silly.uri", "Prop1");
|
||||||
|
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
|
||||||
|
props.put(n1, p1);
|
||||||
|
QName n2 = QName.createQName("silly.uri", "Prop2");
|
||||||
|
PropertyValue p2 = new PropertyValue(null, "A String Property.");
|
||||||
|
props.put(n2, p2);
|
||||||
|
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||||
|
PropertyValue p3 = new PropertyValue(null, 42);
|
||||||
|
props.put(n3, p3);
|
||||||
|
fService.setStoreProperties("main", props);
|
||||||
|
props = fService.getStoreProperties("main");
|
||||||
|
assertEquals(4, props.size());
|
||||||
|
assertEquals(p1.toString(), props.get(n1).toString());
|
||||||
|
assertEquals(p2.toString(), props.get(n2).toString());
|
||||||
|
assertEquals(p3.toString(), props.get(n3).toString());
|
||||||
|
fService.deleteStoreProperty("main", name);
|
||||||
|
props = fService.getStoreProperties("main");
|
||||||
|
assertEquals(3, props.size());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -274,14 +274,14 @@ public interface AVMStore
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @param value The value to set.
|
* @param value The value to set.
|
||||||
*/
|
*/
|
||||||
public void setProperty(String path, QName name, PropertyValue value);
|
public void setNodeProperty(String path, QName name, PropertyValue value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a collection of properties on a node.
|
* Set a collection of properties on a node.
|
||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param properties The Map of QNames to PropertyValues.
|
* @param properties The Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public void setProperties(String path, Map<QName, PropertyValue> properties);
|
public void setNodeProperties(String path, Map<QName, PropertyValue> properties);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property by name.
|
* Get a property by name.
|
||||||
@@ -290,14 +290,14 @@ public interface AVMStore
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @return A PropertyValue or null if not found.
|
* @return A PropertyValue or null if not found.
|
||||||
*/
|
*/
|
||||||
public PropertyValue getProperty(int version, String path, QName name);
|
public PropertyValue getNodeProperty(int version, String path, QName name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a single property from a node.
|
* Delete a single property from a node.
|
||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
*/
|
*/
|
||||||
public void deleteProperty(String path, QName name);
|
public void deleteNodeProperty(String path, QName name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the properties associated with a node.
|
* Get all the properties associated with a node.
|
||||||
@@ -305,5 +305,37 @@ public interface AVMStore
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @return A Map of QNames to PropertyValues.
|
* @return A Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public Map<QName, PropertyValue> getProperties(int version, String path);
|
public Map<QName, PropertyValue> getNodeProperties(int version, String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property on this store. Replaces if property already exists.
|
||||||
|
* @param name The QName of the property.
|
||||||
|
* @param value The actual PropertyValue.
|
||||||
|
*/
|
||||||
|
public void setProperty(QName name, PropertyValue value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a group of properties on this store. Replaces any property that exists.
|
||||||
|
* @param properties A Map of QNames to PropertyValues to set.
|
||||||
|
*/
|
||||||
|
public void setProperties(Map<QName, PropertyValue> properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property by name.
|
||||||
|
* @param name The QName of the property to fetch.
|
||||||
|
* @return The PropertyValue or null if non-existent.
|
||||||
|
*/
|
||||||
|
public PropertyValue getProperty(QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with this node.
|
||||||
|
* @return A Map of the properties.
|
||||||
|
*/
|
||||||
|
public Map<QName, PropertyValue> getProperties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property.
|
||||||
|
* @param name The name of the property to delete.
|
||||||
|
*/
|
||||||
|
public void deleteProperty(QName name);
|
||||||
}
|
}
|
@@ -24,6 +24,7 @@ import java.io.RandomAccessFile;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
@@ -833,7 +834,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @param value The value to set.
|
* @param value The value to set.
|
||||||
*/
|
*/
|
||||||
public void setProperty(String path, QName name, PropertyValue value)
|
public void setNodeProperty(String path, QName name, PropertyValue value)
|
||||||
{
|
{
|
||||||
Lookup lPath = lookup(-1, path, true);
|
Lookup lPath = lookup(-1, path, true);
|
||||||
AVMNode node = lPath.getCurrentNode();
|
AVMNode node = lPath.getCurrentNode();
|
||||||
@@ -845,7 +846,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param properties The Map of QNames to PropertyValues.
|
* @param properties The Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public void setProperties(String path, Map<QName, PropertyValue> properties)
|
public void setNodeProperties(String path, Map<QName, PropertyValue> properties)
|
||||||
{
|
{
|
||||||
Lookup lPath = lookup(-1, path, true);
|
Lookup lPath = lookup(-1, path, true);
|
||||||
AVMNode node = lPath.getCurrentNode();
|
AVMNode node = lPath.getCurrentNode();
|
||||||
@@ -859,7 +860,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
* @return A PropertyValue or null if not found.
|
* @return A PropertyValue or null if not found.
|
||||||
*/
|
*/
|
||||||
public PropertyValue getProperty(int version, String path, QName name)
|
public PropertyValue getNodeProperty(int version, String path, QName name)
|
||||||
{
|
{
|
||||||
Lookup lPath = lookup(version, path, false);
|
Lookup lPath = lookup(version, path, false);
|
||||||
AVMNode node = lPath.getCurrentNode();
|
AVMNode node = lPath.getCurrentNode();
|
||||||
@@ -872,7 +873,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @return A Map of QNames to PropertyValues.
|
* @return A Map of QNames to PropertyValues.
|
||||||
*/
|
*/
|
||||||
public Map<QName, PropertyValue> getProperties(int version, String path)
|
public Map<QName, PropertyValue> getNodeProperties(int version, String path)
|
||||||
{
|
{
|
||||||
Lookup lPath = lookup(version, path, false);
|
Lookup lPath = lookup(version, path, false);
|
||||||
AVMNode node = lPath.getCurrentNode();
|
AVMNode node = lPath.getCurrentNode();
|
||||||
@@ -884,10 +885,71 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
* @param path The path to the node.
|
* @param path The path to the node.
|
||||||
* @param name The name of the property.
|
* @param name The name of the property.
|
||||||
*/
|
*/
|
||||||
public void deleteProperty(String path, QName name)
|
public void deleteNodeProperty(String path, QName name)
|
||||||
{
|
{
|
||||||
Lookup lPath = lookup(-1, path, true);
|
Lookup lPath = lookup(-1, path, true);
|
||||||
AVMNode node = lPath.getCurrentNode();
|
AVMNode node = lPath.getCurrentNode();
|
||||||
node.deleteProperty(name);
|
node.deleteProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a property on this store. Replaces if property already exists.
|
||||||
|
* @param name The QName of the property.
|
||||||
|
* @param value The actual PropertyValue.
|
||||||
|
*/
|
||||||
|
public void setProperty(QName name, PropertyValue value)
|
||||||
|
{
|
||||||
|
AVMStoreProperty prop = new AVMStorePropertyImpl();
|
||||||
|
prop.setStore(this);
|
||||||
|
prop.setName(name);
|
||||||
|
prop.setValue(value);
|
||||||
|
AVMContext.fgInstance.fAVMStorePropertyDAO.save(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a group of properties on this store. Replaces any property that exists.
|
||||||
|
* @param properties A Map of QNames to PropertyValues to set.
|
||||||
|
*/
|
||||||
|
public void setProperties(Map<QName, PropertyValue> properties)
|
||||||
|
{
|
||||||
|
for (QName name : properties.keySet())
|
||||||
|
{
|
||||||
|
setProperty(name, properties.get(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property by name.
|
||||||
|
* @param name The QName of the property to fetch.
|
||||||
|
* @return The PropertyValue or null if non-existent.
|
||||||
|
*/
|
||||||
|
public PropertyValue getProperty(QName name)
|
||||||
|
{
|
||||||
|
return AVMContext.fgInstance.fAVMStorePropertyDAO.get(this, name).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with this node.
|
||||||
|
* @return A Map of the properties.
|
||||||
|
*/
|
||||||
|
public Map<QName, PropertyValue> getProperties()
|
||||||
|
{
|
||||||
|
List<AVMStoreProperty> props =
|
||||||
|
AVMContext.fgInstance.fAVMStorePropertyDAO.get(this);
|
||||||
|
Map<QName, PropertyValue> retVal = new HashMap<QName, PropertyValue>();
|
||||||
|
for (AVMStoreProperty prop : props)
|
||||||
|
{
|
||||||
|
retVal.put(prop.getName(), prop.getValue());
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property.
|
||||||
|
* @param name The name of the property to delete.
|
||||||
|
*/
|
||||||
|
public void deleteProperty(QName name)
|
||||||
|
{
|
||||||
|
AVMContext.fgInstance.fAVMStorePropertyDAO.delete(this, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
64
source/java/org/alfresco/repo/avm/AVMStoreProperty.java
Normal file
64
source/java/org/alfresco/repo/avm/AVMStoreProperty.java
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.avm;
|
||||||
|
|
||||||
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arbitrary properties associated with AVMStores.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public interface AVMStoreProperty
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set the AVMStore.
|
||||||
|
* @param store The AVMStore to set.
|
||||||
|
*/
|
||||||
|
public void setStore(AVMStore store);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AVMStore.
|
||||||
|
* @return The AVMStore this property belongs to.
|
||||||
|
*/
|
||||||
|
public AVMStore getStore();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the property.
|
||||||
|
* @param name The QName for the property.
|
||||||
|
*/
|
||||||
|
public void setName(QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this property.
|
||||||
|
* @return The QName of this property.
|
||||||
|
*/
|
||||||
|
public QName getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the actual property value.
|
||||||
|
* @param value The PropertyValue to set.
|
||||||
|
*/
|
||||||
|
public void setValue(PropertyValue value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual property value.
|
||||||
|
* @return The actual PropertyValue.
|
||||||
|
*/
|
||||||
|
public PropertyValue getValue();
|
||||||
|
}
|
69
source/java/org/alfresco/repo/avm/AVMStorePropertyDAO.java
Normal file
69
source/java/org/alfresco/repo/avm/AVMStorePropertyDAO.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.avm;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DAO interface for AVMStoreProperties.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public interface AVMStorePropertyDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Persist a property.
|
||||||
|
* @param prop The AVMStoreProperty to persist.
|
||||||
|
*/
|
||||||
|
public void save(AVMStoreProperty prop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property by store and name.
|
||||||
|
* @param store The AVMStore.
|
||||||
|
* @param name The QName of the property.
|
||||||
|
* @return The given AVMStoreProperty or null if not found.
|
||||||
|
*/
|
||||||
|
public AVMStoreProperty get(AVMStore store, QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with a store.
|
||||||
|
* @param store The AVMStore whose properties should be fetched.
|
||||||
|
* @return A List of properties associated with the store.
|
||||||
|
*/
|
||||||
|
public List<AVMStoreProperty> get(AVMStore store);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a modified property.
|
||||||
|
* @param prop The AVMStoreProperty to update.
|
||||||
|
*/
|
||||||
|
public void update(AVMStoreProperty prop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property from a store by name.
|
||||||
|
* @param store The AVMStore to delete from.
|
||||||
|
* @param name The name of the property.
|
||||||
|
*/
|
||||||
|
public void delete(AVMStore store, QName name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all properties associated with a store.
|
||||||
|
* @param store The AVMStore whose properties are to be deleted.
|
||||||
|
*/
|
||||||
|
public void delete(AVMStore store);
|
||||||
|
}
|
106
source/java/org/alfresco/repo/avm/AVMStorePropertyImpl.java
Normal file
106
source/java/org/alfresco/repo/avm/AVMStorePropertyImpl.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.avm;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple bean to hold properties attached to AVMStores.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -5419606158990318723L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The store that owns this property.
|
||||||
|
*/
|
||||||
|
private AVMStore fStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the property.
|
||||||
|
*/
|
||||||
|
private QName fName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual PropertyValue.
|
||||||
|
*/
|
||||||
|
private PropertyValue fValue;
|
||||||
|
|
||||||
|
public AVMStorePropertyImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the property.
|
||||||
|
* @return The QName for the property.
|
||||||
|
*/
|
||||||
|
public QName getName()
|
||||||
|
{
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the property.
|
||||||
|
* @param name The QName of the property.
|
||||||
|
*/
|
||||||
|
public void setName(QName name)
|
||||||
|
{
|
||||||
|
fName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the store this property belongs to.
|
||||||
|
* @return The AVMStore that owns this.
|
||||||
|
*/
|
||||||
|
public AVMStore getStore()
|
||||||
|
{
|
||||||
|
return fStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the store that this property belongs to.
|
||||||
|
* @param store The AVMStore.
|
||||||
|
*/
|
||||||
|
public void setStore(AVMStore store)
|
||||||
|
{
|
||||||
|
fStore = store;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual property value.
|
||||||
|
* @return A PropertyValue object.
|
||||||
|
*/
|
||||||
|
public PropertyValue getValue()
|
||||||
|
{
|
||||||
|
return fValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the actual property value.
|
||||||
|
* @param value The PropertyValue to set.
|
||||||
|
*/
|
||||||
|
public void setValue(PropertyValue value)
|
||||||
|
{
|
||||||
|
fValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -197,6 +197,23 @@
|
|||||||
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
||||||
</component>
|
</component>
|
||||||
</class>
|
</class>
|
||||||
|
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
|
||||||
|
<composite-id>
|
||||||
|
<key-many-to-one name="store" class="AVMStoreImpl" column="avm_store_id"/>
|
||||||
|
<key-property name="name" column="qname" type="QName" length="200"/>
|
||||||
|
</composite-id>
|
||||||
|
<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" />
|
||||||
|
<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>
|
||||||
<query name="ChildEntry.ByNameParent">
|
<query name="ChildEntry.ByNameParent">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
from ChildEntryImpl ce
|
from ChildEntryImpl ce
|
||||||
|
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.avm.hibernate;
|
||||||
|
|
||||||
|
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.service.namespace.QName;
|
||||||
|
import org.hibernate.Query;
|
||||||
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Hibernate implementation of the DAO for AVMNodeProperties.
|
||||||
|
* @author britt
|
||||||
|
*/
|
||||||
|
public class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMStorePropertyDAO
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Persist a property.
|
||||||
|
* @param prop The AVMStoreProperty to persist.
|
||||||
|
*/
|
||||||
|
public void save(AVMStoreProperty prop)
|
||||||
|
{
|
||||||
|
getSession().save(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a property by store and name.
|
||||||
|
* @param store The AVMStore.
|
||||||
|
* @param name The QName of the property.
|
||||||
|
* @return The given AVMStoreProperty or null if not found.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the properties associated with a store.
|
||||||
|
* @param store The AVMStore whose properties should be fetched.
|
||||||
|
* @return A List of properties associated with the store.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<AVMStoreProperty> get(AVMStore store)
|
||||||
|
{
|
||||||
|
Query query =
|
||||||
|
getSession().createQuery("from AVMStorePropertyImpl asp where asp.store = :store");
|
||||||
|
query.setEntity("store", store);
|
||||||
|
return (List<AVMStoreProperty>)query.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a modified property.
|
||||||
|
* @param prop The AVMStoreProperty to update.
|
||||||
|
*/
|
||||||
|
public void update(AVMStoreProperty prop)
|
||||||
|
{
|
||||||
|
// This is a no op for hibernate.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a property from a store by name.
|
||||||
|
* @param store The AVMStore to delete from.
|
||||||
|
* @param name The name of the property.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all properties associated with a store.
|
||||||
|
* @param store The AVMStore whose properties are to be deleted.
|
||||||
|
*/
|
||||||
|
public void delete(AVMStore store)
|
||||||
|
{
|
||||||
|
Query delete =
|
||||||
|
getSession().createQuery("delete from AVMStorePropertyImpl asp where asp.store = :store");
|
||||||
|
delete.setEntity("store", store);
|
||||||
|
delete.executeUpdate();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user