Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml	(revision 4181)
@@ -243,9 +243,4 @@
             <version>${slf4j.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.glassfish.jersey.core</groupId>
-            <artifactId>jersey-server</artifactId>
-            <version>2.3.1</version>
-        </dependency>
     </dependencies>
     <properties>
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/TargetDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/TargetDao.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/TargetDao.java	(revision 4181)
@@ -142,5 +142,3 @@
     public int deleteTargetCachedRepresentation(Number TargetID, Number chachedID);  
     
-    
-  
 }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/DBIntegrityServiceImlp.java	(revision 4181)
@@ -135,6 +135,5 @@
     }
 
-    ////////////////////////////////////////////////////////
-    // TODO: refactor, Target grabbing should be made a separate private method
+    
     @Override
     public Annotation getAnnotation(Number annotationID) {
@@ -150,9 +149,5 @@
             TargetInfoList sis = new TargetInfoList();
             for (Number targetID : targetIDs) {
-                Target target = targetDao.getTarget(targetID);
-                TargetInfo targetInfo = new TargetInfo();
-                targetInfo.setLink(target.getLink());
-                targetInfo.setRef(target.getURI());
-                targetInfo.setVersion(target.getVersion());
+                TargetInfo targetInfo = getTargetInfoFromTarget(targetDao.getTarget(targetID));
                 sis.getTargetInfo().add(targetInfo);
             }
@@ -547,3 +542,11 @@
         return addedPermissions;
     }
+    
+     private TargetInfo getTargetInfoFromTarget(Target target) {
+        TargetInfo targetInfo = new TargetInfo();
+        targetInfo.setRef(target.getURI());
+        targetInfo.setLink(target.getLink());
+        targetInfo.setVersion(target.getVersion());
+        return targetInfo;
+    }
 }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java	(revision 4181)
@@ -89,5 +89,5 @@
     final static protected String principalExternal_id = principalTableName + "." + external_id;
     final static protected String cachedRepresentationStar = cachedRepresentationTableName + ".*";
-    final static protected String TargetStar = targetTableName + ".*";
+    final static protected String targetStar = targetTableName + ".*";
     final static protected String principalStar = principalTableName + ".*";
     ///////////////////////////////////////////////////
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDao.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDao.java	(revision 4181)
@@ -54,9 +54,9 @@
     public Target getTarget(Number internalID) {
         StringBuilder sql = new StringBuilder("SELECT ");
-        sql.append(TargetStar).append(" FROM ").append(targetTableName).append(" WHERE ").append(target_id).append("= ? LIMIT 1");
-        List<Target> result = getSimpleJdbcTemplate().query(sql.toString(), TargetRowMapper, internalID);
+        sql.append(targetStar).append(" FROM ").append(targetTableName).append(" WHERE ").append(target_id).append("= ? LIMIT 1");
+        List<Target> result = getSimpleJdbcTemplate().query(sql.toString(), targetRowMapper, internalID);
         return (!result.isEmpty() ? result.get(0) : null);
     }
-    private final RowMapper<Target> TargetRowMapper = new RowMapper<Target>() {
+    private final RowMapper<Target> targetRowMapper = new RowMapper<Target>() {
         @Override
         public Target mapRow(ResultSet rs, int rowNumber) throws SQLException {
@@ -71,5 +71,5 @@
     public String getLink(Number internalID) {
         StringBuilder sql = new StringBuilder("SELECT ");
-        sql.append(TargetStar).append(" FROM ").append(targetTableName).append(" WHERE ").append(target_id).append("= ? LIMIT 1");
+        sql.append(targetStar).append(" FROM ").append(targetTableName).append(" WHERE ").append(target_id).append("= ? LIMIT 1");
         List<String> result = getSimpleJdbcTemplate().query(sql.toString(), linkRowMapper, internalID);
         return (!result.isEmpty() ? result.get(0) : null);
@@ -122,5 +122,5 @@
 
         StringBuilder sql = new StringBuilder("SELECT ");
-        sql.append(external_id).append(",").append(link_uri).append(",").append(version).
+        sql.append(external_id).append(",").append(link_uri).append(",").append(version).append(",").append(fragment_descriptor).
                 append(" FROM ").append(targetTableName).append(" WHERE ").append(target_id).append(" IN ").append(targetIDs);
         return getSimpleJdbcTemplate().query(sql.toString(), targetInfoRowMapper);
@@ -129,5 +129,5 @@
         @Override
         public TargetInfo mapRow(ResultSet rs, int rowNumber) throws SQLException {
-            return constructTargetInfo(rs.getString(external_id), rs.getString(link_uri), rs.getString(version));
+            return constructTargetInfo(rs.getString(external_id), rs.getString(link_uri), rs.getString(version), rs.getString(fragment_descriptor));
         }
     };
@@ -166,10 +166,12 @@
     public Number addTarget(Target target) {
         UUID externalID = UUID.randomUUID();
+        String[] linkParts = splitLink(target.getLink());
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("externalId", externalID.toString());
-        params.put("linkUri", target.getLink());
+        params.put("linkUri", linkParts[0]);
         params.put("version", target.getVersion());
+        params.put("fragmentDescriptor", linkParts[1]);
         StringBuilder sql = new StringBuilder("INSERT INTO ");
-        sql.append(targetTableName).append("(").append(external_id).append(",").append(link_uri).append(",").append(version).append(",").append(last_modified).append(" ) VALUES (:externalId, :linkUri,  :version, current_timestamp AT TIME ZONE INTERVAL '00:00' HOUR TO MINUTE)");
+        sql.append(targetTableName).append("(").append(external_id).append(",").append(link_uri).append(",").append(version).append(",").append(last_modified).append(",").append(fragment_descriptor).append(" ) VALUES (:externalId, :linkUri,  :version, current_timestamp AT TIME ZONE INTERVAL '00:00' HOUR TO MINUTE, :fragmentDescriptor)");
         final int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);
         return (affectedRows > 0 ? getInternalID(UUID.fromString(externalID.toString())) : null);
@@ -227,8 +229,8 @@
 
     /////////// HELPERS  ////////////////
-    private TargetInfo constructTargetInfo(String externalID, String link, String version) {
+    private TargetInfo constructTargetInfo(String externalID, String link, String version, String fragment) {
         TargetInfo targetInfo = new TargetInfo();
         targetInfo.setRef(externalIDtoURI(externalID));
-        targetInfo.setLink(link);
+        targetInfo.setLink(((new StringBuilder(link)).append("#").append(fragment)).toString());
         targetInfo.setVersion(version);
         return targetInfo;
@@ -239,8 +241,26 @@
         target.setURI(externalIDtoURI(externalID));
         target.setLastModified(xmlTimeStamp);
-        target.setLink(link);
+        target.setLink(((new StringBuilder(link)).append("#").append(fragment)).toString());
         target.setVersion(version);
-        target.setFragmentDescriptor(fragment);
         return target;
     }
+    
+    private String[] splitLink(String link){
+      if (link!=null) {
+         String[] result = new String[2]; 
+         String[] parts = link.split("#");
+         if (parts.length > 1) {
+             result[0] = parts[0];             
+             StringBuilder buffer = new StringBuilder();
+             for (int i=1; i<parts.length ; i++){
+                 if (parts[i]!=null){
+                     buffer.append(parts[i]);
+                 }
+             }
+             result[1] = buffer.toString();
+         }
+         return result;
+      }
+      else return null;
+    }
 }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestBackendConstants.java	(revision 4181)
@@ -79,4 +79,7 @@
     public static final String _TEST_Target_2_LINK = "http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD";
     
+     public static final String _TEST_Target_1_FRAGMENT = "de_Opdracht";
+    
+    
     public static final String _TEST_Target_1_VERSION = "version 1.0";
     public static final String _TEST_Target_2_VERSION = "version 1.0";
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDaoTest.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDaoTest.java	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/dao/impl/JdbcTargetDaoTest.java	(revision 4181)
@@ -119,7 +119,6 @@
         Target result = jdbcTargetDao.getTarget(1);
         assertEquals(TestBackendConstants._TEST_SERVLET_URI_Targets+TestBackendConstants._TEST_Target_1_EXT_ID, result.getURI());
-        assertEquals(TestBackendConstants._TEST_Target_1_LINK, result.getLink());
+        assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#"+TestBackendConstants._TEST_Target_1_FRAGMENT, result.getLink());
         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, result.getVersion());
-        assertEquals("#de_Opdracht", result.getFragmentDescriptor());
         // TODO :add time stamp test
         
@@ -164,7 +163,6 @@
         System.out.println("addTarget");
 
-        String link = "http://www.sagradafamilia.cat/";
         Target freshTarget = new Target();
-        freshTarget.setLink(link);
+        freshTarget.setLink(TestBackendConstants._TEST_Target_1_LINK+"#Het_ontwerp");
         freshTarget.setVersion(TestBackendConstants._TEST_Target_1_VERSION);
         freshTarget.setLastModified(null);
@@ -174,5 +172,5 @@
         // detailed checking
         Target addedTarget = jdbcTargetDao.getTarget(result);
-        assertEquals(link, addedTarget.getLink());
+        assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#Het_ontwerp", addedTarget.getLink());
         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, addedTarget.getVersion());
         assertTrue(addedTarget.getURI().startsWith(TestBackendConstants._TEST_SERVLET_URI_Targets));
@@ -195,6 +193,6 @@
         assertEquals(TestBackendConstants._TEST_Target_1_VERSION, result.get(0).getVersion());
         assertEquals(TestBackendConstants._TEST_Target_2_VERSION, result.get(1).getVersion());
-        assertEquals(TestBackendConstants._TEST_Target_1_LINK, result.get(0).getLink());
-        assertEquals(TestBackendConstants._TEST_Target_2_LINK, result.get(1).getLink());
+        assertEquals(TestBackendConstants._TEST_Target_1_LINK+"#"+TestBackendConstants._TEST_Target_1_FRAGMENT, result.get(0).getLink());
+        assertEquals(TestBackendConstants._TEST_Target_2_LINK+"#Vroege_werk", result.get(1).getLink());
 
     }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql	(revision 4180)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/resources/test-data/InsertTestData.sql	(revision 4181)
@@ -61,11 +61,11 @@
 
 
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000031', 'http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia', 'version 1.0', '#de_Opdracht'); -- 1
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000032', 'http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD', 'version 1.0', '##Vroege_werk'); --2
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000033', 'http://en.wikipedia.org/wiki/Art_Nouveau', 'june 1013', '##Spain'); --3
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000034', '???', 'back up', '#1111'); --4
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000035', '???', 'back up', '#111111'); --5
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000036', '???', 'version 2.0', '#1111111'); --6 not used by any annotation
-INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000037', '???', 'version 2.0', '#11111111');
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000031', 'http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia', 'version 1.0', 'de_Opdracht'); -- 1
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000032', 'http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD', 'version 1.0', 'Vroege_werk'); --2
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000033', 'http://en.wikipedia.org/wiki/Art_Nouveau', 'june 1013', 'Spain'); --3
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000034', '???', 'back up', '1111'); --4
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000035', '???', 'back up', '111111'); --5
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000036', '???', 'version 2.0', '1111111'); --6 not used by any annotation
+INSERT INTO target (external_id, link_uri, version, fragment_descriptor) VALUES ('00000000-0000-0000-0000-000000000037', '???', 'version 2.0', '11111111');
 
 
