@Override public Object loadObject(Class<?> entityClass, Serializable id, Optional<FilterExpression> filterExpression, RequestScope scope) { Class idType = dictionary.getIdType(entityClass); String idField = dictionary.getIdFieldName(entityClass); FilterExpression idFilter = new InPredicate( new Path.PathElement(entityClass, idType, idField), id ); FilterExpression joinedFilterExpression = filterExpression .map(fe -> (FilterExpression) new AndFilterExpression(idFilter, fe)) .orElse(idFilter); Iterable<Object> results = loadObjects(entityClass, Optional.of(joinedFilterExpression), Optional.empty(), Optional.empty(), scope); Iterator<Object> it = results == null ? null : results.iterator(); if (it != null && it.hasNext()) { return it.next(); } return null; }
@Override public Object loadObject(Class<?> entityClass, Serializable id, Optional<FilterExpression> filterExpression, RequestScope scope) { Class idType = dictionary.getIdType(entityClass); String idField = dictionary.getIdFieldName(entityClass); FilterExpression idFilter = new InPredicate( new Path.PathElement(entityClass, idType, idField), id ); FilterExpression joinedFilterExpression = filterExpression .map(fe -> (FilterExpression) new AndFilterExpression(idFilter, fe)) .orElse(idFilter); Iterable<Object> results = loadObjects(entityClass, Optional.of(joinedFilterExpression), Optional.empty(), Optional.empty(), scope); Iterator<Object> it = results == null ? null : results.iterator(); if (it != null && it.hasNext()) { return it.next(); } return null; }
/** * Build an id filter expression for a particular entity type. * * @param ids Ids to include in the filter expression * @param entityType Type of entity * @return Filter expression for given ids and type. */ private static FilterExpression buildIdFilterExpression(List<String> ids, Class entityType, EntityDictionary dictionary, RequestScope scope) { Class<?> idType = dictionary.getIdType(entityType); String idField = dictionary.getIdFieldName(entityType); String typeAlias = dictionary.getJsonAliasFor(entityType); List<Object> coercedIds = ids.stream() .filter(id -> scope.getObjectById(typeAlias, id) == null) // these don't exist yet .map(id -> CoerceUtil.coerce(id, idType)) .collect(Collectors.toList()); /* construct a new SQL like filter expression, eg: book.id IN [1,2] */ FilterExpression idFilter = new InPredicate( new Path.PathElement( entityType, idType, idField), coercedIds); return idFilter; }
/** * Build an id filter expression for a particular entity type. * * @param ids Ids to include in the filter expression * @param entityType Type of entity * @return Filter expression for given ids and type. */ private static FilterExpression buildIdFilterExpression(List<String> ids, Class entityType, EntityDictionary dictionary, RequestScope scope) { Class<?> idType = dictionary.getIdType(entityType); String idField = dictionary.getIdFieldName(entityType); String typeAlias = dictionary.getJsonAliasFor(entityType); List<Object> coercedIds = ids.stream() .filter(id -> scope.getObjectById(typeAlias, id) == null) // these don't exist yet .map(id -> CoerceUtil.coerce(id, idType)) .collect(Collectors.toList()); /* construct a new SQL like filter expression, eg: book.id IN [1,2] */ FilterExpression idFilter = new InPredicate( new Path.PathElement( entityType, idType, idField), coercedIds); return idFilter; }
final Class<?> entityClass = types[i - 1]; final Class<?> fieldType = ("id".equals(field.toLowerCase(Locale.ENGLISH))) ? dictionary.getIdType(entityClass) : dictionary.getParameterizedType(entityClass, field); if (fieldType == null) {
final Class<?> entityClass = types[i - 1]; final Class<?> fieldType = ("id".equals(field.toLowerCase(Locale.ENGLISH))) ? dictionary.getIdType(entityClass) : dictionary.getParameterizedType(entityClass, field); if (fieldType == null) {
Class<?> idType = dictionary.getIdType(loadClass); obj = tx.loadObject(loadClass, (Serializable) CoerceUtil.coerce(id, idType), permissionFilter, requestScope);
Class<?> idType = dictionary.getIdType(loadClass); obj = tx.loadObject(loadClass, (Serializable) CoerceUtil.coerce(id, idType), permissionFilter, requestScope);
Class<?> idType = dictionary.getIdType(entityClass); String idField = dictionary.getIdFieldName(entityClass);
Class<?> idType = dictionary.getIdType(entityClass); String idField = dictionary.getIdFieldName(entityClass);
Class<?> idType = dictionary.getIdType(entityClass); String idField = dictionary.getIdFieldName(entityClass);
public Query build() { Class<?> parentType = dictionary.lookupEntityClass(relationship.getParentType()); Class<?> idType = dictionary.getIdType(parentType); Object idVal = CoerceUtil.coerce(dictionary.getId(relationship.getParent()), idType); String idField = dictionary.getIdFieldName(parentType);