View Javadoc
1   /*
2    * Copyright (C) 2003-2007 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.ecm.webui.component.explorer.versions;
18  
19  import java.util.Calendar;
20  
21  import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace;
22  import org.exoplatform.services.wcm.core.NodeLocation;
23  import org.exoplatform.webui.config.annotation.ComponentConfig;
24  import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
25  import org.exoplatform.webui.form.UIForm;
26  /**
27   * Created by The eXo Platform SARL
28   * Author : Tran The Trong
29   *          trongtt@gmail.com
30   * Oct 20, 2006
31   */
32  
33  @ComponentConfig(
34      lifecycle = UIFormLifecycle.class,
35      template = "app:/groovy/webui/component/explorer/versions/UINodeInfo.gtmpl"
36  )
37  public class UINodeInfo extends UIForm {
38  
39    private NodeLocation node_ ;
40    private String versionCreatedDate_ ;
41  
42    public UINodeInfo() {
43  
44    }
45  
46    public void update() throws Exception {
47      UIVersionInfo uiVersionInfo = getAncestorOfType(UIDocumentWorkspace.class).getChild(UIVersionInfo.class);
48      node_ = NodeLocation.getNodeLocationByNode(uiVersionInfo.getCurrentNode());
49      Calendar createdTime = uiVersionInfo.getCurrentVersionNode().getCreatedTime();
50      if (createdTime != null) {
51        versionCreatedDate_ = createdTime.getTime().toString();
52      }
53    }
54  
55    public String getNodeType() throws Exception {
56      return NodeLocation.getNodeByLocation(node_).getPrimaryNodeType().getName();
57    }
58  
59    public String getNodeName() throws Exception {
60      return NodeLocation.getNodeByLocation(node_).getName();
61    }
62  
63    public String getVersionName() throws Exception {
64      return getAncestorOfType(UIDocumentWorkspace.class).getChild(UIVersionInfo.class) .getCurrentVersionNode().getName();
65    }
66  
67    public String getVersionLabels() throws Exception{
68      UIVersionInfo uiVersionInfo = getAncestorOfType(UIDocumentWorkspace.class).getChild(UIVersionInfo.class) ;
69      String[] labels = uiVersionInfo.getVersionLabels(uiVersionInfo.getCurrentVersionNode());
70      StringBuilder label = new StringBuilder() ;
71      if(labels.length  == 0 ) return "N/A" ;
72      for(String temp : labels) {
73        label.append(temp).append(" ") ;
74      }
75      return label.toString() ;
76    }
77  
78    public String getVersionCreatedDate() throws Exception {
79      return versionCreatedDate_;
80    }
81  }