Changeset 3455
- Timestamp:
- 08/22/13 12:17:19 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 1 deleted
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/AnnotationDao.java
r3413 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;21 20 import eu.dasish.annotation.schema.Annotation; 22 21 import eu.dasish.annotation.schema.AnnotationInfo; … … 39 38 public interface AnnotationDao extends ResourceDao{ 40 39 41 /** 42 * 43 * @param internalId 44 * @return the external identifier for the annotation with internalId 45 */ 46 public AnnotationIdentifier getExternalID(Number internalId); 40 ////////////// GETTERS ////////////////////////// 41 47 42 48 43 … … 51 46 * @param annotationID 52 47 * @return the Annotation object with empty list of sources 53 * constructing a complete Annotation object from the result and "retrieveSourceIDs" is done in "DaoDispatchter"48 * constructing a complete Annotation object from the result and "retrieveSourceIDs" is done in "DaoDispatchter" 54 49 * 55 50 */ 56 51 public Annotation getAnnotationWithoutSources(Number annotationID) throws SQLException; 57 52 53 54 /** 55 * 56 * @param annotationIDs optional 57 * @param text optional 58 * @param access optional 59 * @param namespace optional TODO: do not know what to do with it 60 * @param ownerID optional 61 * @param after optional 62 * @param before optional 63 * @return the sub-list of internal annotation identifiers from the list "internalIDs" for annotations 64 * -- bodies of which contain the "text", 65 * -- to which inlogged user has "access", 66 * -- owned by "owner", 67 * -- added to the database between "before" and "after" time-dates. 68 * 69 * 70 * The first step for GET api/annotations?<filters> 71 */ 72 public List<Number> getFilteredAnnotationIDs(List<Number> annotationIDs, String text, String access, String namespace, Number ownerID, Timestamp after, Timestamp before); 73 74 /** 75 * 76 * @param annotationIDs 77 * @return the list of annotationInfos (owner, headline, target sources, external_id) for the internal Ids from the input list 78 * used on the second step for GET api/annotations?<filters> 79 */ 80 public List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs); 81 82 83 /** 84 * 85 * @param annotationIDs 86 * @return list of resource references where an i-th reference is constructed from 87 */ 88 public List<ResourceREF> getAnnotationREFs(List<Number> annotationIDs); 89 90 /** 91 * 92 * @param sourceIDs 93 * @return the list of annotationdIDs of the annotations that are having target sources from "sourceIDs" list 94 */ 95 public List<Number> retrieveAnnotationList(List<Number> sourceIDs); 96 97 98 /** 99 * 100 * @param annotationID 101 * @return the list of the source's internal IDs of all the target sources of annotationID 102 */ 103 public List<Number> retrieveSourceIDs(Number annotationID); 104 105 106 /** 107 * 108 * @param annotationId 109 * @return retrieves all the pairs (user-permission) for "annotationId" from the table annotations_principals permissions 110 */ 111 public List<Map<Number, String>> retrievePermissions(Number annotationId); 112 113 114 115 ///////////// ADDERS ///////////////////// 116 117 public int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException; 118 119 120 /** 121 * 122 * @param annotationID 123 * @param userID 124 * @param permission 125 * @return the amount of rows added to the table annotations_principals_permissions 126 */ 127 public int addAnnotationPrincipalPermission(Number annotationID, Number userID, Permission permission) throws SQLException; 128 129 130 131 /** 132 * 133 * @param annotation added to the table with annotations 134 * @return internal Id of the added annotation 135 **/ 136 137 public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException; 138 139 140 /////// UPDATERS ////////////////// 141 142 public int updateBody(Number annotationID, String serializedNewBody); 143 144 145 //////////// DELETERS /////////////////////// 58 146 59 147 /** … … 63 151 */ 64 152 153 154 65 155 public int deleteAnnotation(Number annotationId) throws SQLException; 66 156 … … 74 164 75 165 76 /**77 *78 * @param annotation added to the table with annotations79 * @return internal Id of the added annotation80 **/81 82 public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException;83 84 85 /**86 *87 * @param link optional88 * @param text optional89 * @param access optional90 * @param namespace optional TODO: do not know what to do with it91 * @param owner optional92 * @param after optional93 * @param before optional94 * @return the list of internal annotation identifiers for annotations95 * -- referring to the "link",96 * -- bodies of which contain the "text",97 * -- to which inlogged user has "access",98 * -- owned by "owner",99 * -- added to the database between "before" and "after" time-dates.100 *101 *102 * The first step for GET api/annotations?<filters>103 */104 public List<Number> getFilteredAnnotationIDs(List<Number> annotationIDs, String text, String access, String namespace, Number ownerID, Timestamp after, Timestamp before);105 106 /**107 *108 * @param annotationIDs109 * @return the list of annotationInfos (owner, headline, target sources, external_id) for the internal Ids from the input list110 * used on the second step for GET api/annotations?<filters>111 */112 public List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs);113 114 166 115 116 public List<ResourceREF> getAnnotationREFs(List<Number> annotationIDs);117 118 /**119 *120 * @param sourceIDs121 * @return the list of annotationdIDs of the annotations that are having target sources from "sourceIDs" list122 */123 public List<Number> retrieveAnnotationList(List<Number> sourceIDs);124 125 126 // NOT TESTED127 public int updateBody(Number annotationID, String serializedNewBody);128 129 /**130 *131 * @param annotationID132 * @return the list of the source's internal IDs of all the target sources of annotationID133 */134 public List<Number> retrieveSourceIDs(Number annotationID);135 136 public int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException;137 138 167 public int deleteAnnotationPrincipalPermissions(Number annotationID) throws SQLException ; 139 168 140 /** 141 * 142 * @param annotationID 143 * @param userID 144 * @param permission 145 * @return the amount of rows added to the table annotations_principals_permissions 146 */ 147 public int addAnnotationPrincipalPermission(Number annotationID, Number userID, Permission permission) throws SQLException; 148 149 /** 150 * 151 * @param annotationId 152 * @return retrieves all the pairs (user-permission) for "annotationId" from the table annotations_principals permissions 153 */ 154 public List<Map<Number, String>> retrievePermissions(Number annotationId); 169 170 155 171 156 172 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java
r3407 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;21 20 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 21 … … 25 24 * @author olhsha 26 25 */ 27 public interface CachedRepresentationDao {26 public interface CachedRepresentationDao extends ResourceDao{ 28 27 29 /** 30 * 31 * @param internalID 32 * @return extrnalID identifier of the resource with internalID 33 */ 34 public CachedRepresentationIdentifier getExternalID(Number internalID); 35 36 37 /** 38 * 39 * @param externalID 40 * @return the internal identifier of the resource with the "externalID" 41 */ 42 public Number getInternalID(CachedRepresentationIdentifier externalID); 43 28 29 44 30 45 31 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DaoDispatcher.java
r3452 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;21 import eu.dasish.annotation.backend.identifiers.UserIdentifier;22 20 import eu.dasish.annotation.schema.Annotation; 23 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; … … 28 26 import java.util.List; 29 27 import java.util.Map; 28 import java.util.UUID; 30 29 31 30 /** … … 55 54 Annotation getAnnotation(Number annotationID) throws SQLException; 56 55 57 AnnotationIdentifiergetAnnotationExternalIdentifier(Number annotationID);56 UUID getAnnotationExternalIdentifier(Number annotationID); 58 57 59 58 ///////////// GETTERS ////////////////////////// 60 Number getAnnotationInternalIdentifier( AnnotationIdentifier annotationIdentifier);59 Number getAnnotationInternalIdentifier(UUID UUID); 61 60 62 61 //////////////////////////////////////////////////////////////////////// 63 List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UserIdentifier owner, Timestamp after, Timestamp before); 62 List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UUID 63 owner, Timestamp after, Timestamp before); 64 64 65 U serIdentifiergetUserExternalIdentifier(Number userID);65 UUID getUserExternalIdentifier(Number userID); 66 66 67 Number getUserInternalIdentifier(U serIdentifier userIdentifier);67 Number getUserInternalIdentifier(UUID UUID); 68 68 69 69 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java
r3218 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier; 21 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier; 22 import eu.dasish.annotation.backend.identifiers.UserIdentifier; 20 23 21 import eu.dasish.annotation.schema.Annotations; 24 22 import eu.dasish.annotation.schema.Notebook; … … 26 24 import eu.dasish.annotation.schema.ResourceREF; 27 25 import java.util.List; 26 import java.util.UUID; 28 27 29 28 /** … … 35 34 36 35 // Returns a list of notebook-info for the notebooks accessible to the current user. 37 List<NotebookInfo> getNotebookInfos(U serIdentifieruserID);36 List<NotebookInfo> getNotebookInfos(UUID userID); 38 37 39 38 // Returns the list of all notebooks owned by the current logged user. 40 List<Notebook> getUsersNotebooks(U serIdentifieruserID);39 List<Notebook> getUsersNotebooks(UUID userID); 41 40 42 41 // Creates a new notebook and returns the _nid_ of the created Notebook 43 NotebookIdentifier addNotebook(UserIdentifieruserID, String title);42 UUID addNotebook(UUID userID, String title); 44 43 45 44 // Delete _nid_. Annotations stay, they just lose connection to _nid_.<br> 46 45 // returns the number of records deleted 47 public int deleteNotebook( NotebookIdentifiernotebookId);46 public int deleteNotebook(UUID notebookId); 48 47 49 48 // Adds an annotation _aid_ to the list of annotations of _nid_. 50 public int addAnnotation( NotebookIdentifier notebookId, AnnotationIdentifierannotationId);49 public int addAnnotation(UUID notebookId, UUID annotationId); 51 50 52 51 // Returns the list of annotation Id-s for the notebook id. 53 List<Number> getAnnotationIDs(Number notebookID);52 public List<Number> getAnnotationIDs(Number notebookID); 54 53 55 54 /*Returns the list of annotation info-s for the notebook id. … … 57 56 58 57 // Returns the list of annotations Id-s for the notebook id. 59 List<ResourceREF> getAnnotationREFsOfNotebook(Number notebookID);58 public List<ResourceREF> getAnnotationREFsOfNotebook(Number notebookID); 60 59 61 60 // Returns the Annotations object for the notebook id. 62 Annotations getAnnotations(Number notebookID);61 public Annotations getAnnotations(Number notebookID); 63 62 64 63 /** … … 70 69 NotebookInfo getNotebookInfo(Number notebookID); 71 70 72 /** 73 * 74 * @param externalId 75 * @return the notebook's internal ID, given its extrnalId 76 */ 77 Number getNotebookID(NotebookIdentifier externalId); 71 78 72 79 73 /** … … 81 75 * @return returns the externalIds of the annotations contained in the notebookId 82 76 */ 83 List< AnnotationIdentifier> getAnnotationExternalIDs(NotebookIdentifiernotebookId);77 List<UUID> getAnnotationExternalIDs(UUID notebookId); 84 78 85 79 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ResourceDao.java
r3380 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.DasishIdentifier;20 import java.util.UUID; 21 21 22 22 /** … … 31 31 * @return internal identifier of the resource with externalID 32 32 */ 33 public <T extends DasishIdentifier> Number getInternalID(TexternalId);33 public Number getInternalID(UUID externalId); 34 34 35 35 public UUID getExternalID(Number internalId); 36 36 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/SourceDao.java
r3411 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;21 20 import eu.dasish.annotation.schema.Source; 22 21 import eu.dasish.annotation.schema.SourceInfo; … … 30 29 public interface SourceDao extends ResourceDao{ 31 30 32 /** 33 * 34 * @param internalID 35 * @return extrnalID identifier of the resource with internalID 36 */ 37 public SourceIdentifier getExternalID(Number internalID); 38 39 31 40 32 41 33 /** -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/UserDao.java
r3309 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.UserIdentifier;21 20 22 21 /** … … 27 26 28 27 29 /** 30 * 31 * @param internalId 32 * @return the external UserIdentifier of internalId; 33 */ 34 UserIdentifier getExternalID(Number internalID); 28 35 29 } 36 30 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java
r3408 r3455 18 18 package eu.dasish.annotation.backend.dao; 19 19 20 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;21 20 import eu.dasish.annotation.schema.Version; 22 21 import java.util.List; … … 26 25 * @author olhsha 27 26 */ 28 public interface VersionDao {27 public interface VersionDao extends ResourceDao{ 29 28 30 /** 31 * 32 * @param internalID 33 * @return extrnalID identifier of the resource with internalID 34 */ 35 36 public VersionIdentifier getExternalID(Number internalID); 37 38 /** 39 * 40 * @param externalID 41 * @return the internal Id of the Version with the external ID "externalID" 42 */ 43 public Number getInternalID(VersionIdentifier externalID); 44 45 29 46 30 /** 47 31 * -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DaoDispatcherImpl.java
r3452 r3455 26 26 import eu.dasish.annotation.backend.dao.UserDao; 27 27 import eu.dasish.annotation.backend.dao.VersionDao; 28 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;29 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;30 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;31 import eu.dasish.annotation.backend.identifiers.UserIdentifier;32 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;33 28 import eu.dasish.annotation.schema.Annotation; 34 29 import eu.dasish.annotation.schema.CachedRepresentationInfo; … … 45 40 import java.util.List; 46 41 import java.util.Map; 42 import java.util.UUID; 47 43 import org.springframework.beans.factory.annotation.Autowired; 48 44 … … 70 66 71 67 @Override 72 public Number getAnnotationInternalIdentifier( AnnotationIdentifier annotationIdentifier) {73 return annotationDao.getInternalID( annotationIdentifier);74 } 75 76 @Override 77 public AnnotationIdentifiergetAnnotationExternalIdentifier(Number annotationID) {68 public Number getAnnotationInternalIdentifier(UUID UUID) { 69 return annotationDao.getInternalID(UUID); 70 } 71 72 @Override 73 public UUID getAnnotationExternalIdentifier(Number annotationID) { 78 74 return annotationDao.getExternalID(annotationID); 79 75 } 80 76 81 77 @Override 82 public Number getUserInternalIdentifier(U serIdentifier userIdentifier) {83 return userDao.getInternalID( userIdentifier);84 } 85 86 @Override 87 public U serIdentifiergetUserExternalIdentifier(Number userID) {78 public Number getUserInternalIdentifier(UUID UUID) { 79 return userDao.getInternalID(UUID); 80 } 81 82 @Override 83 public UUID getUserExternalIdentifier(Number userID) { 88 84 return userDao.getExternalID(userID); 89 85 } … … 110 106 //////////////////////////////////////////////////////////////////////// 111 107 @Override 112 public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, U serIdentifierowner, Timestamp after, Timestamp before) {108 public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UUID owner, Timestamp after, Timestamp before) { 113 109 114 110 List<Number> annotationIDs = null; … … 136 132 public Number[] addCachedForVersion(Number versionID, CachedRepresentationInfo cached) { 137 133 Number[] result = new Number[2]; 138 result[1] = cachedRepresentationDao.getInternalID(new CachedRepresentationIdentifier(cached.getRef())); 134 String cachedExternalIDstring = cached.getRef(); 135 UUID cachedUUID = (cachedExternalIDstring != null) ? UUID.fromString(cachedExternalIDstring) : null; 136 result[1] = cachedRepresentationDao.getInternalID(cachedUUID); 139 137 if (result[1] == null) { 140 138 result[1] = cachedRepresentationDao.addCachedRepresentationInfo(cached); … … 149 147 public Number[] addSiblingVersionForSource(Number sourceID, Version version) throws SQLException { 150 148 Number[] result = new Number[2]; 151 result[1] = versionDao.getInternalID(new VersionIdentifier(version.getVersion())); // TOT: change to getURI after the schem is fixed 149 String versionExternalIDstring = version.getVersion();// TOT: change to getURI after the schem is fixed 150 UUID versionUUID = (versionExternalIDstring != null) ? UUID.fromString(versionExternalIDstring) : null; 151 result[1] = versionDao.getInternalID(versionUUID); 152 152 if (result[1] == null) { 153 153 result[1] = versionDao.addVersion(version); … … 164 164 SourceInfo source = noesi.getSource(); 165 165 if (source != null) { 166 int affectedRows = annotationDao.addAnnotationSourcePair(annotationID, sourceDao.getInternalID( new SourceIdentifier(source.getRef())));166 int affectedRows = annotationDao.addAnnotationSourcePair(annotationID, sourceDao.getInternalID(UUID.fromString(source.getRef()))); 167 167 } else { 168 168 Source newSource = createSource(noesi.getNewSource()); … … 277 277 private Source createSource(NewSourceInfo newSource) { 278 278 Source source = new Source(); 279 SourceIdentifier externalIdentifier = new SourceIdentifier();279 UUID externalIdentifier = UUID.randomUUID(); 280 280 source.setURI(externalIdentifier.toString()); 281 281 source.setLink(newSource.getLink()); … … 286 286 private Version createVersion(NewSourceInfo newSource) { 287 287 Version version = new Version(); 288 VersionIdentifier versionIdentifier = new VersionIdentifier();289 version.setVersion( versionIdentifier.toString()); // TODO change after the schem is fixed, shoul be setURI,288 UUID externalIdentifier = UUID.randomUUID(); 289 version.setVersion(externalIdentifier.toString()); // TODO change after the schem is fixed, shoul be setURI, 290 290 return version; 291 291 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java
r3413 r3455 20 20 import eu.dasish.annotation.backend.Helpers; 21 21 import eu.dasish.annotation.backend.dao.AnnotationDao; 22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;23 22 import eu.dasish.annotation.schema.Annotation; 24 23 import eu.dasish.annotation.schema.AnnotationInfo; … … 33 32 import java.util.List; 34 33 import java.util.Map; 34 import java.util.UUID; 35 35 import javax.sql.DataSource; 36 36 import javax.xml.datatype.DatatypeConfigurationException; … … 49 49 resourceTableName = annotationTableName; 50 50 } 51 51 52 52 53 @Override 53 54 public List<Number> retrieveSourceIDs(Number annotationID) { … … 252 253 public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException { 253 254 // generate a new annotation ID 254 AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier();255 UUID externalID = UUID.randomUUID(); 255 256 Map<String, Object> params = new HashMap<String, Object>(); 256 params.put("externalId", annotationIdentifier.toString());257 params.put("externalId", externalID.toString()); 257 258 params.put("ownerId", ownerID); 258 259 params.put("headline", annotation.getHeadline()); … … 264 265 int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params); 265 266 if (affectedRows == 1) { 266 return getInternalID( annotationIdentifier);267 return getInternalID(externalID); 267 268 } else { 268 269 return null; … … 271 272 } 272 273 273 ////////////////////////////////////////////////// 274 @Override 275 public AnnotationIdentifier getExternalID(Number internalID) { 276 return new AnnotationIdentifier(super.getExternalIdentifier(internalID)); 277 } 278 274 279 275 /////////////////////////////////////////////////////////////////////// 280 276 @Override -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
r3408 r3455 19 19 20 20 import eu.dasish.annotation.backend.dao.CachedRepresentationDao; 21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;22 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 import java.lang.String; 23 23 import java.sql.ResultSet; 24 24 import java.sql.SQLException; … … 26 26 import java.util.List; 27 27 import java.util.Map; 28 import java.util.UUID; 28 29 import javax.sql.DataSource; 29 30 import org.springframework.jdbc.core.RowMapper; … … 42 43 } 43 44 44 ////////////////////////////////////////////////////////////////////////////////////////////////////// 45 @Override 46 public CachedRepresentationIdentifier getExternalID(Number internalID) { 47 return new CachedRepresentationIdentifier(super.getExternalIdentifier(internalID)); 48 } 49 50 ////////////////////////////////////////////////////////////////////////////////////////////////////// 51 @Override 52 public Number getInternalID(CachedRepresentationIdentifier externalID) { 53 return super.getInternalID(externalID); 54 } 55 45 56 46 57 47 /////////////////////////////////////////////////////////////////////////////////////// … … 87 77 public Number addCachedRepresentationInfo(CachedRepresentationInfo cached) { 88 78 89 CachedRepresentationIdentifier externalIdentifier = new CachedRepresentationIdentifier(); 90 79 UUID externalIdentifier = UUID.randomUUID(); 91 80 Map<String, Object> params = new HashMap<String, Object>(); 92 81 params.put("externalId", externalIdentifier.toString()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDao.java
r3373 r3455 20 20 import eu.dasish.annotation.backend.dao.AnnotationDao; 21 21 import eu.dasish.annotation.backend.dao.NotebookDao; 22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;23 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;24 import eu.dasish.annotation.backend.identifiers.UserIdentifier;25 22 import eu.dasish.annotation.schema.Annotations; 26 23 import eu.dasish.annotation.schema.Notebook; … … 34 31 import java.util.List; 35 32 import java.util.Map; 33 import java.util.UUID; 36 34 import javax.sql.DataSource; 37 35 import org.springframework.jdbc.core.RowMapper; … … 54 52 55 53 public JdbcNotebookDao(DataSource dataSource) { 56 setDataSource(dataSource); 57 } 58 59 @Override 60 public List<NotebookInfo> getNotebookInfos(UserIdentifier userID) { 54 setDataSource(dataSource); 55 internalIdName = notebook_id; 56 resourceTableName = notebookTableName; 57 } 58 59 @Override 60 public List<NotebookInfo> getNotebookInfos(UUID userID) { 61 61 String sql = "SELECT " + notebookTitle + ", " + notebookExternal_id + " FROM " + notebookTableName + ", " + principalTableName + " where " + principalPrincipal_id + " = " + notebookOwner_id + " and " + principalExternal_id + " = ?"; 62 62 return getSimpleJdbcTemplate().query(sql, notebookInfoRowMapper, userID.toString()); … … 64 64 65 65 @Override 66 public List<Notebook> getUsersNotebooks(U serIdentifieruserID) {66 public List<Notebook> getUsersNotebooks(UUID userID) { 67 67 String sql = "SELECT " + notebookStar + " FROM " + notebookTableName + ", " + principalTableName + " where " + principal_id + " = " + owner_id + " and " + principalExternal_id + " = ?"; 68 68 return getSimpleJdbcTemplate().query(sql, notebookRowMapper, userID.toString()); … … 70 70 71 71 @Override 72 public NotebookIdentifier addNotebook(UserIdentifieruserID, String title) {72 public UUID addNotebook(UUID userID, String title) { 73 73 try { 74 final NotebookIdentifier notebookIdentifier = new NotebookIdentifier();74 final UUID externalIdentifier = UUID.randomUUID(); 75 75 String sql = "INSERT INTO " + notebookTableName + " (" + external_id + ", " + this.title + "," + owner_id + ") VALUES (:notebookId, :title, (SELECT " + principal_id + " FROM " + principalTableName + " WHERE " + principalExternal_id + " = :userID))"; 76 76 Map<String, Object> params = new HashMap<String, Object>(); 77 params.put("notebookId", notebookIdentifier.getUUID().toString());77 params.put("notebookId", externalIdentifier.toString()); 78 78 params.put("userID", userID.toString()); 79 79 params.put("title", title); 80 80 final int updatedRowCount = getSimpleJdbcTemplate().update(sql, params); 81 return notebookIdentifier;81 return externalIdentifier; 82 82 } catch (DataAccessException exception) { 83 83 throw exception; … … 116 116 // returns the number of affected annotations 117 117 @Override 118 public int deleteNotebook( NotebookIdentifiernotebookId) {118 public int deleteNotebook(UUID notebookId) { 119 119 String sql1 = "DELETE FROM " + notebooksAnnotationsTableName + " where " + notebook_id + "= (SELECT " + notebook_id + " FROM " + notebookTableName + " WHERE " + external_id + " = ?)"; 120 120 String sql2 = "DELETE FROM notebook where external_id = ?"; 121 int affectedAnnotations = getSimpleJdbcTemplate().update(sql1, notebookId. getUUID().toString());122 int affectedNotebooks = getSimpleJdbcTemplate().update(sql2, notebookId. getUUID().toString());121 int affectedAnnotations = getSimpleJdbcTemplate().update(sql1, notebookId.toString()); 122 int affectedNotebooks = getSimpleJdbcTemplate().update(sql2, notebookId.toString()); 123 123 return affectedAnnotations; 124 124 } 125 125 126 126 @Override 127 public int addAnnotation( NotebookIdentifier notebookId, AnnotationIdentifierannotationId) {127 public int addAnnotation(UUID notebookId, UUID annotationId) { 128 128 try { 129 129 SimpleJdbcInsert notebookInsert = new SimpleJdbcInsert(getDataSource()).withTableName(notebooksAnnotationsTableName); … … 148 148 @Override 149 149 public List<Number> getAnnotationIDs(Number notebookID) { 150 if (notebookID == null) {151 return null;152 }153 150 StringBuilder sql = new StringBuilder("SELECT DISTINCT "); 154 151 sql.append(notebooksAnnotationsTableNameAnnotation_id).append(" FROM ").append(notebooksAnnotationsTableName).append(" where ").append(notebook_id).append(" = ?"); 155 return getSimpleJdbcTemplate().query(sql.toString(), annotationIDRowMapper, notebookID .toString());152 return getSimpleJdbcTemplate().query(sql.toString(), annotationIDRowMapper, notebookID); 156 153 } 157 154 private final RowMapper<Number> annotationIDRowMapper = new RowMapper<Number>() { … … 230 227 } 231 228 232 ////////////////////////////////////////////////// 233 @Override 234 public Number getNotebookID(NotebookIdentifier externalId) { 235 if (externalId == null) { 236 return null; 237 } 238 239 String sql = "SELECT " + notebookNotebook_id + " FROM " + notebookTableName + " WHERE " + notebookExternal_id + " = ?"; 240 List<Number> result = getSimpleJdbcTemplate().query(sql, notebookIdRowMapper, externalId.toString()); 241 if (result == null) { 242 return null; 243 } 244 if (result.isEmpty()) { 245 return null; 246 } 247 248 return result.get(0); 249 } 250 private final RowMapper<Number> notebookIdRowMapper = new RowMapper<Number>() { 251 @Override 252 public Number mapRow(ResultSet rs, int rowNumber) throws SQLException { 253 Number result = rs.getInt(notebook_id); 254 return result; 255 } 256 }; 257 229 258 230 ////////////////////////////////////////////////////////////////// 259 231 @Override 260 public List< AnnotationIdentifier> getAnnotationExternalIDs(NotebookIdentifiernotebookId) {261 List<Number> internalIds = getAnnotationIDs(get NotebookID(notebookId));232 public List<UUID> getAnnotationExternalIDs(UUID notebookId) { 233 List<Number> internalIds = getAnnotationIDs(getInternalID(notebookId)); 262 234 if (internalIds == null) { 263 235 return null; 264 236 } 265 List< AnnotationIdentifier> annotationIds = new ArrayList<AnnotationIdentifier>();237 List<UUID> annotationIds = new ArrayList<UUID>(); 266 238 for (Number internalId : internalIds) { 267 239 annotationIds.add(jdbcAnnotationDao.getExternalID(internalId)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
r3408 r3455 20 20 import eu.dasish.annotation.backend.Helpers; 21 21 import eu.dasish.annotation.backend.dao.ResourceDao; 22 import eu.dasish.annotation.backend.identifiers.DasishIdentifier;23 22 import java.sql.ResultSet; 24 23 import java.sql.SQLException; 25 24 import java.util.List; 25 import java.util.UUID; 26 26 import javax.xml.datatype.DatatypeConfigurationException; 27 27 import javax.xml.datatype.XMLGregorianCalendar; … … 89 89 ////////////////////////////////////////////////////////////////////////////////// 90 90 @Override 91 public <T extends DasishIdentifier> Number getInternalID(TexternalId) {91 public Number getInternalID(UUID externalId) { 92 92 if (externalId == null) { 93 93 return null; … … 96 96 List<Number> sqlResult = getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalId.toString()); 97 97 98 if (sqlResult == null) {99 return null;100 }101 98 if (sqlResult.isEmpty()) { 102 99 return null; … … 116 113 117 114 118 ///////////////////////////////////////////// 119 protected String getExternalIdentifier(Number internalId) { 120 if (internalId == null) { 121 return null; 122 } 115 @Override 116 public UUID getExternalID(Number internalId) { 123 117 String sql = "SELECT " + external_id + " FROM " + resourceTableName + " WHERE " + internalIdName + "= ? LIMIT 1"; 124 List<String> sqlResult = getSimpleJdbcTemplate().query(sql, externalIDRowMapper, internalId); 125 126 if (sqlResult == null) { 127 return null; 128 } 118 List<UUID> sqlResult = getSimpleJdbcTemplate().query(sql, externalIDRowMapper, internalId); 129 119 if (sqlResult.isEmpty()) { 130 120 return null; … … 134 124 } 135 125 136 protected final RowMapper< String> externalIDRowMapper = new RowMapper<String>() {126 protected final RowMapper<UUID> externalIDRowMapper = new RowMapper<UUID>() { 137 127 @Override 138 public StringmapRow(ResultSet rs, int rowNumber) throws SQLException {139 return ( rs.getString(external_id));128 public UUID mapRow(ResultSet rs, int rowNumber) throws SQLException { 129 return (UUID.fromString(rs.getString(external_id))); 140 130 } 141 131 }; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java
r3413 r3455 20 20 import eu.dasish.annotation.backend.Helpers; 21 21 import eu.dasish.annotation.backend.dao.SourceDao; 22 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;23 22 import eu.dasish.annotation.schema.Source; 24 23 import eu.dasish.annotation.schema.SourceInfo; … … 29 28 import java.util.List; 30 29 import java.util.Map; 30 import java.util.UUID; 31 31 import javax.sql.DataSource; 32 32 import javax.xml.datatype.DatatypeConfigurationException; … … 47 47 } 48 48 49 ////////////////////////////////////////////////////////////////////////////////////////////////////// 50 @Override 51 public SourceIdentifier getExternalID(Number internalID) { 52 return new SourceIdentifier(super.getExternalIdentifier(internalID)); 53 } 49 54 50 55 51 /////////////////////////////////////////////////////////////////////////////// … … 66 62 XMLGregorianCalendar xmlDate = Helpers.setXMLGregorianCalendar(rs.getTimestamp(time_stamp)); 67 63 Source result = 68 constructSource( new SourceIdentifier(rs.getString(external_id)), rs.getString(link_uri), rs.getString(version), xmlDate);64 constructSource(UUID.fromString(rs.getString(external_id)), rs.getString(link_uri), rs.getString(version), xmlDate); 69 65 return result; 70 66 } catch (DatatypeConfigurationException e) { … … 108 104 String sql = "INSERT INTO " + sourceTableName + "(" + external_id + "," + link_uri + "," + version + " ) VALUES (:externalId, :linkUri, :version)"; 109 105 final int affectedRows = getSimpleJdbcTemplate().update(sql, params); 110 Number internalID = getInternalID( new SourceIdentifier(externalID));106 Number internalID = getInternalID(UUID.fromString(externalID)); 111 107 return internalID; 112 108 } … … 159 155 @Override 160 156 public SourceInfo mapRow(ResultSet rs, int rowNumber) throws SQLException { 161 return constructSourceInfo( new SourceIdentifier(rs.getString(external_id)), rs.getString(link_uri), rs.getString(version));157 return constructSourceInfo(UUID.fromString(rs.getString(external_id)), rs.getString(link_uri), rs.getString(version)); 162 158 } 163 159 }; … … 195 191 196 192 197 private SourceInfo constructSourceInfo( SourceIdentifier sourceIdentifier, String link, String version) {193 private SourceInfo constructSourceInfo(UUID UUID, String link, String version) { 198 194 SourceInfo sourceInfo = new SourceInfo(); 199 sourceInfo.setRef( sourceIdentifier.toString());195 sourceInfo.setRef(UUID.toString()); 200 196 sourceInfo.setLink(link); 201 197 sourceInfo.setVersion(version); … … 203 199 } 204 200 205 private Source constructSource( SourceIdentifier sourceIdentifier, String link, String version, XMLGregorianCalendar xmlTimeStamp) {201 private Source constructSource(UUID UUID, String link, String version, XMLGregorianCalendar xmlTimeStamp) { 206 202 Source source = new Source(); 207 source.setURI( sourceIdentifier.toString());203 source.setURI(UUID.toString()); 208 204 source.setTimeSatmp(xmlTimeStamp); 209 205 source.setLink(link); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDao.java
r3370 r3455 19 19 20 20 import eu.dasish.annotation.backend.dao.UserDao; 21 import eu.dasish.annotation.backend.identifiers.UserIdentifier;22 21 import javax.sql.DataSource; 23 22 … … 34 33 } 35 34 36 /////////////////////////////////////////////////////////////////// 37 @Override 38 public UserIdentifier getExternalID(Number internalID) { 39 return new UserIdentifier(super.getExternalIdentifier(internalID)); 40 } 35 41 36 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java
r3408 r3455 19 19 20 20 import eu.dasish.annotation.backend.dao.VersionDao; 21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;22 21 import eu.dasish.annotation.schema.Version; 23 22 import java.sql.ResultSet; … … 26 25 import java.util.List; 27 26 import java.util.Map; 27 import java.util.UUID; 28 28 import javax.sql.DataSource; 29 29 import org.springframework.jdbc.core.RowMapper; … … 42 42 } 43 43 44 ////////////////////////////////////////////////////////////////////////////////////////////////////// 45 @Override 46 public VersionIdentifier getExternalID(Number internalID) { 47 return new VersionIdentifier(super.getExternalIdentifier(internalID)); 48 } 49 50 ////////////////////////////////////////////////////////////////////////////////////////////////////// 51 @Override 52 public Number getInternalID(VersionIdentifier externalID) { 53 return (super.getInternalID(externalID)); 54 } 55 44 56 45 /////////////////////////////////////////////////////////////// 57 46 @Override … … 86 75 String sql = "SELECT " + cached_representation_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + version_id + "= ?"; 87 76 List<Number> result = getSimpleJdbcTemplate().query(sql, cachedIDRowMapper, versionID); 88 89 if (result == null) {90 return null;91 }92 93 77 return result; 94 78 } … … 119 103 @Override 120 104 public Number addVersion(Version freshVersion) { 121 VersionIdentifier externalIdentifier = new VersionIdentifier();105 UUID externalIdentifier = UUID.randomUUID(); 122 106 String newExternalIdentifier = externalIdentifier.toString(); 123 107 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r3453 r3455 20 20 import eu.dasish.annotation.backend.BackendConstants; 21 21 import eu.dasish.annotation.backend.dao.DaoDispatcher; 22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;23 import eu.dasish.annotation.backend.identifiers.UserIdentifier;24 22 import eu.dasish.annotation.schema.Annotation; 25 23 import eu.dasish.annotation.schema.ObjectFactory; 26 24 import java.sql.SQLException; 25 import java.util.UUID; 27 26 import javax.servlet.http.HttpServletRequest; 28 27 import javax.ws.rs.Consumes; … … 62 61 @Produces(MediaType.TEXT_XML) 63 62 @Path("{annotationid: " + BackendConstants.regExpIdentifier + "}") 64 public JAXBElement<Annotation> getAnnotation(@PathParam("annotationid") String annotationIdentifier) throws SQLException {65 final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier( new AnnotationIdentifier(annotationIdentifier));63 public JAXBElement<Annotation> getAnnotation(@PathParam("annotationid") String ExternalIdentifier) throws SQLException { 64 final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(ExternalIdentifier)); 66 65 final Annotation annotation = daoDispatcher.getAnnotation(annotationID); 67 66 return new ObjectFactory().createAnnotation(annotation); … … 72 71 @DELETE 73 72 @Path("{annotationid: " + BackendConstants.regExpIdentifier + "}") 74 public String deleteAnnotation(@PathParam("annotationid") String annotationIdentifier) throws SQLException {75 final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier( new AnnotationIdentifier(annotationIdentifier));73 public String deleteAnnotation(@PathParam("annotationid") String externalIdentifier) throws SQLException { 74 final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(externalIdentifier)); 76 75 int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID); 77 76 String result = Integer.toString(resultDelete[0]); … … 87 86 public JAXBElement<Annotation> createAnnotation(Annotation annotation) throws SQLException { 88 87 String remoteUser = httpServletRequest.getRemoteUser(); 89 Number userID = daoDispatcher.getUserInternalIdentifier(new UserIdentifier(remoteUser)); 88 UUID userExternalID = (remoteUser != null) ? UUID.fromString(remoteUser) : null; 89 Number userID = daoDispatcher.getUserInternalIdentifier(userExternalID); 90 90 Number newAnnotationID = daoDispatcher.addUsersAnnotation(annotation, userID); 91 91 Annotation newAnnotation = daoDispatcher.getAnnotation(newAnnotationID); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java
r3190 r3455 20 20 import eu.dasish.annotation.backend.BackendConstants; 21 21 import eu.dasish.annotation.backend.dao.AnnotationDao; 22 import eu.dasish.annotation.backend.identifiers.UserIdentifier;23 22 import eu.dasish.annotation.backend.dao.NotebookDao; 24 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;25 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;26 23 import eu.dasish.annotation.schema.Notebook; 27 24 import eu.dasish.annotation.schema.NotebookInfo; … … 32 29 import java.util.ArrayList; 33 30 import java.util.List; 31 import java.util.UUID; 34 32 import javax.servlet.http.HttpServletRequest; 35 33 import javax.ws.rs.Consumes; … … 46 44 import javax.ws.rs.core.MediaType; 47 45 import javax.xml.bind.JAXBElement; 46 import javax.xml.namespace.QName; 48 47 import org.springframework.beans.factory.annotation.Autowired; 49 48 import org.springframework.stereotype.Component; … … 69 68 public JAXBElement<NotebookInfos> getNotebookInfo(@Context HttpServletRequest httpServletRequest) { 70 69 final NotebookInfos notebookInfos = new NotebookInfos(); 71 notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos(new UserIdentifier(httpServletRequest.getRemoteUser()))); 70 String remoteUser = httpServletRequest.getRemoteUser(); 71 UUID remoteUserUUID = (remoteUser != null) ? UUID.fromString(remoteUser) : null; 72 notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos(remoteUserUUID)); 72 73 return new ObjectFactory().createNotebooks(notebookInfos); 73 74 } … … 79 80 public JAXBElement<NotebookInfos> getNotebookInfo(@QueryParam("userid") String userId) { 80 81 final NotebookInfos notebookInfos = new NotebookInfos(); 81 notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos( new UserIdentifier(userId)));82 notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos(UUID.fromString(userId))); 82 83 return new ObjectFactory().createNotebooks(notebookInfos); 83 84 } … … 89 90 public List<Notebook> getUsersNotebooks(@Context HttpServletRequest httpServletRequest) { 90 91 // todo: sort out how the user id is obtained and how it is stored it the db 91 return notebookDao.getUsersNotebooks(new UserIdentifier(httpServletRequest.getRemoteUser())); 92 String remoteUser = httpServletRequest.getRemoteUser(); 93 UUID remoteUserUUID = (remoteUser != null) ? UUID.fromString(remoteUser) : null; 94 return notebookDao.getUsersNotebooks(remoteUserUUID); 92 95 } 93 96 … … 110 113 @GET 111 114 @Produces(MediaType.TEXT_XML) 112 @Path("{notebookid: " +BackendConstants.regExpIdentifier+"}/metadata")115 @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}/metadata") 113 116 // Get all metadata about a specified notebook _nid_, including the information if it is private or not. 114 117 public JAXBElement<NotebookInfo> getMetadata(@PathParam("notebookid") String notebookId) { 115 NotebookInfo result = notebookDao.getNotebookInfo(notebookDao.get NotebookID(new NotebookIdentifier(notebookId)));118 NotebookInfo result = notebookDao.getNotebookInfo(notebookDao.getInternalID(UUID.fromString(notebookId))); 116 119 // TODO change the name of the create method to createNotebookInfo! 117 120 return new ObjectFactory().createNotebook(result); 118 119 } 120 121 @GET 122 @Path("{notebookid: " +BackendConstants.regExpIdentifier+"}")121 122 } 123 124 @GET 125 @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}") 123 126 /* 124 127 * Get the list of all annotations _aid_-s contained within a Notebook with related metadata. … … 130 133 * */ 131 134 @Produces(MediaType.TEXT_XML) 132 public List< AnnotationIdentifier> getAllAnnotations(@PathParam("notebookid") String notebookId, @DefaultValue("-1") @QueryParam(value = "maximumAnnotations") final int maximumAnnotations,135 public List<JAXBElement<UUID>> getAllAnnotations(@PathParam("notebookid") String notebookId, @DefaultValue("-1") @QueryParam(value = "maximumAnnotations") final int maximumAnnotations, 133 136 @DefaultValue("-1") @QueryParam(value = "startAnnotation") final int startAnnotation, 134 137 @DefaultValue("dc:created") @QueryParam(value = "orderby") final String orderby, 135 @DefaultValue("0") @QueryParam(value = "orderingMode") final int orderingMode) { 136 List<AnnotationIdentifier> annotationIds = notebookDao.getAnnotationExternalIDs(new NotebookIdentifier(notebookId)); 137 138 return annotationIds; 138 @DefaultValue("0") @QueryParam(value = "orderingMode") final int orderingMode) { 139 UUID notebookUUID = UUID.fromString(notebookId); 140 List<UUID> annotationIDs = notebookDao.getAnnotationExternalIDs(notebookUUID); 141 List<JAXBElement<UUID>> result = new ArrayList<JAXBElement<UUID>>(); 142 for (UUID annotationID : annotationIDs) { 143 final JAXBElement<UUID> jaxbElement = new JAXBElement<UUID>(new QName("http://www.dasish.eu/ns/addit", "uuid"), UUID.class, null, annotationID); 144 result.add(jaxbElement); 145 } 146 return result; 139 147 // TODO implement optional parameters!! 140 148 } … … 175 183 */ 176 184 public String createNotebook(@Context HttpServletRequest httpServletRequest) throws URISyntaxException { 177 NotebookIdentifier notebookId = notebookDao.addNotebook(new UserIdentifier(httpServletRequest.getRemoteUser()), null); 185 String remoteUser = httpServletRequest.getRemoteUser(); 186 UUID remoteUserUUID = (remoteUser != null) ? UUID.fromString(remoteUser) : null; 187 UUID notebookId = notebookDao.addNotebook(remoteUserUUID, null); 178 188 final URI serverUri = new URI(httpServletRequest.getRequestURL().toString()); 179 String fullUrlString = "/api/notebooks/" + notebookId. getUUID().toString();189 String fullUrlString = "/api/notebooks/" + notebookId.toString(); 180 190 return serverUri.resolve(fullUrlString).toString(); 181 191 } … … 198 208 Delete _nid_. Annotations stay, they just lose connection to _nid_.<br> 199 209 */ 200 public String deleteNotebook(@PathParam("notebookid") NotebookIdentifiernotebookId) {210 public String deleteNotebook(@PathParam("notebookid") UUID notebookId) { 201 211 // todo: sort out how the id string passsed in here is mapped eg db column for _nid_ 202 212 return Integer.toString(notebookDao.deleteNotebook(notebookId)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java
r3448 r3455 23 23 package eu.dasish.annotation.backend; 24 24 25 import java.sql.Timestamp;26 27 25 public class TestBackendConstants { 28 26 27 public static final String _TEST_NOTEBOOK_1_EXT_ID ="00000000-0000-0000-0000-000000000001"; 28 public static final String _TEST_NOTEBOOK_2_EXT_ID ="00000000-0000-0000-0000-000000000002"; 29 29 public static final String _TEST_UID_1_ = "00000000-0000-0000-0000-000000000003"; 30 30 public static final String _TEST_UID_2_ = "00000000-0000-0000-0000-000000000004"; -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/DaoDispatcherTest.java
r3452 r3455 27 27 import eu.dasish.annotation.backend.dao.UserDao; 28 28 import eu.dasish.annotation.backend.dao.VersionDao; 29 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;30 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;31 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;32 import eu.dasish.annotation.backend.identifiers.UserIdentifier;33 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;34 29 import eu.dasish.annotation.schema.Annotation; 35 30 import eu.dasish.annotation.schema.AnnotationBody; … … 47 42 import java.util.List; 48 43 import java.util.Map; 44 import java.util.UUID; 49 45 import javax.xml.datatype.XMLGregorianCalendar; 50 46 import org.jmock.Expectations; … … 96 92 public void testGetAnnotationInternalIdentifier() { 97 93 System.out.println("getAnnotationInternalIdentifier"); 98 final AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT);99 100 mockery.checking(new Expectations() { 101 { 102 oneOf(annotationDao).getInternalID( annotationIdentifier);94 final UUID externalID = UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT); 95 96 mockery.checking(new Expectations() { 97 { 98 oneOf(annotationDao).getInternalID(externalID); 103 99 will(returnValue(2)); 104 100 } 105 101 }); 106 assertEquals(2, daoDispatcher.getAnnotationInternalIdentifier( annotationIdentifier));102 assertEquals(2, daoDispatcher.getAnnotationInternalIdentifier(externalID)); 107 103 } 108 104 … … 113 109 public void testGetAnnotationExternalIdentifier() { 114 110 System.out.println("getAnnotationExternalIdentifier"); 115 final AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT);111 final UUID externalID = UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT); 116 112 117 113 mockery.checking(new Expectations() { 118 114 { 119 115 oneOf(annotationDao).getExternalID(2); 120 will(returnValue( annotationIdentifier));116 will(returnValue(externalID)); 121 117 } 122 118 }); … … 131 127 System.out.println("getUserInternalIdentifier"); 132 128 133 final U serIdentifier userIdentifier = new UserIdentifier(TestBackendConstants._TEST_USER_5_EXT_ID);134 135 mockery.checking(new Expectations() { 136 { 137 oneOf(userDao).getInternalID( userIdentifier);129 final UUID externalID = UUID.fromString(TestBackendConstants._TEST_USER_5_EXT_ID); 130 131 mockery.checking(new Expectations() { 132 { 133 oneOf(userDao).getInternalID(externalID); 138 134 will(returnValue(5)); 139 135 } 140 136 }); 141 assertEquals(5, daoDispatcher.getUserInternalIdentifier( userIdentifier));137 assertEquals(5, daoDispatcher.getUserInternalIdentifier(externalID)); 142 138 } 143 139 … … 148 144 public void testGetUserExternalIdentifier() { 149 145 System.out.println("getUserExternalIdentifier"); 150 final U serIdentifier userIdentifier = new UserIdentifier(TestBackendConstants._TEST_USER_5_EXT_ID);146 final UUID externalID = UUID.fromString(TestBackendConstants._TEST_USER_5_EXT_ID); 151 147 152 148 mockery.checking(new Expectations() { 153 149 { 154 150 oneOf(userDao).getExternalID(5); 155 will(returnValue( userIdentifier));151 will(returnValue(externalID)); 156 152 } 157 153 }); … … 248 244 final String access = null; 249 245 final String namespace = null; 250 final U serIdentifier owner = new UserIdentifier(TestBackendConstants._TEST_USER_3_EXT_ID);246 final UUID owner = UUID.fromString(TestBackendConstants._TEST_USER_3_EXT_ID); 251 247 final Timestamp after = new Timestamp(0); 252 248 final Timestamp before = new Timestamp(System.currentTimeMillis()); … … 296 292 mockery.checking(new Expectations() { 297 293 { 298 oneOf(cachedRepresentationDao).getInternalID(n ew CachedRepresentationIdentifier(newCached.getRef()));294 oneOf(cachedRepresentationDao).getInternalID(null); 299 295 will(returnValue(null)); 300 296 … … 324 320 // test adding completely new version 325 321 final Version mockVersion = new Version(); // should be # 8 326 final VersionIdentifier mockVersionIdentifier = new VersionIdentifier();327 mockVersion.setVersion(mock VersionIdentifier.toString());328 329 mockery.checking(new Expectations() { 330 { 331 oneOf(versionDao).getInternalID(mock VersionIdentifier);322 final UUID mockUUID = UUID.randomUUID(); 323 mockVersion.setVersion(mockUUID.toString()); 324 325 mockery.checking(new Expectations() { 326 { 327 oneOf(versionDao).getInternalID(mockUUID); 332 328 will(returnValue(null)); 333 329 … … 350 346 351 347 final Version mockVersionTwo = new Version(); // should be # 3 352 final VersionIdentifier mockVersionIdentifierTwo = new VersionIdentifier(TestBackendConstants._TEST_VERSION_3_EXT_ID);353 mockVersionTwo.setVersion(mock VersionIdentifierTwo.toString());354 355 mockery.checking(new Expectations() { 356 { 357 oneOf(versionDao).getInternalID(mock VersionIdentifierTwo);348 final UUID mockUUIDTwo = UUID.fromString(TestBackendConstants._TEST_VERSION_3_EXT_ID); 349 mockVersionTwo.setVersion(mockUUIDTwo.toString()); 350 351 mockery.checking(new Expectations() { 352 { 353 oneOf(versionDao).getInternalID(mockUUIDTwo); 358 354 will(returnValue(3)); 359 355 … … 377 373 // test 1: adding an existing source 378 374 NewOrExistingSourceInfo testSourceOne = new NewOrExistingSourceInfo(); 379 final SourceIdentifier mockSourceIdentifierOne = new SourceIdentifier(TestBackendConstants._TEST_SOURCE_1_EXT_ID);375 final UUID mockUUIDOne = UUID.fromString(TestBackendConstants._TEST_SOURCE_1_EXT_ID); 380 376 SourceInfo testOldSource = new SourceInfo(); 381 377 testOldSource.setLink(TestBackendConstants._TEST_SOURCE_1_LINK); … … 388 384 mockery.checking(new Expectations() { 389 385 { 390 oneOf(sourceDao).getInternalID(with(aNonNull( SourceIdentifier.class)));386 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class))); 391 387 will(returnValue(1)); 392 388 … … 419 415 //////////// mockery in the call addSiblingVersionForSource ////////////// 420 416 421 oneOf(versionDao).getInternalID(with(aNonNull( VersionIdentifier.class)));417 oneOf(versionDao).getInternalID(with(aNonNull(UUID.class))); 422 418 will(returnValue(null)); 423 419 … … 458 454 459 455 // expectations for addSourcesForannotation 460 oneOf(sourceDao).getInternalID(with(aNonNull( SourceIdentifier.class)));456 oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class))); 461 457 will(returnValue(1)); 462 458 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java
r3450 r3455 21 21 import eu.dasish.annotation.backend.TestBackendConstants; 22 22 import eu.dasish.annotation.backend.TestInstances; 23 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;24 23 import eu.dasish.annotation.schema.Annotation; 25 24 import eu.dasish.annotation.schema.AnnotationInfo; … … 31 30 import java.util.List; 32 31 import java.util.Map; 32 import java.util.UUID; 33 33 import static org.junit.Assert.*; 34 34 import org.junit.Test; … … 159 159 * 160 160 * Test of getAnnotationID method, of class JdbcAnnotationDao. Integer 161 * getAnnotationID( AnnotationIdentifierexternalID)161 * getAnnotationID(UUID externalID) 162 162 */ 163 163 @Test … … 165 165 System.out.println("test getInternalID"); 166 166 167 final Number annotaionId = jdbcAnnotationDao.getInternalID( new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT));167 final Number annotaionId = jdbcAnnotationDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT)); 168 168 assertEquals(2, annotaionId.intValue()); 169 169 170 final Number annotaionIdNE = jdbcAnnotationDao.getInternalID( new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_7_EXT_NOT_IN_DB));170 final Number annotaionIdNE = jdbcAnnotationDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_ANNOT_7_EXT_NOT_IN_DB)); 171 171 assertEquals(null, annotaionIdNE); 172 172 … … 266 266 System.out.println("getExternalID"); 267 267 268 final AnnotationIdentifierexternalId = jdbcAnnotationDao.getExternalID(2);269 assertEquals( new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT), externalId);270 271 272 final AnnotationIdentifierexternalIdThree = jdbcAnnotationDao.getExternalID(null);273 assertEquals(null, externalIdThree .getUUID());268 final UUID externalId = jdbcAnnotationDao.getExternalID(2); 269 assertEquals(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT), externalId); 270 271 272 final UUID externalIdThree = jdbcAnnotationDao.getExternalID(null); 273 assertEquals(null, externalIdThree); 274 274 275 275 } … … 277 277 278 278 /** test 279 * public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, U serIdentifierowner, Timestamp after, Timestamp before) {279 * public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UUID owner, Timestamp after, Timestamp before) { 280 280 **/ 281 281 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java
r3450 r3455 19 19 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;22 21 import eu.dasish.annotation.schema.CachedRepresentationInfo; 22 import java.util.UUID; 23 23 import org.junit.Test; 24 24 import static org.junit.Assert.*; … … 48 48 /** 49 49 * Test of getExternalId method, of class JdbcCachedRepresentationDao. 50 * public CachedRepresentationIdentifiergetExternalId(Number internalID);50 * public UUID getExternalId(Number internalID); 51 51 52 52 */ … … 55 55 System.out.println("getExternalId"); 56 56 Number internalID = 1; 57 CachedRepresentationIdentifier expResult = new CachedRepresentationIdentifier(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);58 CachedRepresentationIdentifierresult = jdbcCachedRepresentationDao.getExternalID(internalID);57 UUID expResult = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_); 58 UUID result = jdbcCachedRepresentationDao.getExternalID(internalID); 59 59 assertEquals(expResult, result); 60 60 } … … 63 63 /** 64 64 * Test of getInternalId method, of class JdbcCachedRepresentationDao. 65 * public Number getInternalId( CachedRepresentationIdentifierexternalID);65 * public Number getInternalId(UUID externalID); 66 66 */ 67 67 @Test 68 68 public void testGetInternalId() { 69 69 System.out.println("getInternalId"); 70 CachedRepresentationIdentifier externalID = new CachedRepresentationIdentifier(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);70 UUID externalID = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_); 71 71 Number result = jdbcCachedRepresentationDao.getInternalID(externalID); 72 72 assertEquals(1, result.intValue()); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcNotebookDaoTest.java
r3452 r3455 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 21 import eu.dasish.annotation.backend.dao.AnnotationDao; 22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;23 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;24 import eu.dasish.annotation.backend.identifiers.UserIdentifier;25 22 import eu.dasish.annotation.schema.Annotations; 26 23 import eu.dasish.annotation.schema.Notebook; … … 71 68 @Test 72 69 public void testGetNotebookInfos() { 73 final List<NotebookInfo> notebookInfoList = jdbcNotebookDao.getNotebookInfos( new UserIdentifier(TestBackendConstants._TEST_UID_2_));70 final List<NotebookInfo> notebookInfoList = jdbcNotebookDao.getNotebookInfos(UUID.fromString(TestBackendConstants._TEST_UID_2_)); 74 71 assertEquals(2, notebookInfoList.size()); 75 72 assertEquals("a notebook", notebookInfoList.get(0).getTitle()); … … 96 93 }); 97 94 98 final List<Notebook> notebooks = jdbcNotebookDao.getUsersNotebooks( new UserIdentifier(TestBackendConstants._TEST_UID_2_));95 final List<Notebook> notebooks = jdbcNotebookDao.getUsersNotebooks(UUID.fromString(TestBackendConstants._TEST_UID_2_)); 99 96 100 97 … … 115 112 }); 116 113 117 final List<Notebook> notebooksEmpty = jdbcNotebookDao.getUsersNotebooks( new UserIdentifier(TestBackendConstants._TEST_UID_1_));114 final List<Notebook> notebooksEmpty = jdbcNotebookDao.getUsersNotebooks(UUID.fromString(TestBackendConstants._TEST_UID_1_)); 118 115 assertEquals(0, notebooksEmpty.size()); 119 116 } … … 124 121 @Test 125 122 public void testAddNotebook() throws URISyntaxException { 126 final NotebookIdentifier addedNotebookId = jdbcNotebookDao.addNotebook(new UserIdentifier(TestBackendConstants._TEST_UID_2_), "a title");127 assertEquals(36, addedNotebookId. getUUID().toString().length());123 final UUID addedNotebookId = jdbcNotebookDao.addNotebook(UUID.fromString(TestBackendConstants._TEST_UID_2_), "a title"); 124 assertEquals(36, addedNotebookId.toString().length()); 128 125 } 129 126 … … 134 131 public void testDeleteNotebook() { 135 132 System.out.println("deleteNotebook"); 136 NotebookIdentifier notebookId = new NotebookIdentifier(new UUID(0, 2));133 UUID notebookId = UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID); 137 134 int result = jdbcNotebookDao.deleteNotebook(notebookId); 138 135 assertEquals(1, result); … … 164 161 // test four, null-notebook 165 162 final List<Number> annotationIDsFour = jdbcNotebookDao.getAnnotationIDs(null); 166 assertEquals( null, annotationIDsFour);163 assertEquals(0, annotationIDsFour.size()); 167 164 168 165 … … 200 197 setMockeryNotebookNonExisting(); 201 198 List<ResourceREF> testListFive = jdbcNotebookDao.getAnnotationREFsOfNotebook(null); 202 assertEquals( null, testListFive);199 assertEquals(0, testListFive.size()); 203 200 } 204 201 … … 264 261 265 262 // test One 266 Number resultOne= jdbcNotebookDao.get NotebookID(new NotebookIdentifier(TestBackendConstants._TEST_NOTEBOOK_3_EXT));263 Number resultOne= jdbcNotebookDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_3_EXT)); 267 264 assertEquals(3, resultOne.intValue()); 268 265 269 266 270 267 // test Three Null-notebook 271 Number resultThree= jdbcNotebookDao.get NotebookID(null);268 Number resultThree= jdbcNotebookDao.getInternalID(null); 272 269 assertEquals(null, resultThree); 273 270 } … … 282 279 { 283 280 oneOf(annotationDao).getExternalID(2); 284 will(returnValue( new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT)));281 will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT))); 285 282 286 283 oneOf(annotationDao).getExternalID(3); 287 will(returnValue( new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_3_EXT)));284 will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT))); 288 285 } 289 286 }); 290 287 291 List< AnnotationIdentifier> resultOne= jdbcNotebookDao.getAnnotationExternalIDs(new NotebookIdentifier(TestBackendConstants._TEST_NOTEBOOK_3_EXT));288 List<UUID> resultOne= jdbcNotebookDao.getAnnotationExternalIDs(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_3_EXT)); 292 289 assertEquals(TestBackendConstants._TEST_ANNOT_2_EXT, resultOne.get(0).toString()); 293 290 assertEquals(TestBackendConstants._TEST_ANNOT_3_EXT, resultOne.get(1).toString()); … … 296 293 297 294 // test Two, non-existing notebook 298 List< AnnotationIdentifier> resultThree= jdbcNotebookDao.getAnnotationExternalIDs(null);299 assertEquals( null, resultThree);295 List<UUID> resultThree= jdbcNotebookDao.getAnnotationExternalIDs(null); 296 assertEquals(0, resultThree.size()); 300 297 301 298 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java
r3450 r3455 19 19 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;22 21 import eu.dasish.annotation.schema.Source; 23 22 import eu.dasish.annotation.schema.SourceInfo; … … 25 24 import java.util.ArrayList; 26 25 import java.util.List; 26 import java.util.UUID; 27 27 import org.junit.Test; 28 28 import static org.junit.Assert.*; … … 50 50 System.out.println("getExternalID"); 51 51 Number internalID = 1; 52 SourceIdentifierresult = jdbcSourceDao.getExternalID(internalID);52 UUID result = jdbcSourceDao.getExternalID(internalID); 53 53 assertEquals(TestBackendConstants._TEST_SOURCE_1_EXT_ID, result.toString()); 54 54 } … … 60 60 public void testGetInternalId() { 61 61 System.out.println("getInternalId"); 62 SourceIdentifier externalID = new SourceIdentifier(TestBackendConstants._TEST_SOURCE_1_EXT_ID);62 UUID externalID = UUID.fromString(TestBackendConstants._TEST_SOURCE_1_EXT_ID); 63 63 Number expResult = 1; 64 64 Number result = jdbcSourceDao.getInternalID(externalID); … … 128 128 freshSource.setLink(link); 129 129 freshSource.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID); 130 freshSource.setURI(( new SourceIdentifier()).toString());130 freshSource.setURI((UUID.randomUUID()).toString()); 131 131 freshSource.setTimeSatmp(null); 132 132 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDaoTest.java
r3309 r3455 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 21 import eu.dasish.annotation.backend.TestInstances; 22 import eu.dasish.annotation.backend.identifiers.UserIdentifier;22 import java.util.UUID; 23 23 import org.junit.Test; 24 24 import static org.junit.Assert.*; … … 43 43 /** 44 44 * Test of getInternalID method, of class JdbcUserDao. Number 45 * getInternalID(U serIdentifier userIDentifier);45 * getInternalID(UUID UUID); 46 46 */ 47 47 @Test 48 48 public void testGetInternalID() { 49 Number testOne = jdbcUserDao.getInternalID( new UserIdentifier(TestBackendConstants._TEST_USER_3_EXT_ID));49 Number testOne = jdbcUserDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_USER_3_EXT_ID)); 50 50 assertEquals(3, testOne.intValue()); 51 51 52 Number testTwo = jdbcUserDao.getInternalID( new UserIdentifier(TestBackendConstants._TEST_USER_XXX_EXT_ID));52 Number testTwo = jdbcUserDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_USER_XXX_EXT_ID)); 53 53 assertEquals(null, testTwo); 54 54 … … 59 59 60 60 /** 61 * public U serIdentifiergetExternalID(Number internalId)61 * public UUID getExternalID(Number internalId) 62 62 */ 63 63 @Test 64 64 public void testGetExternalID() { 65 U serIdentifiertestOne = jdbcUserDao.getExternalID(3);65 UUID testOne = jdbcUserDao.getExternalID(3); 66 66 assertEquals(TestBackendConstants._TEST_USER_3_EXT_ID, testOne.toString()); 67 67 68 U serIdentifiertestTwo = jdbcUserDao.getExternalID(null);69 assertEquals(null, testTwo .getUUID());68 UUID testTwo = jdbcUserDao.getExternalID(null); 69 assertEquals(null, testTwo); 70 70 } 71 71 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDaoTest.java
r3450 r3455 19 19 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;22 21 import eu.dasish.annotation.schema.Version; 23 22 import java.util.ArrayList; 24 23 import java.util.List; 24 import java.util.UUID; 25 25 import org.junit.Test; 26 26 import static org.junit.Assert.*; … … 49 49 System.out.println("getExternalId"); 50 50 Number internalID = 1; 51 VersionIdentifierresult = jdbcVersionDao.getExternalID(internalID);51 UUID result = jdbcVersionDao.getExternalID(internalID); 52 52 assertEquals(TestBackendConstants._TEST_VERSION_1_EXT_ID, result.toString()); 53 53 } … … 59 59 public void testGetInternalId() { 60 60 System.out.println("getInternalId"); 61 VersionIdentifier externalID = new VersionIdentifier(TestBackendConstants._TEST_VERSION_1_EXT_ID);61 UUID externalID = UUID.fromString(TestBackendConstants._TEST_VERSION_1_EXT_ID); 62 62 Number expResult = 1; 63 63 Number result = jdbcVersionDao.getInternalID(externalID); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r3453 r3455 23 23 import eu.dasish.annotation.backend.TestBackendConstants; 24 24 import eu.dasish.annotation.backend.TestInstances; 25 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;26 import eu.dasish.annotation.backend.identifiers.UserIdentifier;27 25 import eu.dasish.annotation.schema.Annotation; 28 26 import eu.dasish.annotation.schema.ResourceREF; … … 39 37 import java.lang.InstantiationException; 40 38 import java.sql.Timestamp; 39 import java.util.UUID; 41 40 import javax.servlet.ServletException; 42 41 import javax.xml.datatype.DatatypeConfigurationException; 43 import org.junit.Ignore;44 42 import org.springframework.mock.web.MockHttpServletRequest; 45 43 /** … … 71 69 public void testGetAnnotation() throws SQLException { 72 70 System.out.println("getAnnotation"); 73 final String annotationIdentifier= TestBackendConstants._TEST_ANNOT_2_EXT;71 final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT; 74 72 final int annotationID = 2; 75 73 final Annotation expectedAnnotation = (new TestInstances()).getAnnotationOne(); 76 74 77 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier));78 //final Annotation annotation = daoDispatcher.getAnnotation(annotationID);79 75 mockery.checking(new Expectations() { 80 76 { 81 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(a NonNull(AnnotationIdentifier.class)));77 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(any(UUID.class))); 82 78 will(returnValue(annotationID)); 83 79 … … 87 83 }); 88 84 89 JAXBElement<Annotation> result = annotationResource.getAnnotation( annotationIdentifier);85 JAXBElement<Annotation> result = annotationResource.getAnnotation(externalIDstring); 90 86 assertEquals(expectedAnnotation, result.getValue()); 91 87 } … … 97 93 public void testDeleteAnnotation() throws SQLException { 98 94 System.out.println("deleteAnnotation"); 99 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier( new AnnotationIdentifier(annotationIdentifier));95 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID)); 100 96 //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID); 101 97 … … 107 103 mockery.checking(new Expectations() { 108 104 { 109 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull( AnnotationIdentifier.class)));105 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class))); 110 106 will(returnValue(5)); 111 107 … … 129 125 // Number userID = null; 130 126 // if (remoteUser != null) { 131 // userID = daoDispatcher.getUserInternalIdentifier( new UserIdentifier(remoteUser));127 // userID = daoDispatcher.getUserInternalIdentifier(UUID.fromString(remoteUser)); 132 128 // } 133 129 // Number newAnnotationID = daoDispatcher.addUsersAnnotation(annotation, userID); … … 140 136 owner.setRef(ownerString); 141 137 addedAnnotation.setOwner(owner); 142 addedAnnotation.setURI(( new AnnotationIdentifier()).toString());138 addedAnnotation.setURI((UUID.randomUUID()).toString()); 143 139 addedAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000"))); 144 140 145 141 mockery.checking(new Expectations() { 146 142 { 147 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(U serIdentifier.class)));143 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UUID.class))); 148 144 will(returnValue(ownerID)); 149 145 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java
r3453 r3455 20 20 import eu.dasish.annotation.backend.dao.DaoDispatcher; 21 21 import com.sun.jersey.api.client.ClientResponse; 22 import com.sun.jersey.api.client.GenericType;23 22 import eu.dasish.annotation.backend.Helpers; 24 23 import eu.dasish.annotation.backend.TestBackendConstants; 25 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;26 import eu.dasish.annotation.backend.identifiers.UserIdentifier;27 24 import eu.dasish.annotation.schema.Annotation; 28 import eu.dasish.annotation.schema.AnnotationBody;29 import eu.dasish.annotation.schema.ObjectFactory;30 25 import eu.dasish.annotation.schema.ResourceREF; 31 26 import java.sql.SQLException; 32 27 import java.sql.Timestamp; 28 import java.util.UUID; 33 29 import javax.ws.rs.core.MediaType; 34 30 import javax.xml.bind.JAXBElement; … … 59 55 public void testGetAnnotation() throws SQLException, DatatypeConfigurationException{ 60 56 System.out.println("testGetAnnotation"); 61 final String annotationIdentifier= TestBackendConstants._TEST_ANNOT_2_EXT;57 final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT; 62 58 final int annotationID = 2; 63 59 final Annotation testAnnotation = new Annotation(); … … 65 61 owner.setRef("5"); 66 62 testAnnotation.setOwner(owner); 67 testAnnotation.setURI( (new AnnotationIdentifier()).toString());63 testAnnotation.setURI(externalIDstring); 68 64 testAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000"))); 69 65 70 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier( new AnnotationIdentifier(annotationIdentifier));66 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID)); 71 67 //final Annotation annotation = daoDispatcher.getAnnotation(annotationID); 72 68 mockery.checking(new Expectations() { 73 69 { 74 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull( AnnotationIdentifier.class)));70 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class))); 75 71 will(returnValue(annotationID)); 76 72 … … 80 76 }); 81 77 82 final String requestUrl = "annotations/" + annotationIdentifier;78 final String requestUrl = "annotations/" + externalIDstring; 83 79 System.out.println("requestUrl: " + requestUrl); 84 80 ClientResponse response = resource().path(requestUrl).accept(MediaType.TEXT_XML).get(ClientResponse.class); … … 101 97 public void testDeleteAnnotation() throws SQLException{ 102 98 System.out.println("testDeleteAnnotation"); 103 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier( new AnnotationIdentifier(annotationIdentifier));99 //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID)); 104 100 //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID); 105 101 … … 111 107 mockery.checking(new Expectations() { 112 108 { 113 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull( AnnotationIdentifier.class)));109 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class))); 114 110 will(returnValue(5)); 115 111 … … 139 135 final JAXBElement<Annotation> jaxbElement = new JAXBElement<Annotation>(new QName("http://www.dasish.eu/ns/addit", "annotation"), Annotation.class, null, annotationToAdd); 140 136 //final Annotation annotToAddJB = jaxbElement.getValue(); 141 142 // for setting up mockery 143 //userID = daoDispatcher.getUserInternalIdentifier(new UserIdentifier(remoteUser)); 144 //Number newAnnotationID = daoDispatcher.addUsersAnnotation(annotation, userID); 145 //Annotation newAnnotation = daoDispatcher.getAnnotation(newAnnotationID); 137 146 138 final String ownerString = "5"; 147 139 final Number ownerID = 5; … … 151 143 owner.setRef(ownerString); 152 144 addedAnnotation.setOwner(owner); 153 addedAnnotation.setURI(( new AnnotationIdentifier()).toString());145 addedAnnotation.setURI((UUID.randomUUID()).toString()); 154 146 155 147 addedAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000"))); 156 148 mockery.checking(new Expectations() { 157 149 { 158 oneOf(daoDispatcher).getUserInternalIdentifier(with(a NonNull(UserIdentifier.class)));150 oneOf(daoDispatcher).getUserInternalIdentifier(with(any(UUID.class))); 159 151 will(returnValue(ownerID)); 160 152 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java
r3453 r3455 20 20 import eu.dasish.annotation.backend.TestBackendConstants; 21 21 import eu.dasish.annotation.backend.dao.NotebookDao; 22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;23 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;24 import eu.dasish.annotation.backend.identifiers.UserIdentifier;25 22 import eu.dasish.annotation.schema.Notebook; 26 23 import eu.dasish.annotation.schema.NotebookInfo; … … 71 68 mockery.checking(new Expectations() { 72 69 { 73 oneOf(notebookDao).getNotebookInfos( new UserIdentifier(httpServletRequest.getRemoteUser()));70 oneOf(notebookDao).getNotebookInfos(UUID.fromString(httpServletRequest.getRemoteUser())); 74 71 will(returnValue(new ArrayList<NotebookInfo>())); 75 72 } … … 87 84 mockery.checking(new Expectations() { 88 85 { 89 oneOf(notebookDao).getUsersNotebooks( new UserIdentifier(TestBackendConstants._TEST_UID_2_));86 oneOf(notebookDao).getUsersNotebooks(UUID.fromString(TestBackendConstants._TEST_UID_2_)); 90 87 will(returnValue(new ArrayList<Notebook>())); 91 88 } … … 107 104 mockery.checking(new Expectations() { 108 105 { 109 oneOf(notebookDao).addNotebook( new UserIdentifier(httpServletRequest.getRemoteUser()), null);110 will(returnValue( new NotebookIdentifier(new UUID(0, 1))));106 oneOf(notebookDao).addNotebook(UUID.fromString(httpServletRequest.getRemoteUser()), null); 107 will(returnValue(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_1_EXT_ID))); 111 108 } 112 109 }); … … 122 119 public void testDeleteNotebook() { 123 120 System.out.println("deleteNotebook"); 124 final NotebookIdentifier notebookIdentifier = new NotebookIdentifier(new UUID(0, 1));121 final UUID externalID = UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_1_EXT_ID); 125 122 mockery.checking(new Expectations() { 126 123 { 127 oneOf(notebookDao).deleteNotebook( notebookIdentifier);124 oneOf(notebookDao).deleteNotebook(externalID); 128 125 will(returnValue(1)); 129 126 } 130 127 }); 131 128 String expResult = "1"; 132 String result = notebookResource.deleteNotebook( notebookIdentifier);129 String result = notebookResource.deleteNotebook(externalID); 133 130 assertEquals(expResult, result); 134 131 } … … 143 140 System.out.println("test GetMetadata"); 144 141 145 final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;142 final String externalID= TestBackendConstants._TEST_NOTEBOOK_3_EXT; 146 143 final int notebookID = 3; 147 144 final NotebookInfo testInfo = new ObjectFactory().createNotebookInfo(); … … 149 146 mockery.checking(new Expectations() { 150 147 { 151 oneOf(notebookDao).get NotebookID(new NotebookIdentifier(notebookIdentifier));148 oneOf(notebookDao).getInternalID(UUID.fromString(externalID)); 152 149 will(returnValue(notebookID)); 153 150 … … 157 154 }); 158 155 159 JAXBElement<NotebookInfo> result = notebookResource.getMetadata( notebookIdentifier);156 JAXBElement<NotebookInfo> result = notebookResource.getMetadata(externalID); 160 157 NotebookInfo entity = result.getValue(); 161 158 assertEquals(testInfo.getRef(), entity.getRef()); … … 167 164 public void testGetAllAnnotations() { 168 165 System.out.println("test getAllAnnotations"); 169 final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;170 final AnnotationIdentifier aIdOne= new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT);171 final AnnotationIdentifier aIdTwo= new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_3_EXT);172 final List< AnnotationIdentifier> annotationIds = new ArrayList<AnnotationIdentifier>();166 final String externalID= TestBackendConstants._TEST_NOTEBOOK_3_EXT; 167 final UUID aIdOne= UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT); 168 final UUID aIdTwo= UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT); 169 final List<UUID> annotationIds = new ArrayList<UUID>(); 173 170 annotationIds.add(aIdOne); 174 171 annotationIds.add(aIdTwo); … … 176 173 mockery.checking(new Expectations() { 177 174 { 178 oneOf(notebookDao).getAnnotationExternalIDs( new NotebookIdentifier(notebookIdentifier));175 oneOf(notebookDao).getAnnotationExternalIDs(UUID.fromString(externalID)); 179 176 will(returnValue(annotationIds)); 180 177 … … 182 179 }); 183 180 184 List< AnnotationIdentifier> result= notebookResource.getAllAnnotations(notebookIdentifier, 0, 0, null, 0);181 List<JAXBElement<UUID>> result= notebookResource.getAllAnnotations(externalID, 0, 0, null, 0); 185 182 assertFalse(null==result); 186 assertEquals(aIdOne, result.get(0) );187 assertEquals(aIdTwo, result.get(1) );183 assertEquals(aIdOne, result.get(0).getValue()); 184 assertEquals(aIdTwo, result.get(1).getValue()); 188 185 189 186 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebooksTest.java
r3211 r3455 23 23 import eu.dasish.annotation.backend.TestBackendConstants; 24 24 import eu.dasish.annotation.backend.dao.NotebookDao; 25 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;26 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;27 import eu.dasish.annotation.backend.identifiers.UserIdentifier;28 25 import eu.dasish.annotation.schema.Notebook; 29 26 import eu.dasish.annotation.schema.NotebookInfo; … … 35 32 import java.util.List; 36 33 import java.util.UUID; 37 import javax.ws.rs.core.EntityTag;38 34 import javax.ws.rs.core.MediaType; 39 35 import javax.xml.bind.JAXBElement; … … 69 65 mockery.checking(new Expectations() { 70 66 { 71 oneOf(notebookDao).getNotebookInfos( new UserIdentifier(null));67 oneOf(notebookDao).getNotebookInfos(with(any(UUID.class))); 72 68 will(returnValue(new ArrayList<NotebookInfo>())); 73 69 } … … 86 82 */ 87 83 @Test 88 @Ignore89 84 public void testGetUsersNotebooks() { 90 85 System.out.println("testGetUsersNotebooks"); 91 86 mockery.checking(new Expectations() { 92 87 { 93 oneOf(notebookDao).getUsersNotebooks( new UserIdentifier("userid"));88 oneOf(notebookDao).getUsersNotebooks(with(any(UUID.class))); 94 89 will(returnValue(new ArrayList<Notebook>())); 95 90 } … … 138 133 System.out.println("test GetMetadata"); 139 134 140 final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;135 final String externalIDstring= TestBackendConstants._TEST_NOTEBOOK_3_EXT; 141 136 final int notebookID = 3; 142 137 final NotebookInfo testInfo = new ObjectFactory().createNotebookInfo(); … … 144 139 mockery.checking(new Expectations() { 145 140 { 146 oneOf(notebookDao).get NotebookID(new NotebookIdentifier(notebookIdentifier));141 oneOf(notebookDao).getInternalID(UUID.fromString(externalIDstring)); 147 142 will(returnValue(notebookID)); 148 143 … … 152 147 }); 153 148 154 final String requestUrl = "notebooks/" + notebookIdentifier+"/metadata";149 final String requestUrl = "notebooks/" + externalIDstring+"/metadata"; 155 150 System.out.println("requestUrl: " + requestUrl); 156 151 ClientResponse response = resource().path(requestUrl).type(MediaType.TEXT_XML).get(ClientResponse.class); … … 177 172 public void testGetAllAnnotations() { 178 173 System.out.println("test GetMetadata"); 179 final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;180 final AnnotationIdentifier aIdOne= new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT);181 final AnnotationIdentifier aIdTwo= new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_3_EXT);182 final List< AnnotationIdentifier> annotationIds = new ArrayList<AnnotationIdentifier>();174 final String externalIDstring= TestBackendConstants._TEST_NOTEBOOK_3_EXT; 175 final UUID aIdOne= UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT); 176 final UUID aIdTwo= UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT); 177 final List<UUID> annotationIds = new ArrayList<UUID>(); 183 178 annotationIds.add(aIdOne); 184 179 annotationIds.add(aIdTwo); … … 186 181 mockery.checking(new Expectations() { 187 182 { 188 oneOf(notebookDao).getAnnotationExternalIDs( new NotebookIdentifier(notebookIdentifier));183 oneOf(notebookDao).getAnnotationExternalIDs(with(aNonNull(UUID.class))); 189 184 will(returnValue(annotationIds)); 190 185 … … 192 187 }); 193 188 194 final String requestUrl = "notebooks/"+ notebookIdentifier;189 final String requestUrl = "notebooks/"+externalIDstring; 195 190 ClientResponse response = resource().path(requestUrl) 196 191 .queryParam("maximumAnnotations", "123") … … 201 196 System.out.println("requestUrl: " + requestUrl); 202 197 assertEquals(200, response.getStatus()); 203 List< AnnotationIdentifier> result = response.getEntity(new GenericType<List<AnnotationIdentifier>>() {});204 assertEquals(aIdOne, result.get(0) );205 assertEquals(aIdTwo, result.get(1) );198 List<JAXBElement<UUID>> result = response.getEntity(new GenericType<List<JAXBElement<UUID>>>() {}); 199 assertEquals(aIdOne, result.get(0).getValue()); 200 assertEquals(aIdTwo, result.get(1).getValue()); 206 201 } 207 202 … … 251 246 mockery.checking(new Expectations() { 252 247 { 253 oneOf(notebookDao).addNotebook( new UserIdentifier(null), null);254 will(returnValue( new NotebookIdentifier(new UUID(0, 1))));248 oneOf(notebookDao).addNotebook(with(any(UUID.class)), with(any(String.class))); 249 will(returnValue(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_1_EXT_ID))); 255 250 } 256 251 }); … … 284 279 mockery.checking(new Expectations() { 285 280 { 286 oneOf(notebookDao).deleteNotebook( new NotebookIdentifier(new UUID(0, 2)));281 oneOf(notebookDao).deleteNotebook(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID)); 287 282 will(returnValue(1)); 288 283 } 289 284 }); 290 final String requestUrl = "notebooks/" + new UUID(0, 2).toString();285 final String requestUrl = "notebooks/" + TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID; 291 286 System.out.println("requestUrl: " + requestUrl); 292 287 ClientResponse response = resource().path(requestUrl).delete(ClientResponse.class);
Note: See TracChangeset
for help on using the changeset viewer.