Ejemplo n.º 1
0
  // 从豆瓣获取图书信息
  protected void fetchDataFromDouban() {

    theBook.setBookISBN(bookForm1.getValueAsString("bookISBN"));
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookISBN())) {
      SC.say("请先输入书籍ISBN!");
      return;
    }

    new RPCCall<SLBook>() {
      @Override
      public void onFailure(Throwable caught) {
        SC.say("通信失败,请检查您的网络连接!");
      }

      @Override
      public void onSuccess(SLBook result) {
        if (result == null) {
          SC.say("无此ISBN编号的书籍信息,请检查输入是否正确!");
          return;
        }
        theBook = result;

        bookForm1.setValue("bookName", theBook.getBookName());
        bookForm1.setValue("bookAuthor", theBook.getBookAuthor());
        bookForm1.setValue("bookISBN", theBook.getBookISBN());
        bookForm1.setValue("bookPublisher", theBook.getBookPublisher());

        bookForm1.setValue("bookPublishDate", theBook.getBookPublishDate());
        bookForm1.setValue("bookClass", theBook.getBookClass());
        bookForm1.setValue("bookLanguage", theBook.getBookLanguage());
        bookForm1.setValue("bookPrice", theBook.getBookPrice());
        bookForm1.setValue("bookContributor", theBook.getBookContributor());

        bookForm2.setValue("bookTotalQuantity", "1");
        bookForm2.setValue("bookInStoreQuantity", "1");
        bookForm2.setValue("bookAvailableQuantity", "1");

        bookForm3.setValue("bookIntro", SLBook.toWords(theBook.getBookIntro()));

        doAfterFinishUpload(theBook.getBookPicUrl());
      }

      @Override
      protected void callService(AsyncCallback<SLBook> cb) {
        bookService.getBookByDoubanAPI(theBook.getBookISBN(), cb);
      }
    }.retry(3);
  }
Ejemplo n.º 2
0
  private boolean updateBookInfo() {

    theBook.setBookName(bookForm1.getValueAsString("bookName"));
    theBook.setBookAuthor(bookForm1.getValueAsString("bookAuthor"));
    theBook.setBookISBN(bookForm1.getValueAsString("bookISBN"));
    theBook.setBookPublisher(bookForm1.getValueAsString("bookPublisher"));
    theBook.setBookPublishDate((Date) bookForm1.getValue("bookPublishDate"));
    theBook.setBookLanguage(bookForm1.getValueAsString("bookLanguage"));
    theBook.setBookPrice(Double.parseDouble((bookForm1.getValueAsString("bookPrice"))));
    theBook.setBookClass(bookForm1.getValueAsString("bookClass"));
    theBook.setBookContributor(bookForm1.getValueAsString("bookContributor"));
    theBook.setBookIntro(bookForm3.getValueAsString("bookIntro"));
    theBook.setBookTotalQuantity(Integer.parseInt(bookForm2.getValueAsString("bookTotalQuantity")));
    theBook.setBookInStoreQuantity(
        Integer.parseInt(bookForm2.getValueAsString("bookInStoreQuantity")));
    theBook.setBookAvailableQuantity(
        Integer.parseInt(bookForm2.getValueAsString("bookAvailableQuantity")));

    theBook.setBookPicUrl(strBookPicUrl);

    if (!FieldVerifier.isNotEmptyValid(theBook.getBookName())) {
      SC.say("请输入书名!");
      return false;
    }
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookAuthor())) {
      SC.say("请输入作者!");
      return false;
    }
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookISBN())) {
      SC.say("请输入书籍ISBN!");
      return false;
    }
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookPublisher())) {
      SC.say("请输入出版商名称!");
      return false;
    }
    if (theBook.getBookPublishDate() == null) {
      SC.say("请输入出版日期!");
      return false;
    }
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookLanguage())) {
      SC.say("请输入语言种类!");
      return false;
    }
    if (!FieldVerifier.isNotEmptyValid(theBook.getBookContributor())) {
      SC.say("请输入贡献者!");
      return false;
    }

    return true;
  }