Search in sources :

Example 1 with ExportedMiraTemplate

use of de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate in project webanno by webanno.

the class AutomationMiraTemplateExporter method importData.

@Override
public void importData(ProjectImportRequest aRequest, Project aProject, ExportedProject aExProject, ZipFile aZip) throws Exception {
    ExportedMiraTemplate[] templates = aExProject.getArrayProperty(MIRA_TEMPLATES, ExportedMiraTemplate.class);
    for (ExportedMiraTemplate exTemplate : templates) {
        MiraTemplate template = new MiraTemplate();
        template.setAnnotateAndRepeat(exTemplate.isAnnotateAndPredict());
        template.setAutomationStarted(false);
        template.setCurrentLayer(exTemplate.isCurrentLayer());
        template.setResult("---");
        AnnotationLayer trainingLayer = annotationService.findLayer(aProject, exTemplate.getTrainFeature().getLayer());
        AnnotationFeature trainingFeature = annotationService.getFeature(exTemplate.getTrainFeature().getName(), trainingLayer);
        template.setTrainFeature(trainingFeature);
        Set<AnnotationFeature> otherFeatures = new HashSet<>();
        if (exTemplate.getOtherFeatures() != null) {
            for (ExportedAnnotationFeatureReference other : exTemplate.getOtherFeatures()) {
                AnnotationLayer layer = annotationService.findLayer(aProject, other.getLayer());
                AnnotationFeature feature = annotationService.getFeature(other.getName(), layer);
                otherFeatures.add(feature);
            }
            template.setOtherFeatures(otherFeatures);
        }
        automationService.createTemplate(template);
    }
}
Also used : ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) MiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature) HashSet(java.util.HashSet)

Example 2 with ExportedMiraTemplate

use of de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate in project webanno by webanno.

the class AutomationMiraTemplateExporter method exportData.

@Override
public void exportData(ProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage) throws Exception {
    List<ExportedMiraTemplate> exTemplates = new ArrayList<>();
    for (MiraTemplate template : automationService.listMiraTemplates(aRequest.getProject())) {
        ExportedMiraTemplate exTemplate = new ExportedMiraTemplate();
        exTemplate.setAnnotateAndPredict(template.isAnnotateAndRepeat());
        exTemplate.setAutomationStarted(template.isAutomationStarted());
        exTemplate.setCurrentLayer(template.isCurrentLayer());
        exTemplate.setResult(template.getResult());
        exTemplate.setTrainFeature(new ExportedAnnotationFeatureReference(template.getTrainFeature()));
        if (template.getOtherFeatures().size() > 0) {
            Set<ExportedAnnotationFeatureReference> exOtherFeatures = new HashSet<>();
            for (AnnotationFeature feature : template.getOtherFeatures()) {
                exOtherFeatures.add(new ExportedAnnotationFeatureReference(feature));
            }
            exTemplate.setOtherFeatures(exOtherFeatures);
        }
        exTemplates.add(exTemplate);
    }
    aExProject.setProperty(MIRA_TEMPLATES, exTemplates);
}
Also used : ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) ExportedMiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate) MiraTemplate(de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate) ArrayList(java.util.ArrayList) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) HashSet(java.util.HashSet) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Aggregations

MiraTemplate (de.tudarmstadt.ukp.clarin.webanno.automation.model.MiraTemplate)2 ExportedMiraTemplate (de.tudarmstadt.ukp.clarin.webanno.automation.service.export.model.ExportedMiraTemplate)2 ExportedAnnotationFeatureReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference)2 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)2 HashSet (java.util.HashSet)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1 ArrayList (java.util.ArrayList)1