Added NodeDaoService.getNodePropertiesRaw(Long nodeId)

- Allow low-level retrieval of the persisted node properties
 - Unmarshalling of cm:auditable properties included


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15042 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-06-30 15:25:39 +00:00
parent e622af0425
commit ffb8441f71
2 changed files with 57 additions and 4 deletions

View File

@@ -32,6 +32,8 @@ import java.util.Set;
import org.alfresco.repo.domain.ChildAssoc;
import org.alfresco.repo.domain.NodeAssoc;
import org.alfresco.repo.domain.NodePropertyValue;
import org.alfresco.repo.domain.PropertyMapKey;
import org.alfresco.repo.domain.Transaction;
import org.alfresco.repo.domain.hibernate.DirtySessionAnnotation;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -136,6 +138,17 @@ public interface NodeDaoService
@DirtySessionAnnotation(markDirty=false)
public Serializable getNodeProperty(Long nodeId, QName propertyQName);
/**
*
* @param nodeId the node's ID
* @return Returns a copy of the low-level properties including auditable properties
* @throws ObjectNotFoundException if the node ID is invalid
*
* @see #getNodePair(NodeRef)
*/
@DirtySessionAnnotation(markDirty=false)
public Map<PropertyMapKey, NodePropertyValue> getNodePropertiesRaw(Long nodeId);
@DirtySessionAnnotation(markDirty=false)
public Map<QName, Serializable> getNodeProperties(Long nodeId);

View File

@@ -1306,12 +1306,52 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
{
Long nodeTypeQNameId = qnameDAO.getOrCreateQName(nodeTypeQName).getFirst();
if (!nodeTypeQNameId.equals(node.getTypeQNameId()))
{
node.setTypeQNameId(nodeTypeQNameId);
// We will need to record the change
recordNodeUpdate(node);
{
node.setTypeQNameId(nodeTypeQNameId);
// We will need to record the change
recordNodeUpdate(node);
}
}
}
public Map<PropertyMapKey, NodePropertyValue> getNodePropertiesRaw(Long nodeId)
{
Node node = getNodeNotNull(nodeId);
Map<PropertyMapKey, NodePropertyValue> props = node.getProperties();
// Copy this for adding
props = new HashMap<PropertyMapKey, NodePropertyValue>(props);
// Add the auditable properties
if (hasNodeAspect(node, ContentModel.ASPECT_AUDITABLE))
{
AuditableProperties auditable = node.getAuditableProperties();
Map<QName, Serializable> auditableProperties = auditable.getAuditableProperties();
for (Map.Entry<QName, Serializable> entry : auditableProperties.entrySet())
{
// Get default locale for the key
Pair<Long, Locale> defaultLocalePair = localeDAO.getDefaultLocalePair();
if (defaultLocalePair == null)
{
continue;
}
QName auditablePropertyQName = entry.getKey();
Pair<Long, QName> auditablePropertyQNamePair = qnameDAO.getQName(auditablePropertyQName);
if (auditablePropertyQNamePair == null)
{
continue;
}
Serializable auditablePropertyValue = entry.getValue();
NodePropertyValue npv = new NodePropertyValue(auditablePropertyQName, auditablePropertyValue);
PropertyMapKey npk = new PropertyMapKey();
npk.setQnameId(auditablePropertyQNamePair.getFirst());
npk.setListIndex(HibernateNodeDaoServiceImpl.IDX_NO_COLLECTION);
npk.setLocaleId(defaultLocalePair.getFirst());
// Add this property to the map
props.put(npk, npv);
}
}
// Done
return props;
}
public Serializable getNodeProperty(Long nodeId, QName propertyQName)