示例#1
0
  public SemanticElement getChild(String elementName) {
    if (elementName == null) {
      return null;
    }

    for (SemanticElement curElem : getChildren()) {
      if (elementName.equals(curElem.getName())) {
        return curElem;
      }
    }

    return null;
  }
示例#2
0
  /**
   * Check if the user object in a tree node references this field. We'll use the node's fieldName
   * attribute to match the name, plus look at the datatype of the parent node
   */
  private static boolean nodeReferencesField(DefaultMutableTreeNode treeNode, Field field) {

    String fieldName = field.getName();
    if (fieldName == null) {
      return false;
    }
    Object userObject = treeNode.getUserObject();

    if (userObject instanceof SemanticElement) {
      SemanticElement se = (SemanticElement) userObject;
      if (se.getDatatype() == field.getOwnerType()
          && (fieldName.equals(se.getEnumValueDescrField())
              || fieldName.equals(se.getEnumValueField())
              || fieldName.equals(se.getEnumValueSet())
              || fieldName.equals(se.getEnumValueSetField()))) {

        return true;
      }

    } else if (userObject instanceof MdmiBusinessElementReference) {
      MdmiBusinessElementReference ber = (MdmiBusinessElementReference) userObject;
      if (ber.getReferenceDatatype() == field.getOwnerType()
          && (fieldName.equals(ber.getEnumValueDescrField())
              || fieldName.equals(ber.getEnumValueField())
              || fieldName.equals(ber.getEnumValueSet())
              || fieldName.equals(ber.getEnumValueSetField()))) {

        return true;
      }

    } else if (userObject instanceof Node) {
      Node node = (Node) userObject;
      // first check if names match
      if (fieldName.equals(node.getFieldName())) {
        // names match, so check datatype
        MdmiDatatype fieldDatatype = field.getDatatype();
        MdmiDatatype nodeDatatype = ((SyntaxNodeNode) treeNode).getDataType();
        if (fieldDatatype == nodeDatatype) {
          // datatypes match - check owner type against the node's parent's datatype
          MdmiDatatype ownerType = field.getOwnerType();
          if (treeNode.getParent() instanceof SyntaxNodeNode) {
            MdmiDatatype parentType = ((SyntaxNodeNode) treeNode.getParent()).getDataType();
            if (ownerType == parentType) {
              return true;
            }
          }
        }
      }
    }

    return false;
  }
示例#3
0
  protected void toString(StringBuffer out, String indent) {
    out.append(indent + "SemanticElement: " + m_name + "\r\n");
    indent += "  ";
    if (m_description != null && m_description.length() > 0) {
      out.append(indent + "description: " + m_description + "\r\n");
    }
    if (m_elementType != null) {
      out.append(indent + "element type: " + m_elementType + "\r\n");
    }
    if (m_datatype != null) {
      out.append(indent + "datatype: " + m_datatype.getTypeName() + "\r\n");
    }
    if (m_multipleInstances) {
      out.append(indent + "multiple instances: true\r\n");
    }
    if (m_parent != null) {
      out.append(indent + "parent: " + m_parent.getName() + "\r\n");
    }
    if (m_ordering != null && m_ordering.length() > 0) {
      out.append(indent + "ordering: " + m_ordering + "\r\n");
    }
    if (m_orderingLanguage != null && m_orderingLanguage.length() > 0) {
      out.append(indent + "ordering expression language: " + m_orderingLanguage + "\r\n");
    }
    if (m_computedValue != null) {
      m_computedValue.toString(out, indent);
    }
    if (m_computedInValue != null) {
      m_computedInValue.toString(out, indent);
    }
    if (m_computedOutValue != null) {
      m_computedOutValue.toString(out, indent);
    }
    if (m_syntaxNode != null) {
      out.append(indent + "syntax node: " + m_syntaxNode.getName() + "\r\n");
    }

    if (m_dataRules.size() > 0) {
      out.append(indent + "DATA RULES: ");
      for (int i = 0; i < m_dataRules.size(); i++) {
        DataRule x = m_dataRules.get(i);
        if (i > 0) {
          out.append(", ");
        }
        out.append(x.getName());
      }
      out.append("\r\n");
    }
    for (int i = 0; i < m_businessRules.size(); i++) {
      SemanticElementBusinessRule x = m_businessRules.get(i);
      x.toString(out, indent);
    }
    for (int i = 0; i < m_toMdmi.size(); i++) {
      ToMessageElement x = m_toMdmi.get(i);
      x.toString(out, indent);
    }
    for (int i = 0; i < m_fromMdmi.size(); i++) {
      ToBusinessElement x = m_fromMdmi.get(i);
      x.toString(out, indent);
    }
    for (int i = 0; i < m_relationships.size(); i++) {
      SemanticElementRelationship x = m_relationships.get(i);
      x.toString(out, indent);
    }
    for (int i = 0; i < m_qualifiers.size(); i++) {
      MEPropertyQualifierInstance x = m_qualifiers.get(i);
      x.toString(out, indent);
    }
    Collection<SemanticElement> c = getChildren();
    if (c.size() > 0) {
      int i = 0;
      out.append(indent + "children: ");
      for (Iterator<SemanticElement> it = c.iterator(); it.hasNext(); ) {
        SemanticElement x = it.next();
        if (i++ <= 0) {
          out.append(", ");
        }
        out.append(x.getName());
      }
      out.append("\r\n");
    }
  }
 public SemanticElementCheckBox(SemanticElement element) {
   super.setText(element.getName());
   this.element = element;
 }