Changeset 9:b2bfc3bc9ba8 in AnnotationManagerN4J for src
- Timestamp:
- Jul 12, 2012, 10:54:46 AM (13 years ago)
- Branch:
- default
- 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 48 48 49 49 /** 50 * The URI of thecreator of this annotation.50 * The creator of this annotation. 51 51 */ 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; 58 53 59 54 /** … … 149 144 150 145 /** 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 /** 151 160 * @return the creatorUri 152 161 */ 153 162 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; 162 167 } 163 168 … … 166 171 */ 167 172 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; 176 177 } 177 178 -
src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
r8 r9 18 18 import org.neo4j.graphdb.index.IndexHits; 19 19 20 import de.mpiwg.itgroup.annotations.Actor; 20 21 import de.mpiwg.itgroup.annotations.Annotation; 21 22 import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes; … … 95 96 annot.setFragmentType(FragmentTypes.valueOf(ft)); 96 97 } 97 // get creator f orm relation98 // get creator from relation 98 99 Iterable<Relationship> creatorRels = annotNode 99 100 .getRelationships(RelationTypes.CREATED); 100 101 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); 104 107 // just the first one 105 108 break; -
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java
r5 r9 5 5 6 6 import java.io.UnsupportedEncodingException; 7 import java.net.URLDecoder;8 import java.net.URLEncoder;9 7 import java.security.InvalidKeyException; 10 8 import java.security.SignatureException; … … 36 34 import org.restlet.resource.ServerResource; 37 35 36 import de.mpiwg.itgroup.annotations.Actor; 38 37 import de.mpiwg.itgroup.annotations.Annotation; 39 38 import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes; … … 194 193 // make short user id 195 194 String userId = annot.getCreatorUri(); 195 // remove namespace from user uri to get id 196 196 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 201 200 userObject.put("id", userId); 202 201 // get full name … … 390 389 * } authUser = httpUser.getIdentifier(); 391 390 */ 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); 392 397 } 393 398 // username not required, if no username given authuser will be used … … 414 419 } 415 420 // try to get full name 416 if ( username != null) {421 if (creator.getName() == null && username != null) { 417 422 RestServer restServer = (RestServer) getApplication(); 418 423 String fullName = restServer.getFullNameFromLdap(username); 419 annot.setCreatorName(fullName);424 creator.setName(fullName); 420 425 } 421 426 // userUri should be a URI, if not it will set to the MPIWG namespace … … 428 433 } 429 434 // TODO: should we overwrite the creator? 430 if ( annot.getCreatorUri() == null) {431 annot.setCreatorUri(userUri);435 if (creator.getUri() == null) { 436 creator.setUri(userUri); 432 437 } 433 438
Note: See TracChangeset
for help on using the changeset viewer.