001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (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 * George Lefter 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.platform.ui.web.directory; 021 022import org.nuxeo.ecm.core.api.DocumentModel; 023 024/** 025 * This class is used by ChainSelectOne / ChainSelectMany components. It represents an entry in a directory. 026 * 027 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a> 028 */ 029public class DirectoryEntry { 030 031 public static final String XVOCABULARY = "xvocabulary"; 032 033 private final String parent; 034 035 private final String id; 036 037 private final String label; 038 039 public DirectoryEntry(String schemaName, DocumentModel model) { 040 if (model == null) { 041 throw new IllegalArgumentException("model cannot be null"); 042 } 043 044 if (schemaName == null) { 045 throw new IllegalArgumentException("schemaName cannot be null"); 046 } 047 048 id = (String) model.getProperty(schemaName, "id"); 049 label = (String) model.getProperty(schemaName, "label"); 050 if (XVOCABULARY.equals(schemaName)) { 051 parent = (String) model.getProperty(schemaName, "parent"); 052 } else { 053 parent = null; 054 } 055 } 056 057 public String getId() { 058 return id; 059 } 060 061 public String getLabel() { 062 return label; 063 } 064 065 public String getParent() { 066 return parent; 067 } 068 069}