Changeset 3455


Ignore:
Timestamp:
08/22/13 12:17:19 (11 years ago)
Author:
olhsha
Message:

replacing DaishIdentifier?-based classes with simply UUID. tested. Works, excpet that UUID seems not be be serailizable, see e.g. getAllAnnotations in NotebookResource? where I have to use Peter's workoaroun to put UUID in JAXBElement<UUID>

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  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    2120import eu.dasish.annotation.schema.Annotation;
    2221import eu.dasish.annotation.schema.AnnotationInfo;
     
    3938public interface AnnotationDao extends ResourceDao{
    4039   
    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   
    4742   
    4843   
     
    5146     * @param annotationID
    5247     * @return the Annotation object with empty list of sources
    53      * constructing a complete Annotation object from there sult and "retrieveSourceIDs" is done in "DaoDispatchter"
     48     * constructing a complete Annotation object from the result and "retrieveSourceIDs" is done in "DaoDispatchter"
    5449     *
    5550     */
    5651    public Annotation getAnnotationWithoutSources(Number annotationID) throws SQLException;
    5752   
     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 ///////////////////////
    58146   
    59147    /**
     
    63151     */
    64152   
     153   
     154   
    65155    public int deleteAnnotation(Number annotationId) throws SQLException;
    66156   
     
    74164   
    75165   
    76     /**
    77      *
    78      * @param annotation added to the table with annotations
    79      * @return  internal Id of the added annotation
    80      **/
    81    
    82     public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException;
    83  
    84      
    85     /**
    86      *
    87      * @param link optional
    88      * @param text optional
    89      * @param access optional
    90      * @param namespace optional TODO: do not know what to do with it
    91      * @param owner optional
    92      * @param after optional
    93      * @param before optional
    94      * @return the list of internal annotation identifiers for annotations
    95      * -- 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 annotationIDs
    109      * @return the list of annotationInfos (owner, headline, target sources, external_id) for the internal Ids from the  input list
    110      * used on the second step for GET api/annotations?<filters>
    111      */
    112     public List<AnnotationInfo> getAnnotationInfos(List<Number> annotationIDs);   
    113      
    114166   
    115    
    116     public List<ResourceREF> getAnnotationREFs(List<Number> annotationIDs);
    117    
    118     /**
    119      *
    120      * @param sourceIDs
    121      * @return the list of annotationdIDs of the annotations that are having target sources from "sourceIDs" list
    122      */
    123     public List<Number> retrieveAnnotationList(List<Number> sourceIDs);
    124    
    125    
    126     // NOT TESTED
    127     public int updateBody(Number annotationID, String serializedNewBody);
    128    
    129      /**
    130      *
    131      * @param annotationID
    132      * @return the list of the source's internal IDs of all the target sources of annotationID
    133      */
    134     public List<Number> retrieveSourceIDs(Number annotationID);
    135    
    136     public int addAnnotationSourcePair(Number annotationID, Number sourceID) throws SQLException;
    137    
    138167    public int deleteAnnotationPrincipalPermissions(Number annotationID) throws SQLException ;
    139168
    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 
    155171   
    156172}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/CachedRepresentationDao.java

    r3407 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;
    2120import eu.dasish.annotation.schema.CachedRepresentationInfo;
    2221
     
    2524 * @author olhsha
    2625 */
    27 public interface CachedRepresentationDao {
     26public interface CachedRepresentationDao extends ResourceDao{
    2827   
    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 
    4430 
    4531    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/DaoDispatcher.java

    r3452 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    21 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2220import eu.dasish.annotation.schema.Annotation;
    2321import eu.dasish.annotation.schema.CachedRepresentationInfo;
     
    2826import java.util.List;
    2927import java.util.Map;
     28import java.util.UUID;
    3029
    3130/**
     
    5554    Annotation getAnnotation(Number annotationID) throws SQLException;
    5655
    57     AnnotationIdentifier getAnnotationExternalIdentifier(Number annotationID);
     56    UUID getAnnotationExternalIdentifier(Number annotationID);
    5857
    5958    ///////////// GETTERS //////////////////////////
    60     Number getAnnotationInternalIdentifier(AnnotationIdentifier annotationIdentifier);
     59    Number getAnnotationInternalIdentifier(UUID UUID);
    6160
    6261    ////////////////////////////////////////////////////////////////////////
    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);
    6464
    65     UserIdentifier getUserExternalIdentifier(Number userID);
     65    UUID getUserExternalIdentifier(Number userID);
    6666
    67     Number getUserInternalIdentifier(UserIdentifier userIdentifier);
     67    Number getUserInternalIdentifier(UUID UUID);
    6868   
    6969}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/NotebookDao.java

    r3218 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    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
    2321import eu.dasish.annotation.schema.Annotations;
    2422import eu.dasish.annotation.schema.Notebook;
     
    2624import eu.dasish.annotation.schema.ResourceREF;
    2725import java.util.List;
     26import java.util.UUID;
    2827
    2928/**
     
    3534
    3635    // Returns a list of notebook-info for the notebooks accessible to the current user.
    37     List<NotebookInfo> getNotebookInfos(UserIdentifier userID);
     36    List<NotebookInfo> getNotebookInfos(UUID userID);
    3837
    3938    // Returns the list of all notebooks owned by the current logged user.
    40     List<Notebook> getUsersNotebooks(UserIdentifier userID);
     39    List<Notebook> getUsersNotebooks(UUID userID);
    4140
    4241    // Creates a new notebook and returns the _nid_ of the created Notebook
    43     NotebookIdentifier addNotebook(UserIdentifier userID, String title);
     42    UUID addNotebook(UUID userID, String title);
    4443
    4544    // Delete _nid_. Annotations stay, they just lose connection to _nid_.<br>
    4645    // returns the number of records deleted
    47     public int deleteNotebook(NotebookIdentifier notebookId);
     46    public int deleteNotebook(UUID notebookId);
    4847
    4948    // Adds an annotation _aid_ to the list of annotations of _nid_.
    50     public int addAnnotation(NotebookIdentifier notebookId, AnnotationIdentifier annotationId);
     49    public int addAnnotation(UUID notebookId, UUID annotationId);
    5150   
    5251     // Returns the list of annotation Id-s  for the notebook id.
    53     List<Number> getAnnotationIDs(Number notebookID);
     52    public List<Number> getAnnotationIDs(Number notebookID);
    5453   
    5554      /*Returns the list of annotation info-s  for the notebook id.
     
    5756   
    5857      // Returns the list of annotations Id-s  for the notebook id.
    59     List<ResourceREF> getAnnotationREFsOfNotebook(Number notebookID);
     58    public List<ResourceREF> getAnnotationREFsOfNotebook(Number notebookID);
    6059   
    6160    // Returns the Annotations object for the notebook id.
    62     Annotations getAnnotations(Number notebookID);
     61    public Annotations getAnnotations(Number notebookID);
    6362   
    6463    /**
     
    7069    NotebookInfo getNotebookInfo(Number notebookID);
    7170   
    72     /**
    73      *
    74      * @param externalId
    75      * @return the notebook's internal ID, given its extrnalId
    76      */
    77     Number getNotebookID(NotebookIdentifier externalId);
     71 
    7872   
    7973     /**
     
    8175     * @return returns the externalIds of the annotations contained in the notebookId
    8276     */
    83     List<AnnotationIdentifier> getAnnotationExternalIDs(NotebookIdentifier notebookId);
     77    List<UUID> getAnnotationExternalIDs(UUID notebookId);
    8478   
    8579    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/ResourceDao.java

    r3380 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.DasishIdentifier;
     20import java.util.UUID;
    2121
    2222/**
     
    3131     * @return internal identifier of the resource with externalID
    3232     */
    33     public <T extends DasishIdentifier> Number getInternalID(T externalId);
     33    public Number getInternalID(UUID externalId);
    3434   
    35    
     35    public UUID getExternalID(Number internalId);
    3636}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/SourceDao.java

    r3411 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;
    2120import eu.dasish.annotation.schema.Source;
    2221import eu.dasish.annotation.schema.SourceInfo;
     
    3029public interface SourceDao extends ResourceDao{
    3130   
    32      /**
    33      *
    34      * @param internalID
    35      * @return extrnalID identifier of the resource with internalID
    36      */
    37     public SourceIdentifier getExternalID(Number internalID);
    38    
    39    
     31 
    4032   
    4133    /**
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/UserDao.java

    r3309 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2120
    2221/**
     
    2726   
    2827 
    29     /**
    30      *
    31      * @param internalId
    32      * @return the external UserIdentifier of internalId;
    33      */
    34     UserIdentifier getExternalID(Number internalID);
     28 
    3529}
    3630
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/VersionDao.java

    r3408 r3455  
    1818package eu.dasish.annotation.backend.dao;
    1919
    20 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;
    2120import eu.dasish.annotation.schema.Version;
    2221import java.util.List;
     
    2625 * @author olhsha
    2726 */
    28 public interface VersionDao {
     27public interface VersionDao extends ResourceDao{
    2928   
    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 
    4630    /**
    4731     *
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DaoDispatcherImpl.java

    r3452 r3455  
    2626import eu.dasish.annotation.backend.dao.UserDao;
    2727import 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;
    3328import eu.dasish.annotation.schema.Annotation;
    3429import eu.dasish.annotation.schema.CachedRepresentationInfo;
     
    4540import java.util.List;
    4641import java.util.Map;
     42import java.util.UUID;
    4743import org.springframework.beans.factory.annotation.Autowired;
    4844
     
    7066
    7167    @Override
    72     public Number getAnnotationInternalIdentifier(AnnotationIdentifier annotationIdentifier) {
    73         return annotationDao.getInternalID(annotationIdentifier);
    74     }
    75 
    76     @Override
    77     public AnnotationIdentifier getAnnotationExternalIdentifier(Number annotationID) {
     68    public Number getAnnotationInternalIdentifier(UUID UUID) {
     69        return annotationDao.getInternalID(UUID);
     70    }
     71
     72    @Override
     73    public UUID getAnnotationExternalIdentifier(Number annotationID) {
    7874        return annotationDao.getExternalID(annotationID);
    7975    }
    8076
    8177    @Override
    82     public Number getUserInternalIdentifier(UserIdentifier userIdentifier) {
    83         return userDao.getInternalID(userIdentifier);
    84     }
    85 
    86     @Override
    87     public UserIdentifier getUserExternalIdentifier(Number userID) {
     78    public Number getUserInternalIdentifier(UUID UUID) {
     79        return userDao.getInternalID(UUID);
     80    }
     81
     82    @Override
     83    public UUID getUserExternalIdentifier(Number userID) {
    8884        return userDao.getExternalID(userID);
    8985    }
     
    110106    ////////////////////////////////////////////////////////////////////////
    111107    @Override
    112     public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UserIdentifier owner, Timestamp after, Timestamp before) {
     108    public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UUID owner, Timestamp after, Timestamp before) {
    113109
    114110        List<Number> annotationIDs = null;
     
    136132    public Number[] addCachedForVersion(Number versionID, CachedRepresentationInfo cached) {
    137133        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);
    139137        if (result[1] == null) {
    140138            result[1] = cachedRepresentationDao.addCachedRepresentationInfo(cached);
     
    149147      public Number[] addSiblingVersionForSource(Number sourceID, Version version) throws SQLException {
    150148        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);
    152152        if (result[1] == null) {
    153153            result[1] = versionDao.addVersion(version);
     
    164164            SourceInfo source = noesi.getSource();
    165165            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())));
    167167            } else {
    168168                Source newSource = createSource(noesi.getNewSource());
     
    277277    private Source createSource(NewSourceInfo newSource) {
    278278        Source source = new Source();
    279         SourceIdentifier externalIdentifier = new SourceIdentifier();
     279        UUID externalIdentifier = UUID.randomUUID();
    280280        source.setURI(externalIdentifier.toString());
    281281        source.setLink(newSource.getLink());
     
    286286    private Version createVersion(NewSourceInfo newSource) {
    287287        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,
    290290        return version;
    291291    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java

    r3413 r3455  
    2020import eu.dasish.annotation.backend.Helpers;
    2121import eu.dasish.annotation.backend.dao.AnnotationDao;
    22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    2322import eu.dasish.annotation.schema.Annotation;
    2423import eu.dasish.annotation.schema.AnnotationInfo;
     
    3332import java.util.List;
    3433import java.util.Map;
     34import java.util.UUID;
    3535import javax.sql.DataSource;
    3636import javax.xml.datatype.DatatypeConfigurationException;
     
    4949        resourceTableName = annotationTableName;
    5050    }
    51 
     51   
     52 
    5253    @Override
    5354    public List<Number> retrieveSourceIDs(Number annotationID) {
     
    252253    public Number addAnnotation(Annotation annotation, Number ownerID) throws SQLException {
    253254        // generate a new annotation ID
    254         AnnotationIdentifier annotationIdentifier = new AnnotationIdentifier();
     255        UUID externalID = UUID.randomUUID();
    255256        Map<String, Object> params = new HashMap<String, Object>();
    256         params.put("externalId", annotationIdentifier.toString());
     257        params.put("externalId", externalID.toString());
    257258        params.put("ownerId", ownerID);
    258259        params.put("headline", annotation.getHeadline());
     
    264265        int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);
    265266        if (affectedRows == 1) {
    266             return getInternalID(annotationIdentifier);
     267            return getInternalID(externalID);
    267268        } else {
    268269            return null;
     
    271272    }
    272273
    273     //////////////////////////////////////////////////
    274     @Override
    275     public AnnotationIdentifier getExternalID(Number internalID) {
    276         return new AnnotationIdentifier(super.getExternalIdentifier(internalID));
    277     }
    278 
     274   
    279275    ///////////////////////////////////////////////////////////////////////
    280276    @Override
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java

    r3408 r3455  
    1919
    2020import eu.dasish.annotation.backend.dao.CachedRepresentationDao;
    21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;
    2221import eu.dasish.annotation.schema.CachedRepresentationInfo;
     22import java.lang.String;
    2323import java.sql.ResultSet;
    2424import java.sql.SQLException;
     
    2626import java.util.List;
    2727import java.util.Map;
     28import java.util.UUID;
    2829import javax.sql.DataSource;
    2930import org.springframework.jdbc.core.RowMapper;
     
    4243    }
    4344
    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 
    5646
    5747    ///////////////////////////////////////////////////////////////////////////////////////
     
    8777    public Number addCachedRepresentationInfo(CachedRepresentationInfo cached) {
    8878
    89         CachedRepresentationIdentifier externalIdentifier = new CachedRepresentationIdentifier();
    90 
     79        UUID externalIdentifier = UUID.randomUUID();
    9180        Map<String, Object> params = new HashMap<String, Object>();
    9281        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  
    2020import eu.dasish.annotation.backend.dao.AnnotationDao;
    2121import 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;
    2522import eu.dasish.annotation.schema.Annotations;
    2623import eu.dasish.annotation.schema.Notebook;
     
    3431import java.util.List;
    3532import java.util.Map;
     33import java.util.UUID;
    3634import javax.sql.DataSource;
    3735import org.springframework.jdbc.core.RowMapper;
     
    5452
    5553    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) {
    6161        String sql = "SELECT " + notebookTitle + ", " + notebookExternal_id + " FROM " + notebookTableName + ", " + principalTableName + " where " + principalPrincipal_id + " = " + notebookOwner_id + " and " + principalExternal_id + " = ?";
    6262        return getSimpleJdbcTemplate().query(sql, notebookInfoRowMapper, userID.toString());
     
    6464
    6565    @Override
    66     public List<Notebook> getUsersNotebooks(UserIdentifier userID) {
     66    public List<Notebook> getUsersNotebooks(UUID userID) {
    6767        String sql = "SELECT " + notebookStar + " FROM " + notebookTableName + ", " + principalTableName + " where " + principal_id + " = " + owner_id + " and " + principalExternal_id + " = ?";
    6868        return getSimpleJdbcTemplate().query(sql, notebookRowMapper, userID.toString());
     
    7070
    7171    @Override
    72     public NotebookIdentifier addNotebook(UserIdentifier userID, String title) {
     72    public UUID addNotebook(UUID userID, String title) {
    7373        try {
    74             final NotebookIdentifier notebookIdentifier = new NotebookIdentifier();
     74            final UUID externalIdentifier = UUID.randomUUID();
    7575            String sql = "INSERT INTO " + notebookTableName + " (" + external_id + ", " + this.title + "," + owner_id + ") VALUES (:notebookId, :title, (SELECT " + principal_id + " FROM " + principalTableName + " WHERE " + principalExternal_id + " = :userID))";
    7676            Map<String, Object> params = new HashMap<String, Object>();
    77             params.put("notebookId", notebookIdentifier.getUUID().toString());
     77            params.put("notebookId", externalIdentifier.toString());
    7878            params.put("userID", userID.toString());
    7979            params.put("title", title);
    8080            final int updatedRowCount = getSimpleJdbcTemplate().update(sql, params);
    81             return notebookIdentifier;
     81            return externalIdentifier;
    8282        } catch (DataAccessException exception) {
    8383            throw exception;
     
    116116    // returns the number of affected annotations
    117117    @Override
    118     public int deleteNotebook(NotebookIdentifier notebookId) {
     118    public int deleteNotebook(UUID notebookId) {
    119119        String sql1 = "DELETE FROM " + notebooksAnnotationsTableName + " where " + notebook_id + "= (SELECT " + notebook_id + " FROM " + notebookTableName + " WHERE " + external_id + " = ?)";
    120120        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());
    123123        return affectedAnnotations;
    124124    }
    125125
    126126    @Override
    127     public int addAnnotation(NotebookIdentifier notebookId, AnnotationIdentifier annotationId) {
     127    public int addAnnotation(UUID notebookId, UUID annotationId) {
    128128        try {
    129129            SimpleJdbcInsert notebookInsert = new SimpleJdbcInsert(getDataSource()).withTableName(notebooksAnnotationsTableName);
     
    148148    @Override
    149149    public List<Number> getAnnotationIDs(Number notebookID) {
    150         if (notebookID == null) {
    151             return null;
    152         }
    153150        StringBuilder sql = new StringBuilder("SELECT DISTINCT ");
    154151        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);
    156153    }
    157154    private final RowMapper<Number> annotationIDRowMapper = new RowMapper<Number>() {
     
    230227    }
    231228
    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   
    258230    //////////////////////////////////////////////////////////////////
    259231    @Override
    260     public List<AnnotationIdentifier> getAnnotationExternalIDs(NotebookIdentifier notebookId) {
    261         List<Number> internalIds = getAnnotationIDs(getNotebookID(notebookId));
     232    public List<UUID> getAnnotationExternalIDs(UUID notebookId) {
     233        List<Number> internalIds = getAnnotationIDs(getInternalID(notebookId));
    262234        if (internalIds == null) {
    263235            return null;
    264236        }
    265         List<AnnotationIdentifier> annotationIds = new ArrayList<AnnotationIdentifier>();
     237        List<UUID> annotationIds = new ArrayList<UUID>();
    266238        for (Number internalId : internalIds) {
    267239            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  
    2020import eu.dasish.annotation.backend.Helpers;
    2121import eu.dasish.annotation.backend.dao.ResourceDao;
    22 import eu.dasish.annotation.backend.identifiers.DasishIdentifier;
    2322import java.sql.ResultSet;
    2423import java.sql.SQLException;
    2524import java.util.List;
     25import java.util.UUID;
    2626import javax.xml.datatype.DatatypeConfigurationException;
    2727import javax.xml.datatype.XMLGregorianCalendar;
     
    8989    //////////////////////////////////////////////////////////////////////////////////
    9090    @Override
    91     public <T extends DasishIdentifier> Number getInternalID(T externalId) {
     91    public Number getInternalID(UUID externalId) {
    9292        if (externalId == null) {
    9393            return null;
     
    9696        List<Number> sqlResult = getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalId.toString());
    9797
    98         if (sqlResult == null) {
    99             return null;
    100         }
    10198        if (sqlResult.isEmpty()) {
    10299            return null;
     
    116113
    117114   
    118     /////////////////////////////////////////////
    119     protected String getExternalIdentifier(Number internalId) {
    120         if (internalId == null) {
    121             return null;
    122         }
     115    @Override
     116    public UUID getExternalID(Number internalId) {
    123117        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);
    129119        if (sqlResult.isEmpty()) {
    130120            return null;
     
    134124    }
    135125   
    136     protected final RowMapper<String> externalIDRowMapper = new RowMapper<String>() {
     126    protected final RowMapper<UUID> externalIDRowMapper = new RowMapper<UUID>() {
    137127        @Override
    138         public String mapRow(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)));
    140130        }
    141131    };
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java

    r3413 r3455  
    2020import eu.dasish.annotation.backend.Helpers;
    2121import eu.dasish.annotation.backend.dao.SourceDao;
    22 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;
    2322import eu.dasish.annotation.schema.Source;
    2423import eu.dasish.annotation.schema.SourceInfo;
     
    2928import java.util.List;
    3029import java.util.Map;
     30import java.util.UUID;
    3131import javax.sql.DataSource;
    3232import javax.xml.datatype.DatatypeConfigurationException;
     
    4747    }
    4848
    49     //////////////////////////////////////////////////////////////////////////////////////////////////////
    50     @Override
    51     public SourceIdentifier getExternalID(Number internalID) {
    52         return new SourceIdentifier(super.getExternalIdentifier(internalID));
    53     }
     49   
    5450
    5551    ///////////////////////////////////////////////////////////////////////////////
     
    6662                XMLGregorianCalendar xmlDate = Helpers.setXMLGregorianCalendar(rs.getTimestamp(time_stamp));
    6763                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);
    6965                return result;
    7066            } catch (DatatypeConfigurationException e) {
     
    108104        String sql = "INSERT INTO " + sourceTableName + "(" + external_id + "," + link_uri + "," + version + " ) VALUES (:externalId, :linkUri,  :version)";
    109105        final int affectedRows = getSimpleJdbcTemplate().update(sql, params);       
    110         Number internalID = getInternalID(new SourceIdentifier(externalID));
     106        Number internalID = getInternalID(UUID.fromString(externalID));
    111107        return internalID;
    112108    }
     
    159155        @Override
    160156        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));
    162158        }
    163159    };
     
    195191   
    196192
    197     private SourceInfo constructSourceInfo(SourceIdentifier sourceIdentifier, String link, String version) {
     193    private SourceInfo constructSourceInfo(UUID UUID, String link, String version) {
    198194        SourceInfo sourceInfo = new SourceInfo();
    199         sourceInfo.setRef(sourceIdentifier.toString());
     195        sourceInfo.setRef(UUID.toString());
    200196        sourceInfo.setLink(link);
    201197        sourceInfo.setVersion(version);
     
    203199    }
    204200
    205     private Source constructSource(SourceIdentifier sourceIdentifier, String link, String version, XMLGregorianCalendar xmlTimeStamp) {
     201    private Source constructSource(UUID UUID, String link, String version, XMLGregorianCalendar xmlTimeStamp) {
    206202        Source source = new Source();
    207         source.setURI(sourceIdentifier.toString());
     203        source.setURI(UUID.toString());
    208204        source.setTimeSatmp(xmlTimeStamp);
    209205        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  
    1919
    2020import eu.dasish.annotation.backend.dao.UserDao;
    21 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2221import javax.sql.DataSource;
    2322
     
    3433    }
    3534
    36     ///////////////////////////////////////////////////////////////////
    37     @Override
    38     public UserIdentifier getExternalID(Number internalID) {
    39         return new UserIdentifier(super.getExternalIdentifier(internalID));
    40     }
     35   
    4136}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java

    r3408 r3455  
    1919
    2020import eu.dasish.annotation.backend.dao.VersionDao;
    21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;
    2221import eu.dasish.annotation.schema.Version;
    2322import java.sql.ResultSet;
     
    2625import java.util.List;
    2726import java.util.Map;
     27import java.util.UUID;
    2828import javax.sql.DataSource;
    2929import org.springframework.jdbc.core.RowMapper;
     
    4242    }
    4343
    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 
    5645    ///////////////////////////////////////////////////////////////
    5746    @Override
     
    8675        String sql = "SELECT " + cached_representation_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + version_id + "= ?";
    8776        List<Number> result = getSimpleJdbcTemplate().query(sql, cachedIDRowMapper, versionID);
    88 
    89         if (result == null) {
    90             return null;
    91         }
    92 
    9377        return result;
    9478    }
     
    119103    @Override
    120104    public Number addVersion(Version freshVersion) {
    121         VersionIdentifier externalIdentifier = new VersionIdentifier();
     105        UUID externalIdentifier = UUID.randomUUID();
    122106        String newExternalIdentifier = externalIdentifier.toString();
    123107
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java

    r3453 r3455  
    2020import eu.dasish.annotation.backend.BackendConstants;
    2121import eu.dasish.annotation.backend.dao.DaoDispatcher;
    22 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    23 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2422import eu.dasish.annotation.schema.Annotation;
    2523import eu.dasish.annotation.schema.ObjectFactory;
    2624import java.sql.SQLException;
     25import java.util.UUID;
    2726import javax.servlet.http.HttpServletRequest;
    2827import javax.ws.rs.Consumes;
     
    6261    @Produces(MediaType.TEXT_XML)
    6362    @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));
    6665        final Annotation annotation = daoDispatcher.getAnnotation(annotationID);
    6766        return new ObjectFactory().createAnnotation(annotation);
     
    7271    @DELETE
    7372    @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));
    7675        int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID);
    7776        String result = Integer.toString(resultDelete[0]);
     
    8786    public JAXBElement<Annotation> createAnnotation(Annotation annotation) throws SQLException {
    8887        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);
    9090        Number newAnnotationID =  daoDispatcher.addUsersAnnotation(annotation, userID);
    9191        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  
    2020import eu.dasish.annotation.backend.BackendConstants;
    2121import eu.dasish.annotation.backend.dao.AnnotationDao;
    22 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2322import eu.dasish.annotation.backend.dao.NotebookDao;
    24 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    25 import eu.dasish.annotation.backend.identifiers.NotebookIdentifier;
    2623import eu.dasish.annotation.schema.Notebook;
    2724import eu.dasish.annotation.schema.NotebookInfo;
     
    3229import java.util.ArrayList;
    3330import java.util.List;
     31import java.util.UUID;
    3432import javax.servlet.http.HttpServletRequest;
    3533import javax.ws.rs.Consumes;
     
    4644import javax.ws.rs.core.MediaType;
    4745import javax.xml.bind.JAXBElement;
     46import javax.xml.namespace.QName;
    4847import org.springframework.beans.factory.annotation.Autowired;
    4948import org.springframework.stereotype.Component;
     
    6968    public JAXBElement<NotebookInfos> getNotebookInfo(@Context HttpServletRequest httpServletRequest) {
    7069        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));
    7273        return new ObjectFactory().createNotebooks(notebookInfos);
    7374    }
     
    7980    public JAXBElement<NotebookInfos> getNotebookInfo(@QueryParam("userid") String userId) {
    8081        final NotebookInfos notebookInfos = new NotebookInfos();
    81         notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos(new UserIdentifier(userId)));
     82        notebookInfos.getNotebook().addAll(notebookDao.getNotebookInfos(UUID.fromString(userId)));
    8283        return new ObjectFactory().createNotebooks(notebookInfos);
    8384    }
     
    8990    public List<Notebook> getUsersNotebooks(@Context HttpServletRequest httpServletRequest) {
    9091        // 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);
    9295    }
    9396
     
    110113    @GET
    111114    @Produces(MediaType.TEXT_XML)
    112     @Path("{notebookid: "+BackendConstants.regExpIdentifier+"}/metadata")
     115    @Path("{notebookid: " + BackendConstants.regExpIdentifier + "}/metadata")
    113116    // Get all metadata about a specified notebook _nid_, including the information if it is private or not.
    114117    public JAXBElement<NotebookInfo> getMetadata(@PathParam("notebookid") String notebookId) {
    115         NotebookInfo result = notebookDao.getNotebookInfo(notebookDao.getNotebookID(new NotebookIdentifier(notebookId)));
     118        NotebookInfo result = notebookDao.getNotebookInfo(notebookDao.getInternalID(UUID.fromString(notebookId)));
    116119        // TODO change the name of the create method to createNotebookInfo!
    117120        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 + "}")
    123126    /*
    124127     * Get the list of all annotations _aid_-s contained within a Notebook with related metadata.
     
    130133     * */
    131134    @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,
    133136            @DefaultValue("-1") @QueryParam(value = "startAnnotation") final int startAnnotation,
    134137            @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;
    139147        // TODO implement optional parameters!!
    140148    }
     
    175183     */
    176184    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);
    178188        final URI serverUri = new URI(httpServletRequest.getRequestURL().toString());
    179         String fullUrlString = "/api/notebooks/" + notebookId.getUUID().toString();
     189        String fullUrlString = "/api/notebooks/" + notebookId.toString();
    180190        return serverUri.resolve(fullUrlString).toString();
    181191    }
     
    198208     Delete _nid_. Annotations stay, they just lose connection to _nid_.<br>
    199209     */
    200     public String deleteNotebook(@PathParam("notebookid") NotebookIdentifier notebookId) {
     210    public String deleteNotebook(@PathParam("notebookid") UUID notebookId) {
    201211        // todo: sort out how the id string passsed in here is mapped eg db column for _nid_
    202212        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  
    2323package eu.dasish.annotation.backend;
    2424
    25 import java.sql.Timestamp;
    26 
    2725public class TestBackendConstants {
    2826   
     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";
    2929    public static final String _TEST_UID_1_ = "00000000-0000-0000-0000-000000000003";
    3030    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  
    2727import eu.dasish.annotation.backend.dao.UserDao;
    2828import 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;
    3429import eu.dasish.annotation.schema.Annotation;
    3530import eu.dasish.annotation.schema.AnnotationBody;
     
    4742import java.util.List;
    4843import java.util.Map;
     44import java.util.UUID;
    4945import javax.xml.datatype.XMLGregorianCalendar;
    5046import org.jmock.Expectations;
     
    9692    public void testGetAnnotationInternalIdentifier() {
    9793        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);
    10399                will(returnValue(2));
    104100            }
    105101        });
    106         assertEquals(2, daoDispatcher.getAnnotationInternalIdentifier(annotationIdentifier));
     102        assertEquals(2, daoDispatcher.getAnnotationInternalIdentifier(externalID));
    107103    }
    108104
     
    113109    public void testGetAnnotationExternalIdentifier() {
    114110        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);
    116112
    117113        mockery.checking(new Expectations() {
    118114            {
    119115                oneOf(annotationDao).getExternalID(2);
    120                 will(returnValue(annotationIdentifier));
     116                will(returnValue(externalID));
    121117            }
    122118        });
     
    131127        System.out.println("getUserInternalIdentifier");
    132128
    133         final UserIdentifier 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);
    138134                will(returnValue(5));
    139135            }
    140136        });
    141         assertEquals(5, daoDispatcher.getUserInternalIdentifier(userIdentifier));
     137        assertEquals(5, daoDispatcher.getUserInternalIdentifier(externalID));
    142138    }
    143139
     
    148144    public void testGetUserExternalIdentifier() {
    149145        System.out.println("getUserExternalIdentifier");
    150         final UserIdentifier userIdentifier = new UserIdentifier(TestBackendConstants._TEST_USER_5_EXT_ID);
     146        final UUID externalID = UUID.fromString(TestBackendConstants._TEST_USER_5_EXT_ID);
    151147
    152148        mockery.checking(new Expectations() {
    153149            {
    154150                oneOf(userDao).getExternalID(5);
    155                 will(returnValue(userIdentifier));
     151                will(returnValue(externalID));
    156152            }
    157153        });
     
    248244        final String access = null;
    249245        final String namespace = null;
    250         final UserIdentifier owner = new UserIdentifier(TestBackendConstants._TEST_USER_3_EXT_ID);
     246        final UUID owner = UUID.fromString(TestBackendConstants._TEST_USER_3_EXT_ID);
    251247        final Timestamp after = new Timestamp(0);
    252248        final Timestamp before = new Timestamp(System.currentTimeMillis());
     
    296292        mockery.checking(new Expectations() {
    297293            {
    298                 oneOf(cachedRepresentationDao).getInternalID(new CachedRepresentationIdentifier(newCached.getRef()));
     294                oneOf(cachedRepresentationDao).getInternalID(null);
    299295                will(returnValue(null));
    300296
     
    324320        // test adding completely new version
    325321        final Version mockVersion = new Version(); // should be # 8
    326         final VersionIdentifier mockVersionIdentifier = new VersionIdentifier();
    327         mockVersion.setVersion(mockVersionIdentifier.toString());
    328 
    329         mockery.checking(new Expectations() {
    330             {
    331                 oneOf(versionDao).getInternalID(mockVersionIdentifier);
     322        final UUID mockUUID = UUID.randomUUID();
     323        mockVersion.setVersion(mockUUID.toString());
     324
     325        mockery.checking(new Expectations() {
     326            {
     327                oneOf(versionDao).getInternalID(mockUUID);
    332328                will(returnValue(null));
    333329
     
    350346
    351347        final Version mockVersionTwo = new Version(); // should be # 3
    352         final VersionIdentifier mockVersionIdentifierTwo = new VersionIdentifier(TestBackendConstants._TEST_VERSION_3_EXT_ID);
    353         mockVersionTwo.setVersion(mockVersionIdentifierTwo.toString());
    354 
    355         mockery.checking(new Expectations() {
    356             {
    357                 oneOf(versionDao).getInternalID(mockVersionIdentifierTwo);
     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);
    358354                will(returnValue(3));
    359355
     
    377373        // test 1: adding an existing source
    378374        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);
    380376        SourceInfo testOldSource = new SourceInfo();
    381377        testOldSource.setLink(TestBackendConstants._TEST_SOURCE_1_LINK);
     
    388384        mockery.checking(new Expectations() {
    389385            {
    390                 oneOf(sourceDao).getInternalID(with(aNonNull(SourceIdentifier.class)));
     386                oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class)));
    391387                will(returnValue(1));
    392388
     
    419415                ////////////  mockery in the call addSiblingVersionForSource //////////////
    420416
    421                 oneOf(versionDao).getInternalID(with(aNonNull(VersionIdentifier.class)));
     417                oneOf(versionDao).getInternalID(with(aNonNull(UUID.class)));
    422418                will(returnValue(null));
    423419
     
    458454
    459455                //  expectations for addSourcesForannotation
    460                 oneOf(sourceDao).getInternalID(with(aNonNull(SourceIdentifier.class)));
     456                oneOf(sourceDao).getInternalID(with(aNonNull(UUID.class)));
    461457                will(returnValue(1));
    462458
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDaoTest.java

    r3450 r3455  
    2121import eu.dasish.annotation.backend.TestBackendConstants;
    2222import eu.dasish.annotation.backend.TestInstances;
    23 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    2423import eu.dasish.annotation.schema.Annotation;
    2524import eu.dasish.annotation.schema.AnnotationInfo;
     
    3130import java.util.List;
    3231import java.util.Map;
     32import java.util.UUID;
    3333import static org.junit.Assert.*;
    3434import org.junit.Test;
     
    159159     *
    160160     * Test of getAnnotationID method, of class JdbcAnnotationDao. Integer
    161      * getAnnotationID(AnnotationIdentifier externalID)
     161     * getAnnotationID(UUID externalID)
    162162     */
    163163    @Test
     
    165165        System.out.println("test getInternalID");
    166166
    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));
    168168        assertEquals(2, annotaionId.intValue());
    169169
    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));
    171171        assertEquals(null, annotaionIdNE);
    172172
     
    266266        System.out.println("getExternalID");
    267267
    268         final AnnotationIdentifier externalId = jdbcAnnotationDao.getExternalID(2);
    269         assertEquals(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT), externalId);
    270 
    271 
    272         final AnnotationIdentifier externalIdThree = 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);
    274274
    275275    }
     
    277277   
    278278    /** test
    279      * public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UserIdentifier owner, Timestamp after, Timestamp before) {
     279     * public List<Number> getFilteredAnnotationIDs(String link, String text, String access, String namespace, UUID owner, Timestamp after, Timestamp before) {
    280280  **/
    281281   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDaoTest.java

    r3450 r3455  
    1919
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    21 import eu.dasish.annotation.backend.identifiers.CachedRepresentationIdentifier;
    2221import eu.dasish.annotation.schema.CachedRepresentationInfo;
     22import java.util.UUID;
    2323import org.junit.Test;
    2424import static org.junit.Assert.*;
     
    4848    /**
    4949     * Test of getExternalId method, of class JdbcCachedRepresentationDao.
    50      * public CachedRepresentationIdentifier getExternalId(Number internalID);
     50     * public UUID getExternalId(Number internalID);
    5151   
    5252     */
     
    5555        System.out.println("getExternalId");
    5656        Number internalID = 1;
    57         CachedRepresentationIdentifier expResult = new CachedRepresentationIdentifier(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);
    58         CachedRepresentationIdentifier result = jdbcCachedRepresentationDao.getExternalID(internalID);
     57        UUID expResult = UUID.fromString(TestBackendConstants._TEST_CACHED_REPRESENTATION_1_EXT_ID_);
     58        UUID result = jdbcCachedRepresentationDao.getExternalID(internalID);
    5959        assertEquals(expResult, result);
    6060    }
     
    6363    /**
    6464     * Test of getInternalId method, of class JdbcCachedRepresentationDao.
    65      * public  Number getInternalId(CachedRepresentationIdentifier externalID);
     65     * public  Number getInternalId(UUID externalID);
    6666     */
    6767    @Test
    6868    public void testGetInternalId() {
    6969        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_);
    7171        Number result = jdbcCachedRepresentationDao.getInternalID(externalID);
    7272        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  
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    2121import 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;
    2522import eu.dasish.annotation.schema.Annotations;
    2623import eu.dasish.annotation.schema.Notebook;
     
    7168    @Test
    7269    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_));
    7471        assertEquals(2, notebookInfoList.size());
    7572        assertEquals("a notebook", notebookInfoList.get(0).getTitle());
     
    9693        });
    9794       
    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_));
    9996
    10097
     
    115112        });
    116113       
    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_));
    118115        assertEquals(0, notebooksEmpty.size());
    119116    }
     
    124121    @Test
    125122    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());
    128125    }
    129126
     
    134131    public void testDeleteNotebook() {
    135132        System.out.println("deleteNotebook");
    136         NotebookIdentifier notebookId = new NotebookIdentifier(new UUID(0, 2));
     133        UUID notebookId = UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID);
    137134        int result = jdbcNotebookDao.deleteNotebook(notebookId);
    138135        assertEquals(1, result);
     
    164161        // test four, null-notebook
    165162        final List<Number> annotationIDsFour = jdbcNotebookDao.getAnnotationIDs(null);
    166         assertEquals(null, annotationIDsFour);
     163        assertEquals(0, annotationIDsFour.size());
    167164       
    168165       
     
    200197        setMockeryNotebookNonExisting();
    201198        List<ResourceREF> testListFive = jdbcNotebookDao.getAnnotationREFsOfNotebook(null);
    202         assertEquals(null, testListFive);
     199        assertEquals(0, testListFive.size());
    203200    }
    204201
     
    264261       
    265262         // test One       
    266         Number resultOne= jdbcNotebookDao.getNotebookID(new NotebookIdentifier(TestBackendConstants._TEST_NOTEBOOK_3_EXT));
     263        Number resultOne= jdbcNotebookDao.getInternalID(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_3_EXT));
    267264        assertEquals(3, resultOne.intValue());
    268265       
    269266     
    270267        // test Three Null-notebook
    271        Number resultThree= jdbcNotebookDao.getNotebookID(null);
     268       Number resultThree= jdbcNotebookDao.getInternalID(null);
    272269       assertEquals(null, resultThree);
    273270    }
     
    282279            {
    283280              oneOf(annotationDao).getExternalID(2);
    284               will(returnValue(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_2_EXT)));
     281              will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_2_EXT)));
    285282             
    286283              oneOf(annotationDao).getExternalID(3);
    287               will(returnValue(new AnnotationIdentifier(TestBackendConstants._TEST_ANNOT_3_EXT)));
     284              will(returnValue(UUID.fromString(TestBackendConstants._TEST_ANNOT_3_EXT)));
    288285            }
    289286        });
    290287       
    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));
    292289        assertEquals(TestBackendConstants._TEST_ANNOT_2_EXT, resultOne.get(0).toString());
    293290        assertEquals(TestBackendConstants._TEST_ANNOT_3_EXT, resultOne.get(1).toString());
     
    296293     
    297294        // 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());
    300297       
    301298    }
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDaoTest.java

    r3450 r3455  
    1919
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    21 import eu.dasish.annotation.backend.identifiers.SourceIdentifier;
    2221import eu.dasish.annotation.schema.Source;
    2322import eu.dasish.annotation.schema.SourceInfo;
     
    2524import java.util.ArrayList;
    2625import java.util.List;
     26import java.util.UUID;
    2727import org.junit.Test;
    2828import static org.junit.Assert.*;
     
    5050        System.out.println("getExternalID");
    5151        Number internalID = 1;
    52         SourceIdentifier result = jdbcSourceDao.getExternalID(internalID);
     52        UUID result = jdbcSourceDao.getExternalID(internalID);
    5353        assertEquals(TestBackendConstants._TEST_SOURCE_1_EXT_ID, result.toString());
    5454    }
     
    6060    public void testGetInternalId() {
    6161        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);
    6363        Number expResult = 1;
    6464        Number result = jdbcSourceDao.getInternalID(externalID);
     
    128128        freshSource.setLink(link);
    129129        freshSource.setVersion(TestBackendConstants._TEST_VERSION_1_EXT_ID);
    130         freshSource.setURI((new SourceIdentifier()).toString());
     130        freshSource.setURI((UUID.randomUUID()).toString());
    131131        freshSource.setTimeSatmp(null);
    132132       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDaoTest.java

    r3309 r3455  
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    2121import eu.dasish.annotation.backend.TestInstances;
    22 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
     22import java.util.UUID;
    2323import org.junit.Test;
    2424import static org.junit.Assert.*;
     
    4343    /**
    4444     * Test of getInternalID method, of class JdbcUserDao. Number
    45      * getInternalID(UserIdentifier userIDentifier);
     45     * getInternalID(UUID UUID);
    4646     */
    4747    @Test
    4848    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));
    5050        assertEquals(3, testOne.intValue());
    5151       
    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));
    5353        assertEquals(null, testTwo);
    5454       
     
    5959   
    6060    /**
    61      * public UserIdentifier getExternalID(Number internalId)
     61     * public UUID getExternalID(Number internalId)
    6262     */
    6363    @Test
    6464    public void testGetExternalID() {
    65         UserIdentifier testOne = jdbcUserDao.getExternalID(3);
     65        UUID testOne = jdbcUserDao.getExternalID(3);
    6666        assertEquals(TestBackendConstants._TEST_USER_3_EXT_ID, testOne.toString());
    6767       
    68         UserIdentifier testTwo = jdbcUserDao.getExternalID(null);
    69         assertEquals(null, testTwo.getUUID());
     68        UUID testTwo = jdbcUserDao.getExternalID(null);
     69        assertEquals(null, testTwo);
    7070    }
    7171   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDaoTest.java

    r3450 r3455  
    1919
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    21 import eu.dasish.annotation.backend.identifiers.VersionIdentifier;
    2221import eu.dasish.annotation.schema.Version;
    2322import java.util.ArrayList;
    2423import java.util.List;
     24import java.util.UUID;
    2525import org.junit.Test;
    2626import static org.junit.Assert.*;
     
    4949        System.out.println("getExternalId");
    5050        Number internalID = 1;
    51         VersionIdentifier result = jdbcVersionDao.getExternalID(internalID);
     51        UUID result = jdbcVersionDao.getExternalID(internalID);
    5252        assertEquals(TestBackendConstants._TEST_VERSION_1_EXT_ID, result.toString());
    5353    }
     
    5959    public void testGetInternalId() {
    6060        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);
    6262        Number expResult = 1;
    6363        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  
    2323import eu.dasish.annotation.backend.TestBackendConstants;
    2424import eu.dasish.annotation.backend.TestInstances;
    25 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    26 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2725import eu.dasish.annotation.schema.Annotation;
    2826import eu.dasish.annotation.schema.ResourceREF;
     
    3937import java.lang.InstantiationException;
    4038import java.sql.Timestamp;
     39import java.util.UUID;
    4140import javax.servlet.ServletException;
    4241import javax.xml.datatype.DatatypeConfigurationException;
    43 import org.junit.Ignore;
    4442import org.springframework.mock.web.MockHttpServletRequest;
    4543/**
     
    7169    public void testGetAnnotation() throws SQLException {
    7270        System.out.println("getAnnotation");
    73         final String annotationIdentifier= TestBackendConstants._TEST_ANNOT_2_EXT;
     71        final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT;
    7472        final int annotationID = 2;       
    7573        final Annotation expectedAnnotation = (new TestInstances()).getAnnotationOne();
    7674       
    77         //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier));
    78         //final Annotation annotation = daoDispatcher.getAnnotation(annotationID);
    7975        mockery.checking(new Expectations() {
    8076            {
    81                 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class)));               
     77                oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(any(UUID.class)));               
    8278                will(returnValue(annotationID));               
    8379               
     
    8783        });
    8884         
    89         JAXBElement<Annotation> result = annotationResource.getAnnotation(annotationIdentifier);
     85        JAXBElement<Annotation> result = annotationResource.getAnnotation(externalIDstring);
    9086        assertEquals(expectedAnnotation, result.getValue());
    9187    }
     
    9793    public void testDeleteAnnotation() throws SQLException {
    9894        System.out.println("deleteAnnotation");
    99         //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier));
     95        //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID));
    10096        //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID);
    10197       
     
    107103        mockery.checking(new Expectations() {
    108104            { 
    109                 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class)));             
     105                oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class)));             
    110106                will(returnValue(5));     
    111107               
     
    129125//        Number userID = null;
    130126//        if (remoteUser != null) {
    131 //            userID = daoDispatcher.getUserInternalIdentifier(new UserIdentifier(remoteUser));
     127//            userID = daoDispatcher.getUserInternalIdentifier(UUID.fromString(remoteUser));
    132128//        }
    133129//        Number newAnnotationID =  daoDispatcher.addUsersAnnotation(annotation, userID);
     
    140136        owner.setRef(ownerString);
    141137        addedAnnotation.setOwner(owner);
    142         addedAnnotation.setURI((new AnnotationIdentifier()).toString());       
     138        addedAnnotation.setURI((UUID.randomUUID()).toString());       
    143139        addedAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000")));
    144140       
    145141        mockery.checking(new Expectations() {
    146142            {
    147                 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UserIdentifier.class)));
     143                oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UUID.class)));
    148144                will(returnValue(ownerID));
    149145               
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r3453 r3455  
    2020import eu.dasish.annotation.backend.dao.DaoDispatcher;
    2121import com.sun.jersey.api.client.ClientResponse;
    22 import com.sun.jersey.api.client.GenericType;
    2322import eu.dasish.annotation.backend.Helpers;
    2423import eu.dasish.annotation.backend.TestBackendConstants;
    25 import eu.dasish.annotation.backend.identifiers.AnnotationIdentifier;
    26 import eu.dasish.annotation.backend.identifiers.UserIdentifier;
    2724import eu.dasish.annotation.schema.Annotation;
    28 import eu.dasish.annotation.schema.AnnotationBody;
    29 import eu.dasish.annotation.schema.ObjectFactory;
    3025import eu.dasish.annotation.schema.ResourceREF;
    3126import java.sql.SQLException;
    3227import java.sql.Timestamp;
     28import java.util.UUID;
    3329import javax.ws.rs.core.MediaType;
    3430import javax.xml.bind.JAXBElement;
     
    5955    public void testGetAnnotation() throws SQLException, DatatypeConfigurationException{
    6056        System.out.println("testGetAnnotation");
    61         final String annotationIdentifier= TestBackendConstants._TEST_ANNOT_2_EXT;
     57        final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT;
    6258        final int annotationID = 2;
    6359        final Annotation testAnnotation = new Annotation();
     
    6561        owner.setRef("5");
    6662        testAnnotation.setOwner(owner);
    67         testAnnotation.setURI((new AnnotationIdentifier()).toString());
     63        testAnnotation.setURI(externalIDstring);
    6864        testAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000")));
    6965       
    70         //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier));
     66        //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID));
    7167        //final Annotation annotation = daoDispatcher.getAnnotation(annotationID);
    7268        mockery.checking(new Expectations() {
    7369            {
    74                 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class)));               
     70                oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class)));               
    7571                will(returnValue(annotationID));               
    7672               
     
    8076        });
    8177       
    82         final String requestUrl = "annotations/" + annotationIdentifier;
     78        final String requestUrl = "annotations/" + externalIDstring;
    8379        System.out.println("requestUrl: " + requestUrl);
    8480        ClientResponse response = resource().path(requestUrl).accept(MediaType.TEXT_XML).get(ClientResponse.class);
     
    10197    public void testDeleteAnnotation() throws SQLException{
    10298        System.out.println("testDeleteAnnotation");
    103          //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(new AnnotationIdentifier(annotationIdentifier));
     99         //final Number annotationID = daoDispatcher.getAnnotationInternalIdentifier(UUID.fromString(UUID));
    104100        //int[] resultDelete = daoDispatcher.deleteAnnotation(annotationID);
    105101       
     
    111107        mockery.checking(new Expectations() {
    112108            { 
    113                 oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(AnnotationIdentifier.class)));             
     109                oneOf(daoDispatcher).getAnnotationInternalIdentifier(with(aNonNull(UUID.class)));             
    114110                will(returnValue(5));     
    115111               
     
    139135        final JAXBElement<Annotation> jaxbElement = new JAXBElement<Annotation>(new QName("http://www.dasish.eu/ns/addit", "annotation"), Annotation.class, null, annotationToAdd);
    140136         //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       
    146138        final String ownerString = "5";
    147139        final Number ownerID =  5;
     
    151143        owner.setRef(ownerString);
    152144        addedAnnotation.setOwner(owner);
    153         addedAnnotation.setURI((new AnnotationIdentifier()).toString());
     145        addedAnnotation.setURI((UUID.randomUUID()).toString());
    154146       
    155147        addedAnnotation.setTimeStamp(Helpers.setXMLGregorianCalendar(Timestamp.valueOf("2013-08-12 11:25:00.383000")));
    156148        mockery.checking(new Expectations() {
    157149            {
    158                 oneOf(daoDispatcher).getUserInternalIdentifier(with(aNonNull(UserIdentifier.class)));
     150                oneOf(daoDispatcher).getUserInternalIdentifier(with(any(UUID.class)));
    159151                will(returnValue(ownerID));
    160152               
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java

    r3453 r3455  
    2020import eu.dasish.annotation.backend.TestBackendConstants;
    2121import 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;
    2522import eu.dasish.annotation.schema.Notebook;
    2623import eu.dasish.annotation.schema.NotebookInfo;
     
    7168        mockery.checking(new Expectations() {
    7269            {
    73                 oneOf(notebookDao).getNotebookInfos(new UserIdentifier(httpServletRequest.getRemoteUser()));               
     70                oneOf(notebookDao).getNotebookInfos(UUID.fromString(httpServletRequest.getRemoteUser()));               
    7471                will(returnValue(new ArrayList<NotebookInfo>()));
    7572            }
     
    8784        mockery.checking(new Expectations() {
    8885            {
    89                 oneOf(notebookDao).getUsersNotebooks(new UserIdentifier(TestBackendConstants._TEST_UID_2_));
     86                oneOf(notebookDao).getUsersNotebooks(UUID.fromString(TestBackendConstants._TEST_UID_2_));
    9087                will(returnValue(new ArrayList<Notebook>()));
    9188            }
     
    107104        mockery.checking(new Expectations() {
    108105            {
    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)));
    111108            }
    112109        });
     
    122119    public void testDeleteNotebook() {
    123120        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);
    125122        mockery.checking(new Expectations() {
    126123            {
    127                 oneOf(notebookDao).deleteNotebook(notebookIdentifier);
     124                oneOf(notebookDao).deleteNotebook(externalID);
    128125                will(returnValue(1));
    129126            }
    130127        });
    131128        String expResult = "1";
    132         String result = notebookResource.deleteNotebook(notebookIdentifier);
     129        String result = notebookResource.deleteNotebook(externalID);
    133130        assertEquals(expResult, result);
    134131    }
     
    143140        System.out.println("test GetMetadata");
    144141       
    145         final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;
     142        final String externalID= TestBackendConstants._TEST_NOTEBOOK_3_EXT;
    146143        final int notebookID = 3;
    147144        final NotebookInfo testInfo = new ObjectFactory().createNotebookInfo();
     
    149146        mockery.checking(new Expectations() {
    150147            {
    151                 oneOf(notebookDao).getNotebookID(new NotebookIdentifier(notebookIdentifier));               
     148                oneOf(notebookDao).getInternalID(UUID.fromString(externalID));               
    152149                will(returnValue(notebookID));
    153150               
     
    157154        });
    158155       
    159         JAXBElement<NotebookInfo> result = notebookResource.getMetadata(notebookIdentifier);
     156        JAXBElement<NotebookInfo> result = notebookResource.getMetadata(externalID);
    160157        NotebookInfo entity = result.getValue();
    161158        assertEquals(testInfo.getRef(), entity.getRef());
     
    167164    public void testGetAllAnnotations() {
    168165        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>();
    173170        annotationIds.add(aIdOne);
    174171        annotationIds.add(aIdTwo);
     
    176173        mockery.checking(new Expectations() {
    177174            {
    178                 oneOf(notebookDao).getAnnotationExternalIDs(new NotebookIdentifier(notebookIdentifier));               
     175                oneOf(notebookDao).getAnnotationExternalIDs(UUID.fromString(externalID));               
    179176                will(returnValue(annotationIds));
    180177               
     
    182179        });
    183180       
    184         List<AnnotationIdentifier> result= notebookResource.getAllAnnotations(notebookIdentifier, 0, 0, null, 0);
     181        List<JAXBElement<UUID>> result= notebookResource.getAllAnnotations(externalID, 0, 0, null, 0);
    185182        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());
    188185       
    189186       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebooksTest.java

    r3211 r3455  
    2323import eu.dasish.annotation.backend.TestBackendConstants;
    2424import 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;
    2825import eu.dasish.annotation.schema.Notebook;
    2926import eu.dasish.annotation.schema.NotebookInfo;
     
    3532import java.util.List;
    3633import java.util.UUID;
    37 import javax.ws.rs.core.EntityTag;
    3834import javax.ws.rs.core.MediaType;
    3935import javax.xml.bind.JAXBElement;
     
    6965        mockery.checking(new Expectations() {
    7066            {
    71                 oneOf(notebookDao).getNotebookInfos(new UserIdentifier(null));
     67                oneOf(notebookDao).getNotebookInfos(with(any(UUID.class)));
    7268                will(returnValue(new ArrayList<NotebookInfo>()));
    7369            }
     
    8682     */
    8783    @Test
    88     @Ignore
    8984    public void testGetUsersNotebooks() {
    9085        System.out.println("testGetUsersNotebooks");
    9186        mockery.checking(new Expectations() {
    9287            {
    93                 oneOf(notebookDao).getUsersNotebooks(new UserIdentifier("userid"));
     88                oneOf(notebookDao).getUsersNotebooks(with(any(UUID.class)));
    9489                will(returnValue(new ArrayList<Notebook>()));
    9590            }
     
    138133        System.out.println("test GetMetadata");
    139134       
    140         final String notebookIdentifier= TestBackendConstants._TEST_NOTEBOOK_3_EXT;
     135        final String externalIDstring= TestBackendConstants._TEST_NOTEBOOK_3_EXT;
    141136        final int notebookID = 3;
    142137        final NotebookInfo testInfo = new ObjectFactory().createNotebookInfo();
     
    144139        mockery.checking(new Expectations() {
    145140            {
    146                 oneOf(notebookDao).getNotebookID(new NotebookIdentifier(notebookIdentifier));               
     141                oneOf(notebookDao).getInternalID(UUID.fromString(externalIDstring));               
    147142                will(returnValue(notebookID));
    148143               
     
    152147        });
    153148       
    154         final String requestUrl = "notebooks/" + notebookIdentifier+"/metadata";
     149        final String requestUrl = "notebooks/" + externalIDstring+"/metadata";
    155150        System.out.println("requestUrl: " + requestUrl);
    156151        ClientResponse response = resource().path(requestUrl).type(MediaType.TEXT_XML).get(ClientResponse.class);
     
    177172    public void testGetAllAnnotations() {
    178173        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>();
    183178        annotationIds.add(aIdOne);
    184179        annotationIds.add(aIdTwo);
     
    186181        mockery.checking(new Expectations() {
    187182            {
    188                 oneOf(notebookDao).getAnnotationExternalIDs(new NotebookIdentifier(notebookIdentifier));               
     183                oneOf(notebookDao).getAnnotationExternalIDs(with(aNonNull(UUID.class)));               
    189184                will(returnValue(annotationIds));
    190185               
     
    192187        });
    193188       
    194         final String requestUrl = "notebooks/"+notebookIdentifier;
     189        final String requestUrl = "notebooks/"+externalIDstring;
    195190        ClientResponse response = resource().path(requestUrl)
    196191                .queryParam("maximumAnnotations", "123")
     
    201196        System.out.println("requestUrl: " + requestUrl);
    202197        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());
    206201    }
    207202
     
    251246        mockery.checking(new Expectations() {
    252247            {
    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)));
    255250            }
    256251        });
     
    284279        mockery.checking(new Expectations() {
    285280            {
    286                 oneOf(notebookDao).deleteNotebook(new NotebookIdentifier(new UUID(0, 2)));
     281                oneOf(notebookDao).deleteNotebook(UUID.fromString(TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID));
    287282                will(returnValue(1));
    288283            }
    289284        });
    290         final String requestUrl = "notebooks/" + new UUID(0, 2).toString();
     285        final String requestUrl = "notebooks/" + TestBackendConstants._TEST_NOTEBOOK_2_EXT_ID;
    291286        System.out.println("requestUrl: " + requestUrl);
    292287        ClientResponse response = resource().path(requestUrl).delete(ClientResponse.class);
Note: See TracChangeset for help on using the changeset viewer.