Search in sources :

Example 1 with ObjectDetachOperation

use of org.apache.cayenne.util.ObjectDetachOperation in project cayenne by apache.

the class ClientServerChannelQueryAction method singleObjectConversion.

private List<?> singleObjectConversion(List<?> serverObjects) {
    // must clone the list to ensure we do not mess up the server list that can be
    // used elsewhere (e.g. it can be cached).
    List<Object> clientObjects = new ArrayList<>(serverObjects.size());
    ObjectDetachOperation op = new ObjectDetachOperation(serverResolver.getClientEntityResolver());
    PrefetchTreeNode prefetchTree = serverMetadata.getPrefetchTree();
    for (Object serverObject : serverObjects) {
        clientObjects.add(convertSingleObject(prefetchTree, op, serverObject));
    }
    return clientObjects;
}
Also used : ObjectDetachOperation(org.apache.cayenne.util.ObjectDetachOperation) PrefetchTreeNode(org.apache.cayenne.query.PrefetchTreeNode) ArrayList(java.util.ArrayList)

Example 2 with ObjectDetachOperation

use of org.apache.cayenne.util.ObjectDetachOperation in project cayenne by apache.

the class ClientServerChannelQueryAction method processMixedResult.

private List<Object[]> processMixedResult(List<Object[]> serverObjects, List<Object> rsMapping) {
    // must clone the list to ensure we do not mess up the server list that can be
    // used elsewhere (e.g. it can be cached).
    List<Object[]> clientObjects = new ArrayList<>(serverObjects.size());
    ObjectDetachOperation op = new ObjectDetachOperation(serverResolver.getClientEntityResolver());
    int width = rsMapping.size();
    for (Object[] serverObject : serverObjects) {
        Object[] clientObject = new Object[width];
        for (int i = 0; i < width; i++) {
            if (rsMapping.get(i) instanceof EntityResultSegment) {
                clientObject[i] = convertSingleObject(serverMetadata.getPrefetchTree(), op, serverObject[i]);
            } else {
                clientObject[i] = serverObject[i];
            }
        }
        clientObjects.add(clientObject);
    }
    return clientObjects;
}
Also used : ObjectDetachOperation(org.apache.cayenne.util.ObjectDetachOperation) ArrayList(java.util.ArrayList) EntityResultSegment(org.apache.cayenne.query.EntityResultSegment)

Aggregations

ArrayList (java.util.ArrayList)2 ObjectDetachOperation (org.apache.cayenne.util.ObjectDetachOperation)2 EntityResultSegment (org.apache.cayenne.query.EntityResultSegment)1 PrefetchTreeNode (org.apache.cayenne.query.PrefetchTreeNode)1