001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Thierry Delprat 016 */ 017package org.nuxeo.apidoc.tree; 018 019import org.nuxeo.apidoc.api.AssociatedDocuments; 020import org.nuxeo.apidoc.api.ComponentInfo; 021import org.nuxeo.apidoc.api.NuxeoArtifact; 022import org.nuxeo.apidoc.api.VirtualNodesConsts; 023import org.nuxeo.ecm.core.api.CoreSession; 024 025public class VirtualNode implements NuxeoArtifact { 026 027 protected final String cid; 028 029 protected final String version; 030 031 protected final String type; 032 033 protected final String id; 034 035 protected final String basePath; 036 037 public VirtualNode(ComponentInfo ci, String type, String id) { 038 cid = ci.getId(); 039 version = ci.getVersion(); 040 this.type = type; 041 this.id = id; 042 basePath = ci.getHierarchyPath(); 043 } 044 045 public String getComponentId() { 046 return cid; 047 } 048 049 @Override 050 public String getArtifactType() { 051 return type; 052 } 053 054 @Override 055 public AssociatedDocuments getAssociatedDocuments(CoreSession session) { 056 return null; 057 } 058 059 @Override 060 public String getId() { 061 return id; 062 } 063 064 @Override 065 public String getVersion() { 066 return version; 067 } 068 069 @Override 070 public String getHierarchyPath() { 071 if (VirtualNodesConsts.Services_VNODE.equals(type)) { 072 return basePath + "/" + VirtualNodesConsts.Services_VNODE_NAME; 073 } else if (VirtualNodesConsts.Contributions_VNODE.equals(type)) { 074 return basePath + "/" + VirtualNodesConsts.Contributions_VNODE_NAME; 075 } else if (VirtualNodesConsts.ExtensionPoints_VNODE.equals(type)) { 076 return basePath + "/" + VirtualNodesConsts.ExtensionPoints_VNODE_NAME; 077 } 078 return ""; 079 } 080 081 public String getAnchor() { 082 if (VirtualNodesConsts.Services_VNODE.equals(type)) { 083 return "services"; 084 } else if (VirtualNodesConsts.ExtensionPoints_VNODE.equals(type)) { 085 return "extensionPoints"; 086 } else if (VirtualNodesConsts.Contributions_VNODE.equals(type)) { 087 return "contributions"; 088 } 089 return ""; 090 } 091}