public RootCollectionPageTotalsQueryBuilder(Class<?> entityClass, EntityDictionary dictionary, Session session) { super(dictionary, session); this.entityClass = dictionary.lookupEntityClass(entityClass); }
public RootCollectionFetchQueryBuilder(Class<?> entityClass, EntityDictionary dictionary, Session session) { super(dictionary, session); this.entityClass = dictionary.lookupEntityClass(entityClass); }
/** * Lookup subordinate database manager for provided entity class. * @param <T> type * @param cls provided class * @return database manager handling this entity */ protected <T> DataStore getSubManager(Class<T> cls) { // Follow for this class or super-class for Entity annotation Class<T> type = (Class<T>) dictionary.lookupEntityClass(cls); return dataStoreMap.get(type); } }
/** * Entity type. * * @return type resource class */ @Override @JsonIgnore public Class<T> getResourceClass() { return (Class) dictionary.lookupEntityClass(obj.getClass()); }
private static FilterExpressionPath getFilterExpressionPath( Class<?> type, String method, EntityDictionary dictionary) throws NoSuchMethodException { FilterExpressionPath path = dictionary.lookupEntityClass(type) .getMethod(method) .getAnnotation(FilterExpressionPath.class); return path; }
private static FilterExpressionPath getFilterExpressionPath( Class<?> type, String method, EntityDictionary dictionary) throws NoSuchMethodException { FilterExpressionPath path = dictionary.lookupEntityClass(type) .getMethod(method) .getAnnotation(FilterExpressionPath.class); return path; }
/** * Entity type. * * @return type resource class */ @Override @JsonIgnore public Class<T> getResourceClass() { return (Class) dictionary.lookupEntityClass(obj.getClass()); }
/** * Binds the entity class if not yet bound. * @param entityClass the class to bind. */ private void bindIfUnbound(Class<?> entityClass) { if (! entityBindings.containsKey(lookupEntityClass(entityClass))) { bindEntity(entityClass); } } }
/** * Binds the entity class if not yet bound. * @param entityClass the class to bind. */ private void bindIfUnbound(Class<?> entityClass) { if (! entityBindings.containsKey(lookupEntityClass(entityClass))) { bindEntity(entityClass); } } }
protected DataStoreTransaction getTransaction(Class<?> cls) { DataStoreTransaction transaction = transactions.get(this.multiplexManager.getSubManager(cls)); if (transaction == null) { Class entityClass = multiplexManager.getDictionary().lookupEntityClass(cls); throw new InvalidCollectionException(entityClass == null ? cls.getName() : entityClass.getName()); } return transaction; }
protected EntityBinding getEntityBinding(Class<?> entityClass) { if (isMappedInterface(entityClass)) { return EntityBinding.EMPTY_BINDING; } return entityBindings.getOrDefault(lookupEntityClass(entityClass), EntityBinding.EMPTY_BINDING); }
/** * Clone contents of object for possible reverse transaction. */ private Object cloneObject(Object object) { if (object == null) { return null; } Class<?> cls = multiplexManager.getDictionary().lookupEntityClass(object.getClass()); try { Object clone = cls.newInstance(); for (Field field : cls.getFields()) { field.set(clone, field.get(object)); } for (Method method : cls.getMethods()) { if (method.getName().startsWith("set")) { try { Method getMethod = cls.getMethod("get" + method.getName().substring(3)); method.invoke(clone, getMethod.invoke(object)); } catch (IllegalStateException | IllegalArgumentException | ReflectiveOperationException | SecurityException e) { return null; } } } return clone; } catch (InstantiationException | IllegalAccessException e) { // ignore } return null; }
/** * Walks the entity graph and performs a transform function on each element. * @param entities The roots of the entity graph. * @param transform The function to transform each entity class into a result. * @param <T> The result type. * @return The collection of results. */ public <T> List<T> walkEntityGraph(Set<Class<?>> entities, Function<Class<?>, T> transform) { ArrayList<T> results = new ArrayList<>(); Queue<Class<?>> toVisit = new ArrayDeque<>(entities); Set<Class<?>> visited = new HashSet<>(); while (! toVisit.isEmpty()) { Class<?> clazz = toVisit.remove(); results.add(transform.apply(clazz)); visited.add(clazz); for (String relationship : getElideBoundRelationships(clazz)) { Class<?> relationshipClass = getParameterizedType(clazz, relationship); try { lookupEntityClass(relationshipClass); } catch (IllegalArgumentException e) { /* The relationship hasn't been bound */ continue; } if (!visited.contains(relationshipClass)) { toVisit.add(relationshipClass); } } } return results; }
/** * Walks the entity graph and performs a transform function on each element. * @param entities The roots of the entity graph. * @param transform The function to transform each entity class into a result. * @param <T> The result type. * @return The collection of results. */ public <T> List<T> walkEntityGraph(Set<Class<?>> entities, Function<Class<?>, T> transform) { ArrayList<T> results = new ArrayList<>(); Queue<Class<?>> toVisit = new ArrayDeque<>(entities); Set<Class<?>> visited = new HashSet<>(); while (! toVisit.isEmpty()) { Class<?> clazz = toVisit.remove(); results.add(transform.apply(clazz)); visited.add(clazz); for (String relationship : getElideBoundRelationships(clazz)) { Class<?> relationshipClass = getParameterizedType(clazz, relationship); try { lookupEntityClass(relationshipClass); } catch (IllegalArgumentException e) { /* The relationship hasn't been bound */ continue; } if (!visited.contains(relationshipClass)) { toVisit.add(relationshipClass); } } } return results; }
protected EntityBinding getEntityBinding(Class<?> entityClass) { if (isMappedInterface(entityClass)) { return EntityBinding.EMPTY_BINDING; } return entityBindings.getOrDefault(lookupEntityClass(entityClass), EntityBinding.EMPTY_BINDING); }
protected void bindEntity(EntityDictionary dictionary, EntityType type) { try { Class mappedClass = type.getJavaType(); // Ignore this result. We are just checking to see if it throws an exception meaning that // provided class was _not_ an entity. dictionary.lookupEntityClass(mappedClass); // Bind if successful dictionary.bindEntity(mappedClass); } catch (IllegalArgumentException e) { // Ignore this entity // Turns out that hibernate may include non-entity types in this list when using things // like envers. Since they are not entities, we do not want to bind them into the entity // dictionary } }
protected void bindEntity(EntityDictionary dictionary, EntityType type) { try { Class mappedClass = type.getJavaType(); // Ignore this result. We are just checking to see if it throws an exception meaning that // provided class was _not_ an entity. dictionary.lookupEntityClass(mappedClass); // Bind if successful dictionary.bindEntity(mappedClass); } catch (IllegalArgumentException e) { // Ignore this entity // Turns out that hibernate may include non-entity types in this list when using things // like envers. Since they are not entities, we do not want to bind them into the entity // dictionary } }
/** * The filter expression is evaluated in memory if it cannot be pushed to the data store by elide for any reason. * * @param object object returned from datastore * @param requestScope Request scope object * @param changeSpec Summary of modifications * @return true if the object pass evaluation against FilterExpression. */ @Override public final boolean ok(T object, RequestScope requestScope, Optional<ChangeSpec> changeSpec) { Class entityClass = coreScope(requestScope).getDictionary().lookupEntityClass(object.getClass()); FilterExpression filterExpression = getFilterExpression(entityClass, requestScope); return filterExpression.accept(new FilterExpressionCheckEvaluationVisitor(object, this, requestScope)); }
/** * The filter expression is evaluated in memory if it cannot be pushed to the data store by elide for any reason. * * @param object object returned from datastore * @param requestScope Request scope object * @param changeSpec Summary of modifications * @return true if the object pass evaluation against FilterExpression. */ @Override public final boolean ok(T object, RequestScope requestScope, Optional<ChangeSpec> changeSpec) { Class entityClass = coreScope(requestScope).getDictionary().lookupEntityClass(object.getClass()); FilterExpression filterExpression = getFilterExpression(entityClass, requestScope); return filterExpression.accept(new FilterExpressionCheckEvaluationVisitor(object, this, requestScope)); }
dictionary.lookupEntityClass(mappedClass);