Package com.google.code.apis.rest.client.Wadl

Examples of com.google.code.apis.rest.client.Wadl.MethodNode


   
    Vector buttonTreeItems = WadlTreeRoot.removeChildrenXKeepButtons(parentTreeItem, WadlXml.methodNode);
   
    Iterator methodIterator = methods.iterator();   
    while (methodIterator.hasNext()) {
      MethodNode method = (MethodNode) methodIterator.next();
      MethodItem methodItem = new MethodItem(method, method.getParent(), parentTreeItem, requestString);
      TreeItem methodTreeItem = new TreeItem(methodItem);     
      methodTreeItem.setUserObject(WadlXml.methodNode);
      parentTreeItem.addItem(methodTreeItem);    
     
      if (method.getHref() == null) {
        // request
        RequestItem.listRequest(method, methodTreeItem);
       
        // response
        ResponseItem.listResponse(method, methodTreeItem);
      
        // close method item
        GenericClosingItem methodCloseItem = new GenericClosingItem(WadlXml.methodNode);
        TreeItem methodCloseTreeItem = new TreeItem(methodCloseItem);
        methodCloseTreeItem.setUserObject(WadlXml.methodNode);
        parentTreeItem.addItem(methodCloseTreeItem);
      }
      methodTreeItem.setState(SettingsDialog.treeItemsAlwaysOpen);     
    }
       
    if (!WadlTreeRoot.containsButton(buttonTreeItems, ApplicationItem.button + WadlXml.methodNode)) {     
      // add method button     
      HorizontalPanel addMethodPanel = new HorizontalPanel();
           
      Button addMethodButton = new Button(GuiFactory.strings.addMethod());
      addMethodButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
          if (parentNode instanceof ResourceNode) {
            ((ResourceNode) parentNode).directlyAddMethod(new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
            listMethods(parentNode, parentTreeItem, requestString);
          }
          else if (parentNode instanceof ApplicationNode) {
            MethodNode method = new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, (ApplicationNode) parentNode);
            method.setId(GuiFactory.strings.newId());
            ((ApplicationNode) parentNode).directlyAddMethod(method);
            listMethods(parentNode, parentTreeItem, requestString);
          }
          else if (parentNode instanceof ResourceTypeNode) {
            ((ResourceTypeNode) parentNode).directlyAddMethod(new MethodNode(GuiFactory.strings.newMethod(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication()));
            listMethods(parentNode, parentTreeItem, requestString);
          }         
        }
      });
      addMethodPanel.add(addMethodButton);
View Full Code Here


      ResourceNode resource = (ResourceNode) allResourcesIterator.next();
      if (resource.getAllMethods() != null) {
        Vector allMethods = resource.getAllMethods();
        Iterator allMethodsIterator = allMethods.iterator();
        while(allMethodsIterator.hasNext()) {
          MethodNode method = (MethodNode) allMethodsIterator.next();
          if (id.equals(method.getHref().substring(1))) {
            ResourceNode resourceNode = ((ResourceNode) method.getParent());
            String name = resourceNode.getPath();
            String absoluteAddress = resourceNode.getAbsolutePath() + resourceNode.getPath();                 
            // check if we have a template parameter
            while (resource.getPath().matches(Analyzer.templateParamRegExp)) {
              // don't confuse: param is from the WADL, parameter is for code generation
View Full Code Here

    }   
    if (allObjects != null) {
      Iterator allObjectsIterator = allObjects.iterator();
      while (allObjectsIterator.hasNext()) {
        if (referenceNode instanceof MethodNode) {
          MethodNode referencedMethod = (MethodNode) allObjectsIterator.next();
          if (referencedMethod.getId().equals(href)) {
            treatMethod(referencedMethod);
            return;
          }
        }
        else if (referenceNode instanceof FaultNode) {
View Full Code Here

        treatParam(p);       
      }
    }  
   
    // get the http method name and the request name
    MethodNode thisRequestsMethod = ((MethodNode) request.getParent());
    String httpMethodName = thisRequestsMethod.getName();  
    String absoluteAddress = null;
    String name = null;
    Object thisRequestsMethodsParent = (Object) thisRequestsMethod.getParent();
    if (thisRequestsMethodsParent instanceof ResourceNode) {
      ResourceNode resource = (ResourceNode) thisRequestsMethodsParent;
      name = resource.getPath();
      absoluteAddress = resource.getAbsolutePath() + resource.getPath();     
      // check if we have template parameters
      while (resource.getPath().matches(Analyzer.templateParamRegExp)) {
        // don't confuse: param is from the WADL, parameter is for code generation
        String path = resource.getPath();       
        int indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
        int indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);       
        while(indexOfOpen >= 0 &&
            indexOfClose > 0 &&
            indexOfOpen < indexOfClose) {         
          String templateParamName = path.substring(indexOfOpen + 1, indexOfClose);
          // from all the potential params find the one that matches the template {name}
          Vector templateParams = resource.getAllParams();
          Iterator templateParamsIterator = templateParams.iterator();         
          ParamNode templateParam = null;
          if (templateParamsIterator.hasNext()) {
            templateParam = (ParamNode) templateParamsIterator.next();
          }
          while(!templateParam.getName().equals(templateParamName)) {
            templateParam = (ParamNode) templateParamsIterator.next();
          }
          // now generate the code generation parameter      
          Parameter templateParameter = new Parameter(
              templateParamName + SettingsDialog.templateSuffix,
              templateParam.getType(),
              Parameter.accessPrivate,
              templateParam.getIsRequired(),              
              language,
              true);
          variables.insertElementAt(templateParameter, 0);
         
          path = path.substring(indexOfClose + 1);
          indexOfOpen = path.indexOf(Analyzer.templateParamOpenChar);
          indexOfClose = path.indexOf(Analyzer.templateParamCloseChar);         
        }
        if (resource.getParent().getParent() instanceof ResourceNode) {
          resource = (ResourceNode) resource.getParent().getParent();
        }
        else {
          break;
        }
      }           
    }
    else if (thisRequestsMethodsParent instanceof ResourceTypeNode) {
      // TODO
    }
    else if (thisRequestsMethodsParent instanceof ApplicationNode) {
      // find the reference method of this referenced method
      getMethodById(
          application.getResources(),
          thisRequestsMethod.getId(),         
          httpMethodName,
          request);
      return;
    }
   
View Full Code Here

        // if we still found nothing, check the referenced methods
        if (!application.getAllMethods().isEmpty()) {         
          Vector allMethods = application.getAllMethods();
          Iterator allMethodsIterator = allMethods.iterator();
          while (allMethodsIterator.hasNext()) {
            MethodNode method = (MethodNode) allMethodsIterator.next();                   
            if (method.getRequest() != null) {             
              RequestNode request = method.getRequest();                       
              if (!request.getAllParams().isEmpty()) {               
                examineParams(request.getAllParams())
                return;
              }
            }
          }
        }
      }
    } 
    // do this every time
    Iterator allResourcesIterator = allResources.iterator();
    while(allResourcesIterator.hasNext()) {
      ResourceNode resource = (ResourceNode) allResourcesIterator.next();     
      if (!resource.getAllMethods().isEmpty()) {
        Vector allMethods = resource.getAllMethods();
        Iterator allMethodsIterator = allMethods.iterator();
        while(allMethodsIterator.hasNext()) {
          MethodNode method = (MethodNode) allMethodsIterator.next();         
          if (method.getRequest() != null) {
            RequestNode request = method.getRequest();                   
            if (!request.getAllParams().isEmpty()) {            
              examineParams(request.getAllParams());
              return;
            }
          }         
View Full Code Here

TOP

Related Classes of com.google.code.apis.rest.client.Wadl.MethodNode

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.