Changeset 3216


Ignore:
Timestamp:
07/31/13 15:57:15 (11 years ago)
Author:
olhsha
Message:

DAO: adding getExternalId for users (not tested yet)
adding retrieving of the lists externalUserID-Permission for a given annotationID (internal)

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/nb-configuration.xml

    r3211 r3216  
    1717        <org-netbeans-modules-maven-jaxws.rest_2e_jersey_2e_type>server</org-netbeans-modules-maven-jaxws.rest_2e_jersey_2e_type>
    1818    </properties>
     19    <spring-data xmlns="http://www.netbeans.org/ns/spring-data/1">
     20        <config-files>
     21            <config-file>src/test/resources/spring-test-config/mockPermissions.xml</config-file>
     22        </config-files>
     23        <config-file-groups/>
     24    </spring-data>
    1925</project-shared-configuration>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/UserDao.java

    r3205 r3216  
    2525 */
    2626public interface UserDao extends ResourceDao{
     27   
     28    /**
     29     *
     30     * @param userIDentifier
     31     * @return the internal identifier of "userIDentifier"
     32     */
    2733    Number getInternalID(UserIdentifier userIDentifier);
     34   
     35    /**
     36     *
     37     * @param internalId
     38     * @return the external UserIdentifier of internalId;
     39     */
     40    UserIdentifier getExternalID(Number internalId);
    2841}
     42
     43
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java

    r3214 r3216  
    5151    final static protected String principal_id = "principal_id";
    5252    final static protected String time_stamp = "time_stamp";
     53    final static protected String permission = "permission_";
    5354   
    5455    // derived string constants: table+field names
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcUserDao.java

    r3209 r3216  
    6161        }
    6262    };
     63   
     64    ///////////////////////////////////////////////////////////////////
     65    @Override
     66    public UserIdentifier getExternalID(Number internalId) {
     67        if (internalId == null) {
     68            return null;
     69        }
     70        String sql = "SELECT " + external_id + " FROM " + principalTableName + " WHERE " + principal_id + "= ?";
     71        List<UserIdentifier> result = getSimpleJdbcTemplate().query(sql, internalIDRowMapper, internalId.toString());
     72
     73        if (result == null) {
     74            return null;
     75        }
     76
     77        if (result.isEmpty()) {
     78            return null;
     79        }
     80
     81        return result.get(0);
     82    }
     83    private final RowMapper<UserIdentifier> internalIDRowMapper = new RowMapper<UserIdentifier>() {
     84        @Override
     85        public UserIdentifier mapRow(ResultSet rs, int rowNumber) throws SQLException {
     86            UserIdentifier result = new UserIdentifier(rs.getString(external_id));
     87            return result;
     88        }
     89    };
    6390}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/sql/DashishAnnotatorCreate.sql

    r3215 r3216  
    219219--     </xs:complexType>
    220220
     221
     222
     223
    221224CREATE TABLE annotations_principals_permissions (
    222225annotation_id integer REFERENCES annotation(annotation_id),
     
    225228unique(annotation_id, principal_id),
    226229CHECK(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:
     230-- 1 soundness: ??? owner in this table must be the same as the owner in the annotation table ---
     231-- 2 soundness ??? check for any pair (annotation, principal) there must be exactly one row in this table:
    229232-- impossible because of deleting an nnotation: first we have to remove it from this table
    230233);
     234
    231235
    232236---------------------------------------------------------------------------------------------
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/MockObjectsFactory.java

    r3205 r3216  
    2020import eu.dasish.annotation.backend.dao.AnnotationDao;
    2121import eu.dasish.annotation.backend.dao.NotebookDao;
     22import eu.dasish.annotation.backend.dao.PermissionsDao;
    2223import eu.dasish.annotation.backend.dao.UserDao;
    2324import org.jmock.Mockery;
     
    4748        return context.mock(UserDao.class);
    4849    }
     50   
     51    public PermissionsDao newPermissionsDao() {
     52        return context.mock(PermissionsDao.class);
     53    }
    4954}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql

    r3215 r3216  
    157157INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 4, 'writer');
    158158INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 5, 'writer');
     159-- checking integrity control:
     160-- INSERT INTO annotations_principals_permissions (annotation_id, principal_id, permission_) VALUES (5, 5, 'reader');
Note: See TracChangeset for help on using the changeset viewer.