@WebMethod public List<Asset> getFasilitasAset(int idAset) throws SQLException { String query = "SELECT * FROM " + FASILITAS_ASET_TABLE + " JOIN " + ASSET_TABLE + " ON " + FASILITAS_ASET_TABLE + ".id_fasilitas=" + ASSET_TABLE + ".id" + " WHERE id_aset = " + idAset; System.out.println(query); ResultSet rs = executeQuery(query); List<Asset> assets = null; while (rs.next()) { if (rs.isFirst()) assets = new ArrayList<Asset>(); Asset asset = new Asset(); asset.setId(rs.getInt("id")); asset.setNama(rs.getString("nama")); asset.setKategori(rs.getString("kategori")); asset.setKategori(rs.getString("jenis")); asset.setTanggalMasuk(rs.getDate("tanggal_masuk")); asset.setKondisi(AssetCondition.getInstance(rs.getString("kondisi"))); asset.setPemilik(rs.getString("pemilik")); asset.setVendor(getVendorAset(rs.getInt("id_vendor"))); asset.setHarga(rs.getString("harga")); asset.setPublicAsset(rs.getBoolean("is_public")); assets.add(asset); } return assets; }
private Asset _getAset(int idAset) throws SQLException { String query = "SELECT * FROM " + ASSET_TABLE + " WHERE id = " + idAset; ResultSet rs = executeQuery(query); Asset asset = null; if (rs.next()) { asset = new Asset(); asset.setId(rs.getInt("id")); asset.setNama(rs.getString("nama")); asset.setKategori(rs.getString("kategori")); asset.setKategori(rs.getString("jenis")); asset.setTanggalMasuk(rs.getDate("tanggal_masuk")); asset.setKondisi(AssetCondition.getInstance(rs.getString("kondisi"))); asset.setPemilik(rs.getString("pemilik")); asset.setVendor(getVendorAset(rs.getInt("id_vendor"))); asset.setHarga(rs.getString("harga")); asset.setPublicAsset(rs.getBoolean("is_public")); } return asset; }
@WebMethod public List<Asset> getAsetByJenis(String jenis) throws SQLException { String query = "SELECT * FROM " + ASSET_TABLE + " WHERE jenis= '" + jenis + "'"; ResultSet rs = executeQuery(query); List<Asset> assets = null; while (rs.next()) { if (rs.isFirst()) assets = new ArrayList<Asset>(); Asset asset = new Asset(); asset.setId(rs.getInt("id")); asset.setNama(rs.getString("nama")); asset.setKategori(rs.getString("kategori")); asset.setKategori(rs.getString("jenis")); asset.setTanggalMasuk(rs.getDate("tanggal_masuk")); asset.setKondisi(AssetCondition.getInstance(rs.getString("kondisi"))); asset.setPemilik(rs.getString("pemilik")); asset.setVendor(getVendorAset(rs.getInt("id_vendor"))); asset.setHarga(rs.getString("harga")); asset.setPublicAsset(rs.getBoolean("is_public")); assets.add(asset); } return assets; }