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