Ignore:
Timestamp:
06/24/14 17:43:30 (10 years ago)
Author:
olhsha@mpi.nl
Message:

ref --> href
+ xml:id for instances
refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/TestInstances.java

    r4903 r5385  
    2626import eu.dasish.annotation.schema.Permission;
    2727import eu.dasish.annotation.schema.PermissionList;
     28import java.util.UUID;
    2829import javax.xml.datatype.DatatypeConfigurationException;
    2930import javax.xml.datatype.DatatypeFactory;
     
    3839    final private Annotation _annotationToAdd;
    3940
    40     public TestInstances(String baseURI) {
    41         _annotationOne = makeAnnotationOne(baseURI);
    42         _annotationToAdd = makeAnnotationToAdd(baseURI);
     41    public TestInstances(String relativePath) {
     42        _annotationOne = makeAnnotationOne(relativePath);
     43        _annotationToAdd = makeAnnotationToAdd(relativePath);
    4344    }
    4445
    45     private Annotation makeAnnotationOne(String baseURI) {
    46         Annotation result = makeAnnotation(baseURI, "<html><body>some html 1</body></html>", "text/html", "Sagrada Famiglia", "00000000-0000-0000-0000-000000000111");
    47         result.setURI(baseURI+"annotations/00000000-0000-0000-0000-000000000021");
    48        
     46    private Annotation makeAnnotationOne(String relativePath) {
     47        Annotation result = makeAnnotation(relativePath, "<html><body>some html 1</body></html>", "text/html", "Sagrada Famiglia", "00000000-0000-0000-0000-000000000111", "00000000-0000-0000-0000-000000000021");
     48
    4949        try {
    5050            result.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar("2013-08-12T09:25:00.383000Z"));
     
    5959
    6060        Permission up1 = new Permission();
    61         up1.setPrincipalRef(baseURI + "principals/00000000-0000-0000-0000-000000000112");
     61        up1.setPrincipalHref(relativePath + "/principals/00000000-0000-0000-0000-000000000112");
    6262        up1.setLevel(Access.WRITE);
    6363
    6464        Permission up2 = new Permission();
    65         up2.setPrincipalRef(baseURI + "principals/00000000-0000-0000-0000-000000000113");
     65        up2.setPrincipalHref(relativePath + "/principals/00000000-0000-0000-0000-000000000113");
    6666        up2.setLevel(Access.READ);
    6767
     
    7272        TargetInfo target1 = new TargetInfo();
    7373        target1.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia");
    74         target1.setRef(baseURI + "targets/00000000-0000-0000-0000-000000000031");
     74        target1.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000031");
    7575        target1.setVersion("version 1.0");
    7676
    7777        TargetInfo target2 = new TargetInfo();
    7878        target2.setLink("http://nl.wikipedia.org/wiki/Antoni_Gaud%C3%AD");
    79         target2.setRef(baseURI + "targets/00000000-0000-0000-0000-000000000032");
     79        target2.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000032");
    8080        target2.setVersion("version 1.1");
    8181
     
    8686    }
    8787
    88     private Annotation makeAnnotationToAdd(String baseURI) {
    89         Annotation result = makeAnnotation(baseURI, "<html><body>some html 3</body></html>", "text/plain", "Annotation to add to test DAO", "00000000-0000-0000-0000-000000000113");
     88    private Annotation makeAnnotationToAdd(String relativePath) {
     89        Annotation result = makeAnnotation(relativePath, "<html><body>some html 3</body></html>", "text/plain", "Annotation to add to test DAO", "00000000-0000-0000-0000-000000000113",  UUID.randomUUID().toString());
    9090
    9191        TargetInfo TargetInfo = new TargetInfo();
    9292        TargetInfo.setLink("http://nl.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia#de_Opdracht");
    93         TargetInfo.setRef(baseURI+  "targets/00000000-0000-0000-0000-000000000031");
     93        TargetInfo.setHref(relativePath + "/targets/00000000-0000-0000-0000-000000000031");
    9494        TargetInfo.setVersion("version 1.0");
    9595
     
    9797        targetInfos.getTargetInfo().add(TargetInfo);
    9898        result.setTargets(targetInfos);
    99        
     99
    100100        PermissionList permissions = new PermissionList();
    101101        permissions.setPublic(Access.WRITE);
    102102        result.setPermissions(permissions);
    103        
     103
    104104        return result;
    105105    }
    106106
    107     private Annotation makeAnnotation(String baseURI, String bodyTxt, String bodyMimeType, String headline, String ownerExternalId) {
     107    private Annotation makeAnnotation(String relativePath, String bodyTxt, String bodyMimeType, String headline, String ownerExternalId, String externalId) {
    108108        Annotation result = new Annotation();
     109       
    109110        AnnotationBody body = new AnnotationBody();
    110111        result.setBody(body);
     
    113114        textBody.setMimeType(bodyMimeType);
    114115        textBody.setBody(bodyTxt);
    115 
     116       
    116117        result.setHeadline(headline);
    117 
    118         if (baseURI != null) {
    119             result.setOwnerRef(baseURI + "principals/" + ownerExternalId);
    120         } else {
    121             result.setOwnerRef("principals/" + ownerExternalId);
    122         }
    123 
     118        result.setOwnerHref(relativePath + "/principals/" + ownerExternalId);
    124119        result.setLastModified(null);
    125         result.setURI(null);
     120        result.setId(externalId);
     121        result.setHref(relativePath + "/annotations/"+externalId);
    126122        result.setTargets(null);
    127         result.setURI(null);
    128 
    129123        return result;
    130124    }
Note: See TracChangeset for help on using the changeset viewer.