Skip to content
Snippets Groups Projects
Commit d1877b83 authored by GAYDAMAKHA MIKHAIL's avatar GAYDAMAKHA MIKHAIL
Browse files

:coffin: remove getCategories method from IDatabase

parent e747375c
Branches
2 merge requests!25Develop,!19:recycle: Use dependency injection for categories controller
......@@ -4,7 +4,6 @@
*/
package fr.unistra.sil.erp.back.db;
import fr.unistra.sil.erp.back.model.Category;
import fr.unistra.sil.erp.back.model.Item;
import fr.unistra.sil.erp.back.model.RegistryEntry;
import fr.unistra.sil.erp.back.model.Stock;
......@@ -14,7 +13,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -48,13 +46,7 @@ public class DatabaseSQLiteImpl implements IDatabase {
*/
private static final String SQL_GETITEMSFROMCATEGORY = SQL_GETALLITEMS +
" WHERE category = ?";
/**
* Query used to retrieve all categories stored in the database.
*/
private static final String SQL_GETCATEGORIES =
"SELECT id, name FROM categories";
/**
* Query used to fetch all stocks stored in the database.
*/
......@@ -200,32 +192,6 @@ public class DatabaseSQLiteImpl implements IDatabase {
return res;
}
/**
* Retrieves all categories from the database.
* @return the list of categories.
*/
@Override
public List<Category> getCategories() {
ResultSet rs = this.query(SQL_GETCATEGORIES);
if(rs == null)
return null;
List<Category> res = new ArrayList<>();
try {
while(rs.next())
{
Category c = new Category(rs.getInt("id"), rs.getString("name"));
res.add(c);
}
} catch (SQLException ex) {
Logger.getLogger(DatabaseSQLiteImpl.class.getName()).log(
Level.SEVERE, "Failed to fetch results.", ex);
return null;
}
return res;
}
/**
* Retrieves all stock entries from the database.
* @return the list of stock entries.
......
......@@ -32,14 +32,7 @@ public interface IDatabase {
* @return the list of items, or null if an error occurred.
*/
public List<Item> getItemsFromCategory(int category);
/**
* Returns the list of all categories.
*
* @return the list of categories, or null if an error occurred.
*/
public List<Category> getCategories();
/**
* Returns the list of all stocks.
*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment