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 * <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 016 * 017 * $Id: IORelationResources.java 25081 2007-09-18 14:57:22Z atchertchian $ 018 */ 019 020package org.nuxeo.ecm.platform.relations.io; 021 022import java.util.Collections; 023import java.util.List; 024import java.util.Map; 025import java.util.Set; 026 027import org.nuxeo.ecm.core.api.DocumentRef; 028import org.nuxeo.ecm.platform.io.api.IOResources; 029import org.nuxeo.ecm.platform.relations.api.Resource; 030import org.nuxeo.ecm.platform.relations.api.Statement; 031 032/** 033 * IO Resources for relations 034 * <p> 035 * Holds a map of document resources, with a document reference as key, and a list of RDF resources as values. 036 * <p> 037 * Actual statements to manage for export/import are not kept here. 038 * 039 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 040 */ 041public class IORelationResources implements IOResources { 042 043 private static final long serialVersionUID = 3613545698356485035L; 044 045 final Map<String, String> namespaces; 046 047 final Map<DocumentRef, Set<Resource>> documentResources; 048 049 final List<Statement> statements; 050 051 public IORelationResources(Map<String, String> namespaces, Map<DocumentRef, Set<Resource>> documentResources, 052 List<Statement> statements) { 053 this.namespaces = namespaces; 054 this.documentResources = documentResources; 055 this.statements = statements; 056 } 057 058 public Map<String, String> getNamespaces() { 059 return namespaces; 060 } 061 062 public Map<DocumentRef, Set<Resource>> getResourcesMap() { 063 return Collections.unmodifiableMap(documentResources); 064 } 065 066 public Set<Resource> getDocumentResources(DocumentRef docRef) { 067 Set<Resource> res = documentResources.get(docRef); 068 if (res != null) { 069 return Collections.unmodifiableSet(res); 070 } 071 return null; 072 } 073 074 public List<Statement> getStatements() { 075 return statements; 076 } 077 078}