Remove unneeded code from AbstractDhRepo and refactor

This commit is contained in:
James Seibel
2023-10-05 19:07:48 -05:00
parent f0238dc4ea
commit bbaea5e614
4 changed files with 5 additions and 19 deletions
@@ -113,14 +113,14 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
public void delete(TDTO dto) { this.deleteByPrimaryKey(dto.getPrimaryKeyString()); }
public void deleteByPrimaryKey(String primaryKey)
{
String whereEqualStatement = this.createWherePrimaryKeyStatement(primaryKey);
String whereEqualStatement = this.createWherePrimaryKeySql(primaryKey);
this.queryDictionaryFirst("DELETE FROM "+this.getTableName()+" WHERE "+whereEqualStatement);
}
public boolean exists(TDTO dto) { return this.existsWithPrimaryKey(dto.getPrimaryKeyString()); }
public boolean existsWithPrimaryKey(String primaryKey)
{
String whereEqualStatement = this.createWherePrimaryKeyStatement(primaryKey);
String whereEqualStatement = this.createWherePrimaryKeySql(primaryKey);
Map<String, Object> result = this.queryDictionaryFirst("SELECT EXISTS(SELECT 1 FROM "+this.getTableName()+" WHERE "+whereEqualStatement+") as 'existingCount';");
return result != null && (int)result.get("existingCount") != 0;
}
@@ -221,9 +221,9 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
//================//
/** Example: <code> Id = '0' </code> */
public String createWherePrimaryKeyStatement(TDTO dto) { return this.createWherePrimaryKeyStatement(dto.getPrimaryKeyString()); }
public String createWherePrimaryKeySql(TDTO dto) { return this.createWherePrimaryKeySql(dto.getPrimaryKeyString()); }
/** Example: <code> Id = '0' </code> */
public String createWherePrimaryKeyStatement(String primaryKeyValue) { return this.getPrimaryKeyName()+" = '"+primaryKeyValue+"'"; }
public String createWherePrimaryKeySql(String primaryKeyValue) { return this.getPrimaryKeyName()+" = '"+primaryKeyValue+"'"; }
public static List<Map<String, Object>> convertResultSetToDictionaryList(ResultSet resultSet) throws SQLException
{
@@ -271,6 +271,4 @@ public abstract class AbstractDhRepo<TDTO extends IBaseDTO>
public abstract String createInsertSql(TDTO dto);
public abstract String createUpdateSql(TDTO dto);
public abstract String createDeleteSql(TDTO dto);
}
@@ -97,11 +97,5 @@ public abstract class AbstractMetaDataRepo extends AbstractDhRepo<MetaDataDto>
"WHERE DhSectionPos = '"+pos+"'";
}
@Override
public String createDeleteSql(MetaDataDto dto)
{
String pos = dto.pos.serialize();
return "DELETE FROM "+this.getTableName()+" WHERE DhSectionPos = '"+pos+"'";
}
}
@@ -85,10 +85,4 @@ public class TestDataRepo extends AbstractDhRepo<TestDto>
"WHERE Id = "+id;
}
@Override
public String createDeleteSql(TestDto dto)
{
return "DELETE FROM "+this.getTableName()+" WHERE Id = '"+dto.id+"'";
}
}
@@ -40,7 +40,7 @@ public class DhRepoSqliteTest
@Test
public void testFileSqlite()
{
String dbFileName = "test_fullData.sqlite";
String dbFileName = "test.sqlite";
File dbFile = new File(dbFileName);