001/* 002 * (C) Copyright 2006-2016 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 * Anahide Tchertchian 018 * Florent Guillaume 019 */ 020package org.nuxeo.ecm.platform.relations.api; 021 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}