Search in sources :

Example 1 with ExportedAnnotationFeature

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature in project webanno by webanno.

the class ImportUtil method exportLayerDetails.

@Deprecated
public static ExportedAnnotationLayer exportLayerDetails(Map<AnnotationLayer, ExportedAnnotationLayer> aLayerToExLayer, Map<AnnotationFeature, ExportedAnnotationFeature> aFeatureToExFeature, AnnotationLayer aLayer, AnnotationSchemaService aAnnotationService) {
    ExportedAnnotationLayer exLayer = new ExportedAnnotationLayer();
    exLayer.setAllowStacking(aLayer.isAllowStacking());
    exLayer.setBuiltIn(aLayer.isBuiltIn());
    exLayer.setReadonly(aLayer.isReadonly());
    exLayer.setCrossSentence(aLayer.isCrossSentence());
    exLayer.setDescription(aLayer.getDescription());
    exLayer.setEnabled(aLayer.isEnabled());
    exLayer.setLockToTokenOffset(AnchoringMode.SINGLE_TOKEN.equals(aLayer.getAnchoringMode()));
    exLayer.setMultipleTokens(AnchoringMode.TOKENS.equals(aLayer.getAnchoringMode()));
    exLayer.setOverlapMode(aLayer.getOverlapMode());
    exLayer.setAnchoringMode(aLayer.getAnchoringMode());
    exLayer.setValidationMode(aLayer.getValidationMode());
    exLayer.setLinkedListBehavior(aLayer.isLinkedListBehavior());
    exLayer.setName(aLayer.getName());
    exLayer.setProjectName(aLayer.getProject().getName());
    exLayer.setType(aLayer.getType());
    exLayer.setUiName(aLayer.getUiName());
    if (aLayerToExLayer != null) {
        aLayerToExLayer.put(aLayer, exLayer);
    }
    List<ExportedAnnotationFeature> exFeatures = new ArrayList<>();
    for (AnnotationFeature feature : aAnnotationService.listAnnotationFeature(aLayer)) {
        ExportedAnnotationFeature exFeature = new ExportedAnnotationFeature();
        exFeature.setDescription(feature.getDescription());
        exFeature.setEnabled(feature.isEnabled());
        exFeature.setRemember(feature.isRemember());
        exFeature.setRequired(feature.isRequired());
        exFeature.setHideUnconstraintFeature(feature.isHideUnconstraintFeature());
        exFeature.setName(feature.getName());
        exFeature.setProjectName(feature.getProject().getName());
        exFeature.setType(feature.getType());
        exFeature.setUiName(feature.getUiName());
        exFeature.setVisible(feature.isVisible());
        exFeature.setMultiValueMode(feature.getMultiValueMode());
        exFeature.setLinkMode(feature.getLinkMode());
        exFeature.setLinkTypeName(feature.getLinkTypeName());
        exFeature.setLinkTypeRoleFeatureName(feature.getLinkTypeRoleFeatureName());
        exFeature.setLinkTypeTargetFeatureName(feature.getLinkTypeTargetFeatureName());
        exFeature.setTraits(feature.getTraits());
        if (feature.getTagset() != null) {
            TagSet tagSet = feature.getTagset();
            ExportedTagSet exTagSet = new ExportedTagSet();
            exTagSet.setDescription(tagSet.getDescription());
            exTagSet.setLanguage(tagSet.getLanguage());
            exTagSet.setName(tagSet.getName());
            exTagSet.setCreateTag(tagSet.isCreateTag());
            List<ExportedTag> exportedTags = new ArrayList<>();
            for (Tag tag : aAnnotationService.listTags(tagSet)) {
                ExportedTag exTag = new ExportedTag();
                exTag.setDescription(tag.getDescription());
                exTag.setName(tag.getName());
                exportedTags.add(exTag);
            }
            exTagSet.setTags(exportedTags);
            exFeature.setTagSet(exTagSet);
        }
        exFeatures.add(exFeature);
        if (aFeatureToExFeature != null) {
            aFeatureToExFeature.put(feature, exFeature);
        }
    }
    exLayer.setFeatures(exFeatures);
    return exLayer;
}
Also used : ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ExportedTagSet(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTagSet) TagSet(de.tudarmstadt.ukp.clarin.webanno.model.TagSet) ExportedTagSet(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTagSet) ArrayList(java.util.ArrayList) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) ExportedTag(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTag) Tag(de.tudarmstadt.ukp.clarin.webanno.model.Tag) ExportedTag(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTag) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 2 with ExportedAnnotationFeature

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature in project webanno by webanno.

the class LayerExporter method exportLayerDetails.

private ExportedAnnotationLayer exportLayerDetails(Map<AnnotationLayer, ExportedAnnotationLayer> aLayerToExLayer, Map<AnnotationFeature, ExportedAnnotationFeature> aFeatureToExFeature, AnnotationLayer aLayer) {
    ExportedAnnotationLayer exLayer = new ExportedAnnotationLayer();
    exLayer.setAllowStacking(aLayer.isAllowStacking());
    exLayer.setBuiltIn(aLayer.isBuiltIn());
    exLayer.setReadonly(aLayer.isReadonly());
    exLayer.setCrossSentence(aLayer.isCrossSentence());
    exLayer.setDescription(aLayer.getDescription());
    exLayer.setEnabled(aLayer.isEnabled());
    exLayer.setLockToTokenOffset(AnchoringMode.SINGLE_TOKEN.equals(aLayer.getAnchoringMode()));
    exLayer.setMultipleTokens(AnchoringMode.TOKENS.equals(aLayer.getAnchoringMode()));
    exLayer.setOverlapMode(aLayer.getOverlapMode());
    exLayer.setAnchoringMode(aLayer.getAnchoringMode());
    exLayer.setValidationMode(aLayer.getValidationMode());
    exLayer.setLinkedListBehavior(aLayer.isLinkedListBehavior());
    exLayer.setName(aLayer.getName());
    exLayer.setProjectName(aLayer.getProject().getName());
    exLayer.setType(aLayer.getType());
    exLayer.setUiName(aLayer.getUiName());
    exLayer.setTraits(aLayer.getTraits());
    if (aLayerToExLayer != null) {
        aLayerToExLayer.put(aLayer, exLayer);
    }
    // Export features
    List<ExportedAnnotationFeature> exFeatures = new ArrayList<>();
    for (AnnotationFeature feature : annotationService.listAnnotationFeature(aLayer)) {
        ExportedAnnotationFeature exFeature = exportFeatureDetails(feature);
        exFeatures.add(exFeature);
        if (aFeatureToExFeature != null) {
            aFeatureToExFeature.put(feature, exFeature);
        }
    }
    exLayer.setFeatures(exFeatures);
    return exLayer;
}
Also used : ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ArrayList(java.util.ArrayList) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 3 with ExportedAnnotationFeature

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature 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());
}
Also used : ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) HashMap(java.util.HashMap) ExportedAnnotationLayerReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference) ArrayList(java.util.ArrayList) ExportedAnnotationFeatureReference(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 4 with ExportedAnnotationFeature

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature in project webanno by webanno.

the class LayerExporter method importLayers.

/**
 * Create a {@link TagSet} for the imported project,
 *
 * @param aProject
 *            a project.
 * @param aExProject
 *            the settings.
 * @throws IOException
 *             if an I/O error occurs.
 */
private void importLayers(Project aProject, ExportedProject aExProject) throws IOException {
    // Round 1: layers and features
    for (ExportedAnnotationLayer exLayer : aExProject.getLayers()) {
        if (annotationService.existsLayer(exLayer.getName(), exLayer.getType(), aProject)) {
            AnnotationLayer layer = annotationService.findLayer(aProject, exLayer.getName());
            importLayer(layer, exLayer, aProject);
            for (ExportedAnnotationFeature exfeature : exLayer.getFeatures()) {
                if (annotationService.existsFeature(exfeature.getName(), layer)) {
                    AnnotationFeature feature = annotationService.getFeature(exfeature.getName(), layer);
                    importFeature(feature, exfeature, aProject);
                    continue;
                }
                AnnotationFeature feature = new AnnotationFeature();
                feature.setLayer(layer);
                importFeature(feature, exfeature, aProject);
            }
        } else {
            AnnotationLayer layer = new AnnotationLayer();
            importLayer(layer, exLayer, aProject);
            for (ExportedAnnotationFeature exfeature : exLayer.getFeatures()) {
                AnnotationFeature feature = new AnnotationFeature();
                feature.setLayer(layer);
                importFeature(feature, exfeature, aProject);
            }
        }
    }
    // Round 2: attach-layers, attach-features
    for (ExportedAnnotationLayer exLayer : aExProject.getLayers()) {
        if (exLayer.getAttachType() != null) {
            AnnotationLayer layer = annotationService.findLayer(aProject, exLayer.getName());
            AnnotationLayer attachLayer = annotationService.findLayer(aProject, exLayer.getAttachType().getName());
            layer.setAttachType(attachLayer);
            if (exLayer.getAttachFeature() != null) {
                AnnotationFeature attachFeature = annotationService.getFeature(exLayer.getAttachFeature().getName(), attachLayer);
                layer.setAttachFeature(attachFeature);
            }
            annotationService.createOrUpdateLayer(layer);
        }
    }
}
Also used : ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) ExportedAnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature) AnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)

Example 5 with ExportedAnnotationFeature

use of de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature in project webanno by webanno.

the class LayerExporter method exportFeatureDetails.

private ExportedAnnotationFeature exportFeatureDetails(AnnotationFeature feature) {
    ExportedAnnotationFeature exFeature = new ExportedAnnotationFeature();
    exFeature.setDescription(feature.getDescription());
    exFeature.setEnabled(feature.isEnabled());
    exFeature.setRemember(feature.isRemember());
    exFeature.setRequired(feature.isRequired());
    exFeature.setHideUnconstraintFeature(feature.isHideUnconstraintFeature());
    exFeature.setName(feature.getName());
    exFeature.setProjectName(feature.getProject().getName());
    exFeature.setType(feature.getType());
    exFeature.setUiName(feature.getUiName());
    exFeature.setVisible(feature.isVisible());
    exFeature.setMultiValueMode(feature.getMultiValueMode());
    exFeature.setLinkMode(feature.getLinkMode());
    exFeature.setLinkTypeName(feature.getLinkTypeName());
    exFeature.setLinkTypeRoleFeatureName(feature.getLinkTypeRoleFeatureName());
    exFeature.setLinkTypeTargetFeatureName(feature.getLinkTypeTargetFeatureName());
    exFeature.setTraits(feature.getTraits());
    if (feature.getTagset() != null) {
        TagSet tagSet = feature.getTagset();
        // We export only the name here as a stub. The actual tag set is exported by
        // the TagSetExporter.
        ExportedTagSet exTagSet = new ExportedTagSet();
        exTagSet.setName(tagSet.getName());
        exFeature.setTagSet(exTagSet);
    }
    return exFeature;
}
Also used : ExportedTagSet(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTagSet) TagSet(de.tudarmstadt.ukp.clarin.webanno.model.TagSet) ExportedTagSet(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTagSet) ExportedAnnotationFeature(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature)

Aggregations

ExportedAnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeature)5 ExportedAnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayer)4 AnnotationFeature (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature)4 ArrayList (java.util.ArrayList)3 ExportedTagSet (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTagSet)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)2 TagSet (de.tudarmstadt.ukp.clarin.webanno.model.TagSet)2 ExportedAnnotationFeatureReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationFeatureReference)1 ExportedAnnotationLayerReference (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedAnnotationLayerReference)1 ExportedTag (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedTag)1 Tag (de.tudarmstadt.ukp.clarin.webanno.model.Tag)1 HashMap (java.util.HashMap)1