Exemplo n.º 1
0
 protected boolean requiresSObjectClass(Definitions definitions) {
   return definitions.getApiType() == SfdcApiType.Partner
       || definitions.getApiType() == SfdcApiType.CrossInstance
       || definitions.getApiType() == SfdcApiType.Internal
       || definitions.getApiType() == SfdcApiType.ClientSync
       || definitions.getApiType() == SfdcApiType.SyncApi;
 }
  public ElementDefn getElementForPath(String pathname, Definitions definitions, String purpose)
      throws Exception {
    String[] path = pathname.split("\\.");

    if (!path[0].equals(getName()))
      throw new Exception(
          "Element Path '" + pathname + "' is not legal in this context (" + purpose + ")");

    ElementDefn res = this;

    for (int i = 1; i < path.length; i++) {
      String en = path[i];
      if (en.length() == 0) throw new Exception("Improper path " + pathname);
      ElementDefn t = null;

      if (res.typeCode().startsWith("@")) {
        res = this.getElementForPath(res.typeCode().substring(1), definitions, purpose);
      } else if (definitions.dataTypeIsSharedInfo(res.typeCode())) {
        res = definitions.getElementDefn(res.typeCode());
      } else if (definitions.hasType(res.typeCode())) {
        res = definitions.getElementDefn(res.typeCode());
      }
      t = res.getElementByName(en);
      if (t == null) {
        throw new Exception("unable to resolve " + pathname);
      }
      res = t;
    }

    return res;
  }
Exemplo n.º 3
0
 private static Definitions createFromInputStream(InputStream in) throws WsdlParseException {
   XmlInputStream parser = new XmlInputStream();
   WsdlParser wsdlParser = new WsdlParser(parser);
   Definitions definitions = new Definitions();
   wsdlParser.setInput(in, "UTF-8");
   definitions.read(wsdlParser);
   return definitions;
 }
Exemplo n.º 4
0
  public void robotInit() {
    System.load("/usr/local/lib/lib_OpenCV/java/libopencv_java2410.so");
    Definitions.initPeripherals();
    //    	frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
    //
    //    	try {
    //    		front = NIVision.IMAQdxOpenCamera("cam1",
    // NIVision.IMAQdxCameraControlMode.CameraControlModeController);
    //    	}
    //    	catch (Exception e){
    //    		frontfailed = true;
    //    	}
    //    	try {
    //    	back = NIVision.IMAQdxOpenCamera("cam0",
    // NIVision.IMAQdxCameraControlMode.CameraControlModeController);
    //    	}
    //    	catch (Exception e){
    //    		backfailed = true;
    //    	}
    //    	if (!backfailed){
    //    		currsession = back;
    //    		NIVision.IMAQdxConfigureGrab(currsession);
    //    	}
    //    	else if (!frontfailed){
    //    		currsession = front;
    //    		NIVision.IMAQdxConfigureGrab(currsession);
    //    	}
    //    	else {
    //    		System.out.println("No cameras");
    //    	}

  }
Exemplo n.º 5
0
 /** Get the flow definition, or null if it fails */
 public Definitions getLegacyFlowDefinition(String flowUuid) {
   try {
     Response<FlowDefinition> flowDefinitionResponse =
         m_api.getLegacyFlowDefinition(getToken(), flowUuid).execute();
     checkResponse(flowDefinitionResponse);
     FlowDefinition def = flowDefinitionResponse.body();
     Definitions definitions = new Definitions();
     definitions.version = def.version;
     definitions.flows = new ArrayList<>();
     definitions.flows.add(def);
     return definitions;
   } catch (IOException e) {
     Surveyor.LOG.e("Error fetching flow definition", e);
   }
   return null;
 }
  /**
   * @param context
   * @param parent
   * @param e
   */
  private boolean parseGlobalJAXWSBindings(
      TWSDLParserContext context, TWSDLExtensible parent, Element e) {
    context.push();
    context.registerNamespaces(e);

    JAXWSBinding jaxwsBinding = getJAXWSExtension(parent);
    if (jaxwsBinding == null) {
      jaxwsBinding = new JAXWSBinding(context.getLocation(e));
    }
    String attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.WSDL_LOCATION_ATTR);
    if (attr != null) {
      jaxwsBinding.setWsdlLocation(attr);
    }

    attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NODE_ATTR);
    if (attr != null) {
      jaxwsBinding.setNode(attr);
    }

    attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.VERSION_ATTR);
    if (attr != null) {
      jaxwsBinding.setVersion(attr);
    }

    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) {
      Element e2 = Util.nextElement(iter);
      if (e2 == null) {
        break;
      }

      if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) {
        parsePackage(context, jaxwsBinding, e2);
        if ((jaxwsBinding.getJaxwsPackage() != null)
            && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) {
          ((Definitions) parent)
              .setDocumentation(new Documentation(jaxwsBinding.getJaxwsPackage().getJavaDoc()));
        }
      } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
        parseWrapperStyle(context, jaxwsBinding, e2);
      } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
        parseAsynMapping(context, jaxwsBinding, e2);
      } //            else if(XmlUtil.matchesTagNS(e2,
        // JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
      //                parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
      //            }
      else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
        parseMimeContent(context, jaxwsBinding, e2);
      } else {
        Util.fail("parsing.invalidExtensionElement", e2.getTagName(), e2.getNamespaceURI());
        return false;
      }
    }
    parent.addExtension(jaxwsBinding);
    context.pop();
    //        context.fireDoneParsingEntity(
    //                JAXWSBindingsConstants.JAXWS_BINDINGS,
    //                jaxwsBinding);
    return true;
  }
Exemplo n.º 7
0
  /**
   * Print a list of definitions in different format: fqdn, vdlt, and vdlx
   *
   * @param writer the target to output the list
   * @param defList a list of definitions
   * @param format the output format
   * @see #FORMAT_FQDN
   * @see #FORMAT_VDLT
   * @see #FORMAT_VDLX NOTE: might be better to move into another module?
   */
  public void printDefinitionList(Writer writer, java.util.List defList, int format)
      throws IOException {
    if (defList == null || defList.isEmpty()) return;
    Definitions defs = new Definitions();
    if (format != FORMAT_FQDN) {
      defs.setDefinition(defList);
      if (format == FORMAT_VDLX) defs.toXML(writer, "");
      else if (format == FORMAT_VDLT) defs.toString(writer);
    } else {
      for (Iterator i = defList.iterator(); i.hasNext(); ) {
        Definition def = (Definition) i.next();

        writer.write(def.identify());
        writer.write("\n");
      }
      writer.flush();
    }
  }
 private boolean nameMatches(
     String n, ElementDefn e, boolean throughChoice, Definitions definitions) {
   if (e.getName().equals(n)) return true;
   else if (!throughChoice || !e.getName().endsWith("[x]")) return false;
   else {
     String b = e.getName().substring(0, e.getName().indexOf("["));
     if (!n.startsWith(b)) return false;
     String tn = n.substring(b.length());
     if (e.typeCode().equals("*") && definitions != null) {
       for (TypeRef t : definitions.getKnownTypes()) {
         if (!definitions.getInfrastructure().containsKey(t.getName())
             && !definitions.getConstraints().containsKey(t.getName())) {
           if (t.getName().equalsIgnoreCase(tn)) return true;
         }
       }
     } else for (TypeRef t : e.getTypes()) if (t.getName().equalsIgnoreCase(tn)) return true;
     return false;
   }
 }
  public ElementDefn getElementByName(
      String name, boolean throughChoice, Definitions definitions, String purpose)
      throws Exception {
    String n = name.contains(".") ? name.substring(0, name.indexOf(".")) : name;
    String t = name.contains(".") ? name.substring(name.indexOf(".") + 1) : null;
    if (n.equals(this.name) && t != null) return getElementByName(t);

    ElementDefn focus = this;

    if (typeCode().startsWith("@")) {
      String s = typeCode().substring(1);
      focus = definitions.getElementDefn(s.substring(0, s.indexOf(".")));
      focus = focus.getElementForPath(s, definitions, purpose, throughChoice);
    }

    for (int i = focus.elements.size() - 1; i >= 0; i--) {
      ElementDefn e = focus.elements.get(i);
      if (nameMatches(n, e, throughChoice, definitions))
        return t == null ? e : e.getElementByName(t);
    }
    return null;
  }
Exemplo n.º 10
0
 public void generate(URL wsdl, File dest) throws WsdlParseException, ToolsException, IOException {
   Definitions definitions = WsdlFactory.create(wsdl);
   SfdcApiType sfdcApiType = definitions.getApiType();
   Types types = definitions.getTypes();
   generate(definitions, sfdcApiType, types, dest);
 }
Exemplo n.º 11
0
 protected boolean requiresAggregateResultClass(Definitions definitions) {
   return definitions.getApiType() == SfdcApiType.Enterprise;
 }
Exemplo n.º 12
0
 protected String getPackageName(Definitions definitions) {
   return NameMapper.getPackageName(definitions.getApiType().getSobjectNamespace(), packagePrefix);
 }