コード例 #1
0
ファイル: TestBook.java プロジェクト: scaria/biblioteca
 @Test
 public void testSetorGetName() {
   String name = "Book";
   Book test = new Book(null);
   test.setName(name);
   assertEquals(name, test.getName());
 }
コード例 #2
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 @GET
 @Path("/books/redirectComplete")
 public Book getBookRedirectComplete(@Context HttpServletRequest request) {
   Book book = (Book) request.getAttribute(Book.class.getSimpleName().toLowerCase());
   book.setName("Redirect complete: " + request.getRequestURI());
   return book;
 }
コード例 #3
0
  // This method will parse json data
  private void parseData(JSONArray array) {
    for (int i = 0; i < array.length(); i++) {
      // Creating the superhero object
      Book books = new Book();
      JSONObject json = null;
      try {
        // Getting json
        json = array.getJSONObject(i);

        // Adding data to the superhero object
        books.setImageUrl(json.getString(Config.TAG_IMAGE_URL));
        books.setEmail(json.getString(Config.TAG_EMAIL));
        books.setName(json.getString(Config.TAG_AUTHOR_NAME));
        books.setPublisher(json.getString(Config.TAG_PUBLISHER_NAME));
        books.setBookName(json.getString(Config.TAG_BOOK_NAME));
        books.setDepartment(json.getString(Config.TAG_DEPART));
        books.setCondition(json.getString(Config.TAG_CONDITION));
        books.setSelling(json.getString(Config.TAG_SELLING_PRICE));
        books.setLocation(json.getString(Config.TAG_LOCATION));
        books.setSell(json.getString(Config.TAG_SELL));
        books.setBuy(json.getString(Config.TAG_BUY));
      } catch (JSONException e) {
        e.printStackTrace();
      }
      // Adding the superhero object to the list
      listBookes.add(books);
    }

    // Notifying the adapter that data has been added or changed
    adapter.notifyDataSetChanged();
  }
コード例 #4
0
  /**
   * Import books
   *
   * @param nodes
   * @return
   */
  private Boolean processBooks(NodeList nodes) {
    NodeList books = nodes.item(0).getChildNodes();

    for (int i = 0; i < books.getLength(); i++) {
      if (books.item(i).getNodeType() == Node.ELEMENT_NODE) {
        Element bookNode = (Element) books.item(i);

        Book book = new Book();

        book.setIdbook(Integer.parseInt(getTagValue("idbook", bookNode)));
        book.setCode(getTagValue("code", bookNode));
        book.setEdition(Integer.parseInt(getTagValue("edition", bookNode)));
        book.setPages(Integer.parseInt(getTagValue("pages", bookNode)));
        book.setPlace(getTagValue("place", bookNode));
        book.setYear(DatatypeConverter.parseDateTime(getTagValue("year", bookNode)).getTime());
        book.setType(getTagValue("type", bookNode));
        book.setName(getTagValue("name", bookNode));

        // find and set publisher
        Publisher publisher =
            publisherMgr.findByIdpublisher(Integer.parseInt(getTagValue("publisher", bookNode)));
        if (publisher == null) {
          continue;
        }

        book.setPublisher(publisher);

        // find and set genre
        Genre genre = genreMgr.findByIdgenre(Integer.parseInt(getTagValue("genre", bookNode)));
        if (genre == null) {
          continue;
        }

        book.setGenre(genre);

        // setup book authors
        List<String> authors = getTagsValues("authorCollection", bookNode);

        if (book.getAuthorCollection() == null) {
          book.setAuthorCollection(new ArrayList<Author>());
        }

        for (String authorId : authors) {
          Author author = authorMgr.findByIdauthor(Integer.parseInt(authorId));
          if (author != null) {
            //						book.getAuthorCollection().add(author);
            author.getBooksCollection().add(book);
            authorMgr.save(author);
          }
        }

        try {
          bookMgr.save(book);
        } catch (EJBException ex) {
          ex.printStackTrace(System.out);
        }
      }
    }
    return true;
  }
コード例 #5
0
ファイル: BookDao.java プロジェクト: ClaudeJeong/comics
  // 신간 리스트
  public List<Book> SelectNewDataList(int beginRow, int endRow, String month) {
    // 랭킹을 이용하여 모든 데이터를 조회한다.
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    String sql =
        "select bookcode, name, volume, writer, publisher, pubdate, genre, image, bookstat, bookstory, ranking ";
    sql += " from ";
    sql += " ( ";
    sql +=
        " select bookcode, name, volume, writer, publisher, pubdate, genre, image, bookstat, bookstory, rank() over( order by name asc, volume desc, bookcode desc) as ranking ";
    sql += " from books ";
    sql += " where bookstat != '대출 불가' and pubdate between " + month;
    sql += " ) ";
    sql += " where ranking between ? and ? ";

    List<Book> lists = new ArrayList<Book>();
    try {
      // if( this.conn == null ){
      this.conn = this.getConn();
      // }
      pstmt = this.conn.prepareStatement(sql);
      pstmt.setInt(1, beginRow);
      pstmt.setInt(2, endRow);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        Book bean = new Book();
        bean.setBookcode(rs.getInt("bookcode"));
        bean.setName(rs.getString("name"));
        bean.setVolume(rs.getInt("volume"));
        bean.setWriter(rs.getString("writer"));
        bean.setPublisher(rs.getString("publisher"));
        bean.setPubdate(String.valueOf(rs.getDate("pubdate")));
        bean.setGenre(rs.getString("genre"));
        bean.setImage(rs.getString("image"));
        bean.setBookstat(rs.getString("bookstat"));
        bean.setBookstory(rs.getString("bookstory"));

        lists.add(bean);
      }

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        this.closeConn();
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
    return lists;
  }
コード例 #6
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 @GET
 @Path("books/aegis")
 @Produces({"application/html;q=1.0", "application/xml;q=0.5", "application/json;q=0.5"})
 public Book getBookAegis() {
   // how to have Book2 populated ?
   Book b = new Book();
   b.setId(124);
   b.setName("CXF in Action - 2");
   return b;
 }
コード例 #7
0
ファイル: BookDao.java プロジェクト: ClaudeJeong/comics
  // 인기 도서
  public List<Book> SelectHitDataList() {
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    String sql =
        " select bookcode, name, volume, image, writer, publisher, pubdate, bookstat, cnt, ranking from ( ";
    sql +=
        " select bookcode, name, volume, image, writer, publisher, pubdate, bookstat, cnt, rank() over( order by cnt desc ) as ranking from ( ";
    sql +=
        " select bk.bookcode, bk.name, bk.volume, bk.image, bk.writer, bk.publisher, bk.pubdate, bk.bookstat, count(rc.bcode) as cnt ";
    sql += " from books bk inner join records rc ";
    sql += " on bk.bookcode = rc.bcode ";
    sql +=
        " group by bk.bookcode, bk.name, bk.volume, bk.image, bk.writer, bk.publisher, bk.pubdate, bk.bookstat)) ";
    sql += " where ranking <= 10 ";

    List<Book> lists = new ArrayList<Book>();
    try {
      if (this.conn == null) {
        this.conn = this.getConn();
      }
      pstmt = this.conn.prepareStatement(sql);
      rs = pstmt.executeQuery();
      while (rs.next()) {
        Book bean = new Book();
        bean.setBookcode(rs.getInt("bookcode"));
        bean.setName(rs.getString("name"));
        bean.setVolume(rs.getInt("volume"));
        bean.setWriter(rs.getString("writer"));
        bean.setPublisher(rs.getString("publisher"));
        bean.setPubdate(String.valueOf(rs.getDate("pubdate")));
        bean.setImage(rs.getString("image"));
        bean.setBookstat(rs.getString("bookstat"));

        lists.add(bean);
      }

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        this.closeConn();
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
    return lists;
  }
コード例 #8
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 @POST
 @Path("books/convert")
 @Consumes({"application/xml", "application/json", "application/vnd.example-com.foo+json"})
 @Produces({"application/xml", "application/vnd.example-com.foo+json"})
 public Book convertBook(Book2 book) {
   // how to have Book2 populated ?
   Book b = new Book();
   b.setId(book.getId());
   b.setName(book.getName());
   return b;
 }
コード例 #9
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 @GET
 @Path("books/xslt/{id}")
 @Produces({"text/html", "application/xhtml+xml", "application/xml"})
 public Book getBookXSLT(
     @PathParam("id") long id,
     @QueryParam("name") String name,
     @MatrixParam("name2") String name2) {
   // how to have Book2 populated ?
   Book b = new Book();
   b.setId(999);
   b.setName("CXF in ");
   return b;
 }
コード例 #10
0
ファイル: BookDao.java プロジェクト: ClaudeJeong/comics
  // 책 1건에 대한 상세 정보 보기
  public Book SelectDataByPk(int bookcode) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String sql = "select * ";
    sql += " from books ";
    sql += " where bookcode = ? ";
    Book bean = null;
    try {
      if (this.conn == null) {
        this.conn = this.getConn();
      }
      pstmt = this.conn.prepareStatement(sql);
      // placehodelr 치환은 반드시 execute 메소드 실행 바로 직전에 하세요.
      pstmt.setInt(1, bookcode);
      rs = pstmt.executeQuery();

      if (rs.next()) {
        bean = new Book();
        bean.setBookcode(rs.getInt("bookcode"));
        bean.setName(rs.getString("name"));
        bean.setVolume(rs.getInt("volume"));
        bean.setWriter(rs.getString("writer"));
        bean.setPublisher(rs.getString("publisher"));
        bean.setPubdate(String.valueOf(rs.getDate("pubdate")));
        bean.setGenre(rs.getString("genre"));
        bean.setImage(rs.getString("image"));
        bean.setBookstat(rs.getString("bookstat"));
        bean.setBookstory(rs.getString("bookstory"));
      }

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        this.closeConn();
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
    return bean;
  }
コード例 #11
0
ファイル: BookDao.java プロジェクト: ClaudeJeong/comics
  // 책 시리즈 리스트
  public List<Book> SelectDataList(String name, String writer) {
    // 랭킹을 이용하여 모든 데이터를 조회한다.
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    String sql = " select bookcode, name, volume, writer ";
    sql += " from books ";
    sql += " where name = ? and writer = ? ";
    sql += " order by volume asc ";
    List<Book> lists = new ArrayList<Book>();
    try {
      // if( this.conn == null ){
      this.conn = this.getConn();
      // }
      pstmt = this.conn.prepareStatement(sql);
      pstmt.setString(1, name);
      pstmt.setString(2, writer);

      rs = pstmt.executeQuery();
      while (rs.next()) {
        Book bean = new Book();
        bean.setBookcode(rs.getInt("bookcode"));
        bean.setName(rs.getString("name"));
        bean.setVolume(rs.getInt("volume"));
        bean.setWriter(rs.getString("writer"));
        lists.add(bean);
      }

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        if (rs != null) {
          rs.close();
        }
        if (pstmt != null) {
          pstmt.close();
        }
        this.closeConn();
      } catch (Exception e2) {
        e2.printStackTrace();
      }
    }
    return lists;
  }
コード例 #12
0
  private Entry createBookEntry(int id, String name) throws Exception {

    Book b = new Book();
    b.setId(id);
    b.setName(name);

    Factory factory = Abdera.getNewFactory();
    JAXBContext jc = JAXBContext.newInstance(Book.class);

    Entry e = factory.getAbdera().newEntry();
    e.setTitle(b.getName());
    e.setId(Long.toString(b.getId()));

    StringWriter writer = new StringWriter();
    jc.createMarshaller().marshal(b, writer);

    Content ct = factory.newContent(Content.Type.XML);
    ct.setValue(writer.toString());
    e.setContentElement(ct);
    return e;
  }
コード例 #13
0
 private void init() {
   Book book = new Book();
   book.setId(123);
   book.setName("CXF in Action");
   books.put(book.getId(), book);
 }
コード例 #14
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 final void init() {
   Book book = new Book();
   book.setId(mainId);
   book.setName("CXF in Action");
   books.put(book.getId(), book);
 }
コード例 #15
0
ファイル: Student.java プロジェクト: dzejj/MPR_s9241
 public void renameAllBooksByAuthor(List<Book> bookList, String newAuthor) {
   for (Book k : bookList) {
     k.setName(newAuthor);
   }
 }
コード例 #16
0
ファイル: Student.java プロジェクト: dzejj/MPR_s9241
 public void renameAllBooksByName(List<Book> bookList, String newName) {
   for (Book k : bookList) {
     k.setName(newName);
   }
 }