View Javadoc
1   /*
2    * Copyright (C) 2003-2011 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero General Public License
15   * along with this program. If not, see <http://www.gnu.org/licenses/>.
16   */
17  
18  package org.exoplatform.social.core.chromattic.entity;
19  
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.chromattic.api.annotations.Create;
24  import org.chromattic.api.annotations.FormattedBy;
25  import org.chromattic.api.annotations.Id;
26  import org.chromattic.api.annotations.MappedBy;
27  import org.chromattic.api.annotations.NamingPrefix;
28  import org.chromattic.api.annotations.OneToMany;
29  import org.chromattic.api.annotations.OneToOne;
30  import org.chromattic.api.annotations.Owner;
31  import org.chromattic.api.annotations.PrimaryType;
32  import org.chromattic.api.annotations.Properties;
33  import org.chromattic.api.annotations.Property;
34  import org.chromattic.ext.format.BaseEncodingObjectFormatter;
35  import org.chromattic.ext.ntdef.NTFile;
36  import org.exoplatform.social.core.storage.query.PropertyLiteralExpression;
37  
38  /**
39   * @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
40   * @version $Revision$
41   */
42  @PrimaryType(name = "soc:profiledefinition")
43  @FormattedBy(BaseEncodingObjectFormatter.class)
44  @NamingPrefix("soc")
45  public abstract class ProfileEntity {
46  
47    @Id
48    public abstract String getId();
49  
50    /**
51     * The users's avatar.
52     */
53    @MappedBy("soc:avatar")
54    @OneToOne
55    @Owner
56    public abstract NTFile getAvatar();
57    public abstract void setAvatar(NTFile avatar);
58  
59    @MappedBy("soc:profile")
60    @OneToOne
61    public abstract IdentityEntity getIdentity();
62    public abstract void setIdentity(IdentityEntity identity);
63    
64    @MappedBy("soc:activityprofile")
65    @OneToOne
66    @Owner
67    public abstract ActivityProfileEntity getActivityProfile();
68    public abstract void setActivityProfile(ActivityProfileEntity entity);
69  
70    /**
71     * The external URL of an identity who does not exist in the identities list of the Social providers,
72     * (_OrganizationIdentityProvider_ and _SpaceIdentityProvider_).
73     * @return
74     */
75  
76    @Property(name = "soc:externalUrl")
77    public abstract String getExternalUrl();
78    public abstract void setExternalUrl(String profileUrl);
79  
80    /**
81     * The external avatar URL of an identity who does not exist in the identities list of the Social providers,
82     * (_OrganizationIdentityProvider_ and _SpaceIdentityProvider_).
83     * @return
84     */
85  
86    @Property(name = "soc:externalAvatarUrl")
87    public abstract String getExternalAvatarUrl();
88    public abstract void setExternalAvatarUrl(String avatarUrl);
89    
90    /**
91     * The parent Id is the identity Id. It is used for queries.
92     * @return
93     */
94    // TODO : find better
95    @Property(name = "soc:parentId")
96    public abstract String getParentId();
97    public abstract void setParentId(String parentid);
98    public static final PropertyLiteralExpression<String> parentId =
99        new PropertyLiteralExpression<String>(String.class, "soc:parentId");
100 
101   /**
102    * The created time
103    */
104   @Property(name = "soc:createdTime")
105   public abstract Long getCreatedTime();
106   public abstract void setCreatedTime(Long createdTime);
107   public static final PropertyLiteralExpression<Long> createdTime =
108       new PropertyLiteralExpression<Long>(Long.class, "soc:createdTime");
109 
110   /**
111    * All the experiences stored in the profile.
112    */
113   @OneToMany
114   @Owner
115   public abstract Map<String, ProfileXpEntity> getXps();
116 
117   @Properties
118   public abstract Map<String, List<String>> getProperties();
119   public static final PropertyLiteralExpression<String> firstName =
120       new PropertyLiteralExpression<String>(String.class, "void-firstName");
121   
122   public static final PropertyLiteralExpression<String> lastName =
123       new PropertyLiteralExpression<String>(String.class, "void-lastName");
124 
125   public static final PropertyLiteralExpression<String> fullName =
126       new PropertyLiteralExpression<String>(String.class, "void-fullName");
127 
128   public static final PropertyLiteralExpression<String> aboutMe =
129       new PropertyLiteralExpression<String>(String.class, "void-aboutMe");
130 
131   public static final PropertyLiteralExpression<String> position =
132       new PropertyLiteralExpression<String>(String.class, "void-position");
133   
134   public static final PropertyLiteralExpression<String> gender =
135       new PropertyLiteralExpression<String>(String.class, "void-gender");
136 
137   public static final PropertyLiteralExpression<String> deleted =
138       new PropertyLiteralExpression<String>(String.class, "void-deleted");
139 
140   public static final PropertyLiteralExpression<String> skills =
141       new PropertyLiteralExpression<String>(String.class, "index-skills");
142 
143   public static final PropertyLiteralExpression<String> positions =
144       new PropertyLiteralExpression<String>(String.class, "index-position");
145 
146   public static final PropertyLiteralExpression<String> organizations =
147       new PropertyLiteralExpression<String>(String.class, "index-company");
148 
149   public static final PropertyLiteralExpression<String> jobsDescription =
150       new PropertyLiteralExpression<String>(String.class, "index-description");
151 
152   @Create
153   public abstract NTFile createAvatar();
154 
155   @Create
156   public abstract ProfileXpEntity createXp();
157   
158   @Create
159   public abstract ActivityProfileEntity createActivityProfile();
160 
161   public List<String> getProperty(String key) {
162     return getProperties().get(key);
163   }
164 
165   public void setProperty(String key, List<String> value) {
166     getProperties().put(key, value);
167   }
168   
169   public String getPropertyFirst(String key) {
170     List<String> value = getProperties().get(key);
171     return (value.size() > 0 ? value.get(0) : null);
172   }
173 }