use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference in project webanno by webanno.
the class LayerDetailForm method exportLayerJson.
private IResourceStream exportLayerJson() {
try {
AnnotationLayer layer = getModelObject();
List<ExportedAnnotationLayer> exLayers = new ArrayList<>();
ExportedAnnotationLayer exMainLayer = ImportUtil.exportLayerDetails(null, null, layer, annotationService);
exLayers.add(exMainLayer);
// that, otherwise we would be missing it during re-import.
if (layer.getAttachType() != null) {
AnnotationLayer attachLayer = layer.getAttachType();
ExportedAnnotationLayer exAttachLayer = ImportUtil.exportLayerDetails(null, null, attachLayer, annotationService);
exMainLayer.setAttachType(new ExportedAnnotationLayerReference(exAttachLayer.getName()));
exLayers.add(exAttachLayer);
}
return new InputStreamResourceStream(new ByteArrayInputStream(JSONUtil.toPrettyJsonString(exLayers).getBytes("UTF-8")));
} catch (Exception e) {
error("Unable to generate the JSON file: " + ExceptionUtils.getRootCauseMessage(e));
ProjectLayersPanel.LOG.error("Unable to generate the JSON file", e);
RequestCycle.get().find(IPartialPageRequestHandler.class).ifPresent(handler -> handler.addChildren(getPage(), IFeedback.class));
return null;
}
}
use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference in project webanno by webanno.
the class LayerExporter method exportData.
@Override
public void exportData(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage) throws Exception {
List<ExportedAnnotationLayer> exLayers = new ArrayList<>();
// Store map of layer and its equivalent exLayer so that the attach type is attached later
Map<AnnotationLayer, ExportedAnnotationLayer> layerToExLayers = new HashMap<>();
// Store map of feature and its equivalent exFeature so that the attach feature is attached
// later
Map<AnnotationFeature, ExportedAnnotationFeature> featureToExFeatures = new HashMap<>();
for (AnnotationLayer layer : annotationService.listAnnotationLayer(aRequest.getProject())) {
exLayers.add(exportLayerDetails(layerToExLayers, featureToExFeatures, layer));
}
// add the attach-type and attach-feature to the exported layers and exported feature
for (AnnotationLayer layer : layerToExLayers.keySet()) {
if (layer.getAttachType() != null) {
layerToExLayers.get(layer).setAttachType(new ExportedAnnotationLayerReference(layer.getAttachType().getName()));
}
if (layer.getAttachFeature() != null) {
layerToExLayers.get(layer).setAttachFeature(new ExportedAnnotationFeatureReference(layer.getAttachFeature()));
}
}
aExProject.setLayers(exLayers);
LOG.info("Exported [{}] layers for project [{}]", exLayers.size(), aRequest.getProject().getName());
}
Aggregations