001/* 002 * (C) Copyright 2010-2011 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 * mcedica 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.routing.api; 023 024import java.util.ArrayList; 025import java.util.List; 026 027import org.nuxeo.ecm.core.api.DocumentModel; 028 029/** 030 * Wraps a documentElement adding informations about the level where the document is inside the container documentRoute 031 * 032 * @author <a href="mailto:[email protected]">Mariana Cedica</a> 033 * @deprecated since 5.9.2 - Use only routes of type 'graph' 034 */ 035public class DocumentRouteTableElement { 036 037 protected final DocumentRouteElement element; 038 039 protected final RouteTable table; 040 041 protected final int depth; 042 043 protected RouteFolderElement parent; 044 045 protected boolean isFirstChild; 046 047 protected List<RouteFolderElement> firstChildList = new ArrayList<RouteFolderElement>(); 048 049 public DocumentRouteTableElement(DocumentRouteElement element, RouteTable table, int depth, 050 RouteFolderElement parent, boolean isFirstChild) { 051 this.table = table; 052 this.depth = depth; 053 this.element = element; 054 this.parent = parent; 055 this.isFirstChild = isFirstChild; 056 } 057 058 public RouteFolderElement getParent() { 059 return parent; 060 } 061 062 public DocumentRouteElement getElement() { 063 return element; 064 } 065 066 public int getDepth() { 067 return depth; 068 } 069 070 public RouteTable getRouteTable() { 071 return table; 072 } 073 074 public List<RouteFolderElement> getFirstChildFolders() { 075 return firstChildList; 076 } 077 078 public int getRouteMaxDepth() { 079 return table.getMaxDepth(); 080 } 081 082 public DocumentModel getDocument() { 083 return element.getDocument(); 084 } 085 086 public void computeFirstChildList() { 087 RouteFolderElement currentParent = parent; 088 boolean currentIsFirst = isFirstChild; 089 while (currentIsFirst && currentParent != null) { 090 currentIsFirst = currentParent.isFirstChild; 091 firstChildList.add(0, currentParent); 092 currentParent = currentParent.parent; 093 } 094 } 095}