/** * {@inheritDoc} */ @Override public <T> Attribute<T> getSearchAttribute(String attributeName) { return new Attribute(attributeName); }
/** * Create a range criteria between the given min/max (inclusive). This is the same as calling <code>between(min, max, true, true)</code> * * @param min the minimum value in the range * @param max the maximum value in the range * @return criteria instance */ public Criteria between(T min, T max) { return between(min, max, true, true); }
/** * Get the defined search attributes indexed by attribute name *excluding* any search attributes that are automatically/implicitly * defined (eg. key and value attributes) * * @return search attributes */ public Map<String, SearchAttribute> getUserDefinedSearchAttributes() { Map<String, SearchAttribute> copy = new HashMap<String, SearchAttribute>(searchAttributes); copy.remove(Query.KEY.getAttributeName()); copy.remove(Query.VALUE.getAttributeName()); return copy; }
/** * Return this model aggregator as an ehacache aggregator. * * @return the aggregator */ public Aggregator asEhcacheObject(ClassLoader loader) { switch (op) { case Sum: return ma.asEhcacheObject(loader).sum(); case Min: return ma.asEhcacheObject(loader).min(); case Max: return ma.asEhcacheObject(loader).max(); case Count: return ma.asEhcacheObject(loader).count(); case Average: return ma.asEhcacheObject(loader).average(); } throw new IllegalStateException("Unknown agg operator: " + op); }
/** * Retrieve the object in the cache for the specified key. * * @param attribute The name of the attribute to match. * @param value The value of the attribute to match. * * @return The list of matching element or <code>null</code> if the key or element is <code>null</code> */ @SuppressWarnings("unchecked") public @Nullable List<E> list(String attribute, String value) { if (value == null) return null; Query query = this._cache.createQuery(); Attribute<String> byId = this._cache.getSearchAttribute(attribute); query.addCriteria(byId.eq(value)); Results results = query.execute(); List<Result> all = results.all(); List<E> entities = new ArrayList<>(); for (Result r : all) { entities.add((E)r.getValue()); } return entities; }
} else { for (Attribute attr : getAttributesImpliedByStar(ehcache)) { if (Query.KEY.equals(attr) || Query.VALUE.equals(attr)) continue; // TODO targetList.add(attr.getAttributeName()); if (Query.KEY.equals(attr) || Query.VALUE.equals(attr)) continue; // TODO q.includeAttribute(attr);
/** * Return this model aggregator as an ehacache aggregator. * * @return the aggregator */ public Aggregator asEhcacheObject(ClassLoader loader) { switch (op) { case Sum: return ma.asEhcacheObject(loader).sum(); case Min: return ma.asEhcacheObject(loader).min(); case Max: return ma.asEhcacheObject(loader).max(); case Count: return ma.asEhcacheObject(loader).count(); case Average: return ma.asEhcacheObject(loader).average(); } throw new IllegalStateException("Unknown agg operator: " + op); }
/** * Retrieve the object in the cache for the specified key. * * @param id The ID of the PageSeeder entity in the PageSeeder database. * * @return The version of the element or <code>null</code> if the key or element is <code>null</code> */ @Override @SuppressWarnings("unchecked") public synchronized @Nullable E get(Long id) { if (id == null) return null; @Nullable E o = null; Query query = this._cache.createQuery(); Attribute<Long> byId = this._cache.getSearchAttribute("id"); query.includeValues().addCriteria(byId.eq(id)); Results results = query.execute(); List<Result> all = results.all(); if (all.size() > 0) { Result r = all.get(0); o = (E)r.getValue(); } return o; }
} else { for (Attribute attr : getAttributesImpliedByStar(ehcache)) { if (Query.KEY.equals(attr) || Query.VALUE.equals(attr)) continue; // TODO targetList.add(attr.getAttributeName()); if (Query.KEY.equals(attr) || Query.VALUE.equals(attr)) continue; // TODO q.includeAttribute(attr);
private void disallowBuiltins(String attributeName) { if (Query.KEY.getAttributeName().equals(attributeName) || Query.VALUE.getAttributeName().equals(attributeName)) { throw new InvalidConfigurationException("\"" + attributeName + "\" is a reserved attribute name"); } }
@Override public Set<Attribute<?>> getAttributes() { return Collections.<Attribute<?>>singleton(new Attribute(attributeName)); }
/** * Retrieve the object in the cache for the specified key. * * @param attribute The name of the attribute to match. * @param value The value of the attribute to match. * * @return The version of the element or <code>null</code> if the key or element is <code>null</code> */ @SuppressWarnings("unchecked") public @Nullable E get(String attribute, String value) { if (value == null) return null; @Nullable E o = null; Query query = this._cache.createQuery(); Attribute<String> byId = this._cache.getSearchAttribute(attribute); query.includeValues().addCriteria(byId.eq(value)); Results results = query.execute(); List<Result> all = results.all(); if (all.size() > 0) { Result r = all.get(0); o = (E)r.getValue(); } return o; }
/** * Create a range criteria between the given min/max (inclusive). This is the same as calling <code>between(min, max, true, true)</code> * * @param min the minimum value in the range * @param max the maximum value in the range * @return criteria instance */ public Criteria between(T min, T max) { return between(min, max, true, true); }
private void processAttributes(Set<Attribute<?>> attributes) { for (Attribute<?> attr : attributes) { attribute(attr.getAttributeName()); } }
@Override public Set<Attribute<?>> getAttributes() { return Collections.<Attribute<?>>singleton(new Attribute(attributeName)); }
.includeKeys() .addCriteria( usernameSearchAttribute.eq(user.getEntityIdentifier().getKey())) .end(); final List<Result> queryResults = query.execute().all();
/** * Create a range criteria between the given min/max (inclusive). This is the same as calling <code>between(min, max, true, true)</code> * * @param min the minimum value in the range * @param max the maximum value in the range * @return criteria instance */ public Criteria between(T min, T max) { return between(min, max, true, true); }
private void processGroupBy(Set<Attribute<?>> attributes) { for (Attribute attr : attributes) { groupBy(attr.getAttributeName()); } }
@Override public Set<Attribute<?>> getAttributes() { return Collections.<Attribute<?>>singleton(new Attribute(attributeName)); }