La palaba get es mas bonita que find

This commit is contained in:
Daniel Cortes
2019-03-07 16:16:01 -03:00
parent b6021c82d7
commit 9c0765b81f
8 changed files with 100 additions and 100 deletions

View File

@@ -49,7 +49,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
}
@Override
public List<Documentos> findAll() {
public List<Documentos> getAll() {
List<Documentos> documentosList = new ArrayList<>();
String query = "select * from documentos";
try (Connection conn = connectionHolder.getConnection()) {
@@ -80,7 +80,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
}
@Override
public Optional<Documentos> findById(int id) {
public Optional<Documentos> getById(int id) {
Documentos documentos = null;
try (Connection conn = connectionHolder.getConnection()) {
@@ -111,7 +111,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
}
@Override
public Optional<Documentos> findByCaja(Caja caja) {
public Optional<Documentos> getByCaja(Caja caja) {
Documentos documentos = null;
if (Caja.EMPTY == caja) {
@@ -141,6 +141,29 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
return Optional.ofNullable(documentos);
}
@Override
public int getTotalDocumentos(Caja caja) {
int total = 0;
if (Caja.EMPTY == caja) {
return total;
}
String query = "select cheques + tarjetas + retiros from documentos where caja_id = ?";
try (Connection conn = connectionHolder.getConnection()) {
try (PreparedStatement ps = conn.prepareStatement(query)) {
ps.setInt(1, caja.getId());
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
total = rs.getInt(1);
}
}
}
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
}
return total;
}
@Override
public void insertDocumentos(Documentos documentos) {
String query = "insert into documentos (cheques, tarjetas, retiros, caja_id) values (?,?,?,?)";
@@ -213,26 +236,4 @@ public class SQLiteDocumentosDAO implements DocumentosDAO {
}
}
@Override
public int getTotalDocumentos(Caja caja) {
int total = 0;
if (Caja.EMPTY == caja) {
return total;
}
String query = "select cheques + tarjetas + retiros from documentos where caja_id = ?";
try (Connection conn = connectionHolder.getConnection()) {
try (PreparedStatement ps = conn.prepareStatement(query)) {
ps.setInt(1, caja.getId());
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
total = rs.getInt(1);
}
}
}
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
}
return total;
}
}