Class ClientImpl
- java.lang.Object
-
- org.topbraidlive.client.java.impl.ClientImpl
-
- All Implemented Interfaces:
AutoCloseable
,Api
,UnzipProjectApiFunction
,AddProjectImportApiFunction
,AddRoleToGroupApiFunction
,AddTriplesApiFunction
,ApiFunction
,CanCreateProjectApiFunction
,CanDeleteProjectApiFunction
,CheckGovernanceAreaExistsApiFunction
,CheckProjectExistsApiFunction
,ClearProjectApiFunction
,CreateGovernanceAreaApiFunction
,CreateProjectApiFunction
,DeleteProjectApiFunction
,DeleteResourceApiFunction
,EnableGovernanceRoleApiFunction
,ExecuteSpinTemplateApiFunction
,ExecuteSwpViewClassApiFunction
,ExportToRdfApiFunction
,GetPlatformGraphqlConnectionApiFunction
,GetProjectGraphqlConnectionApiFunction
,GetRawGraphqlConnectionApiFunction
,GetSparqlConnectionApiFunction
,ListProjectsApiFunction
,QuerySparqlApiFunction
,SetGovernanceAreaPermission
,Client
public final class ClientImpl extends Object implements Client
Main entry point, a facade client that delegates to various client implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.topbraidlive.client.java.api.exception.UnzipProjectApiFunction
UnzipProjectApiFunction.OldProject
-
-
Constructor Summary
Constructors Constructor Description ClientImpl(ClientConfiguration configuration)
Construct a Client instance with a given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProjectImport(String import_, String projectGraph)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
addProjectImport(Uri import_, ProjectGraphUri projectGraph)
Add an import to a project.void
addRoleToGroup(String group, String role)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
addRoleToGroup(RightsGroupId group, SecurityRoleId role)
Add a security role to a rights group.void
addTriples(boolean complete, String graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
addTriples(boolean complete, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Add all triples from the given graphvoid
addTriplesBatched(int batchSize, String graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
addTriplesBatched(int batchSize, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Convenience method to add triples in batches from an iterator.boolean
canCreateProject()
Can the current user create a project?boolean
canDeleteProject(String projectGraph)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.boolean
canDeleteProject(ProjectGraphUri projectGraph)
Can the current user create a project?boolean
checkGovernanceAreaExists(String uri)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.boolean
checkGovernanceAreaExists(GovernanceAreaUri uri)
Check if a governance area exists.boolean
checkProjectExists(String projectGraph)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.boolean
checkProjectExists(ProjectGraphUri projectGraph)
Check if a project exists.void
clearProject(String projectGraph)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
clearProject(ProjectGraphUri projectGraph)
Clear the contents of a project.void
close()
ClientConfiguration
configuration()
Get the client's configuration.void
createGovernanceArea(String label, String type, String uri, String labelLang)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
createGovernanceArea(String label, GovernanceAreaType type, GovernanceAreaUri uri, Optional<String> labelLang)
Create a governance area.ProjectGraphUri
createProject(CreateProjectParameters parameters)
Create a project.void
deleteProject(String projectGraph)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
deleteProject(ProjectGraphUri projectGraph)
Delete a project.void
deleteResource(String base, String resource)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
deleteResource(Uri base, Uri resource)
Delete a resource such as a governance area.void
enableGovernanceRole(String governanceRole, String subjectArea)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
enableGovernanceRole(GovernanceRoleUri governanceRole, GovernanceAreaUri subjectArea)
Enable a governance role.String
executeSpinTemplate(ExecuteSpinTemplateParameters parameters)
Execute a SPIN template.org.apache.http.client.methods.CloseableHttpResponse
executeSwpViewClass(ExecuteSwpViewClassParameters parameters)
Execute an arbitrary SWP view class.String
executeSwpViewClassToString(ExecuteSwpViewClassParameters parameters)
Execute an arbitrary SWP view class and return its response (body) as a String.String
exportToRdf(ExportToRdfParameters parameters)
Export a project's contents to RDF.TypedGraphqlConnection<RootRDFQueryQuery,RootRDFQuery>
getPlatformGraphqlConnection()
Get a GraphQL connection for the platform APIO.<RootQueryT extends AbstractQuery<RootQueryT>,RootResponseT extends AbstractResponse<RootResponseT>>
TypedGraphqlConnection<RootQueryT,RootResponseT>getProjectGraphqlConnection(GetProjectGraphqlConnectionParameters<RootQueryT,RootResponseT> parameters)
Get a GraphQL connection for a specific project.RawGraphqlConnection
getRawGraphqlConnection(String endpointUrlPath)
Get a raw GraphQL connection.RawGraphqlConnection
getRawGraphqlConnection(ProjectGraphUri projectGraphUri)
Convenience method to get a raw GraphQL connection for a project.RawGraphqlConnection
getRawGraphqlConnection(ProjectGraphUri projectGraphUri, Optional<ProjectGraphqlSchemaType> projectGraphqlSchemaType)
Convenience method to get a raw GraphQL connection for a project.org.apache.jena.rdfconnection.RDFConnection
getSparqlConnection()
Interact with the server via SPARQL.com.google.common.collect.ImmutableList<ProjectGraphUri>
listProjects()
List project graphs known to the server.org.apache.jena.query.QueryExecution
querySparql(org.apache.jena.query.Query query, Optional<String> defaultGraph)
Query the EDG SPARQL endpoint.void
setGovernanceRolePermission(String governanceArea, String governancePermission, String governanceRole)
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.void
setGovernanceRolePermission(GovernanceAreaUri governanceArea, GovernancePermission governancePermission, GovernanceRoleUri governanceRole)
Set the permission of a governance role in a governance area.void
unzipProject(Path projectZipFilePath, Optional<UnzipProjectApiFunction.OldProject> oldProject)
Upload a project as a .zip file to the server.
-
-
-
Constructor Detail
-
ClientImpl
public ClientImpl(ClientConfiguration configuration)
Construct a Client instance with a given configuration.
-
-
Method Detail
-
addProjectImport
public final void addProjectImport(String import_, String projectGraph)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
addProjectImport
in interfaceClient
- See Also:
AddProjectImportApiFunction.addProjectImport(Uri, ProjectGraphUri)
-
addProjectImport
public final void addProjectImport(Uri import_, ProjectGraphUri projectGraph)
Description copied from interface:AddProjectImportApiFunction
Add an import to a project.- Specified by:
addProjectImport
in interfaceAddProjectImportApiFunction
- Parameters:
import_
- URI of a graph to import (importee), such as urn:x-evn-master:childprojectGraph
- URI of the project graph to be imported into (importer), such as urn:x-evn-master:parent
-
addTriples
public final void addTriples(boolean complete, String graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
addTriples
in interfaceClient
- See Also:
AddTriplesApiFunction.addTriples(boolean, Uri, PrefixMapping, Iterator)
-
addTriples
public final void addTriples(boolean complete, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Description copied from interface:AddTriplesApiFunction
Add all triples from the given graph- Specified by:
addTriples
in interfaceAddTriplesApiFunction
- Parameters:
complete
- signal whether this is the last batch of triples or notgraphUri
- graph URI to add the triples toprefixMapping
- namespace prefix mappingtriples
- iterator over triples
-
addRoleToGroup
public final void addRoleToGroup(String group, String role)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
addRoleToGroup
in interfaceClient
- See Also:
AddRoleToGroupApiFunction.addRoleToGroup(RightsGroupId, SecurityRoleId)
-
addRoleToGroup
public final void addRoleToGroup(RightsGroupId group, SecurityRoleId role)
Description copied from interface:AddRoleToGroupApiFunction
Add a security role to a rights group.- Specified by:
addRoleToGroup
in interfaceAddRoleToGroupApiFunction
- Parameters:
group
- a rights group such as "readAnyGraphGrp"role
- a role such as "ANY_ROLE" or "Admin"
-
addTriplesBatched
public final void addTriplesBatched(int batchSize, String graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
addTriplesBatched
in interfaceClient
- See Also:
Client.addTriplesBatched(int, Uri, PrefixMapping, Iterator)
-
addTriplesBatched
public final void addTriplesBatched(int batchSize, Uri graphUri, org.apache.jena.shared.PrefixMapping prefixMapping, Iterator<org.apache.jena.graph.Triple> triples)
Description copied from interface:Client
Convenience method to add triples in batches from an iterator. Delegates to addTriples.- Specified by:
addTriplesBatched
in interfaceClient
-
canCreateProject
public final boolean canCreateProject()
Description copied from interface:CanCreateProjectApiFunction
Can the current user create a project?- Specified by:
canCreateProject
in interfaceCanCreateProjectApiFunction
- Returns:
- true if the current user can create a project
-
canDeleteProject
public final boolean canDeleteProject(String projectGraph)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
canDeleteProject
in interfaceClient
- See Also:
CanDeleteProjectApiFunction.canDeleteProject(ProjectGraphUri)
-
canDeleteProject
public final boolean canDeleteProject(ProjectGraphUri projectGraph)
Description copied from interface:CanDeleteProjectApiFunction
Can the current user create a project?- Specified by:
canDeleteProject
in interfaceCanDeleteProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg- Returns:
- true if the current user can delete the project
-
checkGovernanceAreaExists
public final boolean checkGovernanceAreaExists(String uri)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
checkGovernanceAreaExists
in interfaceClient
- See Also:
CheckGovernanceAreaExistsApiFunction.checkGovernanceAreaExists(GovernanceAreaUri)
-
checkGovernanceAreaExists
public final boolean checkGovernanceAreaExists(GovernanceAreaUri uri)
Description copied from interface:CheckGovernanceAreaExistsApiFunction
Check if a governance area exists.- Specified by:
checkGovernanceAreaExists
in interfaceCheckGovernanceAreaExistsApiFunction
- Parameters:
uri
- URI of the governance area- Returns:
- true if the governance area exists
-
checkProjectExists
public final boolean checkProjectExists(String projectGraph)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
checkProjectExists
in interfaceClient
- See Also:
CheckProjectExistsApiFunction.checkProjectExists(ProjectGraphUri)
-
checkProjectExists
public final boolean checkProjectExists(ProjectGraphUri projectGraph)
Description copied from interface:CheckProjectExistsApiFunction
Check if a project exists.- Specified by:
checkProjectExists
in interfaceCheckProjectExistsApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg- Returns:
- true if the project exists
-
clearProject
public final void clearProject(String projectGraph)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
clearProject
in interfaceClient
- See Also:
ClearProjectApiFunction.clearProject(ProjectGraphUri)
-
clearProject
public final void clearProject(ProjectGraphUri projectGraph)
Description copied from interface:ClearProjectApiFunction
Clear the contents of a project.- Specified by:
clearProject
in interfaceClearProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg
-
close
public final void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceClient
- Throws:
IOException
-
configuration
public final ClientConfiguration configuration()
Description copied from interface:Client
Get the client's configuration.- Specified by:
configuration
in interfaceClient
-
createGovernanceArea
public final void createGovernanceArea(String label, String type, String uri, String labelLang)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
createGovernanceArea
in interfaceClient
- See Also:
CreateGovernanceAreaApiFunction.createGovernanceArea(String, GovernanceAreaType, GovernanceAreaUri, Optional)
-
createGovernanceArea
public final void createGovernanceArea(String label, GovernanceAreaType type, GovernanceAreaUri uri, Optional<String> labelLang)
Description copied from interface:CreateGovernanceAreaApiFunction
Create a governance area.- Specified by:
createGovernanceArea
in interfaceCreateGovernanceAreaApiFunction
- Parameters:
label
- label of the new governance areatype
- type of governance areauri
- URI for the new governance arealabelLang
- optional language specifier for the laber
-
createProject
public final ProjectGraphUri createProject(CreateProjectParameters parameters)
Description copied from interface:CreateProjectApiFunction
Create a project.This function will not fail if you try to create a duplicate project graph. Instead, the server will append a suffix to the project graph URI. This function returns the project graph URI that was created.
- Specified by:
createProject
in interfaceCreateProjectApiFunction
- Parameters:
parameters
- parameters object- Returns:
- result object
-
deleteProject
public final void deleteProject(String projectGraph)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
deleteProject
in interfaceClient
- See Also:
DeleteProjectApiFunction.deleteProject(ProjectGraphUri)
-
deleteProject
public final void deleteProject(ProjectGraphUri projectGraph)
Description copied from interface:DeleteProjectApiFunction
Delete a project.- Specified by:
deleteProject
in interfaceDeleteProjectApiFunction
- Parameters:
projectGraph
- URI of the project graph e.g., urn:x-evn-master:abcdefg
-
deleteResource
public final void deleteResource(String base, String resource)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
deleteResource
in interfaceClient
- See Also:
DeleteResourceApiFunction.deleteResource(Uri, Uri)
-
deleteResource
public final void deleteResource(Uri base, Uri resource)
Description copied from interface:DeleteResourceApiFunction
Delete a resource such as a governance area.- Specified by:
deleteResource
in interfaceDeleteResourceApiFunction
- Parameters:
base
- URI of the project graph e.g., urn:x-evn-master:abcdefgresource
- URI of the resource
-
enableGovernanceRole
public final void enableGovernanceRole(String governanceRole, String subjectArea)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
enableGovernanceRole
in interfaceClient
- See Also:
EnableGovernanceRoleApiFunction.enableGovernanceRole(GovernanceRoleUri, GovernanceAreaUri)
-
enableGovernanceRole
public final void enableGovernanceRole(GovernanceRoleUri governanceRole, GovernanceAreaUri subjectArea)
Description copied from interface:EnableGovernanceRoleApiFunction
Enable a governance role.- Specified by:
enableGovernanceRole
in interfaceEnableGovernanceRoleApiFunction
- Parameters:
governanceRole
- URI of the governance role e.g., http://edg.topbraid.solutions/model/dataStewardsubjectArea
- URI of the governance subject area e.g., urn:x-tb-governance:test
-
executeSpinTemplate
public final String executeSpinTemplate(ExecuteSpinTemplateParameters parameters)
Description copied from interface:ExecuteSpinTemplateApiFunction
Execute a SPIN template.- Specified by:
executeSpinTemplate
in interfaceExecuteSpinTemplateApiFunction
- Parameters:
parameters
- : parameters object- Returns:
- String comprising the body, encoded in the format specified in parameters
-
executeSwpViewClass
public final org.apache.http.client.methods.CloseableHttpResponse executeSwpViewClass(ExecuteSwpViewClassParameters parameters)
Description copied from interface:ExecuteSwpViewClassApiFunction
Execute an arbitrary SWP view class.- Specified by:
executeSwpViewClass
in interfaceExecuteSwpViewClassApiFunction
- Parameters:
parameters
- parameters object- Returns:
- HTTP response; must be closed by the caller
-
executeSwpViewClassToString
public final String executeSwpViewClassToString(ExecuteSwpViewClassParameters parameters)
Description copied from interface:ExecuteSwpViewClassApiFunction
Execute an arbitrary SWP view class and return its response (body) as a String.- Specified by:
executeSwpViewClassToString
in interfaceExecuteSwpViewClassApiFunction
- Parameters:
parameters
- parameters object- Returns:
- the response body
-
exportToRdf
public final String exportToRdf(ExportToRdfParameters parameters)
Description copied from interface:ExportToRdfApiFunction
Export a project's contents to RDF.- Specified by:
exportToRdf
in interfaceExportToRdfApiFunction
- Parameters:
parameters
- : parameters object- Returns:
- exported RDF as a String
-
getPlatformGraphqlConnection
public final TypedGraphqlConnection<RootRDFQueryQuery,RootRDFQuery> getPlatformGraphqlConnection()
Description copied from interface:GetPlatformGraphqlConnectionApiFunction
Get a GraphQL connection for the platform APIO.- Specified by:
getPlatformGraphqlConnection
in interfaceGetPlatformGraphqlConnectionApiFunction
-
getProjectGraphqlConnection
public final <RootQueryT extends AbstractQuery<RootQueryT>,RootResponseT extends AbstractResponse<RootResponseT>> TypedGraphqlConnection<RootQueryT,RootResponseT> getProjectGraphqlConnection(GetProjectGraphqlConnectionParameters<RootQueryT,RootResponseT> parameters)
Description copied from interface:GetProjectGraphqlConnectionApiFunction
Get a GraphQL connection for a specific project.- Specified by:
getProjectGraphqlConnection
in interfaceGetProjectGraphqlConnectionApiFunction
-
getRawGraphqlConnection
public final RawGraphqlConnection getRawGraphqlConnection(ProjectGraphUri projectGraphUri)
Description copied from interface:Client
Convenience method to get a raw GraphQL connection for a project.- Specified by:
getRawGraphqlConnection
in interfaceClient
-
getRawGraphqlConnection
public final RawGraphqlConnection getRawGraphqlConnection(ProjectGraphUri projectGraphUri, Optional<ProjectGraphqlSchemaType> projectGraphqlSchemaType)
Description copied from interface:Client
Convenience method to get a raw GraphQL connection for a project.- Specified by:
getRawGraphqlConnection
in interfaceClient
-
getRawGraphqlConnection
public final RawGraphqlConnection getRawGraphqlConnection(String endpointUrlPath)
Description copied from interface:GetRawGraphqlConnectionApiFunction
Get a raw GraphQL connection.- Specified by:
getRawGraphqlConnection
in interfaceGetRawGraphqlConnectionApiFunction
- Parameters:
endpointUrlPath
- relative endpoint URL path as /tbl/graphql/_
-
getSparqlConnection
public final org.apache.jena.rdfconnection.RDFConnection getSparqlConnection()
Description copied from interface:GetSparqlConnectionApiFunction
Interact with the server via SPARQL.- Specified by:
getSparqlConnection
in interfaceGetSparqlConnectionApiFunction
-
listProjects
public final com.google.common.collect.ImmutableList<ProjectGraphUri> listProjects()
Description copied from interface:ListProjectsApiFunction
List project graphs known to the server.- Specified by:
listProjects
in interfaceListProjectsApiFunction
-
querySparql
public final org.apache.jena.query.QueryExecution querySparql(org.apache.jena.query.Query query, Optional<String> defaultGraph)
Description copied from interface:QuerySparqlApiFunction
Query the EDG SPARQL endpoint.- Specified by:
querySparql
in interfaceQuerySparqlApiFunction
- Parameters:
query
- SPARQL querydefaultGraph
- optional default graph URI- Returns:
- Jena QueryExecution, which must be closed by the caller
-
setGovernanceRolePermission
public final void setGovernanceRolePermission(String governanceArea, String governancePermission, String governanceRole)
Description copied from interface:Client
Convenience method that only uses built-in and Jena types, to make the client easier to use from languages besides Java.- Specified by:
setGovernanceRolePermission
in interfaceClient
- See Also:
SetGovernanceAreaPermission.setGovernanceRolePermission(GovernanceAreaUri, GovernancePermission, GovernanceRoleUri)
-
setGovernanceRolePermission
public final void setGovernanceRolePermission(GovernanceAreaUri governanceArea, GovernancePermission governancePermission, GovernanceRoleUri governanceRole)
Description copied from interface:SetGovernanceAreaPermission
Set the permission of a governance role in a governance area.- Specified by:
setGovernanceRolePermission
in interfaceSetGovernanceAreaPermission
-
unzipProject
public final void unzipProject(Path projectZipFilePath, Optional<UnzipProjectApiFunction.OldProject> oldProject)
Description copied from interface:UnzipProjectApiFunction
Upload a project as a .zip file to the server.- Specified by:
unzipProject
in interfaceUnzipProjectApiFunction
- Parameters:
projectZipFilePath
- path to a .zip file containing the projectoldProject
- delete or update an existing project
-
-