/** * Fetches data from the channel. */ protected void runQuery() { this.response = actingContext.getChannel().onQuery(actingContext, query); } }
/** * Fetches data from the channel. */ protected void runQuery() { this.response = actingContext.getChannel().onQuery(actingContext, query); } }
private void runQuery() { this.response = channel.getParentChannel().onQuery(null, serverQuery); }
/** * Returns a DataDomain used by this DataContext. DataDomain is looked up in * the DataChannel hierarchy. If a channel is not a DataDomain or a * DataContext, null is returned. * * @return DataDomain that is a direct or indirect parent of this * DataContext in the DataChannel hierarchy. * @since 1.1 */ public DataDomain getParentDataDomain() { attachToRuntimeIfNeeded(); if (channel == null) { return null; } if (channel instanceof DataDomain) { return (DataDomain) channel; } List response = channel.onQuery(this, new DataDomainQuery()).firstList(); if (response != null && response.size() > 0 && response.get(0) instanceof DataDomain) { return (DataDomain) response.get(0); } return null; }
/** * Returns a snapshot for ObjectId from the underlying snapshot cache. If cache * contains no snapshot, it will attempt fetching it using provided QueryEngine. If * fetch attempt fails or inconsistent data is returned, underlying cache will throw a * CayenneRuntimeException. * * @since 1.2 */ public synchronized DataRow getSnapshot(ObjectId oid) { if (context != null && context.getChannel() != null) { ObjectIdQuery query = new ObjectIdQuery(oid, true, ObjectIdQuery.CACHE); List<?> results = context.getChannel().onQuery(context, query).firstList(); return results.isEmpty() ? null : (DataRow) results.get(0); } else { return null; } }
/** * Returns a snapshot for ObjectId from the underlying snapshot cache. If cache * contains no snapshot, a null is returned. * * @since 1.1 */ public DataRow getCachedSnapshot(ObjectId oid) { if (context != null && context.getChannel() != null) { ObjectIdQuery query = new CachedSnapshotQuery(oid); List<?> results = context.getChannel().onQuery(context, query).firstList(); return results.isEmpty() ? null : (DataRow) results.get(0); } else { return null; } }
/** * Returns a snapshot for ObjectId from the underlying snapshot cache. If cache * contains no snapshot, it will attempt fetching it using provided QueryEngine. If * fetch attempt fails or inconsistent data is returned, underlying cache will throw a * CayenneRuntimeException. * * @since 1.2 */ public synchronized DataRow getSnapshot(ObjectId oid) { if (context != null && context.getChannel() != null) { ObjectIdQuery query = new ObjectIdQuery(oid, true, ObjectIdQuery.CACHE); List results = context.getChannel().onQuery(context, query).firstList(); return results.isEmpty() ? null : (DataRow) results.get(0); } else { return null; } }
/** * Returns a snapshot for ObjectId from the underlying snapshot cache. If cache * contains no snapshot, a null is returned. * * @since 1.1 */ public DataRow getCachedSnapshot(ObjectId oid) { if (context != null && context.getChannel() != null) { ObjectIdQuery query = new CachedSnapshotQuery(oid); List results = context.getChannel().onQuery(context, query).firstList(); return results.isEmpty() ? null : (DataRow) results.get(0); } else { return null; } }
List results = channel.onQuery(null, query).firstList();
private List objectsFromDataRowsFromParentContext(ClassDescriptor descriptor, List<? extends DataRow> dataRows) { return getChannel().onQuery(this, new ObjectsFromDataRowsQuery(descriptor, dataRows)).firstList(); }
protected Persistent findObject(Object nodeId) { // first do a lookup in ObjectStore; if even a hollow object is found, // return it; // if not - fetch. Persistent object = (Persistent) context.getGraphManager().getNode(nodeId); if (object != null) { return object; } ObjectId id = (ObjectId) nodeId; // this can happen if a NEW object is deleted and after that its // relationships are // modified if (id.isTemporary()) { return null; } // skip context cache lookup, go directly to its channel Query query = new ObjectIdQuery((ObjectId) nodeId); QueryResponse response = context.getChannel().onQuery(context, query); List<?> objects = response.firstList(); if (objects.size() == 0) { throw new CayenneRuntimeException("No object for ID exists: %s", nodeId); } else if (objects.size() > 1) { throw new CayenneRuntimeException("Expected zero or one object, instead query matched: %d", objects.size()); } return (Persistent) objects.get(0); }
QueryResponse response = context.getChannel().onQuery(context, query);
QueryResponse response = context.getChannel().onQuery(context, query);
QueryResponse result = channel.onQuery(null, query);
protected Object findReflexiveMaster(Persistent object, ObjRelationship toOneRel, String targetEntityName) { DbRelationship finalRel = toOneRel.getDbRelationships().get(0); ObjectContext context = object.getObjectContext(); // find committed snapshot - so we can't fetch from the context as it // will return // dirty snapshot; must go down the stack instead // how do we handle this for NEW objects correctly? For now bail from // the method if (object.getObjectId().isTemporary()) { return null; } ObjectIdQuery query = new ObjectIdQuery(object.getObjectId(), true, ObjectIdQuery.CACHE); QueryResponse response = context.getChannel().onQuery(null, query); List<?> result = response.firstList(); if (result == null || result.size() == 0) { return null; } DataRow snapshot = (DataRow) result.get(0); ObjectId id = snapshot.createTargetObjectId(targetEntityName, finalRel); // not using 'localObject', looking up in context instead, as within the // sorter // we only care about objects participating in transaction, so no need // to create // hollow objects return (id != null) ? context.getGraphManager().getNode(id) : null; }
static Object dispatch(DataChannel channel, ClientMessage message) { // do most common messages first... if (message instanceof QueryMessage) { return channel.onQuery(null, ((QueryMessage) message).getQuery()); } else if (message instanceof SyncMessage) { SyncMessage sync = (SyncMessage) message; return channel.onSync(null, sync.getSenderChanges(), sync.getType()); } else if (message instanceof BootstrapMessage) { return channel.getEntityResolver().getClientEntityResolver(); } else { throw new CayenneRuntimeException("Message dispatch error. Unsupported message: %s", message); } } }
static Object dispatch(DataChannel channel, ClientMessage message) { // do most common messages first... if (message instanceof QueryMessage) { return channel.onQuery(null, ((QueryMessage) message).getQuery()); } else if (message instanceof SyncMessage) { SyncMessage sync = (SyncMessage) message; return channel.onSync(null, sync.getSenderChanges(), sync.getType()); } else if (message instanceof BootstrapMessage) { return channel.getEntityResolver().getClientEntityResolver(); } else { throw new CayenneRuntimeException( "Message dispatch error. Unsupported message: " + message); } } }