Ejemplo n.º 1
0
  public String SqlExcute(String xmlStr) {
    String outstr = "false";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      DBTable datatable = new DBTable();

      for (int i = 0; i < list.size(); i++) {
        Element childRoot = (Element) list.get(i);
        // System.out.print(childRoot.getText());
        outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText()));
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }
    return outstr;
  }
Ejemplo n.º 2
0
  /**
   * ** Gets a virtual DBRecord from the specified remote service ** @param servReq The remote web
   * service ** @return The virtual DBRecord (cannot be saved or reloaded)
   */
  @SuppressWarnings("unchecked")
  public gDBR getVirtualDBRecord(final ServiceRequest servReq) throws DBException {
    String CMD_dbget = DBFactory.CMD_dbget;
    String TAG_Response = servReq.getTagResponse();
    String TAG_Record = DBFactory.TAG_Record;
    String ATTR_command = servReq.getAttrCommand();
    String ATTR_result = servReq.getAttrResult();

    /* send request / get response */
    Document xmlDoc = null;
    try {
      xmlDoc =
          servReq.sendRequest(
              CMD_dbget,
              new ServiceRequest.RequestBody() {
                public StringBuffer appendRequestBody(StringBuffer sb, int indent) {
                  return DBRecordKey.this.toRequestXML(sb, indent);
                }
              });
    } catch (IOException ioe) {
      Print.logException("Error", ioe);
      throw new DBException("Request read error", ioe);
    }

    /* parse 'GTSResponse' */
    Element gtsResponse = xmlDoc.getDocumentElement();
    if (!gtsResponse.getTagName().equalsIgnoreCase(TAG_Response)) {
      Print.logError("Request XML does not start with '%s'", TAG_Response);
      throw new DBException("Response XML does not begin eith '" + TAG_Response + "'");
    }

    /* request command/argument */
    String cmd = StringTools.trim(gtsResponse.getAttribute(ATTR_command));
    String result = StringTools.trim(gtsResponse.getAttribute(ATTR_result));
    if (StringTools.isBlank(result)) {
      result = StringTools.trim(gtsResponse.getAttribute("type"));
    }
    if (!result.equalsIgnoreCase("success")) {
      Print.logError("Response indicates failure");
      throw new DBException("Response does not indicate 'success'");
    }

    /* Record */
    NodeList rcdList = XMLTools.getChildElements(gtsResponse, TAG_Record);
    if (rcdList.getLength() <= 0) {
      Print.logError("No 'Record' tags");
      throw new DBException("GTSResponse does not contain any 'Record' tags");
    }
    Element rcdElem = (Element) rcdList.item(0);

    /* return DBRecord */
    gDBR dbr = (gDBR) DBFactory.parseXML_DBRecord(rcdElem);
    dbr.setVirtual(true);
    return dbr;
  }
Ejemplo n.º 3
0
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("InvoiceCustDetail");
    root.setAttribute("Id", String.valueOf(mOrderItemData));

    Element node;

    node = doc.createElement("InvoiceCustDetailData");
    node.appendChild(doc.createTextNode(String.valueOf(mInvoiceCustDetailData)));
    root.appendChild(node);

    return root;
  }
Ejemplo n.º 4
0
  public String QuerySQL(String xmlStr) {
    String outstr = "";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      String SqlStr = "select " + rootNode.getAttributeValue("fieldStr");
      SqlStr = SqlStr + "  from  " + rootNode.getAttributeValue("tableStr");
      SqlStr = SqlStr + "  where (1=1) " + rootNode.getAttributeValue("whereStr");

      DBTable datatable = new DBTable();

      RecordSet rs = datatable.queryData(SqlStr);
      String[] fieldArr = rootNode.getAttributeValue("fieldStr").split(",");

      outstr = "<queryDataS success=\"true\">";
      while (rs.next()) {
        outstr = outstr + "<queryData";
        for (int i = 0; i < fieldArr.length; i++) {
          outstr =
              outstr + "  " + fieldArr[i].trim() + "=\"" + rs.getString(fieldArr[i].trim()) + "\"";
        }
        outstr = outstr + "/>";
      }
      outstr = outstr + "</queryDataS>";

    } catch (JDOMException ex) {
      outstr = "<queryDataS success=false>";
      outstr = outstr + ex.getMessage() + "</queryDataS>";
    }
    return Basic.encode(outstr);
  }
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("InboundPollockOrderGuideLoader");
    root.setAttribute("Id", String.valueOf(mEditType));

    Element node;

    node = doc.createElement("RecordType");
    node.appendChild(doc.createTextNode(String.valueOf(mRecordType)));
    root.appendChild(node);

    node = doc.createElement("RecordValue1");
    node.appendChild(doc.createTextNode(String.valueOf(mRecordValue1)));
    root.appendChild(node);

    node = doc.createElement("RecordValue2");
    node.appendChild(doc.createTextNode(String.valueOf(mRecordValue2)));
    root.appendChild(node);

    node = doc.createElement("RecordValue3");
    node.appendChild(doc.createTextNode(String.valueOf(mRecordValue3)));
    root.appendChild(node);

    return root;
  }
Ejemplo n.º 6
0
  public String getDataTableXML(String xmlStr) {
    String outstr = "";
    Document doc;
    Element rootNode, child;

    ConnectionManager cm = ConnectionManager.getInstance();

    try {
      cm.get();

      Reader reader = new StringReader(xmlStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      Element childRoot = (Element) list.get(0);

      DBGrid dbGrid = new DBGrid();
      dbGrid.setGridID(childRoot.getAttributeValue("id"));
      dbGrid.setGridType(childRoot.getAttributeValue("gridType"));
      dbGrid.setfieldSQL(childRoot.getAttributeValue("SQLStr"));
      dbGrid.setfieldcn(childRoot.getAttributeValue("fieldCN"));
      dbGrid.setenumType(childRoot.getAttributeValue("enumType"));
      dbGrid.setvisible(childRoot.getAttributeValue("visible"));
      dbGrid.setfieldName(childRoot.getAttributeValue("fieldname"));
      dbGrid.setfieldWidth(childRoot.getAttributeValue("fieldwidth"));
      dbGrid.setfieldType(childRoot.getAttributeValue("fieldtype"));
      dbGrid.setfieldCheck(childRoot.getAttributeValue("fieldCheck"));
      dbGrid.setcountSQL(childRoot.getAttributeValue("countSQL"));

      dbGrid.setpagesize(Integer.parseInt(childRoot.getAttributeValue("pageSize")));
      dbGrid.setAbsolutePage(Integer.parseInt(childRoot.getAttributeValue("AbsolutePage")));
      dbGrid.setRecordCount(Integer.parseInt(childRoot.getAttributeValue("RecordCount")));
      dbGrid.setCheck(childRoot.getAttributeValue("checkbl").toLowerCase().trim().equals("true"));
      dbGrid.setAlign(childRoot.getAttributeValue("tralign"));

      /*
            if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true"))
              dbGrid.setGridBottomVisible(true);
            else
              dbGrid.setGridBottomVisible(false);
      */
      // zr
      if (childRoot.getAttributeValue("bottomVisible").toLowerCase().equals("true")) {
        dbGrid.setGridBottomVisible(true);
        //            dbGrid.setSumfield(childRoot.getAttributeValue("sumfield"));
      } else dbGrid.setGridBottomVisible(false);

      dbGrid.setWhereStr(Basic.decode(childRoot.getAttributeValue("whereStr")));

      outstr = dbGrid.getEditDataTable();
      // System.out.println(outstr);

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());

    } finally {
      cm.release();
    }
    return outstr;
  }
Ejemplo n.º 7
0
  public String doExcelHou(String xmlStr, WritableWorkbook wwb) {
    String outstr = "";
    Document doc;
    Element rootNode, child;
    // System.out.println(xmlStr);

    try {
      Reader reader = new StringReader(xmlStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      if (rootNode.getAttributeValue("type").equals("lp")) {
        return getloadspell(rootNode.getText());
      }

      if (rootNode.getAttributeValue("type").equals("lm")) {
        return getLoadName(rootNode.getText());
      }

      List list = rootNode.getChildren();

      Element childRoot = (Element) list.get(0);
      String fieldTitle = childRoot.getAttributeValue("fieldTitle");

      if (rootNode.getAttributeValue("type").equals("enum")) {
        String enumType = childRoot.getAttributeValue("enumType");

        return getEnumType(enumType, fieldTitle);
      }
      if (rootNode.getAttributeValue("type").equals("sql")) {
        String SqlStr = childRoot.getAttributeValue("SqlStr");
        DBTable datatable = new DBTable();
        return datatable.getDropDownStr(SqlStr, fieldTitle);
      }

      if (rootNode.getAttributeValue("type").equals("excel")) {
        String SqlStr = childRoot.getAttributeValue("SQLStr");
        // System.out.println(SqlStr);

        String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr"));
        // System.out.println(whereStr);
        DBTable datatable = new DBTable();
        return datatable.getExcel(SqlStr, whereStr);
      }

      // !
      if (rootNode.getAttributeValue("type").equals("excelhou")) {
        String SqlStr = childRoot.getAttributeValue("SQLStr");
        String fieldCN = childRoot.getAttributeValue("fieldCN");
        String fieldType = childRoot.getAttributeValue("fieldType");
        String fieldWidth = childRoot.getAttributeValue("fieldWidth");
        String visible = childRoot.getAttributeValue("visible");
        String enumType = childRoot.getAttributeValue("enumType");
        String whereStr = Basic.decode(childRoot.getAttributeValue("whereStr"));

        DBTable datatable = new DBTable();
        return datatable.writeExcel_new(
            wwb, SqlStr, whereStr, fieldCN, fieldType, fieldWidth, visible, enumType);
      }
      if (rootNode.getAttributeValue("type").equals("comboBox")) {

        String comboBoxID = childRoot.getAttributeValue("comboBoxID");

        JOption jOption = new JOption(comboBoxID);

        String enumType = childRoot.getAttributeValue("enumType");
        String titleStr = childRoot.getAttributeValue("titleStr");
        String sqlStr = childRoot.getAttributeValue("sqlStr");
        String defaultoption = childRoot.getAttributeValue("defaultOption");

        String titleVisible = childRoot.getAttributeValue("titleVisible");
        String keyVisible = childRoot.getAttributeValue("keyVisible");

        if (defaultoption != null) {
          String[] options = defaultoption.split(",", -2);

          if (options.length == 2) {
            jOption.addOption(options[0], options[1]);
          }
        }
        if (titleVisible.toLowerCase().trim().equals("false")) jOption.setTitleVisible(false);
        if (keyVisible.toLowerCase().trim().equals("false")) jOption.setKeyVisible(false);

        jOption.setEnumType(enumType);
        jOption.setSQlStr(sqlStr);
        jOption.setTitleStr(titleStr);
        return jOption.getDropHtml();
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }

    return outstr;
  }
Ejemplo n.º 8
0
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("ProductViewDef");

    Element node;

    root.setAttribute("Id", String.valueOf(mProductViewDefId));

    node = doc.createElement("StatusCd");
    node.appendChild(doc.createTextNode(String.valueOf(mStatusCd)));
    root.appendChild(node);

    node = doc.createElement("AccountId");
    node.appendChild(doc.createTextNode(String.valueOf(mAccountId)));
    root.appendChild(node);

    node = doc.createElement("Attributename");
    node.appendChild(doc.createTextNode(String.valueOf(mAttributename)));
    root.appendChild(node);

    node = doc.createElement("SortOrder");
    node.appendChild(doc.createTextNode(String.valueOf(mSortOrder)));
    root.appendChild(node);

    node = doc.createElement("Width");
    node.appendChild(doc.createTextNode(String.valueOf(mWidth)));
    root.appendChild(node);

    node = doc.createElement("StyleClass");
    node.appendChild(doc.createTextNode(String.valueOf(mStyleClass)));
    root.appendChild(node);

    node = doc.createElement("ProductViewCd");
    node.appendChild(doc.createTextNode(String.valueOf(mProductViewCd)));
    root.appendChild(node);

    node = doc.createElement("AddDate");
    node.appendChild(doc.createTextNode(String.valueOf(mAddDate)));
    root.appendChild(node);

    node = doc.createElement("AddBy");
    node.appendChild(doc.createTextNode(String.valueOf(mAddBy)));
    root.appendChild(node);

    node = doc.createElement("ModDate");
    node.appendChild(doc.createTextNode(String.valueOf(mModDate)));
    root.appendChild(node);

    node = doc.createElement("ModBy");
    node.appendChild(doc.createTextNode(String.valueOf(mModBy)));
    root.appendChild(node);

    return root;
  }
Ejemplo n.º 9
0
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("NscUs");
    root.setAttribute("Id", String.valueOf(mUserName));

    Element node;

    node = doc.createElement("Password");
    node.appendChild(doc.createTextNode(String.valueOf(mPassword)));
    root.appendChild(node);

    node = doc.createElement("CustomerNumber");
    node.appendChild(doc.createTextNode(String.valueOf(mCustomerNumber)));
    root.appendChild(node);

    node = doc.createElement("ContactName");
    node.appendChild(doc.createTextNode(String.valueOf(mContactName)));
    root.appendChild(node);

    node = doc.createElement("EmailAddress");
    node.appendChild(doc.createTextNode(String.valueOf(mEmailAddress)));
    root.appendChild(node);

    node = doc.createElement("CatalogName");
    node.appendChild(doc.createTextNode(String.valueOf(mCatalogName)));
    root.appendChild(node);

    node = doc.createElement("LocationNumber");
    node.appendChild(doc.createTextNode(String.valueOf(mLocationNumber)));
    root.appendChild(node);

    node = doc.createElement("MemberNumber");
    node.appendChild(doc.createTextNode(String.valueOf(mMemberNumber)));
    root.appendChild(node);

    node = doc.createElement("FirstName");
    node.appendChild(doc.createTextNode(String.valueOf(mFirstName)));
    root.appendChild(node);

    node = doc.createElement("LastName");
    node.appendChild(doc.createTextNode(String.valueOf(mLastName)));
    root.appendChild(node);

    node = doc.createElement("UserId");
    node.appendChild(doc.createTextNode(String.valueOf(mUserId)));
    root.appendChild(node);

    node = doc.createElement("UserAction");
    node.appendChild(doc.createTextNode(String.valueOf(mUserAction)));
    root.appendChild(node);

    node = doc.createElement("StoreId");
    node.appendChild(doc.createTextNode(String.valueOf(mStoreId)));
    root.appendChild(node);

    node = doc.createElement("StoreAssocId");
    node.appendChild(doc.createTextNode(String.valueOf(mStoreAssocId)));
    root.appendChild(node);

    node = doc.createElement("StoreAssocAction");
    node.appendChild(doc.createTextNode(String.valueOf(mStoreAssocAction)));
    root.appendChild(node);

    node = doc.createElement("AccountId");
    node.appendChild(doc.createTextNode(String.valueOf(mAccountId)));
    root.appendChild(node);

    node = doc.createElement("AccountAssocId");
    node.appendChild(doc.createTextNode(String.valueOf(mAccountAssocId)));
    root.appendChild(node);

    node = doc.createElement("AccountAssocAction");
    node.appendChild(doc.createTextNode(String.valueOf(mAccountAssocAction)));
    root.appendChild(node);

    node = doc.createElement("SiteId");
    node.appendChild(doc.createTextNode(String.valueOf(mSiteId)));
    root.appendChild(node);

    node = doc.createElement("SiteAssocId");
    node.appendChild(doc.createTextNode(String.valueOf(mSiteAssocId)));
    root.appendChild(node);

    node = doc.createElement("SiteAssocAction");
    node.appendChild(doc.createTextNode(String.valueOf(mSiteAssocAction)));
    root.appendChild(node);

    node = doc.createElement("EmailId");
    node.appendChild(doc.createTextNode(String.valueOf(mEmailId)));
    root.appendChild(node);

    node = doc.createElement("EmailAction");
    node.appendChild(doc.createTextNode(String.valueOf(mEmailAction)));
    root.appendChild(node);

    node = doc.createElement("MemberId");
    node.appendChild(doc.createTextNode(String.valueOf(mMemberId)));
    root.appendChild(node);

    node = doc.createElement("CatalogId");
    node.appendChild(doc.createTextNode(String.valueOf(mCatalogId)));
    root.appendChild(node);

    return root;
  }
Ejemplo n.º 10
0
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("OrderAssoc");

    Element node;

    root.setAttribute("Id", String.valueOf(mOrderAssocId));

    node = doc.createElement("Order1Id");
    node.appendChild(doc.createTextNode(String.valueOf(mOrder1Id)));
    root.appendChild(node);

    node = doc.createElement("Order2Id");
    node.appendChild(doc.createTextNode(String.valueOf(mOrder2Id)));
    root.appendChild(node);

    node = doc.createElement("OrderAssocCd");
    node.appendChild(doc.createTextNode(String.valueOf(mOrderAssocCd)));
    root.appendChild(node);

    node = doc.createElement("OrderAssocStatusCd");
    node.appendChild(doc.createTextNode(String.valueOf(mOrderAssocStatusCd)));
    root.appendChild(node);

    node = doc.createElement("AddDate");
    node.appendChild(doc.createTextNode(String.valueOf(mAddDate)));
    root.appendChild(node);

    node = doc.createElement("AddBy");
    node.appendChild(doc.createTextNode(String.valueOf(mAddBy)));
    root.appendChild(node);

    node = doc.createElement("ModDate");
    node.appendChild(doc.createTextNode(String.valueOf(mModDate)));
    root.appendChild(node);

    node = doc.createElement("ModBy");
    node.appendChild(doc.createTextNode(String.valueOf(mModBy)));
    root.appendChild(node);

    node = doc.createElement("WorkOrderItemId");
    node.appendChild(doc.createTextNode(String.valueOf(mWorkOrderItemId)));
    root.appendChild(node);

    node = doc.createElement("ServiceTicketId");
    node.appendChild(doc.createTextNode(String.valueOf(mServiceTicketId)));
    root.appendChild(node);

    return root;
  }
Ejemplo n.º 11
0
  /**
   * Converts value object to XML representation.
   *
   * @return Element.
   */
  public Element toXml(Document doc) {
    Element root = doc.createElement("Event");

    Element node;

    root.setAttribute("Id", String.valueOf(mEventId));

    node = doc.createElement("Type");
    node.appendChild(doc.createTextNode(String.valueOf(mType)));
    root.appendChild(node);

    node = doc.createElement("Status");
    node.appendChild(doc.createTextNode(String.valueOf(mStatus)));
    root.appendChild(node);

    node = doc.createElement("Cd");
    node.appendChild(doc.createTextNode(String.valueOf(mCd)));
    root.appendChild(node);

    node = doc.createElement("Attempt");
    node.appendChild(doc.createTextNode(String.valueOf(mAttempt)));
    root.appendChild(node);

    node = doc.createElement("AddDate");
    node.appendChild(doc.createTextNode(String.valueOf(mAddDate)));
    root.appendChild(node);

    node = doc.createElement("AddBy");
    node.appendChild(doc.createTextNode(String.valueOf(mAddBy)));
    root.appendChild(node);

    node = doc.createElement("ModDate");
    node.appendChild(doc.createTextNode(String.valueOf(mModDate)));
    root.appendChild(node);

    node = doc.createElement("ModBy");
    node.appendChild(doc.createTextNode(String.valueOf(mModBy)));
    root.appendChild(node);

    node = doc.createElement("EventPriority");
    node.appendChild(doc.createTextNode(String.valueOf(mEventPriority)));
    root.appendChild(node);

    node = doc.createElement("ProcessTime");
    node.appendChild(doc.createTextNode(String.valueOf(mProcessTime)));
    root.appendChild(node);

    return root;
  }