/** * Process the traversal start event for a query {@link org.plasma.query.model.Property property} * within an {@link org.plasma.query.model.Expression expression} just traversing the property * path if exists and capturing context information for the current {@link * org.plasma.query.model.Expression expression}. * * @see org.plasma.query.visitor.DefaultQueryVisitor#start(org.plasma.query.model.Property) */ @Override public void start(Property property) { org.plasma.query.model.FunctionValues function = property.getFunction(); if (function != null) throw new GraphFilterException( "aggregate functions only supported in subqueries not primary queries"); Path path = property.getPath(); PlasmaType targetType = (PlasmaType) this.rootType; if (path != null) { for (int i = 0; i < path.getPathNodes().size(); i++) { AbstractPathElement pathElem = path.getPathNodes().get(i).getPathElement(); if (pathElem instanceof WildcardPathElement) throw new DataAccessException( "wildcard path elements applicable for 'Select' clause paths only, not 'Where' clause paths"); String elem = ((PathElement) pathElem).getValue(); PlasmaProperty prop = (PlasmaProperty) targetType.getProperty(elem); targetType = (PlasmaType) prop.getType(); // traverse } } PlasmaProperty endpointProp = (PlasmaProperty) targetType.getProperty(property.getName()); this.contextProperty = endpointProp; this.contextType = targetType; this.contextPropertyPath = property.asPathString(); super.start(property); }
public static Query createQuery(long seqId) { Select select = new Select( new String[] { "*", "left/*", "left/category/*", "right/*", "right/category/*", "categoryLink/left/*", "categoryLink/right/*", "categoryLink/left/parent/*", "categoryLink/right/parent/*", "categoryLink/left/parent/parent/*", "categoryLink/right/parent/parent/*", "categoryLink/left/parent/parent/parent/*", "categoryLink/right/parent/parent/parent/*", "categoryLink/left/parent/parent/parent/parent/*", "categoryLink/right/parent/parent/parent/parent/*", "categoryLink/left/parent/parent/parent/parent/parent/*", "categoryLink/right/parent/parent/parent/parent/parent/*", "categoryLink/left/parent/parent/parent/parent/parent/parent/*", "categoryLink/right/parent/parent/parent/parent/parent/parent/*", }); From from = new From(TaxonomyMap.TYPE_NAME_TAXONOMY_MAP, TaxonomyMap.NAMESPACE_URI); Where where = new Where(); where.addExpression(Property.forName(TaxonomyMap.PROPERTY.seqId.name()).eq(seqId)); return new Query(select, from, where); }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append(this.getClass().getSimpleName()); buf.append(" ["); buf.append(property.getName()); buf.append(" "); buf.append(this.operator.getValue().name()); buf.append(" "); buf.append(this.literal.getValue()); buf.append("]"); return buf.toString(); }
public static Query createQuery() { Select select = new Select( new String[] { "*", }); From from = new From(TaxonomyMap.TYPE_NAME_TAXONOMY_MAP, TaxonomyMap.NAMESPACE_URI); OrderBy orderBy = new OrderBy(); orderBy.addProperty(Property.forName(TaxonomyMap.PROPERTY.name.name())); Query query = new Query(select, from, orderBy); return query; }