Search in sources :

Example 1 with NodePropertyEntity

use of org.alfresco.repo.domain.node.NodePropertyEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectNodeProperties.

@Override
protected Map<NodeVersionKey, Map<NodePropertyKey, NodePropertyValue>> selectNodeProperties(Set<Long> nodeIds) {
    if (nodeIds.size() == 0) {
        return Collections.emptyMap();
    }
    NodePropertyEntity prop = new NodePropertyEntity();
    prop.setNodeIds(new ArrayList<Long>(nodeIds));
    List<NodePropertyEntity> rows = template.selectList(SELECT_NODE_PROPERTIES, prop);
    return makePersistentPropertiesMap(rows);
}
Also used : NodePropertyEntity(org.alfresco.repo.domain.node.NodePropertyEntity)

Example 2 with NodePropertyEntity

use of org.alfresco.repo.domain.node.NodePropertyEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectNodeProperties.

@Override
protected Map<NodeVersionKey, Map<NodePropertyKey, NodePropertyValue>> selectNodeProperties(Long nodeId, Set<Long> qnameIds) {
    NodePropertyEntity prop = new NodePropertyEntity();
    // Node
    prop.setNodeId(nodeId);
    // QName(s)
    switch(qnameIds.size()) {
        case 0:
            // Ignore
            break;
        case 1:
            prop.setKey(new NodePropertyKey());
            prop.getKey().setQnameId(qnameIds.iterator().next());
            break;
        default:
            prop.setQnameIds(new ArrayList<Long>(qnameIds));
    }
    List<NodePropertyEntity> rows = template.selectList(SELECT_NODE_PROPERTIES, prop);
    return makePersistentPropertiesMap(rows);
}
Also used : NodePropertyKey(org.alfresco.repo.domain.node.NodePropertyKey) NodePropertyEntity(org.alfresco.repo.domain.node.NodePropertyEntity)

Example 3 with NodePropertyEntity

use of org.alfresco.repo.domain.node.NodePropertyEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method insertNodeProperties.

@Override
protected void insertNodeProperties(Long nodeId, Map<NodePropertyKey, NodePropertyValue> persistableProps) {
    if (persistableProps.isEmpty()) {
        return;
    }
    List<NodePropertyEntity> rows = makePersistentRows(nodeId, persistableProps);
    startBatch();
    try {
        for (NodePropertyEntity row : rows) {
            template.insert(INSERT_NODE_PROPERTY, row);
        }
    } finally {
        executeBatch();
    }
}
Also used : NodePropertyEntity(org.alfresco.repo.domain.node.NodePropertyEntity)

Example 4 with NodePropertyEntity

use of org.alfresco.repo.domain.node.NodePropertyEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method makePersistentPropertiesMap.

/**
 * Pull out the key-value pairs from the rows
 */
private Map<NodeVersionKey, Map<NodePropertyKey, NodePropertyValue>> makePersistentPropertiesMap(List<NodePropertyEntity> rows) {
    Map<NodeVersionKey, Map<NodePropertyKey, NodePropertyValue>> results = new HashMap<NodeVersionKey, Map<NodePropertyKey, NodePropertyValue>>(3);
    for (NodePropertyEntity row : rows) {
        Long nodeId = row.getNodeId();
        Long nodeVersion = row.getNodeVersion();
        if (nodeId == null || nodeVersion == null) {
            throw new RuntimeException("Expect results with a Node and Version: " + row);
        }
        NodeVersionKey nodeTxnKey = new NodeVersionKey(nodeId, nodeVersion);
        Map<NodePropertyKey, NodePropertyValue> props = results.get(nodeTxnKey);
        if (props == null) {
            props = new HashMap<NodePropertyKey, NodePropertyValue>(17);
            results.put(nodeTxnKey, props);
        }
        props.put(row.getKey(), row.getValue());
    }
    // Done
    return results;
}
Also used : AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) NodeVersionKey(org.alfresco.repo.domain.node.NodeVersionKey) HashMap(java.util.HashMap) NodePropertyKey(org.alfresco.repo.domain.node.NodePropertyKey) NodePropertyValue(org.alfresco.repo.domain.node.NodePropertyValue) NodePropertyEntity(org.alfresco.repo.domain.node.NodePropertyEntity) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with NodePropertyEntity

use of org.alfresco.repo.domain.node.NodePropertyEntity in project alfresco-repository by Alfresco.

the class NodeDAOImpl method selectNodePropertiesByTypes.

@Override
@SuppressWarnings("rawtypes")
public List<NodePropertyEntity> selectNodePropertiesByTypes(Set<QName> qnames) {
    final List<NodePropertyEntity> properties = new ArrayList<NodePropertyEntity>();
    // qnames of properties that are encrypted
    Set<Long> qnameIds = qnameDAO.convertQNamesToIds(qnames, false);
    if (qnameIds.size() > 0) {
        IdsEntity param = new IdsEntity();
        param.setIds(new ArrayList<Long>(qnameIds));
        // TODO - use a callback approach
        template.select(SELECT_PROPERTIES_BY_TYPES, param, new ResultHandler() {

            @Override
            public void handleResult(ResultContext context) {
                properties.add((NodePropertyEntity) context.getResultObject());
            }
        });
    }
    return properties;
}
Also used : ResultContext(org.apache.ibatis.session.ResultContext) DefaultResultContext(org.apache.ibatis.executor.result.DefaultResultContext) IdsEntity(org.alfresco.ibatis.IdsEntity) NodePropertyEntity(org.alfresco.repo.domain.node.NodePropertyEntity) ArrayList(java.util.ArrayList) ResultHandler(org.apache.ibatis.session.ResultHandler)

Aggregations

NodePropertyEntity (org.alfresco.repo.domain.node.NodePropertyEntity)12 NodePropertyKey (org.alfresco.repo.domain.node.NodePropertyKey)5 ArrayList (java.util.ArrayList)4 NodePropertyValue (org.alfresco.repo.domain.node.NodePropertyValue)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IdsEntity (org.alfresco.ibatis.IdsEntity)2 BatchProcessor (org.alfresco.repo.batch.BatchProcessor)2 QName (org.alfresco.service.namespace.QName)2 DefaultResultContext (org.apache.ibatis.executor.result.DefaultResultContext)2 ResultContext (org.apache.ibatis.session.ResultContext)2 ResultHandler (org.apache.ibatis.session.ResultHandler)2 Serializable (java.io.Serializable)1 HashSet (java.util.HashSet)1 SealedObject (javax.crypto.SealedObject)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 BatchProcessWorkProvider (org.alfresco.repo.batch.BatchProcessWorkProvider)1 NodeVersionKey (org.alfresco.repo.domain.node.NodeVersionKey)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1