Changeset 9:b2bfc3bc9ba8 in AnnotationManagerN4J for src


Ignore:
Timestamp:
Jul 12, 2012, 10:54:46 AM (12 years ago)
Author:
casties
Branch:
default
Message:

new internal actor class for creator.

Location:
src/main/java/de/mpiwg/itgroup/annotations
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/Annotation.java

    r8 r9  
    4848   
    4949    /**
    50      * The URI of the creator of this annotation.
     50     * The creator of this annotation.
    5151     */
    52     protected String creatorUri;
    53    
    54     /**
    55      * The full name of the creator of this annotation.
    56      */
    57     protected String creatorName;
     52    protected Actor creator;
    5853   
    5954    /**
     
    149144
    150145    /**
     146     * @return the creator
     147     */
     148    public Actor getCreator() {
     149        return creator;
     150    }
     151
     152    /**
     153     * @param creator the creator to set
     154     */
     155    public void setCreator(Actor creator) {
     156        this.creator = creator;
     157    }
     158
     159    /**
    151160     * @return the creatorUri
    152161     */
    153162    public String getCreatorUri() {
    154         return creatorUri;
    155     }
    156 
    157     /**
    158      * @param creatorUri the creatorUri to set
    159      */
    160     public void setCreatorUri(String creatorUri) {
    161         this.creatorUri = creatorUri;
     163        if (creator != null) {
     164            return creator.getUri();
     165        }
     166        return null;
    162167    }
    163168
     
    166171     */
    167172    public String getCreatorName() {
    168         return creatorName;
    169     }
    170 
    171     /**
    172      * @param creatorName the creatorName to set
    173      */
    174     public void setCreatorName(String creatorName) {
    175         this.creatorName = creatorName;
     173        if (creator != null) {
     174            return creator.getName();
     175        }
     176        return null;
    176177    }
    177178
  • src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java

    r8 r9  
    1818import org.neo4j.graphdb.index.IndexHits;
    1919
     20import de.mpiwg.itgroup.annotations.Actor;
    2021import de.mpiwg.itgroup.annotations.Annotation;
    2122import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes;
     
    9596                        annot.setFragmentType(FragmentTypes.valueOf(ft));
    9697                }
    97                 // get creator form relation
     98                // get creator from relation
    9899                Iterable<Relationship> creatorRels = annotNode
    99100                                .getRelationships(RelationTypes.CREATED);
    100101                for (Relationship creatorRel : creatorRels) {
    101                         Node creator = creatorRel.getStartNode();
    102                         annot.setCreatorUri((String) creator.getProperty("uri", null));
    103                         annot.setCreatorName((String) creator.getProperty("name", null));
     102                        Node creatorNode = creatorRel.getStartNode();
     103                        String uri = (String) creatorNode.getProperty("uri", null);
     104                        String name = (String) creatorNode.getProperty("name", null);
     105            Actor creator = new Actor(false, uri, name);
     106            annot.setCreator(creator);
    104107                        // just the first one
    105108                        break;
  • src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java

    r5 r9  
    55
    66import java.io.UnsupportedEncodingException;
    7 import java.net.URLDecoder;
    8 import java.net.URLEncoder;
    97import java.security.InvalidKeyException;
    108import java.security.SignatureException;
     
    3634import org.restlet.resource.ServerResource;
    3735
     36import de.mpiwg.itgroup.annotations.Actor;
    3837import de.mpiwg.itgroup.annotations.Annotation;
    3938import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes;
     
    194193                // make short user id
    195194                String userId = annot.getCreatorUri();
     195                // remove namespace from user uri to get id
    196196                if (userId != null && userId.startsWith(NS.MPIWG_PERSONS_URL)) {
    197                     userId = userId.replace(NS.MPIWG_PERSONS_URL, ""); // entferne
    198                                                                        // NAMESPACE
    199                 }
    200                 // save as id
     197                    userId = userId.replace(NS.MPIWG_PERSONS_URL, "");
     198                }
     199                // set as id
    201200                userObject.put("id", userId);
    202201                // get full name
     
    390389             * } authUser = httpUser.getIdentifier();
    391390             */
     391        }
     392        // get or create creator object
     393        Actor creator = annot.getCreator();
     394        if (creator == null) {
     395            creator = new Actor(false, null, null);
     396            annot.setCreator(creator);
    392397        }
    393398        // username not required, if no username given authuser will be used
     
    414419        }
    415420        // try to get full name
    416         if (username != null) {
     421        if (creator.getName() == null && username != null) {
    417422            RestServer restServer = (RestServer) getApplication();
    418423            String fullName = restServer.getFullNameFromLdap(username);
    419             annot.setCreatorName(fullName);
     424            creator.setName(fullName);
    420425        }
    421426        // userUri should be a URI, if not it will set to the MPIWG namespace
     
    428433        }
    429434        // TODO: should we overwrite the creator?
    430         if (annot.getCreatorUri() == null) {
    431             annot.setCreatorUri(userUri);
     435        if (creator.getUri() == null) {
     436            creator.setUri(userUri);
    432437        }
    433438       
Note: See TracChangeset for help on using the changeset viewer.