Changeset 3222
- Timestamp:
- 08/02/13 14:30:50 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3221 r3222 19 19 20 20 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier; 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 import eu.dasish.annotation.schema.CachedRepresentations; 23 import java.util.List; 21 24 22 25 /** … … 26 29 public interface CachedRepresentationDao { 27 30 31 /** 32 * 33 * @param internalID 34 * @return extrnalID identifier of the resource with internalID 35 */ 28 36 public CachedRepresentationIdentifier getExternalId(Number internalID); 37 38 /** 39 * 40 * @param externalID 41 * @return internal identifier of the resource with externalID 42 */ 43 public Number getExternalId(CachedRepresentationIdentifier externalID); 44 45 /** 46 * 47 * @param internalID 48 * @return the object which fields have the corresponding column values of the row internalID 49 */ 50 public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID); 51 52 /** 53 * 54 * @param versionID 55 * @return List of cached_representation_id-s of all the cached representations of the version with versionID 56 */ 57 public List<Number> retrieveCachedRepresentationList(Number versionID); 58 59 /** 60 * 61 * @param versionID 62 * @return List of cached_representation_id-s of all the cached representations of the version with versionID 63 */ 64 public CachedRepresentations retrieveCachedRepresentations(Number versionID); 65 66 29 67 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java
r3221 r3222 19 19 20 20 import eu.dasish.annotation.backend.identifiers.VersionIdentifier; 21 import eu.dasish.annotation.schema.Version; 21 22 22 23 /** … … 26 27 public interface VersionDao { 27 28 29 /** 30 * 31 * @param internalID 32 * @return extrnalID identifier of the resource with internalID 33 */ 34 28 35 public VersionIdentifier getExternalId(Number internalID); 36 37 /** 38 * 39 * @param externalID 40 * @return internal identifier of the resource with externalID 41 */ 42 public Number getExternalId(VersionIdentifier externalID); 43 44 45 /** 46 * 47 * @param internalID 48 * @return the object which fields have the corresponding column values of the row internalID 49 */ 50 public Version getVersion(Number internalID); 51 29 52 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
r3221 r3222 20 20 import eu.dasish.annotation.backend.dao.CachedRepresentationDao; 21 21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier; 22 import eu.dasish.annotation.schema. Annotation;23 import eu.dasish.annotation.schema. NewOrExistingSourceInfos;22 import eu.dasish.annotation.schema.CachedRepresentationInfo; 23 import eu.dasish.annotation.schema.CachedRepresentations; 24 24 import eu.dasish.annotation.schema.ResourceREF; 25 import eu.dasish.annotation.schema.SourceInfo;26 25 import java.sql.ResultSet; 27 26 import java.sql.SQLException; 27 import java.util.ArrayList; 28 28 import java.util.List; 29 29 import javax.sql.DataSource; … … 40 40 } 41 41 42 ////////////////////////////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////////////////////////// 43 @Override 43 44 public CachedRepresentationIdentifier getExternalId(Number internalID){ 44 45 if (internalID == null) { … … 65 66 } 66 67 }; 68 69 ////////////////////////////////////////////////////////////////////////////////////////////////////// 70 @Override 71 public Number getExternalId(CachedRepresentationIdentifier externalID){ 72 if (externalID == null) { 73 return null; 74 } 75 String sql = "SELECT "+cached_representation_id+" FROM "+cachedRepresentationTableName+" WHERE "+external_id +"= ?"; 76 List<Number> sqlResult= getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalID); 77 78 if (sqlResult == null) { 79 return null; 80 } 81 if (sqlResult.isEmpty()) { 82 return null; 83 } 84 85 Number result = sqlResult.get(0); 86 return result; 87 } 88 89 private final RowMapper<Number> internalIDRowMapper = new RowMapper<Number>() { 90 @Override 91 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 92 return(rs.getInt(cached_representation_id)); 93 } 94 }; 95 96 /////////////////////////////////////////////////////////////// 97 @Override 98 public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID){ 99 100 String sql = "SELECT "+cachedRepresentationStar+" FROM "+cachedRepresentationTableName+" WHERE "+cached_representation_id +"= ?"; 101 List<CachedRepresentationInfo> result= getSimpleJdbcTemplate().query(sql, cachedRepresentationRowMapper, internalID); 102 103 if (result == null) { 104 return null; 105 } 106 if (result.isEmpty()) { 107 return null; 108 } 109 return result.get(0); 110 } 111 112 private final RowMapper<CachedRepresentationInfo> cachedRepresentationRowMapper = new RowMapper<CachedRepresentationInfo>() { 113 @Override 114 public CachedRepresentationInfo mapRow(ResultSet rs, int rowNumber) throws SQLException { 115 CachedRepresentationInfo result = new CachedRepresentationInfo(); 116 //external_id, mime_type, tool, type_, where_is_the_file 117 result.setMimeType(rs.getString(mime_type)); 118 result.setRef(rs.getString(external_id)); 119 result.setTool(rs.getString(tool)); 120 result.setType(rs.getString(type_)); 121 // TODO add where is the file when the schem is updated!!!!s 122 return result; 123 } 124 }; 125 126 127 //////////////////////////////////////////////////////////////////////////// 128 @Override 129 public List<Number> retrieveCachedRepresentationList(Number versionID){ 130 String sql = "SELECT "+cached_representation_id+" FROM "+versionsCachedRepresentationsTableName+" WHERE "+version_id +"= ?"; 131 List<Number> result= getSimpleJdbcTemplate().query(sql, internalIDRowMapper, versionID); 132 133 if (result == null) { 134 return null; 135 } 136 if (result.isEmpty()) { 137 return null; 138 } 139 return result; 140 }; 141 142 143 ///////////////////////////////////////////////////// 144 145 @Override 146 public CachedRepresentations retrieveCachedRepresentations(Number versionID){ 147 CachedRepresentations result = new CachedRepresentations(); 148 149 List<Number> cachedRepresenationIDs = retrieveCachedRepresentationList(versionID); 150 List<ResourceREF> cachedRepresenationIdentifierList = new ArrayList<ResourceREF>(); 151 152 for (Number cachedRepresentationID : cachedRepresenationIDs){ 153 ResourceREF resourceREF = new ResourceREF(); 154 resourceREF.setRef(getExternalId(cachedRepresentationID).toString()); 155 cachedRepresenationIdentifierList.add(resourceREF); 156 } 157 158 result.getCachedRepresentation().addAll(cachedRepresenationIdentifierList); 159 return result; 160 }; 161 67 162 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r3221 r3222 89 89 final static protected String principalExternal_id = principalTableName+"."+external_id; 90 90 91 92 final static protected String cachedRepresentationStar = cachedRepresentationTableName+".*"; 93 94 final static protected String versionStar = versionTableName+".*"; 95 91 96 ////////////////////////////////////////// 92 97 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java
r3221 r3222 19 19 20 20 import eu.dasish.annotation.backend.dao.VersionDao; 21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;22 21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier; 22 import eu.dasish.annotation.schema.CachedRepresentationInfo; 23 import eu.dasish.annotation.schema.Version; 23 24 import java.sql.ResultSet; 24 25 import java.sql.SQLException; … … 62 63 return(rs.getString(external_id)); 63 64 } 64 }; 65 }; 66 67 ////////////////////////////////////////////////////////////////////////////////////////////////////// 68 @Override 69 public Number getExternalId(VersionIdentifier externalID){ 70 if (externalID == null) { 71 return null; 72 } 73 String sql = "SELECT "+version_id+" FROM "+versionTableName+" WHERE "+external_id +"= ?"; 74 List<Number> sqlResult= getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalID); 75 76 if (sqlResult == null) { 77 return null; 78 } 79 if (sqlResult.isEmpty()) { 80 return null; 81 } 82 83 Number result = sqlResult.get(0); 84 return result; 85 } 86 87 private final RowMapper<Number> internalIDRowMapper = new RowMapper<Number>() { 88 @Override 89 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 90 return(rs.getInt(version_id)); 91 } 92 }; 93 94 95 /////////////////////////////////////////////////////////////// 96 @Override 97 public Version getVersion(Number internalID){ 98 99 String sql = "SELECT "+versionStar+" FROM "+versionTableName+" WHERE "+version_id +"= ?"; 100 List<Version> result= getSimpleJdbcTemplate().query(sql, versionRowMapper, internalID); 101 102 if (result == null) { 103 return null; 104 } 105 if (result.isEmpty()) { 106 return null; 107 } 108 return result.get(0); 109 } 110 111 private final RowMapper<Version> versionRowMapper = new RowMapper<Version>() { 112 @Override 113 public Version mapRow(ResultSet rs, int rowNumber) throws SQLException { 114 Version result = new Version(); 115 //external_id, mime_type, tool, type_, where_is_the_file 116 // result.setCachedRepresentations((rs.get) 117 // result.setRef(rs.getString(external_id)); 118 // result.setTool(rs.getString(tool)); 119 // result.setType(rs.getString(type_)); 120 // TODO add where is the file when the schem is updated!!!!s 121 return result; 122 } 123 }; 124 65 125 }
Note: See TracChangeset
for help on using the changeset viewer.