use of de.tudarmstadt.ukp.clarin.webanno.model.TrainingDocument in project webanno by webanno.
the class ExportUtil method exportTrainingDocuments.
/**
* Export {@link TrainingDocument}
*/
public static void exportTrainingDocuments(AutomationService automationService, ProjectExportRequest model, Project aProject, File aCopyDir) throws IOException, ProjectExportException {
File trainDocumentDir = new File(aCopyDir + TRAIN_FOLDER);
FileUtils.forceMkdir(trainDocumentDir);
// Get all the training documents from the project
List<TrainingDocument> documents = automationService.listTrainingDocuments(aProject);
int i = 1;
for (TrainingDocument trainingDocument : documents) {
try {
FileUtils.copyFileToDirectory(automationService.getTrainingDocumentFile(trainingDocument), trainDocumentDir);
model.progress = (int) Math.ceil(((double) i) / documents.size() * 10.0);
i++;
LOG.info("Imported content for training document [" + trainingDocument.getId() + "] in project [" + aProject.getName() + "] with id [" + aProject.getId() + "]");
} catch (FileNotFoundException e) {
// error(e.getMessage());
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("Source file '");
errorMessage.append(trainingDocument.getName());
errorMessage.append("' related to project couldn't be located in repository");
LOG.error(errorMessage.toString(), ExceptionUtils.getRootCause(e));
model.messages.add(errorMessage.toString());
throw new ProjectExportException("Couldn't find some source file(s) related to project");
// continue;
}
}
}
Aggregations