use of de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportException in project webanno by webanno.
the class SourceDocumentExporter method exportSourceDocumentContents.
private void exportSourceDocumentContents(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage) throws IOException, ProjectExportException {
Project project = aRequest.getProject();
File sourceDocumentDir = new File(aStage, SOURCE_FOLDER);
FileUtils.forceMkdir(sourceDocumentDir);
// Get all the source documents from the project
List<SourceDocument> documents = documentService.listSourceDocuments(project);
int i = 1;
for (SourceDocument sourceDocument : documents) {
try {
FileUtils.copyFileToDirectory(documentService.getSourceDocumentFile(sourceDocument), sourceDocumentDir);
aMonitor.setProgress((int) Math.ceil(((double) i) / documents.size() * 10.0));
i++;
log.info("Exported content for source document [" + sourceDocument.getId() + "] in project [" + project.getName() + "] with id [" + project.getId() + "]");
} catch (FileNotFoundException e) {
log.error("Source file [{}] related to project couldn't be located in repository", sourceDocument.getName(), ExceptionUtils.getRootCause(e));
aMonitor.addMessage(LogMessage.error(this, "Source file [%s] related to project couldn't be located in repository", sourceDocument.getName()));
throw new ProjectExportException("Couldn't find some source file(s) related to project");
}
}
}
use of de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportException in project webanno by webanno.
the class AutomationTrainingDocumentExporter method exportTrainingDocumentContents.
private void exportTrainingDocumentContents(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aCopyDir) throws IOException, ProjectExportException {
Project project = aRequest.getProject();
File trainDocumentDir = new File(aCopyDir + TRAIN_FOLDER);
FileUtils.forceMkdir(trainDocumentDir);
// Get all the training documents from the project
List<TrainingDocument> documents = automationService.listTrainingDocuments(project);
int i = 1;
for (TrainingDocument trainingDocument : documents) {
try {
FileUtils.copyFileToDirectory(automationService.getTrainingDocumentFile(trainingDocument), trainDocumentDir);
aMonitor.setProgress((int) Math.ceil(((double) i) / documents.size() * 10.0));
i++;
log.info("Imported content for training document [" + trainingDocument.getId() + "] in project [" + project.getName() + "] with id [" + project.getId() + "]");
} catch (FileNotFoundException e) {
log.error("Source file [{}] related to project couldn't be located in repository", trainingDocument.getName(), ExceptionUtils.getRootCause(e));
aMonitor.addMessage(LogMessage.error(this, "Source file [%s] related to project couldn't be located in repository", trainingDocument.getName()));
throw new ProjectExportException("Couldn't find some source file(s) related to project");
}
}
}
Aggregations