@Override public String currentNamespace() { return namespace.getNs(); }
public void set(Class<?> clazz) { previousNs = driver.get(); configureNs(clazz.isAnnotationPresent(Global.class) ? GLOBAL : ns); }
private Repository() { this.namespace = new Namespace(driver().namespace()); }
@Override public Repository namespace(String ns) { namespace.setNs(ns); return this; }
private Repository(String ns) { this.namespace = new Namespace(ns, driver().namespace()); }
private Payload createPayload(Pipe pipe, Object source, SourceMarker marker, Object oldSource, boolean present) { logger.finer("creating payload"); Payload payload = new Payload(); payload.setNs(r.namespace().getNs()); payload.setPipeClazz(pipe.getClass()); payload.setSourceJson(source); payload.setSourceMarkerJson(marker); payload.setOldSourceJson(oldSource); payload.setPresent(present); logger.finer("done"); return payload; }
@Override public Object action(IdRef<?> id, Class<?> clazz, ActionKey actionKey, String json, Map<String, String> params) { namespace.set(clazz); try { ActionMethod actionMethod = repositoryFeatures.getByClazz(clazz).getAction(actionKey); return RepositoryActions.execute(this, actionMethod, id, json, params); } finally { namespace.reset(); } }
private static Key convertWithinRightNamespace(Repository r, Class<?> clazz, IdRef<?> id) { r.namespace().set(clazz); try { Key parent = id.getParentId() == null ? null : toKey(r, id.getParentId()); String kind = KindResolver.getKindFromClass(id.getClazz()); return createKey(id, parent, kind); } finally { r.namespace().reset(); } }
private static Key convertWithinRightNamespace(Repository r, Class<?> clazz, IdRef<?> id) { r.namespace().set(clazz); try { Key parent = id.getParentId() == null ? null : toKey(r, id.getParentId()); String kind = KindResolver.getKindFromClass(id.getClazz()); return createKey(id, parent, kind); } finally { r.namespace().reset(); } }
public T only() throws NoResultException, MoreThanOneResultException { r.namespace().set(getClazz()); try { T object; if (isQueryById()) { object = executeQueryById(); } else { object = executeQueryOnly(); } if (object == null) { throw new NoResultException(); } return object; } finally { r.namespace().reset(); } }
public List<IdRef<T>> ids() { if (hasPostFilter() || hasPostOrder()) { throw new RuntimeException("ids() cannot be used with post query filter or order. You may need to add @Index to your model attributes."); } r.namespace().set(getClazz()); try { executedQueryType = QueryType.IDS; RepositoryHooks.beforeQuery(this); List<IdRef<T>> ids = hasForcedResponse(executedQueryType) ? getForcedResultIds() : doFetchIds(); executedResponse = ids; RepositoryHooks.afterQuery(this); return ids; } finally { r.namespace().reset(); } }