source: AnnotationManagerN4J/src/main/java/de/mpiwg/itgroup/annotations/Person.java @ 105:7417f5915181

Last change on this file since 105:7417f5915181 was 103:f83eb8b335b1, checked in by casties, 7 years ago

fix problem with anonymous being different.

File size: 2.5 KB
Line 
1package de.mpiwg.itgroup.annotations;
2
3/*
4 * #%L
5 * AnnotationManager
6 * %%
7 * Copyright (C) 2012 - 2014 MPIWG Berlin
8 * %%
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program.  If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * #L%
23 */
24
25import java.util.Set;
26
27import de.mpiwg.itgroup.annotations.restlet.BaseRestlet;
28
29/**
30 * @author casties
31 *
32 */
33public class Person extends Actor {
34
35    public Set<String> groups;
36   
37    public Person() {
38    }
39
40    public Person(String id) {
41        super();
42        this.id = id;
43    }
44
45    public Person(String uri, String name) {
46        super();
47        this.uri = uri;
48        this.name = name;
49    }
50
51    public Person(String id, String uri, String name) {
52        super();
53        this.id = id;
54        this.uri = uri;
55        this.name = name;
56    }
57
58    @Override
59    public boolean isGroup() {
60        return false;
61    }
62
63    public String getIdString() {
64        if (id == null) {
65            id = getIdFromUri(uri, false);
66        }
67        return id;
68    }
69
70    /**
71     * Returns a Person with this id or null.
72     *
73     * @param id
74     * @return
75     */
76    public static Person createPersonWithId(String id) {
77        if (id != null) {
78            return new Person(id);
79        }
80        return null;
81    }
82
83    /**
84     * Sets the name from the id using getFullNameForId of the Application.
85     * 
86     * @param application
87     * @return
88     */
89    public String updateName(BaseRestlet application) {
90        if (id != null) {
91            name = application.getFullNameForId(id);
92        }
93        return name;
94    }
95   
96    /**
97     * Returns the anonymous Person.
98     *
99     * @return
100     */
101    public static Person getAnonymous() {
102        return new Person("anonymous", null, "Anonymous");
103    }
104
105    /* (non-Javadoc)
106     * @see java.lang.Object#toString()
107     */
108    @Override
109    public String toString() {
110        String s = "PERSON["+id+"]";
111        if (name != null) {
112            s += ": "+name;
113        }
114        return s;
115    }
116}
Note: See TracBrowser for help on using the repository browser.