Package org.dbwiki.data.database

Examples of org.dbwiki.data.database.DatabaseElementList


      // only display nodes that have not been deleted
      if (versionParameter.matches(groupNode)) {
        content.openTR();
        for (int iColumn = 0; iColumn < schemaNode.children().size(); iColumn++) {
          //DatabaseElementList nodes = groupNode.children().get(schemaNode.children().get(iColumn));
          DatabaseElementList nodes = groupNode.children().get(schemaNode.children().get(iColumn).label());
          if (groupNode.getTimestamp().isCurrent()) {
            content.openTD(layout.getCSS(CSS.CSSContentCellActive));
          } else {
            content.openTD(layout.getCSS(CSS.CSSContentCellInactive));
          }
          boolean hasAnnotation = groupNode.hasAnnotation();
          for (int iElement = 0; iElement < nodes.size(); iElement++) {
            DatabaseElementNode element = nodes.get(iElement);
            hasAnnotation = (hasAnnotation || element.hasAnnotation());
            if (element.isAttribute()) {
              printAttributeValue((DatabaseAttributeNode)element, versionParameter, layout, content);
            } else {
              this.printGroupNode((DatabaseGroupNode)element, versionParameter, content);
View Full Code Here


          result.value().add(value.get(i));
        }
        outputNode = result;
      } else if(node.isGroup()) {
        ResultGroupNode result = new ResultGroupNode((GroupSchemaNode)_schema, node.getTimestamp());
        DatabaseElementList children = ((DatabaseGroupNode)node).children();
        for(int i = 0; i < children.size(); i++) {
          result.children().add(children.get(i));
        }
        outputNode = result;
      }
    }
     
View Full Code Here

   
    boolean nonEmpty = false;
    for (int i = 0; i < rs.size(); i++) {
      DatabaseGroupNode r = (DatabaseGroupNode)rs.get(i);

      DatabaseElementList children = r.children();
      if(children.size() < 2)
        continue;

      DatabaseElementList matches = children.get(labels.get(0));
      if(matches.size() == 0)
        continue;
     
      // take the first value (the system allows multiple values)
      DatabaseAttributeNode rx = (DatabaseAttributeNode)matches.get(0);
      String x = "'" + escapeString(rx.value().getCurrent().value()) + "'";

      ArrayList<String> yvalues = new ArrayList<String>(schemaSize-1);

      for (int j = 1; j < schemaSize; j++) {
        // Add the empty string if there are no matches
        // or the result isn't a number.
        // Otherwise add the first matching number.

        matches = children.get(labels.get(j));
        if(matches.size() == 0) {
          yvalues.add("");
          continue;
        }

        String y = ((DatabaseAttributeNode)(matches.get(0))).value().getCurrent().value();
        if (!y.matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+"))
          y = "";
        yvalues.add(y);
      }
View Full Code Here

   
    boolean nonEmpty = false;
    for (int i = 0; i < rs.size(); i++) {
      DatabaseGroupNode r = (DatabaseGroupNode)rs.get(i);

      DatabaseElementList children = r.children();
      if(children.size() == 0)
        continue;

      ArrayList<String> components = new ArrayList<String>();
      for(int j = 0; j < labels.size(); j++) {
        DatabaseElementList matches = children.get(labels.get(j));
        for (int k = 0; k < matches.size(); k++) {
          components.add(((DatabaseAttributeNode)(matches.get(k))).value().getCurrent().value());
        }
      }
      String location = stringConcat(components, ", ");

      String prefix;
View Full Code Here

   
    public String getString(DatabaseElementNode node, RequestParameterVersion version) {
      String label = null;
     
      try {
        DatabaseElementList nodes = ((DatabaseGroupNode)node).find(_path);
        for (int iNode = 0; iNode < nodes.size(); iNode++) {
          DatabaseAttributeNode attribute = (DatabaseAttributeNode)nodes.get(iNode);
          for (int iText = 0; iText < attribute.value().size(); iText++) {
            DatabaseTextNode text = attribute.value().get(iText);
            if (version.matches(text)) {
              if (label != null) {
                label = label + ", " + text.value();
View Full Code Here

      // schema node.
      for (int iChild = 0; iChild < schemaNode.children().size(); iChild++) {
        SchemaNode childSchema = schemaNode.children().get(iChild);
        if ((childSchema.label().equals(nodeIdentifier)) && (childSchema.isAttribute())) {
          // Make sure that there is only one child
          DatabaseElementList nodes = node.find(childSchema.path().substring(node.schema().path().length() + 1));
          if (nodes.size() > 1) {
            throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
          } else if (nodes.size() == 1) {
            if (pathIndex == (url.size() - 1)) {
              return nodes.get(0).identifier();
            } else {
              return this.decode(database, (DatabaseGroupNode)nodes.get(0), versionParameter, url, pathIndex + 1);
            }
          } else {
            throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
          }
        }
      }
      // This part of the code is only reached if the nodeIdentifier does not point
      // to an attribute node. There should only be one schema node child with a rule defined
      // for that node.
      for (int iChild = 0; iChild < schemaNode.children().size(); iChild++) {
        URLDecodingRule childRule = this.get(schemaNode.children().get(iChild));
        if (childRule != null) {
          if (rule == null) {
            rule = childRule;
          } else {
            throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
          }
        }
      }
    }

    if (rule != null) {
      DatabaseElementList nodes = node.find(rule.node().path().substring(node.schema().path().length() + 1));
      DatabaseGroupNode nextNode = null;
      for (int iNode = 0; iNode < nodes.size(); iNode++) {
        DatabaseGroupNode childNode = (DatabaseGroupNode)nodes.get(iNode);
        if (versionParameter.matches(childNode)) {
          int matches = 0;
          DatabaseElementList valueNodes = childNode.find(rule.value().path().substring(childNode.schema().path().length() + 1));
          for (int iValueNode = 0; iValueNode < valueNodes.size(); iValueNode++) {
            DatabaseAttributeNode attributeNode = (DatabaseAttributeNode)valueNodes.get(iValueNode);
            for (int iAttrValue = 0; iAttrValue < attributeNode.value().size(); iAttrValue++) {
              DatabaseTextNode textNode = attributeNode.value().get(iAttrValue);
              if ((versionParameter.matches(textNode)) && (textNode.value().equals(keyValue))) {
                matches++;
                break;
View Full Code Here

TOP

Related Classes of org.dbwiki.data.database.DatabaseElementList

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.