1 19 20 package org.apache.cayenne.project.validator; 21 22 import org.apache.cayenne.access.DataDomain; 23 import org.apache.cayenne.access.DataNode; 24 import org.apache.cayenne.map.DataMap; 25 import org.apache.cayenne.map.DbAttribute; 26 import org.apache.cayenne.map.DbEntity; 27 import org.apache.cayenne.map.DbRelationship; 28 import org.apache.cayenne.map.ObjAttribute; 29 import org.apache.cayenne.map.ObjEntity; 30 import org.apache.cayenne.map.ObjRelationship; 31 import org.apache.cayenne.map.Procedure; 32 import org.apache.cayenne.map.ProcedureParameter; 33 import org.apache.cayenne.project.ProjectPath; 34 import org.apache.cayenne.query.ProcedureQuery; 35 import org.apache.cayenne.query.SQLTemplate; 36 import org.apache.cayenne.query.SelectQuery; 37 38 44 public abstract class TreeNodeValidator { 45 46 protected static final DomainValidator domainValidator = new DomainValidator(); 48 protected static final DataNodeValidator nodeValidator = new DataNodeValidator(); 49 protected static final DataMapValidator mapValidator = new DataMapValidator(); 50 protected static final ObjEntityValidator objEntityValidator = new ObjEntityValidator(); 51 protected static final ObjAttributeValidator objAttrValidator = new ObjAttributeValidator(); 52 protected static final ObjRelationshipValidator objRelValidator = new ObjRelationshipValidator(); 53 protected static final DbEntityValidator dbEntityValidator = new DbEntityValidator(); 54 protected static final DbAttributeValidator dbAttrValidator = new DbAttributeValidator(); 55 protected static final DbRelationshipValidator dbRelValidator = new DbRelationshipValidator(); 56 57 protected static final ProcedureValidator procedureValidator = new ProcedureValidator(); 58 59 protected static final ProcedureParameterValidator procedureParameterValidator = new ProcedureParameterValidator(); 60 protected static final SelectQueryValidator selectQueryValidator = new SelectQueryValidator(); 61 62 protected static final ProcedureQueryValidator procedureQueryValidator = new ProcedureQueryValidator(); 63 64 protected static final SQLTemplateValidator sqlTemplateValidator = new SQLTemplateValidator(); 65 66 69 public static void validate(ProjectPath path, Validator validator) { 70 Object validatedObj = path.getObject(); 71 TreeNodeValidator validatorObj = null; 72 if (validatedObj instanceof ObjAttribute) { 73 validatorObj = objAttrValidator; 74 } 75 else if (validatedObj instanceof ObjRelationship) { 76 validatorObj = objRelValidator; 77 } 78 else if (validatedObj instanceof ObjEntity) { 79 validatorObj = objEntityValidator; 80 } 81 else if (validatedObj instanceof DbAttribute) { 82 validatorObj = dbAttrValidator; 83 } 84 else if (validatedObj instanceof DbRelationship) { 85 validatorObj = dbRelValidator; 86 } 87 else if (validatedObj instanceof DbEntity) { 88 validatorObj = dbEntityValidator; 89 } 90 else if (validatedObj instanceof DataNode) { 91 validatorObj = nodeValidator; 92 } 93 else if (validatedObj instanceof DataMap) { 94 validatorObj = mapValidator; 95 } 96 else if (validatedObj instanceof DataDomain) { 97 validatorObj = domainValidator; 98 } 99 else if (validatedObj instanceof Procedure) { 100 validatorObj = procedureValidator; 101 } 102 else if (validatedObj instanceof ProcedureParameter) { 103 validatorObj = procedureParameterValidator; 104 } 105 else if (validatedObj instanceof SelectQuery) { 106 validatorObj = selectQueryValidator; 107 } 108 else if (validatedObj instanceof SQLTemplate) { 109 validatorObj = sqlTemplateValidator; 110 } 111 else if (validatedObj instanceof ProcedureQuery) { 112 validatorObj = procedureQueryValidator; 113 } 114 else { 115 return; 117 } 118 119 validatorObj.validateObject(path, validator); 120 } 121 122 125 public TreeNodeValidator() { 126 super(); 127 } 128 129 135 public abstract void validateObject(ProjectPath treeNodePath, Validator validator); 136 } 137 | Popular Tags |