Interface IStorageWrapper
-
- All Superinterfaces:
ISourceFileHelper
- All Known Implementing Classes:
BaseStorage
public interface IStorageWrapper extends ISourceFileHelper
Storage module interface, defines a storage implementation, should be self contained and fully manage stored data
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Shutdown the databaseIWorkspace
createWorkspace(java.lang.String name, java.lang.String lang)
Create a new IWorkspace instancejava.lang.Class<? extends ICodeBlockGroup>
getCodeBlockGroupClass()
Fetches the class of ICodeBlockGroup used in this IStorageWrapper implementationIReportManager
getReportGenerator(IResultJob resultJob)
Returns a prepared report manager for the IResultJob, uses cached instances were possibleISubmission
getSubmissionFromName(IWorkspace workspace, java.lang.String submissionName)
Fetches a submission for the passed name if one exists, else returns nulljava.util.List<IWorkspace>
getWorkspaces()
Get all stored workspacesjava.util.List<IWorkspace>
getWorkspaces(java.util.List<java.lang.Long> ids)
void
mergePendingSubmission(ISubmission existing, ISubmission pending)
Merge two submissions into a single submission, can be used to sort out name collisionsvoid
removePendingSubmission(ISubmission pendingSubmission)
Forget and remove a pending submission, and cleans up after itboolean
storeCodeBlockGroups(java.util.List<ICodeBlockGroup> groups)
Stores the passed code block groups to the databasejava.util.List<ITuple<ISubmission,ISubmission>>
storeFile(IWorkspace workspace, java.lang.String filename, byte[] fileContent)
Store filejava.util.List<ITuple<ISubmission,ISubmission>>
storeFile(IWorkspace workspace, java.lang.String filename, byte[] fileContent, boolean archiveContainsMultipleSubmissions)
Store filevoid
writePendingSubmission(ISubmission pendingSubmission)
If the submission clashes with an already existing submission, it will be set as pending-
Methods inherited from interface uk.ac.warwick.dcs.sherlock.api.component.ISourceFileHelper
getSourceFile
-
-
-
-
Method Detail
-
close
void close()
Shutdown the database
-
createWorkspace
IWorkspace createWorkspace(java.lang.String name, java.lang.String lang)
Create a new IWorkspace instance- Parameters:
name
- name to create workspace underlang
- language of the workspace- Returns:
- instance
-
getCodeBlockGroupClass
java.lang.Class<? extends ICodeBlockGroup> getCodeBlockGroupClass()
Fetches the class of ICodeBlockGroup used in this IStorageWrapper implementation- Returns:
- class for ICodeBlockGroup
-
getReportGenerator
IReportManager getReportGenerator(IResultJob resultJob) throws ResultJobUnsupportedException
Returns a prepared report manager for the IResultJob, uses cached instances were possible- Parameters:
resultJob
- result to generate reports for- Returns:
- instance of ReportManager
- Throws:
ResultJobUnsupportedException
- Thrown if IResultJob instance was not created by this IStorageWrapper implementation
-
getSubmissionFromName
ISubmission getSubmissionFromName(IWorkspace workspace, java.lang.String submissionName) throws WorkspaceUnsupportedException
Fetches a submission for the passed name if one exists, else returns null- Parameters:
workspace
- workspace to search for submissionsubmissionName
- submission name- Returns:
- submission if exists, else null
- Throws:
WorkspaceUnsupportedException
- Thrown if IWorkspace instance was not created by this IStorageWrapper implementation
-
getWorkspaces
java.util.List<IWorkspace> getWorkspaces(java.util.List<java.lang.Long> ids)
- Parameters:
ids
- workspace ids to fetch- Returns:
- a list of all workspaces matching the passed ids in the database
-
getWorkspaces
java.util.List<IWorkspace> getWorkspaces()
Get all stored workspaces- Returns:
- a list of all workspaces in the database
-
mergePendingSubmission
void mergePendingSubmission(ISubmission existing, ISubmission pending) throws SubmissionUnsupportedException
Merge two submissions into a single submission, can be used to sort out name collisions- Parameters:
existing
- first submission, is left, must already exist in the databasepending
- second submission, is removed after merge- Throws:
SubmissionUnsupportedException
- Thrown if ISubmission instance was not created by this IStorageWrapper implementation
-
removePendingSubmission
void removePendingSubmission(ISubmission pendingSubmission) throws SubmissionUnsupportedException
Forget and remove a pending submission, and cleans up after it- Parameters:
pendingSubmission
- pending submission to forget and remove- Throws:
SubmissionUnsupportedException
- Thrown if ISubmission instance was not created by this IStorageWrapper implementation
-
storeCodeBlockGroups
boolean storeCodeBlockGroups(java.util.List<ICodeBlockGroup> groups)
Stores the passed code block groups to the database- Parameters:
groups
- list of the code block groups to store- Returns:
- was successful?
-
storeFile
java.util.List<ITuple<ISubmission,ISubmission>> storeFile(IWorkspace workspace, java.lang.String filename, byte[] fileContent) throws WorkspaceUnsupportedException
Store file- Parameters:
workspace
- workspace to upload file tofilename
- filename uploaded, used as the identifier to show to the user, identifying the file or filesfileContent
- raw content of the file- Returns:
- list of tuples, which contain any collisions between submission names. The first element is the existing submission, the second is the new
- Throws:
WorkspaceUnsupportedException
- Thrown if IWorkspace instance was not created by this IStorageWrapper implementation
-
storeFile
java.util.List<ITuple<ISubmission,ISubmission>> storeFile(IWorkspace workspace, java.lang.String filename, byte[] fileContent, boolean archiveContainsMultipleSubmissions) throws WorkspaceUnsupportedException
Store file- Parameters:
workspace
- workspace to upload file tofilename
- filename uploaded, used as the identifier to show to the user, identifying the file or filesfileContent
- raw content of the filearchiveContainsMultipleSubmissions
- are the archive top level directories separate submissions?- Returns:
- list of tuples, which contain any collisions between submission names. The first element is the existing submission, the second is the new
- Throws:
WorkspaceUnsupportedException
- Thrown if IWorkspace instance was not created by this IStorageWrapper implementation
-
writePendingSubmission
void writePendingSubmission(ISubmission pendingSubmission) throws SubmissionUnsupportedException
If the submission clashes with an already existing submission, it will be set as pendingIF a submission is pending this method will remove existing submission with the same name and write the pending submission to the database
- Parameters:
pendingSubmission
- pending submission to properly write- Throws:
SubmissionUnsupportedException
- Thrown if ISubmission instance was not created by this IStorageWrapper implementation
-
-