@GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/create")
  public Criteria create() {
    Criteria criteria = new Criteria();
    criteria.setResultCount(100);
    // ("DocStatus" = 'P' OR "DocStatus" = 'F')
    ICondition condition = criteria.getConditions().create();
    condition.setBracketOpenNum(1);
    condition.setAlias("DocumentStatus");
    condition.setCondVal(emDocumentStatus.Planned);
    condition = criteria.getConditions().create();
    condition.setBracketCloseNum(1);
    condition.setAlias("DocumentStatus");
    condition.setCondVal(emDocumentStatus.Released);
    condition.setRelationship(ConditionRelationship.cr_OR);
    // ORDER BY "DocEntry" DESC, "CardCode" ASC
    ISort sort = criteria.getSorts().create();
    sort.setAlias("DocEntry");
    sort.setSortType(SortType.st_Descending);
    sort = criteria.getSorts().create();
    sort.setAlias("CustomerCode");
    sort.setSortType(SortType.st_Ascending);
    // 子项查询
    IChildCriteria childCriteria = criteria.getChildCriterias().create();
    condition = childCriteria.getConditions().create();
    condition.setAlias("ItemCode");
    condition.setOperation(ConditionOperation.co_CONTAIN);
    condition.setCondVal("T000");

    return criteria;
  }
 @POST
 @Produces(MediaType.TEXT_PLAIN)
 @Consumes(MediaType.APPLICATION_JSON)
 @Path("/fetch")
 public String fetch(Criteria criteria) {
   System.out.println(criteria.toString("xml"));
   System.out.println(i18n.prop("msg_bobas_operation_successful"));
   return "ok.";
 }
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  @Path("/fetchSalesOrder")
  public OperationResult<SalesOrder> fetchSalesOrder(
      Criteria criteria, @QueryParam("token") String token) {
    System.out.println(String.format("fetch by %s.", token));
    System.out.println(criteria.toString("xml"));

    OperationResult<SalesOrder> operationResult = new OperationResult<SalesOrder>();
    SalesOrder order = new SalesOrder();
    order.setDocEntry(1);
    order.setCustomerCode("C00001");
    order.setDeliveryDate(DateTime.getToday());
    order.setDocumentStatus(emDocumentStatus.Released);
    order.setDocumentTotal(new Decimal("99.99"));
    order.setCycle(new Time(1.05, emTimeUnit.hour));

    order.getUserFields().addUserField("U_OrderType", DbFieldType.db_Alphanumeric);
    order.getUserFields().addUserField("U_OrderId", DbFieldType.db_Numeric);
    order.getUserFields().addUserField("U_OrderDate", DbFieldType.db_Date);
    order.getUserFields().addUserField("U_OrderTotal", DbFieldType.db_Decimal);
    order.getUserFields().setValue("U_OrderType", "S0000");
    order.getUserFields().setValue("U_OrderId", 5768);
    order.getUserFields().setValue("U_OrderDate", DateTime.getToday());
    order.getUserFields().setValue("U_OrderTotal", new Decimal("999.888"));

    ISalesOrderItem orderItem = order.getSalesOrderItems().create();
    orderItem.setItemCode("A00001");
    orderItem.setQuantity(new Decimal(10));
    orderItem.setPrice(new Decimal(99.99));
    orderItem = order.getSalesOrderItems().create();
    orderItem.setItemCode("A00002");
    orderItem.setQuantity(10);
    orderItem.setPrice(199.99);

    // order.setDocumentUser(new User());
    // 此处json序列化存在问题,可能是jersey导致
    // order.setTeamUsers(new User[] { new User(), new User() });
    operationResult.addResultObjects(order);
    return operationResult;
  }