Package org.dbwiki.data.document

Examples of org.dbwiki.data.document.DocumentAttributeNode


      if (_valueReader.hasOpenElements()) {
        _valueReader.endElement();
      } else if (!_elementStack.isEmpty()) {
        DocumentNode currentElement = _elementStack.peek();
        if (currentElement.isAttribute()) {
          DocumentAttributeNode attribute = (DocumentAttributeNode)currentElement;
          if (!attribute.hasValue()) {
            attribute.setValue(_valueReader.value());
            _valueReader = null;
            _elementStack.pop();
          } else {
            throw new WikiDataException(WikiDataException.InvaldInputData, "Duplicate text value for attribute " + attribute.label());
          }
        } else {
          throw new WikiDataException(WikiDataException.InvaldInputData, "Unexpected text value under element " + currentElement.label());
        }
      } else {
View Full Code Here


    } else if (_valueReader != null) {
      _valueReader.startElement(label);
    } else if (_root == null) {
      if (_rootSchemaNode.label().equals(label)) {
        if (_rootSchemaNode.isAttribute()) {
          _root = new DocumentAttributeNode((AttributeSchemaNode)_rootSchemaNode);
          _valueReader = new NodeValueReader();
        } else {
          _root = new DocumentGroupNode((GroupSchemaNode)_rootSchemaNode);
        }
        _elementStack.push(_root);
      } else {
        throw new WikiDataException(WikiDataException.InvaldInputData, "Expected root label " + _rootSchemaNode.label() + " instead of " + label);
      }
    } else if (!_elementStack.isEmpty()) {
      DocumentNode element = _elementStack.peek();
      if (element.isGroup()) {
        DocumentGroupNode group = (DocumentGroupNode)element;
        SchemaNode childSchemaNode = ((GroupSchemaNode)group.schema()).children().get(label);
        if (childSchemaNode != null && childSchemaNode.getTimestamp().isCurrent()) {
          DocumentNode child = null;
          if (childSchemaNode.isAttribute()) {
            child = new DocumentAttributeNode((AttributeSchemaNode)childSchemaNode);
            _valueReader = new NodeValueReader();
          } else {
            child = new DocumentGroupNode((GroupSchemaNode)childSchemaNode);
          }
          group.children().add(child);
View Full Code Here

          int entry)
      throws java.sql.SQLException, org.dbwiki.exception.WikiException {
    for (int iChild = 0; iChild < group.children().size(); iChild++) {
      DocumentNode element = group.children().get(iChild);
      if (element.isAttribute()) {
        DocumentAttributeNode attributeChild = (DocumentAttributeNode)element;
        insertAttributeNode((AttributeSchemaNode)attributeChild.schema(), parent, entry, null, attributeChild.value(), attributeChild.getpre(), attributeChild.getpost());

      } else {
        DocumentGroupNode groupChild = (DocumentGroupNode)element;
        RDBMSDatabaseGroupNode node = insertGroupNode((GroupSchemaNode)groupChild.schema(), parent, entry, null, groupChild.getpre(), groupChild.getpost());
View Full Code Here

      }
    }
   
    if (schemaNode != null) {
      if (schemaNode.isAttribute()) {
        return new DocumentAttributeNode((AttributeSchemaNode)schemaNode, ((PasteAttributeNode)sourceNode).getValue().getValue());
      } else {
        DocumentGroupNode group = new DocumentGroupNode((GroupSchemaNode)schemaNode);
        for (int iChild = 0; iChild < ((PasteGroupNode)sourceNode).children().size(); iChild++) {
          DocumentNode insertChild = getPasteInsertNode((GroupSchemaNode)schemaNode, (PasteElementNode)((PasteGroupNode)sourceNode).children().get(iChild), schema);
          if (insertChild != null) {
View Full Code Here

   */
  protected DocumentNode getInsertNode(WikiDataRequest  request) throws org.dbwiki.exception.WikiException {
    SchemaNode schemaNode = database().schema().get(Integer.parseInt(request.parameters().get(RequestParameter.ActionValueSchemaNode).value()));
    if (schemaNode.isAttribute()) {
      AttributeSchemaNode attributeSchemaNode = (AttributeSchemaNode)schemaNode;
      DocumentAttributeNode attribute = new DocumentAttributeNode(attributeSchemaNode);
      RequestParameter parameter = request.parameters().get(RequestParameter.TextFieldIndicator + attributeSchemaNode.id());
      if (parameter.hasValue()) {
        if (!parameter.value().equals("")) {
          attribute.setValue(parameter.value());
        }
      }
      return attribute;
    } else {
      Hashtable<Integer, DocumentGroupNode> groupIndex = new Hashtable<Integer, DocumentGroupNode>();
      DocumentGroupNode root = SchemaNode.createGroupNode((GroupSchemaNode)schemaNode, groupIndex);
      for (int iParameter = 0; iParameter < request.parameters().size(); iParameter++) {
        RequestParameter parameter = request.parameters().get(iParameter);
        if ((parameter.name().startsWith(RequestParameter.TextFieldIndicator)) && (parameter.hasValue())) {
          if (!parameter.value().equals("")) {
            SchemaNode child = database().schema().get(Integer.parseInt(parameter.name().substring(RequestParameter.TextFieldIndicator.length())));
            if (child.isAttribute()) {
              DocumentAttributeNode attribute = new DocumentAttributeNode((AttributeSchemaNode)child);
              attribute.setValue(parameter.value());
              groupIndex.get(new Integer(attribute.schema().parent().id())).children().add(attribute);
            }
          }
        }
      }
      DocumentGroupNode.removeEmptyNodes(root);
View Full Code Here

TOP

Related Classes of org.dbwiki.data.document.DocumentAttributeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.