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);
}
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);
}
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();
}
}
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;
}
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;
}
Aggregations