protected <T> Class<? extends T> validate(String property, Class<T> propertyType) { Class<T> validatedType = (Class)validator.validate(getType(), property, propertyType); if (validatedType != null) { return validatedType; } else { throw new IllegalArgumentException("Illegal property " + property); } }
/** * Get a PathBuilder for the given property with the given type * * @param <A> * @param property property name * @param type * @return */ @SuppressWarnings("unchecked") public <A> PathBuilder<A> get(String property, Class<A> type) { PathBuilder<A> path = (PathBuilder<A>) properties.get(property); if (path == null || !type.isAssignableFrom(path.getType())) { Class<? extends A> vtype = validate(property, type); path = new PathBuilder<A>(vtype, forProperty(property), validator); properties.put(property, path); } return path; }
LOGGER.debug( "findByCriteria handle baseSearch by map-of-values for entity '{}'...", entity.getType());
/** * {@inheritDoc} */ @Override public <T> Class<?> getFieldType1(String fieldName, PathBuilder<T> entity) { Class<?> entityType = entity.getType(); String fieldNameToFindType = fieldName; // Makes the array of classes to find fieldName agains them Class<?>[] classArray = ArrayUtils.<Class<?>> toArray(entityType); if (fieldName.contains(SEPARATOR_FIELDS)) { String[] fieldNameSplitted = StringUtils.split(fieldName, SEPARATOR_FIELDS); for (int i = 0; i < fieldNameSplitted.length - 1; i++) { Class<?> fieldType = BeanUtils.findPropertyType( fieldNameSplitted[i], ArrayUtils.<Class<?>> toArray(entityType)); classArray = ArrayUtils.add(classArray, fieldType); entityType = fieldType; } fieldNameToFindType = fieldNameSplitted[fieldNameSplitted.length - 1]; } return BeanUtils.findPropertyType(fieldNameToFindType, classArray); }
JPAQuery query, Map<String, PathBuilder<?>> associationMap) { LOGGER.debug("Preparing associationMap and joins for entity {}...", entity.getType()); for (ColumnDef column : datatablesCriterias.getColumnDefs()) { LOGGER.trace("Added join {} -> {} as {}...", entity.getType(), associationPath, associationName);
/** * Obtains the class type of the property named as {@code fieldName} of the * entity. * * @param fieldName the field name. * @param entity the entity with a property named as {@code fieldName} * @return the class type */ public static <T> Class<?> getFieldType1(String fieldName, PathBuilder<T> entity) { Class<?> entityType = entity.getType(); String fieldNameToFindType = fieldName; // Makes the array of classes to find fieldName agains them Class<?>[] classArray = ArrayUtils.<Class<?>> toArray(entityType); if (fieldName.contains(SEPARATOR_FIELDS)) { String[] fieldNameSplitted = StringUtils.split(fieldName, SEPARATOR_FIELDS); for (int i = 0; i < fieldNameSplitted.length - 1; i++) { Class<?> fieldType = BeanUtils.findPropertyType( fieldNameSplitted[i], ArrayUtils.<Class<?>> toArray(entityType)); classArray = ArrayUtils.add(classArray, fieldType); entityType = fieldType; } fieldNameToFindType = fieldNameSplitted[fieldNameSplitted.length - 1]; } return BeanUtils.findPropertyType(fieldNameToFindType, classArray); }
JPAQuery query, Map<String, PathBuilder<?>> associationMap) { LOGGER.debug("Preparing associationMap and joins for entity {}...", entity.getType()); for (ColumnDef column : datatablesCriterias.getColumnDefs()) { LOGGER.trace("Added join {} -> {} as {}...", entity.getType(), associationPath, associationName);
searchStr, entity.getType()); if (findInAllColumns) { boolean expressionExists = false;
searchStr, entity.getType()); if (findInAllColumns) { boolean expressionExists = false;
/** * {@inheritDoc} */ @Override public <T> TypeDescriptor getTypeDescriptor(String fieldName, PathBuilder<T> entity) { Class<?> entityType = entity.getType(); if (entityType == Object.class) { // Remove from path the root "entity" alias String fromRootPath = entity.toString().replaceFirst("^[^.]+[.]", ""); TypeDescriptor fromRoot = getTypeDescriptor(fromRootPath, entity .getRoot().getType()); if (fromRoot == null) { return null; } entityType = fromRoot.getType(); } return getTypeDescriptor(fieldName, entityType); }
/** * Obtains the descriptor of the filtered field * * @param fieldName * @param entity * @return */ public static <T> TypeDescriptor getTypeDescriptor(String fieldName, PathBuilder<T> entity) { Class<?> entityType = entity.getType(); if (entityType == Object.class) { // Remove from path the root "entity" alias String fromRootPath = entity.toString().replaceFirst("^[^.]+[.]", ""); TypeDescriptor fromRoot = getTypeDescriptor(fromRootPath, entity .getRoot().getType()); if (fromRoot == null) { return null; } entityType = fromRoot.getType(); } return getTypeDescriptor(fieldName, entityType); }
throw new IllegalArgumentException(String.format( "Can't found field '%s' on entity '%s'", fieldName, entityPath.getType()));
throw new IllegalArgumentException(String.format( "Can't found field '%s' on entity '%s'", fieldName, entityPath.getType()));
.getEntityManager(entity.getType()); Assert.notNull(entityManager); Assert.notNull(datatablesCriterias); entity.getType(), isPaged, findInAllColumns); entity.getType(), e); SearchResults<T> searchResults = new SearchResults<T>( new ArrayList<T>(0), 0, isPaged, new Long( .getMetamodel().entity(entity.getType());
LOGGER.debug( "findByCriteria handle baseSearch by map-of-values for entity '{}'...", entity.getType()); entity.getType(), isPaged, findInAllColumns); entity.getType(), e); SearchResults<T> searchResults = new SearchResults<T>( new ArrayList<T>(0), 0, isPaged, new Long( .getMetamodel().entity(entity.getType());