Exemplo n.º 1
0
  private boolean expandMetaRelation1(
      Writer output,
      DbObject object,
      MetaRelation1 metaRelation1,
      boolean state[],
      MetaClass childrenMetaClass,
      RuleOptions options)
      throws DbException, IOException, RuleException {

    boolean expanded = false;
    Object child;
    if (childrenMetaClass != null) {
      if (metaRelation1 == DbObject.fComposite) {
        child = object.getCompositeOfType(childrenMetaClass);
      } else {
        child = object.get(metaRelation1);
        if (child instanceof DbObject) {
          DbObject dbChild = (DbObject) child;
          MetaClass mc = dbChild.getMetaClass();
          if (mc != childrenMetaClass) {
            child = null;
          }
        }
      }
    } else {
      child = object.get(metaRelation1);
    } // end if

    if (child != null) {
      if (child instanceof DbObject) {
        DbObject dbChild = (DbObject) child;
        MetaClass metaClass = dbChild.getMetaClass();
        String className = metaClass.getGUIName();
        boolean excluded = false;

        // check if child's class is excluded
        if (options != null) {
          excluded = options.isExcluded(className);

          // if not, check if parent's connection is excluded
          if (!excluded) {
            metaClass = object.getMetaClass();
            String parentClassName = metaClass.getGUIName();
            String connectionName = parentClassName + "." + metaRelation1.getGUIName();
            excluded = options.isExcluded(connectionName);
          } // end if
        } // end if

        if (!excluded) {
          expanded |= expandChild(output, object, dbChild, 1, state, options);
        } // end if
      } // end if
    } // end if

    // if a SUF modifier has to be expanded
    if ((expanded) && (suffixModifier != null)) {
      suffixModifier.expand(output, object, options);
    }

    // if a NULL modifier has to be expanded
    if ((!expanded) && (nullModifier != null)) {
      expanded |= nullModifier.expand(output, object, options);
    }

    return expanded;
  } // end expandMetaRelation1