Mercurial > hg > AnnotationManagerN4J
diff src/main/java/de/mpiwg/itgroup/annotations/Actor.java @ 10:90911b2da322
more work on permissions...
author | casties |
---|---|
date | Thu, 12 Jul 2012 17:01:32 +0200 |
parents | b2bfc3bc9ba8 |
children | abe25edf2178 |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/Actor.java Thu Jul 12 12:54:46 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/Actor.java Thu Jul 12 17:01:32 2012 +0200 @@ -3,42 +3,24 @@ */ package de.mpiwg.itgroup.annotations; +import de.mpiwg.itgroup.annotations.old.NS; + /** * @author casties * */ -public class Actor { +public abstract class Actor { - public boolean isGroup; public String uri; public String name; + public String id; /** - * @param isGroup - * @param id - * @param uri - * @param name + * @return if this Actor is a Group */ - public Actor(boolean isGroup, String uri, String name) { - super(); - this.isGroup = isGroup; - this.uri = uri; - this.name = name; - } + public abstract boolean isGroup(); /** - * @return the isGroup - */ - public boolean isGroup() { - return isGroup; - } - /** - * @param isGroup the isGroup to set - */ - public void setGroup(boolean isGroup) { - this.isGroup = isGroup; - } - /** * @return the uri */ public String getUri() { @@ -62,4 +44,62 @@ public void setName(String name) { this.name = name; } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * Returns id as a String starting with "group:" for groups. + * + * @return + */ + public abstract String getIdString(); + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * Returns a short id from an uri. + * + * @param uri + * @return + */ + public static String getIdFromUri(String uri, boolean isGroup) { + String id = null; + String prefix = NS.MPIWG_PERSONS_URL; + if (isGroup) { + prefix = NS.MPIWG_GROUPS_URL; + } + if (uri != null && uri.startsWith(prefix)) { + id = uri.replace(prefix, ""); + } + return id; + } + + /** + * Returns an uri from a short id. + * + * @param id + * @return + */ + public static String getUriFromId(String id, boolean isGroup) { + String uri = null; + String prefix = NS.MPIWG_PERSONS_URL; + if (isGroup) { + prefix = NS.MPIWG_GROUPS_URL; + } + if (id != null && ! id.startsWith("http://")) { + uri = prefix + id; + } + return uri; + } + }