Changeset 3214


Ignore:
Timestamp:
07/31/13 11:37:47 (11 years ago)
Author:
olhsha
Message:

permission tables added to the test database, new bugs (connected to new integrity constraints) are fixed: before deleting an annotation delete all the rows with this annotation id in "annotations_principals_permissions" and "notebooks_annotations" tables

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcAnnotationDao.java

    r3206 r3214  
    219219     public int deleteAnnotation(Number annotationId) throws SQLException{
    220220        String sqlAnnotation = "DELETE FROM " + annotationTableName + " where "+annotation_id + " = ?";
     221        String sqlPermissions = "DELETE FROM " + permissionsTableName + " where "+annotation_id + " = ?";
     222        String sqlNotebooks = "DELETE FROM " + notebooksAnnotationsTableName + " where "+annotation_id + " = ?";
     223        int affectedNotebooks = getSimpleJdbcTemplate().update(sqlNotebooks, annotationId);
     224        int affectedPermissions = getSimpleJdbcTemplate().update(sqlPermissions, annotationId);
    221225        int affectedAnnotations = getSimpleJdbcTemplate().update(sqlAnnotation, annotationId);
    222226        if (affectedAnnotations>1) {
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java

    r3188 r3214  
    3838    final static protected String principalTableName = "principal";   
    3939    final static protected String notebooksAnnotationsTableName = "notebooks_annotations";
    40    
     40    final static protected String permissionsTableName = "annotations_principals_permissions";
    4141   
    4242    // base string constants: field Names
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/sql/DashishAnnotatorCreate.sql

    r3213 r3214  
    219219--     </xs:complexType>
    220220
    221 CREATE TABLE annotations_users_permissions (
     221CREATE TABLE annotations_principals_permissions (
    222222annotation_id integer REFERENCES annotation(annotation_id),
    223223principal_id integer REFERENCES principal(principal_id),
    224224permission_  text,
    225225unique(annotation_id, principal_id),
    226 CHECK(permission_ = 'reader' OR permission_='writer' OR permission_='owner')
    227 )
     226CHECK(permission_ = 'reader' OR permission_='writer' OR permission_='owner'),
     227-- soundness: owner in this table must be the same as the owner in the annotation table ---
     228-- check for any pair (annotation, principal) there must be exactly one row in this table -- ???
     229);
    228230
    229231---------------------------------------------------------------------------------------------
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql

    r3212 r3214  
    5050INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (3,3);
    5151INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (4,4);
     52INSERT INTO notebooks_annotations (notebook_id,annotation_id) VALUES (5,5);
    5253
    5354
     
    136137INSERT INTO versions_cached_representations (version_id, cached_representation_id) VALUES (3, 2);
    137138INSERT INTO versions_cached_representations (version_id, cached_representation_id) VALUES (4, 4);
     139
     140
     141---- PERMISSIONS --------------------------------------------------------------------------------------------
     142
     143INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 3, 'owner');
     144INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 4, 'writer');
     145INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (2, 5, 'reader');
     146
     147INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 4, 'owner');
     148INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 3, 'reader');
     149INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (3, 5, 'writer');
     150
     151INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 5, 'owner');
     152INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 3, 'reader');
     153INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (4, 4, 'reader');
     154
     155INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 3, 'owner');
     156INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 4, 'writer');
     157INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 5, 'writer');
Note: See TracChangeset for help on using the changeset viewer.