public PersistentResource toPersistentResource(RequestScope requestScope) throws ForbiddenAccessException, InvalidObjectIdentifierException { Class<?> cls = requestScope.getDictionary().getEntityClass(type); return PersistentResource.loadRecord(cls, id, requestScope); }
/** * Return annotation from class, parents or package. * * @param record the record * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(PersistentResource record, Class<A> annotationClass) { return getAnnotation(record.getResourceClass(), annotationClass); }
/** * Determine if a given (entity class, permission) pair have any permissions defined. * * @param resourceClass the entity class * @param annotationClass the permission annotation * @return {@code true} if that permission is defined anywhere within the class */ public boolean entityHasChecksForPermission(Class<?> resourceClass, Class<? extends Annotation> annotationClass) { EntityBinding binding = getEntityBinding(resourceClass); return binding.entityPermissions.hasChecksForPermission(annotationClass); }
public PersistentResource toPersistentResource(RequestScope requestScope) throws ForbiddenAccessException, InvalidObjectIdentifierException { Class<?> cls = requestScope.getDictionary().getEntityClass(type); if (cls == null) { throw new UnknownEntityException(type); } return PersistentResource.loadRecord(cls, id, requestScope); } }
/** * Set resource ID. * * @param id resource id */ public void setId(String id) { this.setValue(dictionary.getIdFieldName(getResourceClass()), id); }
/** * Bind a particular initializer to a class. * * @param <T> the type parameter * @param initializer Initializer to use for class * @param cls Class to bind initialization */ public <T> void bindInitializer(Initializer<T> initializer, Class<T> cls) { bindIfUnbound(cls); getEntityBinding(cls).setInitializer(initializer); }
/** * Returns annotations applied to the ID field. * * @return Collection of Annotations */ private Collection<Annotation> getIdAnnotations() { return dictionary.getIdAnnotations(getObject()); }
/** * Gets the specified permission definition (if any) at the class level. * * @param resourceClass the entity to check * @param annotationClass the permission to look for * @return a {@code ParseTree} expressing the permissions, if one exists * or {@code null} if the permission is not specified at a class level */ public ParseTree getPermissionsForClass(Class<?> resourceClass, Class<? extends Annotation> annotationClass) { EntityBinding binding = getEntityBinding(resourceClass); return binding.entityPermissions.getClassChecksForPermission(annotationClass); }
public <A extends Annotation> Collection<LifeCycleHook> getTriggers(Class<?> cls, Class<A> annotationClass, String fieldName) { return getEntityBinding(cls).getTriggers(annotationClass, fieldName); }
/** * Return annotation from class, parents or package. * * @param recordClass the record class * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(Class<?> recordClass, Class<A> annotationClass) { return getEntityBinding(recordClass).getAnnotation(annotationClass); }
/** * Returns the name of the id field. * * @param entityClass Entity class * @return id field name */ public String getIdFieldName(Class<?> entityClass) { return getEntityBinding(entityClass).getIdFieldName(); }
/** * Returns whether the entire entity uses Field or Property level access. * @param entityClass Entity Class * @return The JPA Access Type */ public AccessType getAccessType(Class<?> entityClass) { return getEntityBinding(entityClass).getAccessType(); }
/** * Returns type of id field. * * @param entityClass the entity class * @return ID type */ public Class<?> getIdType(Class<?> entityClass) { return getEntityBinding(entityClass).getIdType(); }
/** * Gets a check instance by first checking the entity dictionary for a mapping on the provided identifier. * In the event that no such mapping is found the identifier is used as a canonical name. * @param dictionary the entity dictionary to search for a mapping * @param checkName the identifier of the check to instantiate * @return the check instance * @throws IllegalArgumentException if there is no mapping for {@code checkName} and {@code checkName} is not * a canonical identifier */ default Check getCheck(EntityDictionary dictionary, String checkName) { Class<? extends Check> checkCls = dictionary.getCheck(checkName); return instantiateCheck(checkCls); }
public PersistentResource toPersistentResource(RequestScope requestScope) throws ForbiddenAccessException, InvalidObjectIdentifierException { Class<?> cls = requestScope.getDictionary().getEntityClass(type); return PersistentResource.loadRecord(cls, id, requestScope); }
/** * Set resource ID. * * @param id resource id */ public void setId(String id) { this.setValue(dictionary.getIdFieldName(getResourceClass()), id); }
/** * Return annotation from class, parents or package. * * @param record the record * @param annotationClass the annotation class * @param <A> genericClass * @return the annotation */ public <A extends Annotation> A getAnnotation(PersistentResource record, Class<A> annotationClass) { return getAnnotation(record.getResourceClass(), annotationClass); }
/** * Bind a particular initializer to a class. * * @param <T> the type parameter * @param initializer Initializer to use for class * @param cls Class to bind initialization */ public <T> void bindInitializer(Initializer<T> initializer, Class<T> cls) { bindIfUnbound(cls); getEntityBinding(cls).setInitializer(initializer); }
/** * Gets the specified permission definition (if any) at the class level. * * @param resourceClass the entity to check * @param annotationClass the permission to look for * @return a {@code ParseTree} expressing the permissions, if one exists * or {@code null} if the permission is not specified at a class level */ public ParseTree getPermissionsForClass(Class<?> resourceClass, Class<? extends Annotation> annotationClass) { EntityBinding binding = getEntityBinding(resourceClass); return binding.entityPermissions.getClassChecksForPermission(annotationClass); }