View Javadoc
1   /*
2    * Copyright (C) 2003-2009 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (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 General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.wiki.mow.core.api.wiki;
18  
19  import org.chromattic.api.RelationshipType;
20  import org.chromattic.api.annotations.Create;
21  import org.chromattic.api.annotations.ManyToOne;
22  import org.chromattic.api.annotations.MappedBy;
23  import org.chromattic.api.annotations.OneToOne;
24  import org.chromattic.api.annotations.Owner;
25  import org.chromattic.api.annotations.PrimaryType;
26  import org.exoplatform.portal.config.model.PortalConfig;
27  import org.exoplatform.wiki.mow.api.WikiType;
28  
29  /**
30   * @version $Revision$
31   */
32  @PrimaryType(name = WikiNodeType.USER_WIKI)
33  public abstract class UserWiki extends WikiImpl {
34    
35    public WikiType getWikiType() {
36      return WikiType.USER;
37    }
38  
39    @Override
40    public String getType() {
41      return PortalConfig.USER_TYPE;
42    }
43    
44    public PageImpl getDraftPagesContainer() {
45      PageImpl page = getDraftPagesContainerByChromattic();
46      if (page == null) {
47        page = createWikiPage();
48        setDraftPagesContainerByChromattic(page);
49      }
50      return page;
51    }
52    
53    @ManyToOne(type = RelationshipType.REFERENCE)
54    @MappedBy(WikiNodeType.Definition.WIKI_CONTAINER_REFERENCE)
55    public abstract UserWikiContainer getUserWikis();
56    
57    public abstract void setUserWikis(UserWikiContainer userWikiContainer);
58    
59    @OneToOne
60    @Owner
61    @MappedBy(WikiNodeType.Definition.DRAFT_PAGES)
62    protected abstract PageImpl getDraftPagesContainerByChromattic();
63    protected abstract void setDraftPagesContainerByChromattic(PageImpl page);
64     
65    @Create
66    public abstract DraftPageImpl createDraftPage();
67  }