Package org.nuxeo.ecm.platform.relations
Class CoreGraph
- java.lang.Object
-
- org.nuxeo.ecm.platform.relations.CoreGraph
-
- All Implemented Interfaces:
Serializable,Graph
public class CoreGraph extends Object implements Graph
Relation graph implementation delegating to the core.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classCoreGraph.NodeAsStringOnly one of those is filled.protected classCoreGraph.ResourceFinderprotected classCoreGraph.SizeFinderprotected classCoreGraph.StatementAdderprotected classCoreGraph.StatementFinderprotected classCoreGraph.StatementRemoverstatic classCoreGraph.SubjectsFake Node type used to pass down multiple nodes into whereBuilder.
-
Field Summary
Fields Modifier and Type Field Description protected static StatementALLstatic StringBLANK_NSstatic StringCOMMENT_NAMESPACEHas no final slash (compat).static StringDC_CREATEDstatic StringDC_CREATORstatic StringDC_DESCRIPTIONstatic StringDC_MODIFIEDstatic StringDC_TITLEstatic String[]DOC_NAMESPACESprotected StringdocTypestatic StringDOCUMENT_NAMESPACEstatic StringDOCUMENT_NAMESPACE2Without final slash (compat).protected static List<Statement>EMPTY_STATEMENTSprotected StringnameList<String>namespaceListMap<String,String>namespacesstatic StringOPTION_DOCTYPEstatic StringREL_PREDICATEstatic StringREL_SOURCE_IDstatic StringREL_SOURCE_URIstatic StringREL_TARGET_IDstatic StringREL_TARGET_STRINGstatic StringREL_TARGET_URIstatic StringREL_TYPEprotected CoreSessionsessionstatic PatternSPARQL_PO_Sstatic PatternSPARQL_S_POstatic PatternSPARQL_SPO_PO
-
Constructor Summary
Constructors Constructor Description CoreGraph(CoreSession session)A graph with this base session.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(List<Statement> statements)Adds given list of Statement objects to the graph.voidadd(Statement statement)Adds the statement object to the graph.voidclear()Clears the graph, removing all statements in it.protected static StringgetAuthor(Statement statement)protected static StringgetComment(Statement statement)protected static DategetCreationDate(Statement statement)protected static DategetDateProperty(Statement statement, Resource prop)protected static StringgetDefaultRepositoryName()protected static DategetModificationDate(Statement statement)Map<String,String>getNamespaces()Returns namespaces for the graph.protected static CoreGraph.NodeAsStringgetNodeAsString(Node node)List<Node>getObjects(Node subject, Node predicate)Gets items matching the statement pattern (subject, predicate, null).List<Node>getPredicates(Node subject, Node object)Gets items matching the statement pattern (subject, null, object).List<Statement>getStatements()Returns all statements in the graph.List<Statement>getStatements(Node subject, Node predicate, Node object)Returns all statements in the graph matching the pattern.List<Statement>getStatements(Statement statement)Returns all statements in the graph matching the pattern.protected static StringgetStringProperty(Statement statement, Resource prop)List<Node>getSubjects(Node predicate, Node object)Get items matching the statement pattern (null, predicate, object).booleanhasResource(Resource resource)Returns true if given resource appears in any statement of the graph.booleanhasStatement(Statement statement)Returns true if given statement pattern is in the graph.protected static StringlocalNameToId(String localName)QueryResultquery(String queryString, String language, String baseURI)Query the graph using a base URI.intqueryCount(String queryString, String language, String baseURI)Counts the number of results of a query.booleanread(InputStream in, String lang, String base)Parses source into the graph.booleanread(String path, String lang, String base)Parses source into the graph.voidremove(List<Statement> statements)Removes given list of Statement objects from the graph.voidremove(Statement statement)Removes the statement object from the graph.protected static voidsetAuthor(Statement statement, String author)protected static voidsetComment(Statement statement, String comment)protected static voidsetCreationDate(Statement statement, Calendar created)protected static voidsetDateProperty(Statement statement, Resource prop, Calendar date)voidsetDescription(GraphDescription graphDescription)Sets the graph description.protected static voidsetModificationDate(Statement statement, Calendar modified)protected voidsetOptions(Map<String,String> options)protected static voidsetStringProperty(Statement statement, Resource prop, String string)Longsize()Returns the number of statements in the graph.protected StringwhereBuilder(String query, Statement statement)booleanwrite(OutputStream out, String lang, String base)Serializes graph.booleanwrite(String path, String lang, String base)Serializes graph.
-
-
-
Field Detail
-
OPTION_DOCTYPE
public static final String OPTION_DOCTYPE
- See Also:
- Constant Field Values
-
REL_TYPE
public static final String REL_TYPE
- See Also:
- Constant Field Values
-
REL_PREDICATE
public static final String REL_PREDICATE
- See Also:
- Constant Field Values
-
REL_SOURCE_ID
public static final String REL_SOURCE_ID
- See Also:
- Constant Field Values
-
REL_SOURCE_URI
public static final String REL_SOURCE_URI
- See Also:
- Constant Field Values
-
REL_TARGET_ID
public static final String REL_TARGET_ID
- See Also:
- Constant Field Values
-
REL_TARGET_URI
public static final String REL_TARGET_URI
- See Also:
- Constant Field Values
-
REL_TARGET_STRING
public static final String REL_TARGET_STRING
- See Also:
- Constant Field Values
-
DC_CREATED
public static final String DC_CREATED
- See Also:
- Constant Field Values
-
DC_CREATOR
public static final String DC_CREATOR
- See Also:
- Constant Field Values
-
DC_MODIFIED
public static final String DC_MODIFIED
- See Also:
- Constant Field Values
-
DC_TITLE
public static final String DC_TITLE
- See Also:
- Constant Field Values
-
DC_DESCRIPTION
public static final String DC_DESCRIPTION
- See Also:
- Constant Field Values
-
BLANK_NS
public static final String BLANK_NS
- See Also:
- Constant Field Values
-
DOCUMENT_NAMESPACE
public static final String DOCUMENT_NAMESPACE
- See Also:
- Constant Field Values
-
DOCUMENT_NAMESPACE2
public static final String DOCUMENT_NAMESPACE2
Without final slash (compat).
-
COMMENT_NAMESPACE
public static final String COMMENT_NAMESPACE
Has no final slash (compat).- See Also:
- Constant Field Values
-
DOC_NAMESPACES
public static final String[] DOC_NAMESPACES
-
ALL
protected static final Statement ALL
-
session
protected CoreSession session
-
name
protected String name
-
docType
protected String docType
-
SPARQL_SPO_PO
public static final Pattern SPARQL_SPO_PO
-
SPARQL_PO_S
public static final Pattern SPARQL_PO_S
-
SPARQL_S_PO
public static final Pattern SPARQL_S_PO
-
-
Constructor Detail
-
CoreGraph
public CoreGraph(CoreSession session)
A graph with this base session. An unrestricted session will be opened based on it.
-
-
Method Detail
-
setDescription
public void setDescription(GraphDescription graphDescription)
Description copied from interface:GraphSets the graph description.- Specified by:
setDescriptionin interfaceGraph
-
getNamespaces
public Map<String,String> getNamespaces()
Description copied from interface:GraphReturns namespaces for the graph.Namespaces are prefix/namespace bindings, as rdf for http://www.w3.org/1999/02/22-rdf-syntax-ns#.
- Specified by:
getNamespacesin interfaceGraph- Returns:
- namespaces map of namespace bindings for the graph
-
size
public Long size()
Description copied from interface:GraphReturns the number of statements in the graph.
-
clear
public void clear()
Description copied from interface:GraphClears the graph, removing all statements in it.
-
add
public void add(Statement statement)
Description copied from interface:GraphAdds the statement object to the graph.
-
add
public void add(List<Statement> statements)
Description copied from interface:GraphAdds given list of Statement objects to the graph.
-
remove
public void remove(Statement statement)
Description copied from interface:GraphRemoves the statement object from the graph.
-
remove
public void remove(List<Statement> statements)
Description copied from interface:GraphRemoves given list of Statement objects from the graph.
-
getStatements
public List<Statement> getStatements()
Description copied from interface:GraphReturns all statements in the graph.- Specified by:
getStatementsin interfaceGraph- Returns:
- list of Statement instances
-
getStatements
public List<Statement> getStatements(Node subject, Node predicate, Node object)
Description copied from interface:GraphReturns all statements in the graph matching the pattern.- Specified by:
getStatementsin interfaceGraph- Returns:
- list of Statement instances matching the pattern
-
getStatements
public List<Statement> getStatements(Statement statement)
Description copied from interface:GraphReturns all statements in the graph matching the pattern.- Specified by:
getStatementsin interfaceGraph- Parameters:
statement- pattern to match, can hold null nodes as wildcards- Returns:
- list of Statement instances matching the pattern
-
getSubjects
public List<Node> getSubjects(Node predicate, Node object)
Description copied from interface:GraphGet items matching the statement pattern (null, predicate, object).- Specified by:
getSubjectsin interfaceGraph- Parameters:
predicate- predicate pattern, null acceptedobject- object pattern, null accepted- Returns:
- list of subjects
-
getPredicates
public List<Node> getPredicates(Node subject, Node object)
Description copied from interface:GraphGets items matching the statement pattern (subject, null, object).- Specified by:
getPredicatesin interfaceGraph- Parameters:
subject- subject pattern, null acceptedobject- object pattern, null accepted- Returns:
- list of predicates
-
getObjects
public List<Node> getObjects(Node subject, Node predicate)
Description copied from interface:GraphGets items matching the statement pattern (subject, predicate, null).- Specified by:
getObjectsin interfaceGraph- Parameters:
subject- subject pattern, null acceptedpredicate- predicate pattern, null accepted- Returns:
- list of node objects
-
hasStatement
public boolean hasStatement(Statement statement)
Description copied from interface:GraphReturns true if given statement pattern is in the graph.- Specified by:
hasStatementin interfaceGraph- Parameters:
statement- statement pattern, can use null as wild cards- Returns:
- true or false
-
hasResource
public boolean hasResource(Resource resource)
Description copied from interface:GraphReturns true if given resource appears in any statement of the graph.- Specified by:
hasResourcein interfaceGraph- Returns:
- true or false
-
query
public QueryResult query(String queryString, String language, String baseURI)
Description copied from interface:GraphQuery the graph using a base URI.
-
queryCount
public int queryCount(String queryString, String language, String baseURI)
Description copied from interface:GraphCounts the number of results of a query.- Specified by:
queryCountin interfaceGraph- Parameters:
queryString- the query stringlanguage- the query language (sparql, rdql,...)baseURI- the base URI to use for query- Returns:
- the count
-
read
public boolean read(String path, String lang, String base)
Description copied from interface:GraphParses source into the graph.- Specified by:
readin interfaceGraph- Parameters:
path- path on file system where to take the serialization filelang- format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".base- base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.- Returns:
- true on success, else false
-
write
public boolean write(String path, String lang, String base)
Description copied from interface:GraphSerializes graph.- Specified by:
writein interfaceGraph- Parameters:
path- path on file system where to put the serialization filelang- format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".base- base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.- Returns:
- true on success, else false
-
read
public boolean read(InputStream in, String lang, String base)
Description copied from interface:GraphParses source into the graph.- Specified by:
readin interfaceGraph- Parameters:
in- input streamlang- format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".base- base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.- Returns:
- true on success, else false
-
write
public boolean write(OutputStream out, String lang, String base)
Description copied from interface:GraphSerializes graph.- Specified by:
writein interfaceGraph- Parameters:
out- output streamlang- format for the input serialization, may be "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".base- base uri to be used when converting relative uris to absolute uris, may be null. If set to "", allows relative uris to be used in the model.- Returns:
- true on success, else false
-
getDefaultRepositoryName
protected static String getDefaultRepositoryName()
-
getNodeAsString
protected static CoreGraph.NodeAsString getNodeAsString(Node node)
-
setModificationDate
protected static void setModificationDate(Statement statement, Calendar modified)
-
setStringProperty
protected static void setStringProperty(Statement statement, Resource prop, String string)
-
-