Package org.dspace.rdf
Class RDFizer
- java.lang.Object
-
- org.dspace.rdf.RDFizer
-
public class RDFizer extends Object
This class manages the handling of RDF data in DSpace. It generates identifiers, it loads data, it manages the conversion of DSpace Objects into RDF data. It can be used as instantiated object as well as CLI.- Author:
- Pascal-Nicolas Becker (dspace -at- pascal -hyphen- becker -dot- de)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classRDFizer.Callback
-
Field Summary
Fields Modifier and Type Field Description protected CommunityServicecommunityServiceprotected ConfigurationServiceconfigurationServiceprotected ContentServiceFactorycontentServiceFactoryprotected Contextcontextprotected booleandryrunprotected HandleServicehandleServiceprotected ItemServiceitemServiceprotected Stringlangprotected Set<UUID>processedSet to remember with DSpaceObject were converted or deleted from the triplestore already.protected booleanstdoutprotected RDFStoragestorageprotected booleanverbose
-
Constructor Summary
Constructors Constructor Description RDFizer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconvert(DSpaceObject dso, boolean reset)voidconvertAll()Converts and stores all DSpaceObjects that are readable for an anonymous user.protected org.apache.commons.cli.OptionscreateOptions()voiddelete(DSpaceObject dso, boolean reset)Delete the data about the DSpaceObject from the triplestore.voiddeleteAll()Deletes all data stored in the triplestore (drops all named graphs and cleans the default graph).protected voiddspaceDFS(DSpaceObject dso, RDFizer.Callback callback, boolean check, boolean reset)booleanisDryrun()Returns whether this is a dry run.protected booleanisProcessed(DSpaceObject dso)booleanisStdout()Returns whether all converted data is printed to stdout.booleanisVerbose()Returns whether verbose information is printed to System.err.static voidmain(String[] args)protected voidmarkProcessed(DSpaceObject dso)protected voidoverrideContext(Context context)This method allows you to override the context used for conversion and to determine which DSpaceObjects should be deleted from the triplestore, consider well if this is really necessary.protected voidreport(String message)protected DSpaceObjectresolveHandle(String handle)protected voidrunCLI(String[] args)voidsetDryrun(boolean dryrun)Set this true to prevent any changes on the triple store.voidsetStdout(boolean stdout)Set this to true to print all generated data to stdout.voidsetVerbose(boolean verbose)Set this to true to print verbose information to System.err.protected static voidusage(org.apache.commons.cli.Options options)
-
-
-
Field Detail
-
stdout
protected boolean stdout
-
verbose
protected boolean verbose
-
dryrun
protected boolean dryrun
-
lang
protected String lang
-
context
protected Context context
-
configurationService
protected final ConfigurationService configurationService
-
contentServiceFactory
protected final ContentServiceFactory contentServiceFactory
-
communityService
protected final CommunityService communityService
-
itemService
protected final ItemService itemService
-
handleService
protected final HandleService handleService
-
storage
protected final RDFStorage storage
-
-
Method Detail
-
overrideContext
protected void overrideContext(Context context)
This method allows you to override the context used for conversion and to determine which DSpaceObjects should be deleted from the triplestore, consider well if this is really necessary. If this method is not used the context of an anonymous user will be used.Please consider: If your triplestore offers a public sparql endpoint all information readable with the provided context will be exposed to public! If you store your data in a private triplestore that does not provides public access, you might consider to use this method to convert all data stored in your repository.
- Parameters:
context- The relevant DSpace Context.
-
isStdout
public boolean isStdout()
Returns whether all converted data is printed to stdout. Turtle will be used as serialization.- Returns:
trueif print all generated data is to be printed to stdout
-
setStdout
public void setStdout(boolean stdout)
Set this to true to print all generated data to stdout. The data will be stored as well, unlessdryrunis set true. Turtle will be used as serialization.- Parameters:
stdout- iftrue, print all data to standard output
-
isVerbose
public boolean isVerbose()
Returns whether verbose information is printed to System.err. Probably this is helpful for CLI only.- Returns:
trueif verbose mode is on
-
setVerbose
public void setVerbose(boolean verbose)
Set this to true to print verbose information to System.err. Probably this is helpful for CLI only.- Parameters:
verbose- print verbose information to stderr
-
isDryrun
public boolean isDryrun()
Returns whether this is a dry run. Probably this is helpful for CLI only.- Returns:
trueif dry-run mode is on
-
setDryrun
public void setDryrun(boolean dryrun)
Set this true to prevent any changes on the triple store. Probably this is helpful for CLI usage only.- Parameters:
dryrun- test run without any changes to the triple store
-
deleteAll
public void deleteAll()
Deletes all data stored in the triplestore (drops all named graphs and cleans the default graph).
-
delete
public void delete(DSpaceObject dso, boolean reset) throws SQLException
Delete the data about the DSpaceObject from the triplestore. All data about descendent Subcommunities, Collections and Items will be deleted as well.- Parameters:
dso- DSpace objectreset- reset processed status (converted or deleted from the triplestore)- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
convertAll
public void convertAll() throws SQLExceptionConverts and stores all DSpaceObjects that are readable for an anonymous user.- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
convert
protected void convert(DSpaceObject dso, boolean reset) throws SQLException
- Throws:
SQLException
-
dspaceDFS
protected void dspaceDFS(DSpaceObject dso, RDFizer.Callback callback, boolean check, boolean reset) throws SQLException
- Throws:
SQLException
-
isProcessed
protected boolean isProcessed(DSpaceObject dso)
-
markProcessed
protected void markProcessed(DSpaceObject dso)
-
report
protected void report(String message)
-
runCLI
protected void runCLI(String[] args)
-
resolveHandle
protected DSpaceObject resolveHandle(String handle)
-
createOptions
protected org.apache.commons.cli.Options createOptions()
-
usage
protected static void usage(org.apache.commons.cli.Options options)
-
main
public static void main(String[] args)
-
-