/** * Return true if and only if the end of the path is an attribute. * @return the end-is-attribute flag */ public boolean endIsAttribute() { if (endFld == null) { return false; } return endFld.isAttribute(); }
/** * Return true if and only if the end of the path is an attribute. * @return the end-is-attribute flag */ public boolean endIsAttribute() { if (endFld == null) { return false; } return endFld.isAttribute(); }
/** * For a given class/field return true if it is an 'identifying' field. An * identifying field is an attribute (not a reference or collection) of the * class that is part of any key defined for that class. * * @param classKeys * map of classname to set of keys * @param clsName * the class name to look up * @param fieldName * the field name to look up * @return true if the field is an 'identifying' field for the class. */ public static boolean isKeyField(Map<String, List<FieldDescriptor>> classKeys, String clsName, String fieldName) { String className = TypeUtil.unqualifiedName(clsName); List<FieldDescriptor> keys = classKeys.get(className); if (keys != null) { for (FieldDescriptor key : keys) { if (key.getName().equals(fieldName) && key.isAttribute()) { return true; } } } return false; }
/** * For a given class/field return true if it is an 'identifying' field. An * identifying field is an attribute (not a reference or collection) of the * class that is part of any key defined for that class. * * @param classKeys * map of classname to set of keys * @param clsName * the class name to look up * @param fieldName * the field name to look up * @return true if the field is an 'identifying' field for the class. */ public static boolean isKeyField(Map<String, List<FieldDescriptor>> classKeys, String clsName, String fieldName) { String className = TypeUtil.unqualifiedName(clsName); List<FieldDescriptor> keys = classKeys.get(className); if (keys != null) { for (FieldDescriptor key : keys) { if (key.getName().equals(fieldName) && key.isAttribute()) { return true; } } } return false; }
if (!columnFD.isAttribute()) { String message = "field: " + fieldName + " in " + className + " is not an attribute field so cannot be used as a "
if (!columnFD.isAttribute()) { String message = "field: " + fieldName + " in " + className + " is not an attribute field so cannot be used as a "
/** * Return the type of the last element in the path, regardless of whether it is an attribute * or a class. * @return the Class of the last element */ public Class<?> getEndType() { Class<?> retval = null; if (endFld != null && endFld.isAttribute()) { retval = Util.getClassFromString(((AttributeDescriptor) endFld).getType()); } else { retval = getLastClassDescriptor().getType(); } return retval; }
/** * Return the type of the last element in the path, regardless of whether it is an attribute * or a class. * @return the Class of the last element */ public Class<?> getEndType() { Class<?> retval = null; if (endFld != null && endFld.isAttribute()) { retval = Util.getClassFromString(((AttributeDescriptor) endFld).getType()); } else { retval = getLastClassDescriptor().getType(); } return retval; }
body.append("objectText = '$_^" + c.getName() + "';\n"); for (FieldDescriptor fD : classFD) { if (fD.isAttribute() && !"id".equals(fD.getName()) ) { body.append("IF ( NEW." + getDBName(fD.getName()) + " IS NOT NULL ) THEN objectText := objectText || " + "'$_^a"
body.append("objectText = '$_^" + c.getName() + "';\n"); for (FieldDescriptor fD : classFD) { if (fD.isAttribute() && !"id".equals(fD.getName()) ) { body.append("IF ( NEW." + getDBName(fD.getName()) + " IS NOT NULL ) THEN objectText := objectText || " + "'$_^a"
body.append("objectText = '$_^" + c.getName() + "';\n"); for (FieldDescriptor fD : classFD) { if (fD.isAttribute() && !"id".equals(fD.getName()) ) { body.append("IF ( NEW." + getDBName(fD.getName()) + " IS NOT NULL ) THEN objectText := objectText || " + "'$_^a"
body.append("objectText = '$_^" + c.getName() + "';\n"); for (FieldDescriptor fD : classFD) { if (fD.isAttribute() && !"id".equals(fD.getName()) ) { body.append("IF ( NEW." + getDBName(fD.getName()) + " IS NOT NULL ) THEN objectText := objectText || " + "'$_^a"
if (fld.isAttribute()) { throw new PathException("Unable to resolve path '" + path + "': field '" + thisPart + "' of class '" + cld.getName() this.endFld = fld; if (!fld.isAttribute()) { String constrainedClassName = subClassConstraintPaths.get(currentPath.toString());
if (fld.isAttribute()) { throw new PathException("Unable to resolve path '" + path + "': field '" + thisPart + "' of class '" + cld.getName() this.endFld = fld; if (!fld.isAttribute()) { String constrainedClassName = subClassConstraintPaths.get(currentPath.toString());
/** * Attach the model. Throws IllegalArgumentExceptions if node doesn't map onto the model. * * @param model model to attach * @throws IllegalArgumentException if class or field are not found in the model */ public void setModel(Model model) { ClassDescriptor cld = model.getClassDescriptorByName(getParentType()); if (cld == null) { throw new IllegalArgumentException("No class '" + getParentType() + "' found in model '" + model.getName() + "'."); } fd = cld.getFieldDescriptorByName(fieldName); if (fd == null) { throw new IllegalArgumentException("Class '" + cld.getName() + "' does not have field '" + fieldName + "'."); } type = TypeUtil.unqualifiedName(fd.isAttribute() ? ((AttributeDescriptor) fd).getType() : ((ReferenceDescriptor) fd) .getReferencedClassDescriptor().getName()); attribute = fd.isAttribute(); reference = fd.isReference(); collection = fd.isCollection(); this.model = model; }
/** * Attach the model. Throws IllegalArgumentExceptions if node doesn't map onto the model. * * @param model model to attach * @throws IllegalArgumentException if class or field are not found in the model */ public void setModel(Model model) { ClassDescriptor cld = model.getClassDescriptorByName(getParentType()); if (cld == null) { throw new IllegalArgumentException("No class '" + getParentType() + "' found in model '" + model.getName() + "'."); } fd = cld.getFieldDescriptorByName(fieldName); if (fd == null) { throw new IllegalArgumentException("Class '" + cld.getName() + "' does not have field '" + fieldName + "'."); } type = TypeUtil.unqualifiedName(fd.isAttribute() ? ((AttributeDescriptor) fd).getType() : ((ReferenceDescriptor) fd) .getReferencedClassDescriptor().getName()); attribute = fd.isAttribute(); reference = fd.isReference(); collection = fd.isCollection(); this.model = model; }
for (FieldDescriptor fD : superFD) { if (classFD.contains(fD)) { if (fD.isAttribute()) { commonFields.add(fD.getName()); } else if (fD.isReference()) {
for (FieldDescriptor fD : superFD) { if (classFD.contains(fD)) { if (fD.isAttribute()) { commonFields.add(fD.getName()); } else if (fD.isReference()) {
/** * If the last element in the path is a reference or collection return the ClassDescriptor that * the reference or collection references. If the path has one element (eg. "Employee"), * return its ClassDescriptor. If the last element in the path is an attribute, return null. * @return the ClassDescriptor */ public ClassDescriptor getEndClassDescriptor() { if (getEndFieldDescriptor() == null) { return getStartClassDescriptor(); } if (!getEndFieldDescriptor().isAttribute()) { if (getEndFieldDescriptor().isCollection()) { CollectionDescriptor collDesc = (CollectionDescriptor) getEndFieldDescriptor(); return collDesc.getReferencedClassDescriptor(); } if (getEndFieldDescriptor().isReference()) { ReferenceDescriptor refDesc = (ReferenceDescriptor) getEndFieldDescriptor(); return refDesc.getReferencedClassDescriptor(); } } return null; }
/** * If the last element in the path is a reference or collection return the ClassDescriptor that * the reference or collection references. If the path has one element (eg. "Employee"), * return its ClassDescriptor. If the last element in the path is an attribute, return null. * @return the ClassDescriptor */ public ClassDescriptor getEndClassDescriptor() { if (getEndFieldDescriptor() == null) { return getStartClassDescriptor(); } if (!getEndFieldDescriptor().isAttribute()) { if (getEndFieldDescriptor().isCollection()) { CollectionDescriptor collDesc = (CollectionDescriptor) getEndFieldDescriptor(); return collDesc.getReferencedClassDescriptor(); } if (getEndFieldDescriptor().isReference()) { ReferenceDescriptor refDesc = (ReferenceDescriptor) getEndFieldDescriptor(); return refDesc.getReferencedClassDescriptor(); } } return null; }