Package org.dbwiki.data.schema

Examples of org.dbwiki.data.schema.GroupSchemaNode


    // requests further, thus it has to be done here.
    if (request.type().isAction()) {
      RequestParameterAction action = RequestParameter
          .actionParameter(request.parameters().get(
              RequestParameter.ParameterAction));
      GroupSchemaNode parent = null;
      if (action.actionSchemaNode()) {
        if (!request.isRootRequest())
          parent = (GroupSchemaNode) request.schema();
        _database.insertSchemaNode(
            parent,
View Full Code Here


    } else {
      boolean matches = false;
      if (schema.isAttribute()) {
        return false;
      } else {
        GroupSchemaNode group = (GroupSchemaNode)schema;
        for (int iElement = 0; iElement < group.children().size(); iElement++) {
          if (matches(group.children().get(iElement))) {
            matches = true;
            break;
          }
        }
      }
View Full Code Here

   * Public Methods
   */

  public void print(HtmlLinePrinter printer) throws WikiException {
    Vector<SchemaNode> entities = new Vector<SchemaNode>();
    GroupSchemaNode root = _request.wiki().database().schema().root();
    entities.add(root);
    this.listSchemaNodes(root, entities);
   
    printer.paragraph("Database Layout", CSS.CSSHeadline);

View Full Code Here

 
  public ResourceIdentifier decode(Database database, RequestURL url, RequestParameterVersion versionParameter) throws org.dbwiki.exception.WikiException {
   
    // FORMAT: {/[<label>:<key-value>|<key-value>]}+ /[<label>|<label>:<key-value>|<key-value>]

    GroupSchemaNode root = database.schema().root();
    URLDecodingRule rule = this.get(root);
    if (rule != null) {
      String entryIdentifier = url.get(0).decodedText();
      int pos = entryIdentifier.indexOf(':');
      if (pos != -1) {
        if (entryIdentifier.substring(0, pos).equals(root.label())) {
          entryIdentifier = entryIdentifier.substring(pos + 1);
        } else {
          throw new WikiDataException(WikiDataException.UnknownResource, url.toString());
        }
      }
View Full Code Here

 
  public ResourceIdentifier decode(Database database, DatabaseGroupNode node, RequestParameterVersion versionParameter, RequestURL url, int pathIndex) throws org.dbwiki.exception.WikiException {
   
    // FORMAT: {/[<label>:<key-value>|<key-value>]}+ /[<label>|<label>:<key-value>|<key-value>]

    GroupSchemaNode schemaNode = (GroupSchemaNode)node.schema();
    String nodeIdentifier = url.get(pathIndex).decodedText();
   
    URLDecodingRule rule = null;
    String keyValue = nodeIdentifier;
   
    int pos = nodeIdentifier.indexOf(':');

    if (pos != -1) {
      String nodeLabel = nodeIdentifier.substring(0, pos);
      rule = this.get(schemaNode.children().get(nodeLabel));
      keyValue = nodeIdentifier.substring(pos + 1);
    } else {
      // If it's the last element of the URL path the nodeIdentifier could be the node label
      // of an attribute node or a key value for an internal node.
      // First check whether the nodeIdentifier is a valid node label for the current
      // 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());
View Full Code Here

TOP

Related Classes of org.dbwiki.data.schema.GroupSchemaNode

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.