001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thierry Delprat 018 */ 019package org.nuxeo.apidoc.tree; 020 021import org.nuxeo.apidoc.api.AssociatedDocuments; 022import org.nuxeo.apidoc.api.ComponentInfo; 023import org.nuxeo.apidoc.api.NuxeoArtifact; 024import org.nuxeo.apidoc.api.VirtualNodesConsts; 025import org.nuxeo.ecm.core.api.CoreSession; 026 027public class VirtualNode implements NuxeoArtifact { 028 029 protected final String cid; 030 031 protected final String version; 032 033 protected final String type; 034 035 protected final String id; 036 037 protected final String basePath; 038 039 public VirtualNode(ComponentInfo ci, String type, String id) { 040 cid = ci.getId(); 041 version = ci.getVersion(); 042 this.type = type; 043 this.id = id; 044 basePath = ci.getHierarchyPath(); 045 } 046 047 public String getComponentId() { 048 return cid; 049 } 050 051 @Override 052 public String getArtifactType() { 053 return type; 054 } 055 056 @Override 057 public AssociatedDocuments getAssociatedDocuments(CoreSession session) { 058 return null; 059 } 060 061 @Override 062 public String getId() { 063 return id; 064 } 065 066 @Override 067 public String getVersion() { 068 return version; 069 } 070 071 @Override 072 public String getHierarchyPath() { 073 if (VirtualNodesConsts.Services_VNODE.equals(type)) { 074 return basePath + "/" + VirtualNodesConsts.Services_VNODE_NAME; 075 } else if (VirtualNodesConsts.Contributions_VNODE.equals(type)) { 076 return basePath + "/" + VirtualNodesConsts.Contributions_VNODE_NAME; 077 } else if (VirtualNodesConsts.ExtensionPoints_VNODE.equals(type)) { 078 return basePath + "/" + VirtualNodesConsts.ExtensionPoints_VNODE_NAME; 079 } 080 return ""; 081 } 082 083 public String getAnchor() { 084 if (VirtualNodesConsts.Services_VNODE.equals(type)) { 085 return "services"; 086 } else if (VirtualNodesConsts.ExtensionPoints_VNODE.equals(type)) { 087 return "extensionPoints"; 088 } else if (VirtualNodesConsts.Contributions_VNODE.equals(type)) { 089 return "contributions"; 090 } 091 return ""; 092 } 093}