Program: 51156
Project: 51156
Buggy source:
public static String invalid(Messages messages,JDBCValidator jdbcValidator,TreeModel treeModel,TreeModelPath tpath,Object value,Object icube,Object iparentDimension,Object iparentHierarchy,Object iparentLevel){
  String nameMustBeSet=messages.getString("String_Node_Str","String_Node_Str");
  MondrianGuiDef.Cube cube=(MondrianGuiDef.Cube)icube;
  MondrianGuiDef.Dimension parentDimension=(MondrianGuiDef.Dimension)iparentDimension;
  MondrianGuiDef.Hierarchy parentHierarchy=(MondrianGuiDef.Hierarchy)iparentHierarchy;
  MondrianGuiDef.Level parentLevel=(MondrianGuiDef.Level)iparentLevel;
  if (!tpath.isEmpty()) {
    int pathcount=tpath.getPathCount();
    for (int i=0; i < pathcount && (cube == null || parentDimension == null || parentHierarchy == null || parentLevel == null); i++) {
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Cube && cube == null) {
        cube=(MondrianGuiDef.Cube)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Dimension && parentDimension == null) {
        parentDimension=(MondrianGuiDef.Dimension)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Hierarchy && parentHierarchy == null) {
        parentHierarchy=(MondrianGuiDef.Hierarchy)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Level && parentLevel == null) {
        parentLevel=(MondrianGuiDef.Level)tpath.getPathComponent(i);
      }
    }
  }
  if (value instanceof MondrianGuiDef.Schema) {
    if (isEmpty(((MondrianGuiDef.Schema)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCube) {
    if (isEmpty(((MondrianGuiDef.VirtualCube)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCubeDimension) {
    if (isEmpty(((MondrianGuiDef.VirtualCubeDimension)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCubeMeasure) {
    if (isEmpty(((MondrianGuiDef.VirtualCubeMeasure)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.Cube) {
    if (isEmpty(((MondrianGuiDef.Cube)value).name)) {
      return nameMustBeSet;
    }
    if (((MondrianGuiDef.Cube)value).fact == null || isEmpty(((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).name)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (jdbcValidator.isInitialized()) {
      String schemaName=((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).schema;
      String factTable=((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).name;
      if (!jdbcValidator.isTableExists(schemaName,factTable)) {
        return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{factTable,((schemaName == null || schemaName.equals("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str" + schemaName)});
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.CubeDimension) {
    if (isEmpty(((MondrianGuiDef.CubeDimension)value).name)) {
      return nameMustBeSet;
    }
    if (value instanceof MondrianGuiDef.DimensionUsage) {
      if (isEmpty(((MondrianGuiDef.DimensionUsage)value).source)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
      MondrianGuiDef.Schema s=(MondrianGuiDef.Schema)treeModel.getRoot();
      MondrianGuiDef.Dimension ds[]=s.dimensions;
      String sourcename=((MondrianGuiDef.DimensionUsage)value).source;
      boolean notfound=true;
      for (int j=0; j < ds.length; j++) {
        if (ds[j].name.equalsIgnoreCase(sourcename)) {
          notfound=false;
          break;
        }
      }
      if (notfound) {
        return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{sourcename});
      }
    }
    if (value instanceof MondrianGuiDef.Dimension && cube != null) {
      if (!isEmpty(((MondrianGuiDef.Dimension)value).foreignKey)) {
        if (jdbcValidator.isInitialized()) {
          String foreignKey=((MondrianGuiDef.Dimension)value).foreignKey;
          if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,foreignKey)) {
            return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{foreignKey});
          }
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Level) {
    MondrianGuiDef.Level l=(MondrianGuiDef.Level)value;
    if (!isEmpty(l.levelType)) {
      if (parentDimension != null) {
        if ((isEmpty(parentDimension.type) || parentDimension.type.equals("String_Node_Str")) && !isEmpty(l.levelType) && (!l.levelType.equals(MondrianGuiDef.Level._levelType_values[0]))) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{l.levelType});
        }
 else         if (!isEmpty(parentDimension.type) && (parentDimension.type.equals("String_Node_Str")) && !isEmpty(l.levelType)&& (l.levelType.equals(MondrianGuiDef.Level._levelType_values[0]))) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{l.levelType});
        }
      }
    }
    String column=l.column;
    if (isEmpty(column)) {
      if (l.properties == null || l.properties.length == 0) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
 else {
      String theMessage=null;
      try {
        for (int i=0; i < DEF_LEVEL.length; i++) {
          Field theField=l.getClass().getDeclaredField(DEF_LEVEL[i]);
          column=(String)theField.get(l);
          theMessage=validateColumn(column,DEF_LEVEL[i],messages,l,jdbcValidator,cube,parentHierarchy);
          if (theMessage != null) {
            break;
          }
        }
      }
 catch (      Exception ex) {
        LOGGER.error("String_Node_Str",ex);
      }
      return theMessage;
    }
  }
 else   if (value instanceof MondrianGuiDef.Property) {
    MondrianGuiDef.Property p=(MondrianGuiDef.Property)value;
    String column=p.column;
    if (isEmpty(column)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (jdbcValidator.isInitialized()) {
      String table=null;
      if (parentLevel != null) {
        table=parentLevel.table;
      }
      if (isEmpty(table)) {
        if (parentHierarchy != null) {
          if (parentHierarchy.relation == null && cube != null) {
            if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,column)) {
              return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{column});
            }
          }
 else           if (parentHierarchy.relation instanceof MondrianGuiDef.Table) {
            if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)parentHierarchy.relation).schema,((MondrianGuiDef.Table)parentHierarchy.relation).name,column)) {
              return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{((MondrianGuiDef.Table)parentHierarchy.relation).name});
            }
          }
        }
      }
 else {
        if (!jdbcValidator.isColExists(null,table,column)) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{column,table});
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Measure) {
    if (isEmpty(((MondrianGuiDef.Measure)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.Measure)value).aggregator)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (((MondrianGuiDef.Measure)value).measureExp != null) {
    }
 else     if (isEmpty(((MondrianGuiDef.Measure)value).column)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
 else     if (cube != null && cube.fact != null) {
      if (jdbcValidator.isInitialized()) {
        String column=((MondrianGuiDef.Measure)value).column;
        if (jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,column)) {
          int colType=jdbcValidator.getColumnDataType(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,((MondrianGuiDef.Measure)value).column);
          int agIndex=-1;
          if ("String_Node_Str".equals(((MondrianGuiDef.Measure)value).aggregator) || "String_Node_Str".equals(((MondrianGuiDef.Measure)value).aggregator)) {
            agIndex=0;
          }
          if (!(agIndex == -1 || (colType >= 2 && colType <= 8))) {
            return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{((MondrianGuiDef.Measure)value).aggregator,((MondrianGuiDef.Measure)value).column});
          }
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Hierarchy) {
    if (((MondrianGuiDef.Hierarchy)value).relation instanceof MondrianGuiDef.Join) {
      if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKeyTable)) {
        if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKey)) {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
 else {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
      }
      if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKey)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.NamedSet) {
    if (isEmpty(((MondrianGuiDef.NamedSet)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.NamedSet)value).formula)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.UserDefinedFunction) {
    if (isEmpty(((MondrianGuiDef.UserDefinedFunction)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.UserDefinedFunction)value).className)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.CalculatedMember) {
    if (isEmpty(((MondrianGuiDef.CalculatedMember)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.CalculatedMember)value).dimension)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.Join) {
    if (isEmpty(((MondrianGuiDef.Join)value).leftKey)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (isEmpty(((MondrianGuiDef.Join)value).rightKey)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
  int childCnt=treeModel.getChildCount(value);
  for (int i=0; i < childCnt; i++) {
    Object child=treeModel.getChild(value,i);
    String childErrMsg;
    if (child instanceof MondrianGuiDef.Cube) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,child,parentDimension,parentHierarchy,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Dimension) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,child,parentHierarchy,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Hierarchy) {
      if (value instanceof MondrianGuiDef.Dimension && cube != null && ((MondrianGuiDef.Hierarchy)child).relation != null) {
        if (isEmpty(((MondrianGuiDef.Dimension)value).foreignKey)) {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
      }
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,child,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Level) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,parentHierarchy,child);
    }
 else {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,parentHierarchy,parentLevel);
    }
    if (childErrMsg != null) {
      String childClassName=child.getClass().getName();
      String simpleName[]=childClassName.split("String_Node_Str",0);
      String childName;
      try {
        Field f=child.getClass().getField("String_Node_Str");
        childName=(String)f.get(child);
        if (childName == null) {
          childName="String_Node_Str";
        }
        childErrMsg=messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{simpleName[simpleName.length - 1],childName});
      }
 catch (      Exception ex) {
        childErrMsg=messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{simpleName[simpleName.length - 1]});
      }
      return childErrMsg;
    }
  }
  return null;
}

Fixed version (ground truth):
public static String invalid(Messages messages,JDBCValidator jdbcValidator,TreeModel treeModel,TreeModelPath tpath,Object value,Object icube,Object iparentDimension,Object iparentHierarchy,Object iparentLevel){
  String nameMustBeSet=messages.getString("String_Node_Str","String_Node_Str");
  MondrianGuiDef.Cube cube=(MondrianGuiDef.Cube)icube;
  MondrianGuiDef.Dimension parentDimension=(MondrianGuiDef.Dimension)iparentDimension;
  MondrianGuiDef.Hierarchy parentHierarchy=(MondrianGuiDef.Hierarchy)iparentHierarchy;
  MondrianGuiDef.Level parentLevel=(MondrianGuiDef.Level)iparentLevel;
  if (!tpath.isEmpty()) {
    int pathcount=tpath.getPathCount();
    for (int i=0; i < pathcount && (cube == null || parentDimension == null || parentHierarchy == null || parentLevel == null); i++) {
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Cube && cube == null) {
        cube=(MondrianGuiDef.Cube)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Dimension && parentDimension == null) {
        parentDimension=(MondrianGuiDef.Dimension)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Hierarchy && parentHierarchy == null) {
        parentHierarchy=(MondrianGuiDef.Hierarchy)tpath.getPathComponent(i);
      }
      if (tpath.getPathComponent(i) instanceof MondrianGuiDef.Level && parentLevel == null) {
        parentLevel=(MondrianGuiDef.Level)tpath.getPathComponent(i);
      }
    }
  }
  if (value instanceof MondrianGuiDef.Schema) {
    if (isEmpty(((MondrianGuiDef.Schema)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCube) {
    if (isEmpty(((MondrianGuiDef.VirtualCube)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCubeDimension) {
    if (isEmpty(((MondrianGuiDef.VirtualCubeDimension)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.VirtualCubeMeasure) {
    if (isEmpty(((MondrianGuiDef.VirtualCubeMeasure)value).name)) {
      return nameMustBeSet;
    }
  }
 else   if (value instanceof MondrianGuiDef.Cube) {
    if (isEmpty(((MondrianGuiDef.Cube)value).name)) {
      return nameMustBeSet;
    }
    if (((MondrianGuiDef.Cube)value).fact == null || isEmpty(((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).name)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (jdbcValidator.isInitialized()) {
      String schemaName=((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).schema;
      String factTable=((MondrianGuiDef.Table)((MondrianGuiDef.Cube)value).fact).name;
      if (!jdbcValidator.isTableExists(schemaName,factTable)) {
        return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{factTable,((schemaName == null || schemaName.equals("String_Node_Str")) ? "String_Node_Str" : "String_Node_Str" + schemaName)});
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.CubeDimension) {
    if (isEmpty(((MondrianGuiDef.CubeDimension)value).name)) {
      return nameMustBeSet;
    }
    if (value instanceof MondrianGuiDef.DimensionUsage) {
      if (isEmpty(((MondrianGuiDef.DimensionUsage)value).source)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
      MondrianGuiDef.Schema s=(MondrianGuiDef.Schema)treeModel.getRoot();
      MondrianGuiDef.Dimension ds[]=s.dimensions;
      String sourcename=((MondrianGuiDef.DimensionUsage)value).source;
      boolean notfound=true;
      for (int j=0; j < ds.length; j++) {
        if (ds[j].name.equalsIgnoreCase(sourcename)) {
          notfound=false;
          break;
        }
      }
      if (notfound) {
        return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{sourcename});
      }
    }
    if (value instanceof MondrianGuiDef.Dimension && cube != null) {
      if (!isEmpty(((MondrianGuiDef.Dimension)value).foreignKey)) {
        if (jdbcValidator.isInitialized()) {
          String foreignKey=((MondrianGuiDef.Dimension)value).foreignKey;
          if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,foreignKey)) {
            return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{foreignKey});
          }
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Level) {
    MondrianGuiDef.Level l=(MondrianGuiDef.Level)value;
    if (!isEmpty(l.levelType)) {
      if (parentDimension != null) {
        if ((isEmpty(parentDimension.type) || parentDimension.type.equals("String_Node_Str")) && !isEmpty(l.levelType) && (!l.levelType.equals(MondrianGuiDef.Level._levelType_values[0]))) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{l.levelType});
        }
 else         if (!isEmpty(parentDimension.type) && (parentDimension.type.equals("String_Node_Str")) && !isEmpty(l.levelType)&& (l.levelType.equals(MondrianGuiDef.Level._levelType_values[0]))) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{l.levelType});
        }
      }
    }
    String column=l.column;
    if (isEmpty(column)) {
      if (l.properties == null || l.properties.length == 0) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
 else {
      String theMessage=null;
      try {
        for (int i=0; i < DEF_LEVEL.length; i++) {
          Field theField=l.getClass().getDeclaredField(DEF_LEVEL[i]);
          column=(String)theField.get(l);
          theMessage=validateColumn(column,DEF_LEVEL[i],messages,l,jdbcValidator,cube,parentHierarchy);
          if (theMessage != null) {
            break;
          }
        }
      }
 catch (      Exception ex) {
        LOGGER.error("String_Node_Str",ex);
      }
      return theMessage;
    }
  }
 else   if (value instanceof MondrianGuiDef.Property) {
    MondrianGuiDef.Property p=(MondrianGuiDef.Property)value;
    String column=p.column;
    if (isEmpty(column)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (jdbcValidator.isInitialized()) {
      String table=null;
      if (parentLevel != null) {
        table=parentLevel.table;
      }
      if (isEmpty(table)) {
        if (parentHierarchy != null) {
          if (parentHierarchy.relation == null && cube != null) {
            if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,column)) {
              return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{column});
            }
          }
 else           if (parentHierarchy.relation instanceof MondrianGuiDef.Table) {
            if (!jdbcValidator.isColExists(((MondrianGuiDef.Table)parentHierarchy.relation).schema,((MondrianGuiDef.Table)parentHierarchy.relation).name,column)) {
              return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{((MondrianGuiDef.Table)parentHierarchy.relation).name});
            }
          }
        }
      }
 else {
        if (!jdbcValidator.isColExists(null,table,column)) {
          return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{column,table});
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Measure) {
    if (isEmpty(((MondrianGuiDef.Measure)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.Measure)value).aggregator)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (((MondrianGuiDef.Measure)value).measureExp != null) {
    }
 else     if (isEmpty(((MondrianGuiDef.Measure)value).column)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
 else     if (cube != null && cube.fact != null) {
      if (jdbcValidator.isInitialized()) {
        String column=((MondrianGuiDef.Measure)value).column;
        if (jdbcValidator.isColExists(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,column)) {
          int colType=jdbcValidator.getColumnDataType(((MondrianGuiDef.Table)cube.fact).schema,((MondrianGuiDef.Table)cube.fact).name,((MondrianGuiDef.Measure)value).column);
          int agIndex=-1;
          if ("String_Node_Str".equals(((MondrianGuiDef.Measure)value).aggregator) || "String_Node_Str".equals(((MondrianGuiDef.Measure)value).aggregator)) {
            agIndex=0;
          }
          if (!(agIndex == -1 || (colType >= 2 && colType <= 8))) {
            return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{((MondrianGuiDef.Measure)value).aggregator,((MondrianGuiDef.Measure)value).column});
          }
        }
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.Hierarchy) {
    if (((MondrianGuiDef.Hierarchy)value).relation instanceof MondrianGuiDef.Join) {
      if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKeyTable)) {
        if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKey)) {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
 else {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
      }
      if (isEmpty(((MondrianGuiDef.Hierarchy)value).primaryKey)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
    MondrianGuiDef.Hierarchy hierarchy=((MondrianGuiDef.Hierarchy)value);
    String pkTable=null;
    if (hierarchy.relation instanceof MondrianGuiDef.Join) {
      pkTable=SchemaExplorer.getTableNameForAlias(hierarchy.relation,hierarchy.primaryKeyTable);
    }
 else     if (hierarchy.relation instanceof MondrianGuiDef.Table) {
      pkTable=((MondrianGuiDef.Table)hierarchy.relation).name;
    }
    if (!jdbcValidator.isColExists(null,pkTable,hierarchy.primaryKey)) {
      return messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{isEmpty(hierarchy.primaryKey.trim()) ? "String_Node_Str" : hierarchy.primaryKey,"String_Node_Str",pkTable});
    }
    if (hierarchy.relation instanceof MondrianGuiDef.Table) {
      if (!isEmpty(hierarchy.primaryKeyTable)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
    String primaryKeyTable=hierarchy.primaryKeyTable;
    if (!isEmpty(primaryKeyTable) && (hierarchy.relation instanceof MondrianGuiDef.Join)) {
      TreeSet<String> joinTables=new TreeSet<String>();
      SchemaExplorer.getTableNamesForJoin(hierarchy.relation,joinTables);
      if (!joinTables.contains(primaryKeyTable)) {
        return messages.getString("String_Node_Str","String_Node_Str");
      }
    }
  }
 else   if (value instanceof MondrianGuiDef.NamedSet) {
    if (isEmpty(((MondrianGuiDef.NamedSet)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.NamedSet)value).formula)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.UserDefinedFunction) {
    if (isEmpty(((MondrianGuiDef.UserDefinedFunction)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.UserDefinedFunction)value).className)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.CalculatedMember) {
    if (isEmpty(((MondrianGuiDef.CalculatedMember)value).name)) {
      return nameMustBeSet;
    }
    if (isEmpty(((MondrianGuiDef.CalculatedMember)value).dimension)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
 else   if (value instanceof MondrianGuiDef.Join) {
    if (isEmpty(((MondrianGuiDef.Join)value).leftKey)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
    if (isEmpty(((MondrianGuiDef.Join)value).rightKey)) {
      return messages.getString("String_Node_Str","String_Node_Str");
    }
  }
  int childCnt=treeModel.getChildCount(value);
  for (int i=0; i < childCnt; i++) {
    Object child=treeModel.getChild(value,i);
    String childErrMsg;
    if (child instanceof MondrianGuiDef.Cube) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,child,parentDimension,parentHierarchy,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Dimension) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,child,parentHierarchy,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Hierarchy) {
      if (value instanceof MondrianGuiDef.Dimension && cube != null && ((MondrianGuiDef.Hierarchy)child).relation != null) {
        if (isEmpty(((MondrianGuiDef.Dimension)value).foreignKey)) {
          return messages.getString("String_Node_Str","String_Node_Str");
        }
      }
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,child,parentLevel);
    }
 else     if (child instanceof MondrianGuiDef.Level) {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,parentHierarchy,child);
    }
 else {
      childErrMsg=invalid(messages,jdbcValidator,treeModel,tpath,child,cube,parentDimension,parentHierarchy,parentLevel);
    }
    if (childErrMsg != null) {
      String childClassName=child.getClass().getName();
      String simpleName[]=childClassName.split("String_Node_Str",0);
      String childName;
      try {
        Field f=child.getClass().getField("String_Node_Str");
        childName=(String)f.get(child);
        if (childName == null) {
          childName="String_Node_Str";
        }
        childErrMsg=messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{simpleName[simpleName.length - 1],childName});
      }
 catch (      Exception ex) {
        childErrMsg=messages.getFormattedString("String_Node_Str","String_Node_Str",new String[]{simpleName[simpleName.length - 1]});
      }
      return childErrMsg;
    }
  }
  return null;
}