Changeset 3238
- Timestamp:
- 08/05/13 15:07:00 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3237 r3238 20 20 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier; 21 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 import eu.dasish.annotation.schema.CachedRepresentations;23 22 import java.util.List; 24 23 … … 82 81 public int purge(Number internalID); 83 82 83 /** 84 * 85 * @return the list of all the internal id-s of the cached representations. 86 */ 87 public List<Number> cachedRepresentationIDs(); 88 89 /** 90 * removes all the cahed representations which are not referred from the versions_cached_representations table 91 * @return the number of affected rows 92 */ 93 public int purgeAll(); 84 94 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
r3237 r3238 188 188 } 189 189 }; 190 191 ////////////////////////////////////////////////////////////////////////////////////////////// 192 @Override 193 public List<Number> cachedRepresentationIDs(){ 194 String sqlCheck = "SELECT "+cached_representation_id+" FROM "+cachedRepresentationTableName; 195 List<Number> result= getSimpleJdbcTemplate().query(sqlCheck, cachedRepresentationRunnerRowMapper); 196 return result; 197 } 198 199 private final RowMapper<Number> cachedRepresentationRunnerRowMapper = new RowMapper<Number>() { 200 @Override 201 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 202 Number result = rs.getInt(cached_representation_id); 203 return result; 204 } 205 }; 206 207 208 @Override 209 public int purgeAll(){ 210 List<Number> ids = cachedRepresentationIDs(); 211 int countRemoved = 0; 212 for (Number id: ids){ 213 countRemoved = countRemoved + purge(id); 214 } 215 return countRemoved; 216 } 190 217 191 218 ////////// Helpers /////////////////// -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3237 r3238 155 155 /** 156 156 * Test of purge, of class JdbcCachedRepresentationDao. 157 * public CachedRepresentationInfo addCachedRepresentationInfo(CachedRepresentationInfo cached);157 * public int purge(Number internalID) 158 158 */ 159 159 @Test 160 160 public void testPurge() { 161 System.out.println(" purge");161 System.out.println("test purge"); 162 162 int result = jdbcCachedRepresentationDao.purge(6); 163 163 assertEquals(1, result); 164 164 } 165 165 166 /** 167 * test public List<Number> cachedRepresentationIDs() 168 * public List<Number> cachedRepresentationIDs() 169 */ 170 @Test 171 public void testCachedRepresentationIDs() { 172 System.out.println(" test cachedRepresentationIDs"); 173 List<Number> result = jdbcCachedRepresentationDao.cachedRepresentationIDs(); 174 assertEquals(6, result.size()); 175 assertEquals(1, result.get(0)); 176 assertEquals(2, result.get(1)); 177 assertEquals(3, result.get(2)); 178 assertEquals(4, result.get(3)); 179 assertEquals(5, result.get(4)); 180 assertEquals(6, result.get(5)); 181 } 182 183 /** 184 * Test of purgeAll, of class JdbcCachedRepresentationDao. 185 * public int purgeAll() 186 */ 187 @Test 188 public void testPurgeAll() { 189 System.out.println("test purge All"); 190 int result = jdbcCachedRepresentationDao.purgeAll(); 191 assertEquals(1, result); 192 } 166 193 }
Note: See TracChangeset
for help on using the changeset viewer.