Changeset 3146
- Timestamp:
- 07/17/13 10:02:15 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 2 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r3142 r3146 32 32 33 33 34 public interface AnnotationDao {34 public interface AnnotationDao extends ResourceDao{ 35 35 36 36 // Returns the list of annotation Id-s for the notebook id. … … 41 41 42 42 // Returns the list of annotation info-s for the notebook id. 43 List<AnnotationInfo> getAnnotationInfosOfNotebook(Number notebookID); 44 43 List<AnnotationInfo> getAnnotationInfosOfNotebook(Number notebookID); 45 44 46 45 // Returns the list of annotations Id-s for the notebook id. -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java
r3095 r3146 30 30 * @author Peter Withers <peter.withers@mpi.nl> 31 31 */ 32 public interface NotebookDao {32 public interface NotebookDao extends ResourceDao { 33 33 34 34 // Returns a list of notebook-info for the notebooks accessible to the current user. -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r3144 r3146 40 40 41 41 42 public class JdbcAnnotationDao extends SimpleJdbcDaoSupportimplements AnnotationDao {42 public class JdbcAnnotationDao extends JdbcResourceDao implements AnnotationDao { 43 43 44 44 public JdbcAnnotationDao(DataSource dataSource) { … … 46 46 } 47 47 48 //////////////////////////////////////////49 /**50 *51 * @param notebookID52 * @return false if notebookID == null or the notebook with notebookID is not in the DB;53 * @return true if the notebook with notebookID in the DB54 */55 public boolean isNotebookInTheDataBase(Number notebookID){56 57 if (notebookID == null) {58 return false;59 }60 String sql = "SELECT notebook.notebook_id FROM notebook where notebook_id = ?";61 List<Number> result=getSimpleJdbcTemplate().query(sql, isNotebookInTheDataBaseRowMapper, notebookID.toString());62 if (result == null) {63 return false;64 }65 if (result.isEmpty()) {66 return false;67 }68 return true;69 }70 71 private final RowMapper<Number> isNotebookInTheDataBaseRowMapper = new RowMapper<Number>() {72 @Override73 public Integer mapRow(ResultSet rs, int rowNumber) throws SQLException {74 Integer notebookId = rs.getInt("notebook_id");75 return notebookId;76 }77 };78 48 79 49 //////////////////////////////////////////////////////////////////////// -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java
r3105 r3146 46 46 * @author Peter Withers <peter.withers@mpi.nl> 47 47 */ 48 public class JdbcNotebookDao extends SimpleJdbcDaoSupportimplements NotebookDao {48 public class JdbcNotebookDao extends JdbcResourceDao implements NotebookDao { 49 49 50 50 @Autowired -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r3145 r3146 48 48 @ContextConfiguration({"/spring-test-config/dataSource.xml", "/spring-config/annotationDao.xml"}) 49 49 50 public class JdbcAnnotationDaoTest extends JdbcResourceDaoTest Basic{50 public class JdbcAnnotationDaoTest extends JdbcResourceDaoTest{ 51 51 52 52 @Autowired 53 53 JdbcAnnotationDao jdbcAnnotationDao; 54 54 55 @Test 56 public void testIsNotebookInTheDataBase(){ 57 super.testIsNotebookInTheDataBase(jdbcAnnotationDao); 58 } 55 59 56 57 /**58 * Test of getAnnotationIDs method, of class JdbcAnnotationDao.59 * boolean isNotebookInTheDataBase(Number notebookID)60 */61 @Test62 public void testIsNotebookInTheDataBase() {63 System.out.println("isNotebookInTheDataBase");64 65 final boolean testOne = jdbcAnnotationDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_1_INT);66 assertEquals(true, testOne);67 68 final boolean testTwo = jdbcAnnotationDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_2_INT);69 assertEquals(true, testTwo);70 71 final boolean testThree = jdbcAnnotationDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_3_INT);72 assertEquals(true, testThree);73 74 final boolean testFour = jdbcAnnotationDao.isNotebookInTheDataBase(TestBackendConstants._TEST_ANNOT_4_INT_NOT_IN_THE_DB);75 assertEquals(false, testFour);76 77 final boolean testFive = jdbcAnnotationDao.isNotebookInTheDataBase(null);78 assertEquals(false, testFive);79 }80 81 60 /** 82 61 * Test of getAnnotationIDs method, of class JdbcAnnotationDao. -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDaoTest.java
r3145 r3146 46 46 @RunWith(SpringJUnit4ClassRunner.class) 47 47 @ContextConfiguration({"/spring-test-config/mockery.xml", "/spring-test-config/mockAnnotationDao.xml", "/spring-test-config/dataSource.xml", "/spring-config/notebookDao.xml"}) 48 public class JdbcNotebookDaoTest extends JdbcResourceDaoTest Basic{48 public class JdbcNotebookDaoTest extends JdbcResourceDaoTest{ 49 49 50 50 @Autowired … … 55 55 private Mockery mockery; 56 56 57 @Test 58 public void testIsNotebookInTheDataBase(){ 59 super.testIsNotebookInTheDataBase(jdbcNotebookDao); 60 } 61 57 62 58 63 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDaoTest.java
r3145 r3146 18 18 package eu.dasish.annotation.backend.dao.impl; 19 19 20 import eu.dasish.annotation.backend.TestBackendConstants; 20 21 import java.io.File; 21 22 import java.io.FileNotFoundException; … … 25 26 import org.junit.After; 26 27 import org.junit.Before; 27 import org.junit.runner.RunWith;28 28 import org.springframework.beans.factory.annotation.Autowired; 29 29 import org.springframework.dao.DataAccessException; 30 30 import org.springframework.jdbc.core.JdbcTemplate; 31 import org.springframework.test.context.ContextConfiguration; 32 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 33 31 import static org.junit.Assert.assertEquals; 34 32 /** 35 33 * … … 37 35 */ 38 36 39 public class JdbcResourceDaoTestBasic { 37 public class JdbcResourceDaoTest { 38 40 39 @Autowired 41 40 private JdbcTemplate jdbcTemplate; 42 41 43 42 private String getNormalisedSql() throws FileNotFoundException, URISyntaxException { … … 82 81 public void tearDown() { 83 82 } 83 84 85 /** 86 * Test-helper of isNotebookInTheDataBase method, of class JdbcResourceDao. 87 * boolean isNotebookInTheDataBase(Number notebookID) 88 */ 89 protected <T extends JdbcResourceDao> void testIsNotebookInTheDataBase(T jdbcResourceDao) { 90 System.out.println("isNotebookInTheDataBase"); 91 92 final boolean testOne = jdbcResourceDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_1_INT); 93 assertEquals(true, testOne); 94 95 final boolean testTwo = jdbcResourceDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_2_INT); 96 assertEquals(true, testTwo); 97 98 final boolean testThree = jdbcResourceDao.isNotebookInTheDataBase(TestBackendConstants._TEST_NOTEBOOK_3_INT); 99 assertEquals(true, testThree); 100 101 final boolean testFour = jdbcResourceDao.isNotebookInTheDataBase(TestBackendConstants._TEST_ANNOT_4_INT_NOT_IN_THE_DB); 102 assertEquals(false, testFour); 103 104 final boolean testFive = jdbcResourceDao.isNotebookInTheDataBase(null); 105 assertEquals(false, testFive); 106 } 107 84 108 85 109 }
Note: See TracChangeset
for help on using the changeset viewer.