1 56 package org.objectstyle.cayenne.project.validator; 57 58 import org.objectstyle.cayenne.map.ObjAttribute; 59 import org.objectstyle.cayenne.project.ProjectPath; 60 import org.objectstyle.cayenne.util.Util; 61 62 65 public class ObjAttributeValidator extends TreeNodeValidator { 66 67 70 public ObjAttributeValidator() { 71 super(); 72 } 73 74 public void validateObject(ProjectPath path, Validator validator) { 75 ObjAttribute attribute = (ObjAttribute) path.getObject(); 76 77 if (path.getObjectParent() != null 79 && path.getObjectParent() != attribute.getEntity()) { 80 return; 81 } 82 83 if (Util.isEmptyString(attribute.getName())) { 85 validator.registerError("Unnamed ObjAttribute.", path); 86 } 87 else { 88 MappingNamesHelper helper = MappingNamesHelper.getInstance(); 89 String invalidChars = helper.invalidCharsInObjPathComponent(attribute 90 .getName()); 91 92 if (invalidChars != null) { 93 validator.registerWarning( 94 "ObjAttribute name contains invalid characters: " + invalidChars, 95 path); 96 } 97 else if (helper.invalidDataObjectProperty(attribute.getName())) { 98 validator.registerWarning("ObjAttribute name is invalid: " 99 + attribute.getName(), path); 100 } 101 } 102 103 if (Util.isEmptyString(attribute.getType())) { 105 validator.registerWarning("ObjAttribute has no type.", path); 106 } 107 108 if (attribute.getDbAttribute() == null) { 109 validator.registerWarning("ObjAttribute has no DbAttribute mapping.", path); 110 } 111 } 112 } | Popular Tags |