Changeset 3237
- Timestamp:
- 08/05/13 14:41:03 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3236 r3237 62 62 * @return the amount of rows affected by removing from the DB the cached representation with the id "intenalID" 63 63 * should be "1" (or 0 with a non-existing id on the input) 64 * as a obligadory side-effect: deletes all the rows in the table versions_cached_representations containing "internalId" as a cached_representaton_ID 64 65 */ 65 66 public int deleteCachedRepresentationInfo(Number internalID); … … 71 72 */ 72 73 public CachedRepresentationInfo addCachedRepresentationInfo(CachedRepresentationInfo cached); 74 75 76 /** 77 * 78 * @param internalID 79 * removes the version with internalId from the DB is there is no reference to to it n the table versions_cached_representations 80 * @return the amount of removed rows 81 */ 82 public int purge(Number internalID); 73 83 74 84 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java
r3222 r3237 20 20 import eu.dasish.annotation.backend.identifiers.VersionIdentifier; 21 21 import eu.dasish.annotation.schema.Version; 22 import java.util.List; 22 23 23 24 /** … … 40 41 * @return internal identifier of the resource with externalID 41 42 */ 42 public Number get ExternalId(VersionIdentifier externalID);43 public Number getInternalId(VersionIdentifier externalID); 43 44 44 45 … … 46 47 * 47 48 * @param internalID 48 * @return the object which fields have the corresponding column values of the row internalID 49 * @return the insance of Version.class where the veriosn internal Id is "internalID" 50 * 49 51 */ 50 52 public Version getVersion(Number internalID); 51 53 54 /** 55 * 56 * @param sourceID 57 * @return the list of the internal version id-s for the target source with the internal Id "sourceID" 58 */ 59 public List<Number> retrieveVersionList(Number sourceID); 60 61 /** 62 * 63 * @param versionID 64 * removes the version with the internal id "versionID". Obligatory side effect: removes the corresponding rows in the tables 65 * "versions_cached_representations" and "sources_versions" 66 * @return the number of affected rows in "version" table, which normally must be 1 (or 0 if there is no version with this inut "versionID") 67 */ 68 public int deleteVersion(Number versionID); 69 70 /** 71 * 72 * @param version 73 * @return the copy of "version" with the new external Id set in "version" text field (for now) 74 * 75 */ 76 public Version addVersion(Version version); 77 78 /** 79 * Removes the all the rows in the internal ID "internalID" if no references to this versions from the table sources. 80 * @return the amount of removed rows 81 */ 82 public int purgeVersions(Number internalID); 52 83 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
r3236 r3237 167 167 } 168 168 169 ////////////////////////////////////////////////////////////////////////////////////////////// 170 @Override 171 public int purge(Number internalID){ 172 String sqlCheck = "SELECT "+cached_representation_id+" FROM "+versionsCachedRepresentationsTableName+" WHERE "+cached_representation_id +"= ?"; 173 List<Number> result= getSimpleJdbcTemplate().query(sqlCheck, cachedRepresentationCheckerRowMapper, internalID); 174 if (result.size() < 1) { 175 String sql ="DELETE FROM " + cachedRepresentationTableName + " where "+cached_representation_id + " = ?"; 176 return getSimpleJdbcTemplate().update(sql, internalID); 177 } 178 else { 179 return 0; 180 } 181 } 182 183 private final RowMapper<Number> cachedRepresentationCheckerRowMapper = new RowMapper<Number>() { 184 @Override 185 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 186 Number result = rs.getInt(cached_representation_id); 187 return result; 188 } 189 }; 190 169 191 ////////// Helpers /////////////////// 170 192 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java
r3236 r3237 20 20 import eu.dasish.annotation.backend.dao.VersionDao; 21 21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier; 22 import eu.dasish.annotation.schema.CachedRepresentationInfo;23 22 import eu.dasish.annotation.schema.Version; 24 23 import java.sql.ResultSet; … … 67 66 ////////////////////////////////////////////////////////////////////////////////////////////////////// 68 67 @Override 69 public Number get ExternalId(VersionIdentifier externalID){68 public Number getInternalId(VersionIdentifier externalID){ 70 69 if (externalID == null) { 71 70 return null; … … 121 120 }; 122 121 122 123 124 ///////////////////////////////////////// 125 126 @Override 127 public List<Number> retrieveVersionList(Number sourceID){ 128 return null; 129 } 130 131 ///////////////////////////////////////// 132 @Override 133 public int deleteVersion(Number versionID){ 134 return -1; 135 } 136 137 @Override 138 public Version addVersion(Version version){ 139 return null; 140 } 141 142 @Override 143 public int purgeVersions(Number internalID){ 144 return -1; 145 } 123 146 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3236 r3237 66 66 67 67 /** 68 * Test of get ExternalId method, of class JdbcCachedRepresentationDao.69 * public Number get ExternalId(CachedRepresentationIdentifier externalID);68 * Test of getInternalId method, of class JdbcCachedRepresentationDao. 69 * public Number getInternalId(CachedRepresentationIdentifier externalID); 70 70 */ 71 71 @Test … … 138 138 * public CachedRepresentationInfo addCachedRepresentationInfo(CachedRepresentationInfo cached); 139 139 */ 140 @Test 141 @Ignore 140 @Test 142 141 public void testAddCachedRepresentationInfo() { 143 142 System.out.println("addCachedRepresentationInfo"); … … 153 152 assertEquals("text", result.getType()); 154 153 } 154 155 /** 156 * Test of purge, of class JdbcCachedRepresentationDao. 157 * public CachedRepresentationInfo addCachedRepresentationInfo(CachedRepresentationInfo cached); 158 */ 159 @Test 160 public void testPurge() { 161 System.out.println(" purge"); 162 int result = jdbcCachedRepresentationDao.purge(6); 163 assertEquals(1, result); 164 } 165 155 166 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql
r3236 r3237 124 124 INSERT INTO cached_representation_info (external_id, mime_type, tool, type_, where_is_the_file) VALUES ('00000000-0000-0000-0000-000000000054', 'text/html', 'oxygen', 'text', 'corpus1'); --4 125 125 INSERT INTO cached_representation_info (external_id, mime_type, tool, type_, where_is_the_file) VALUES ('00000000-0000-0000-0000-000000000055', 'image/jpg', 'photomaster', 'image', 'TLAscratch'); --5 126 INSERT INTO cached_representation_info (external_id, mime_type, tool, type_, where_is_the_file) VALUES ('00000000-0000-0000-0000-000000000056', 'text/plain', 'some tool', 'text', 'TLAscratch'); --6 126 127 127 128 --------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.