/** * Returns the OrderBy in string format. */ public String toStringFormat() { if (list.isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.size(); i++) { Property property = list.get(i); if (i > 0) { sb.append(", "); } sb.append(property.toStringFormat()); } return sb.toString(); }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<>(pairs.length); for (String pair : pairs) { if (!isEmptyString(pair)) { wordList.add(pair); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } if (wordList.size() == 4) { // nulls high or nulls low as 3rd and 4th boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc, wordList.get(2), wordList.get(3)); } String m = "Expecting a 1, 2 or 4 words in [" + Arrays.toString(pairs) + "] but got " + wordList; throw new RuntimeException(m); }
/** * Return a copy of the OrderBy. */ public OrderBy<T> copy() { OrderBy<T> copy = new OrderBy<T>(); for (int i = 0; i < list.size(); i++) { copy.add(list.get(i).copy()); } return copy; }
/** * Define the select and joins for this query. */ @SuppressWarnings("unchecked") public void configureBeanQuery(SpiQuery<?> query) { if (trimmedProperties != null && trimmedProperties.length() > 0) { query.select(trimmedProperties); if (filterMany != null){ query.setFilterMany(path, filterMany); } } if (secondaryChildren != null) { int trimPath = path.length() + 1; for (int i = 0; i < secondaryChildren.size(); i++) { OrmQueryProperties p = secondaryChildren.get(i); String path = p.getPath(); path = path.substring(trimPath); query.fetch(path, p.getProperties(), p.getFetchConfig()); query.setFilterMany(path, p.getFilterManyTrimPath(trimPath)); } } if (orderBy != null){ List<Property> orderByProps = orderBy.getProperties(); for (int i = 0; i < orderByProps.size(); i++) { orderByProps.get(i).trim(path); } query.setOrder(orderBy); } }
/** * Define the select and joins for this query. */ @SuppressWarnings("unchecked") public void configureBeanQuery(SpiQuery<?> query) { if (trimmedProperties != null && trimmedProperties.length() > 0) { query.select(trimmedProperties); if (filterMany != null){ query.setFilterMany(path, filterMany); } } if (secondaryChildren != null) { int trimPath = path.length() + 1; for (int i = 0; i < secondaryChildren.size(); i++) { OrmQueryProperties p = secondaryChildren.get(i); String path = p.getPath(); path = path.substring(trimPath); query.fetch(path, p.getProperties(), p.getFetchConfig()); query.setFilterMany(path, p.getFilterManyTrimPath(trimPath)); } } if (orderBy != null){ List<Property> orderByProps = orderBy.getProperties(); for (int i = 0; i < orderByProps.size(); i++) { orderByProps.get(i).trim(path); } query.setOrder(orderBy); } }
public List<OrmQueryProperties> removeQueryJoins() { List<OrmQueryProperties> queryJoins = detail.removeSecondaryQueries(); if (queryJoins != null){ if (orderBy != null){ // remove any orderBy properties that relate to // paths of the secondary queries for (int i = 0; i < queryJoins.size(); i++) { OrmQueryProperties joinPath = queryJoins.get(i); // loop through the orderBy properties and // move any ones related to the query join List<Property> properties = orderBy.getProperties(); Iterator<Property> it = properties.iterator(); while (it.hasNext()) { OrderBy.Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())){ // remove this orderBy segment and // add it to the secondary join it.remove(); joinPath.addSecJoinOrderProperty(property); } } } } } return queryJoins; }
public List<OrmQueryProperties> removeQueryJoins() { List<OrmQueryProperties> queryJoins = detail.removeSecondaryQueries(); if (queryJoins != null){ if (orderBy != null){ // remove any orderBy properties that relate to // paths of the secondary queries for (int i = 0; i < queryJoins.size(); i++) { OrmQueryProperties joinPath = queryJoins.get(i); // loop through the orderBy properties and // move any ones related to the query join List<Property> properties = orderBy.getProperties(); Iterator<Property> it = properties.iterator(); while (it.hasNext()) { OrderBy.Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())){ // remove this orderBy segment and // add it to the secondary join it.remove(); joinPath.addSecJoinOrderProperty(property); } } } } } return queryJoins; }
private List<OrmQueryProperties> removeQueryJoins() { List<OrmQueryProperties> queryJoins = detail.removeSecondaryQueries(); if (queryJoins != null) { if (orderBy != null) { // remove any orderBy properties that relate to // paths of the secondary queries for (OrmQueryProperties joinPath : queryJoins) { // loop through the orderBy properties and // move any ones related to the query join List<Property> properties = orderBy.getProperties(); Iterator<Property> it = properties.iterator(); while (it.hasNext()) { Property property = it.next(); if (property.getProperty().startsWith(joinPath.getPath())) { // remove this orderBy segment and // add it to the secondary join it.remove(); joinPath.addSecJoinOrderProperty(property); } } } } } return queryJoins; }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<String>(pairs.length); for (int i = 0; i < pairs.length; i++) { if (!isEmptyString(pairs[i])) { wordList.add(pairs[i]); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } String m = "Expecting a max of 2 words in [" + Arrays.toString(pairs) + "] but got " + wordList.size(); throw new RuntimeException(m); }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<String>(pairs.length); for (int i = 0; i < pairs.length; i++) { if (!isEmptyString(pairs[i])) { wordList.add(pairs[i]); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } String m = "Expecting a max of 2 words in [" + Arrays.toString(pairs) + "] but got " + wordList.size(); throw new RuntimeException(m); }
@Override public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { int childCount = ctx.getChildCount(); String path = child(ctx, 0); boolean asc = true; String nulls = null; String nullsFirstLast = null; if (childCount == 3) { asc = child(ctx, 1).startsWith(ASC); nullsFirstLast = ctx.getChild(2).getChild(1).getText(); nulls = NULLS; } else if (childCount == 2) { String firstChild = child(ctx, 1); if (firstChild.startsWith(NULLS)) { nullsFirstLast = ctx.getChild(1).getChild(1).getText(); nulls = NULLS; } else { asc = firstChild.startsWith(ASC); } } query.orderBy().add(new OrderBy.Property(path, asc, nulls, nullsFirstLast)); }
/** * Validate all the expression properties/paths given the bean descriptor. */ @Override public Set<String> validate(BeanType<T> desc) { SpiExpressionValidation validation = new SpiExpressionValidation(desc); if (whereExpressions != null) { whereExpressions.validate(validation); } if (havingExpressions != null) { havingExpressions.validate(validation); } if (orderBy != null) { for (Property property : orderBy.getProperties()) { validation.validate(property.getProperty()); } } return validation.getUnknownProperties(); }
/** * Returns the OrderBy in string format. */ public String toStringFormat() { if (list.isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.size(); i++) { Property property = list.get(i); if (i > 0) { sb.append(", "); } sb.append(property.toStringFormat()); } return sb.toString(); }
/** * Returns the OrderBy in string format. */ public String toStringFormat() { if (list.isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.size(); i++) { Property property = list.get(i); if (i > 0) { sb.append(", "); } sb.append(property.toStringFormat()); } return sb.toString(); }
private String parseProperty(Property p) { String propName = p.getProperty(); ElPropertyValue el = desc.getElGetValue(propName); if (el == null){ return p.toStringFormat(); } BeanProperty beanProperty = el.getBeanProperty(); if (beanProperty instanceof BeanPropertyAssoc<?>){ BeanPropertyAssoc<?> ap = (BeanPropertyAssoc<?>)beanProperty; IdBinder idBinder = ap.getTargetDescriptor().getIdBinder(); return idBinder.getOrderBy(el.getElName(), p.isAscending()); } return p.toStringFormat(); } }
private String parseProperty(Property p) { String propName = p.getProperty(); ElPropertyValue el = desc.getElGetValue(propName); if (el == null){ return p.toStringFormat(); } BeanProperty beanProperty = el.getBeanProperty(); if (beanProperty instanceof BeanPropertyAssoc<?>){ BeanPropertyAssoc<?> ap = (BeanPropertyAssoc<?>)beanProperty; IdBinder idBinder = ap.getTargetDescriptor().getIdBinder(); return idBinder.getOrderBy(el.getElName(), p.isAscending()); } return p.toStringFormat(); } }
private String parseProperty(Property p) { String propName = p.getProperty(); ElPropertyValue el = desc.getElGetValue(propName); if (el == null) { return p.toStringFormat(); } BeanProperty beanProperty = el.getBeanProperty(); if (beanProperty instanceof BeanPropertyAssoc<?>) { BeanPropertyAssoc<?> ap = (BeanPropertyAssoc<?>) beanProperty; IdBinder idBinder = ap.getTargetDescriptor().getIdBinder(); return idBinder.getOrderBy(el.getElName(), p.isAscending()); } return p.toStringFormat(); } }
public String toString() { return toStringFormat(); }
public String toString() { return toStringFormat(); }
public String toString() { return toStringFormat(); }