001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (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 * Anahide Tchertchian 016 * Florent Guillaume 017 */ 018package org.nuxeo.ecm.platform.relations.api; 019 020import java.io.InputStream; 021import java.io.OutputStream; 022import java.io.Serializable; 023import java.util.List; 024import java.util.Map; 025import java.util.Set; 026 027import org.nuxeo.ecm.core.api.CoreSession; 028 029/** 030 * RelationService common interface. 031 */ 032public interface RelationManager extends Serializable { 033 034 /** 035 * Gets a registered graph by name. 036 * <p> 037 * A {@link CoreSession} should be passed to provide a context in which to store relations when using a "core" 038 * graph. 039 * 040 * @param name string name of the graph used at registration 041 * @param session the core session 042 * @return the graph 043 * @throws RuntimeException if the graph is not found 044 * @since 5.5 045 */ 046 Graph getGraph(String name, CoreSession session); 047 048 /** 049 * Gets a registered graph by name. 050 * 051 * @param name string name of the graph used at registration 052 * @return the graph 053 * @throws RuntimeException if the graph is not found 054 */ 055 Graph getGraphByName(String name); 056 057 /** 058 * Gets a transient graph. 059 * 060 * @param type The graph type. 061 * @return the graph. 062 */ 063 Graph getTransientGraph(String type); 064 065 /** 066 * Gets a resource given a namespace and a serializable object. 067 * <p> 068 * There can be several resources with different namespaces associated to an incoming object. A document can for 069 * instance be used to refer to itself as a precise version as well as to the set of all versions. 070 * <p> 071 * Context can hold any object useful for the adapters, like a {@link CoreSession}. 072 * 073 * @since 5.2-M1 074 */ 075 Resource getResource(String namespace, Serializable object, Map<String, Object> context); 076 077 /** 078 * Computes all resources corresponding to the given object. 079 * <p> 080 * Context can hold any object useful for the adapters, like a {@link CoreSession}. 081 * 082 * @since 5.2-M1 083 * @return the resources as a set 084 */ 085 Set<Resource> getAllResources(Serializable object, Map<String, Object> context); 086 087 /** 088 * Gets an object representing this resource given a namespace. 089 * <p> 090 * Context can hold any object useful for the adapters, like a {@link CoreSession}. 091 * 092 * @since 5.2-M1 093 */ 094 Serializable getResourceRepresentation(String namespace, Resource resource, Map<String, Object> context); 095 096 /** 097 * Gets the list containing the graph names. 098 * 099 * @since 5.2-GA 100 */ 101 List<String> getGraphNames(); 102 103 /** 104 * @see org.nuxeo.ecm.platform.relations.api.Graph#add 105 * @deprecated since 5.5, use the Graph API directly 106 */ 107 @Deprecated 108 void add(String graphName, List<Statement> statements); 109 110 /** 111 * @see org.nuxeo.ecm.platform.relations.api.Graph#remove 112 * @deprecated since 5.5, use the Graph API directly 113 */ 114 @Deprecated 115 void remove(String graphName, List<Statement> statements); 116 117 /** 118 * @see org.nuxeo.ecm.platform.relations.api.Graph#getStatements 119 * @deprecated since 5.5, use the Graph API directly 120 */ 121 @Deprecated 122 List<Statement> getStatements(String graphName); 123 124 /** 125 * @see org.nuxeo.ecm.platform.relations.api.Graph#getStatements 126 * @deprecated since 5.5, use the Graph API directly 127 */ 128 @Deprecated 129 List<Statement> getStatements(String graphName, Statement statement); 130 131 /** 132 * @see org.nuxeo.ecm.platform.relations.api.Graph#getSubjects 133 * @deprecated since 5.5, use the Graph API directly 134 */ 135 @Deprecated 136 List<Node> getSubjects(String graphName, Node predicate, Node object); 137 138 /** 139 * @see org.nuxeo.ecm.platform.relations.api.Graph#getPredicates 140 * @deprecated since 5.5, use the Graph API directly 141 */ 142 @Deprecated 143 List<Node> getPredicates(String graphName, Node subject, Node object); 144 145 /** 146 * @see org.nuxeo.ecm.platform.relations.api.Graph#getObjects 147 * @deprecated since 5.5, use the Graph API directly 148 */ 149 @Deprecated 150 List<Node> getObjects(String graphName, Node subject, Node predicate); 151 152 /** 153 * @see org.nuxeo.ecm.platform.relations.api.Graph#hasStatement 154 * @deprecated since 5.5, use the Graph API directly 155 */ 156 @Deprecated 157 boolean hasStatement(String graphName, Statement statement); 158 159 /** 160 * @see org.nuxeo.ecm.platform.relations.api.Graph#hasResource 161 * @deprecated since 5.5, use the Graph API directly 162 */ 163 @Deprecated 164 boolean hasResource(String graphName, Resource resource); 165 166 /** 167 * @see org.nuxeo.ecm.platform.relations.api.Graph#size 168 * @deprecated since 5.5, use the Graph API directly 169 */ 170 @Deprecated 171 Long size(String graphName); 172 173 /** 174 * @see org.nuxeo.ecm.platform.relations.api.Graph#clear 175 * @deprecated since 5.5, use the Graph API directly 176 */ 177 @Deprecated 178 void clear(String graphName); 179 180 /** 181 * @see org.nuxeo.ecm.platform.relations.api.Graph#query 182 * @deprecated since 5.5, use the Graph API directly 183 */ 184 @Deprecated 185 QueryResult query(String graphName, String queryString, String language, String baseURI); 186 187 /** 188 * @see org.nuxeo.ecm.platform.relations.api.Graph#read 189 * @deprecated since 5.5, use the Graph API directly 190 */ 191 @Deprecated 192 boolean read(String graphName, InputStream in, String lang, String base); 193 194 /** 195 * @see org.nuxeo.ecm.platform.relations.api.Graph#write 196 * @deprecated since 5.5, use the Graph API directly 197 */ 198 @Deprecated 199 boolean write(String graphName, OutputStream out, String lang, String base); 200 201}