private static Path getPathOfClass(TemplateQuery template, String pathStr) throws PathException { Path path = template.makePath(pathStr); if (path.endIsAttribute()) { path = path.getPrefix(); } return path; }
private static Path getPathOfClass(TemplateQuery template, String pathStr) throws PathException { Path path = template.makePath(pathStr); if (path.endIsAttribute()) { path = path.getPrefix(); } return path; }
/** * Returns the outer join group that the given path is in. * * @param stringPath a pathString * @return a String representing the outer join group that the path is in * @throws NullPointerException if pathString is null * @throws PathException if the query is invalid or the path is invalid * @throws NoSuchElementException is the path is not in the query */ public String getOuterJoinGroup(String stringPath) throws PathException { if (stringPath == null) { throw new NullPointerException("stringPath is null"); } Map<String, String> groups = getOuterJoinGroups(); Path path = makePath(stringPath); if (path.endIsAttribute()) { path = path.getPrefix(); } if (!groups.containsKey(path.getNoConstraintsString())) { throw new NoSuchElementException("Path " + stringPath + " is not in the query"); } return groups.get(path.getNoConstraintsString()); }
Path path = new Path(model, constraintEntry.getKey().getPath(), subclasses); if (path.getStartClassDescriptor().getUnqualifiedName().equals(rootClass)) { if (path.endIsAttribute()) { path = path.getPrefix();
Path path = new Path(model, constraintEntry.getKey().getPath(), subclasses); if (path.getStartClassDescriptor().getUnqualifiedName().equals(rootClass)) { if (path.endIsAttribute()) { path = path.getPrefix();
try { Path path = new Path(model, joinPath, subclasses); if (path.endIsAttribute()) { problems.add("Outer join status on path " + joinPath + " must not be on an attribute");
/** * Returns the outer join group that the given path is in. * * @param stringPath a pathString * @return a String representing the outer join group that the path is in * @throws NullPointerException if pathString is null * @throws PathException if the query is invalid or the path is invalid * @throws NoSuchElementException is the path is not in the query */ public String getOuterJoinGroup(String stringPath) throws PathException { if (stringPath == null) { throw new NullPointerException("stringPath is null"); } Map<String, String> groups = getOuterJoinGroups(); Path path = makePath(stringPath); if (path.endIsAttribute()) { path = path.getPrefix(); } if (!groups.containsKey(path.getNoConstraintsString())) { throw new NoSuchElementException("Path " + stringPath + " is not in the query"); } return groups.get(path.getNoConstraintsString()); }
try { Path path = new Path(model, joinPath, subclasses); if (path.endIsAttribute()) { problems.add("Outer join status on path " + joinPath + " must not be on an attribute");
/** * Populate a TemplateQuery that has a single editable constraint with the given value. This * returns a copy of the template with the value filled in. * @param template the template query to populate * @param op operation of the constraint * @param value value to be constrained to * @return a copy of the template with the value filled in * @throws PathException if the template is invalid */ public static TemplateQuery populateTemplateOneConstraint( TemplateQuery template, ConstraintOp op, String value) throws PathException { Map<String, List<TemplateValue>> templateValues = new HashMap<String, List<TemplateValue>>(); if (template.getEditableConstraints().size() != 1) { throw new RuntimeException("Template must have exactly one editable constraint to be " + " configured with a single value."); } String editablePath = template.getEditablePaths().get(0); Path path = template.makePath(editablePath); if (path.endIsAttribute()) { path = path.getPrefix(); } PathConstraint constraint = template.getEditableConstraints(editablePath).get(0); TemplateValue templateValue = new TemplateValue(constraint, op, value, TemplateValue.ValueType.SIMPLE_VALUE, SwitchOffAbility.ON); templateValues.put(constraint.getPath(), new ArrayList<TemplateValue>(Collections.singleton(templateValue))); return TemplatePopulator.getPopulatedTemplate(template, templateValues); }
/** * Populate a TemplateQuery that has a single editable constraint with the given value. This * returns a copy of the template with the value filled in. * @param template the template query to populate * @param op operation of the constraint * @param value value to be constrained to * @return a copy of the template with the value filled in * @throws PathException if the template is invalid */ public static TemplateQuery populateTemplateOneConstraint( TemplateQuery template, ConstraintOp op, String value) throws PathException { Map<String, List<TemplateValue>> templateValues = new HashMap<String, List<TemplateValue>>(); if (template.getEditableConstraints().size() != 1) { throw new RuntimeException("Template must have exactly one editable constraint to be " + " configured with a single value."); } String editablePath = template.getEditablePaths().get(0); Path path = template.makePath(editablePath); if (path.endIsAttribute()) { path = path.getPrefix(); } PathConstraint constraint = template.getEditableConstraints(editablePath).get(0); TemplateValue templateValue = new TemplateValue(constraint, op, value, TemplateValue.ValueType.SIMPLE_VALUE, SwitchOffAbility.ON); templateValues.put(constraint.getPath(), new ArrayList<TemplateValue>(Collections.singleton(templateValue))); return TemplatePopulator.getPopulatedTemplate(template, templateValues); }
private Set<String> validateView(List<String> problems, Set<String> validMainPaths) { if (view.isEmpty()) { problems.add(NO_VIEW_ERROR); } else { for (String viewPath : view) { try { Path path = new Path(model, viewPath, subclasses); if (!path.endIsAttribute()) { problems.add("Path " + viewPath + " in view list must be an attribute"); continue; } if (rootClass == null) { rootClass = path.getStartClassDescriptor().getUnqualifiedName(); } else { String newRootClass = path.getStartClassDescriptor().getUnqualifiedName(); if (!rootClass.equals(newRootClass)) { problems.add("Multiple root classes in query: " + rootClass + " and " + newRootClass); continue; } } addValidPaths(validMainPaths, path.getPrefix()); } catch (PathException e) { problems.add("Path " + viewPath + " in view list is not in the model"); } } } return validMainPaths; }
private Set<String> validateView(List<String> problems, Set<String> validMainPaths) { if (view.isEmpty()) { problems.add(NO_VIEW_ERROR); } else { for (String viewPath : view) { try { Path path = new Path(model, viewPath, subclasses); if (!path.endIsAttribute()) { problems.add("Path " + viewPath + " in view list must be an attribute"); continue; } if (rootClass == null) { rootClass = path.getStartClassDescriptor().getUnqualifiedName(); } else { String newRootClass = path.getStartClassDescriptor().getUnqualifiedName(); if (!rootClass.equals(newRootClass)) { problems.add("Multiple root classes in query: " + rootClass + " and " + newRootClass); continue; } } addValidPaths(validMainPaths, path.getPrefix()); } catch (PathException e) { problems.add("Path " + viewPath + " in view list is not in the model"); } } } return validMainPaths; }
if (path.endIsAttribute()) { throw new IllegalArgumentException("stringPath \"" + stringPath + "\" is an attribute, not a class");
if (path.endIsAttribute()) { throw new IllegalArgumentException("stringPath \"" + stringPath + "\" is an attribute, not a class");
if (path.endIsAttribute()) { constrainedType = path.getPrefix().getEndType().getSimpleName(); } else {
if (path.endIsAttribute()) { constrainedType = path.getPrefix().getEndType().getSimpleName(); } else {
/** * Returns true if the given Path object represents a path that is inner-joined onto the parent * path in this query. This will return false for the root class. Do not call this method with * a Path that is an attribute. * * @param path a Path object * @return true if the join is inner, not outer and not the root * @throws IllegalArgumentException if the path is an attribute */ private boolean isInner(Path path) { if (path.isRootPath()) { return false; } if (path.endIsAttribute()) { throw new IllegalArgumentException("Cannot call isInner() with a path that is an " + "attribute"); } OuterJoinStatus status = getOuterJoinStatus(path.getNoConstraintsString()); if (OuterJoinStatus.INNER.equals(status)) { return true; } else if (OuterJoinStatus.OUTER.equals(status)) { return false; } // Fall back on defaults return true; }
/** * Returns true if the given Path object represents a path that is inner-joined onto the parent * path in this query. This will return false for the root class. Do not call this method with * a Path that is an attribute. * * @param path a Path object * @return true if the join is inner, not outer and not the root * @throws IllegalArgumentException if the path is an attribute */ private boolean isInner(Path path) { if (path.isRootPath()) { return false; } if (path.endIsAttribute()) { throw new IllegalArgumentException("Cannot call isInner() with a path that is an " + "attribute"); } OuterJoinStatus status = getOuterJoinStatus(path.getNoConstraintsString()); if (OuterJoinStatus.INNER.equals(status)) { return true; } else if (OuterJoinStatus.OUTER.equals(status)) { return false; } // Fall back on defaults return true; }
if (path.endIsAttribute()) { path = path.getPrefix(); if (path.endIsAttribute()) { path = path.getPrefix(); if (path.endIsAttribute()) { path = path.getPrefix();
if (path.endIsAttribute()) { path = path.getPrefix(); if (path.endIsAttribute()) { path = path.getPrefix(); if (path.endIsAttribute()) { path = path.getPrefix();