Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4699 - Ability to export all layers as json #5076

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,9 @@ public class ExportedAnnotationLayer
@JsonProperty("multiple_tokens")
private boolean multipleTokens;

@JsonProperty("project_name")
private String projectName;

@JsonProperty("linked_list_behavior")
private boolean linkedListBehavior;

@JsonProperty("on_click_javascript_action")
private String onClickJavascriptAction;

@JsonProperty("traits")
private String traits;

Expand Down Expand Up @@ -315,16 +309,6 @@ public void setAttachFeature(ExportedAnnotationFeatureReference attachFeature)
this.attachFeature = attachFeature;
}

public String isProjectName()
{
return projectName;
}

public void setProjectName(String projectName)
{
this.projectName = projectName;
}

public boolean isLinkedListBehavior()
{
return linkedListBehavior;
Expand All @@ -345,16 +329,6 @@ public void setReadonly(boolean aReadonly)
readonly = aReadonly;
}

public String getOnClickJavascriptAction()
{
return onClickJavascriptAction;
}

public void setOnClickJavascriptAction(String onClickAction)
{
this.onClickJavascriptAction = onClickAction;
}

public String getTraits()
{
return traits;
Expand All @@ -371,14 +345,15 @@ public boolean equals(final Object other)
if (!(other instanceof ExportedAnnotationLayer)) {
return false;
}
ExportedAnnotationLayer castOther = (ExportedAnnotationLayer) other;

var castOther = (ExportedAnnotationLayer) other;
return new EqualsBuilder().append(name, castOther.name).append(type, castOther.type)
.append(projectName, castOther.projectName).isEquals();
.isEquals();
}

@Override
public int hashCode()
{
return new HashCodeBuilder().append(name).append(type).append(projectName).toHashCode();
return new HashCodeBuilder().append(name).append(type).toHashCode();
}
}
4 changes: 4 additions & 0 deletions inception/inception-project-initializers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-schema-api</artifactId>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-schema</artifactId>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-support</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.project.initializers;

import static de.tudarmstadt.ukp.inception.export.JsonImportUtil.importTagSetFromJson;
import static de.tudarmstadt.ukp.inception.schema.exporters.TagsetImportExportUtils.importTagSetFromJson;

import java.io.IOException;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.project.initializers;

import static de.tudarmstadt.ukp.inception.export.JsonImportUtil.importTagSetFromJson;
import static de.tudarmstadt.ukp.inception.schema.exporters.TagsetImportExportUtils.importTagSetFromJson;

import java.io.IOException;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.project.initializers;

import static de.tudarmstadt.ukp.inception.export.JsonImportUtil.importTagSetFromJson;
import static de.tudarmstadt.ukp.inception.schema.exporters.TagsetImportExportUtils.importTagSetFromJson;

import java.io.IOException;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.project.initializers;

import static de.tudarmstadt.ukp.inception.export.JsonImportUtil.importTagSetFromJson;
import static de.tudarmstadt.ukp.inception.schema.exporters.TagsetImportExportUtils.importTagSetFromJson;

import java.io.IOException;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.tudarmstadt.ukp.clarin.webanno.project.initializers;

import static de.tudarmstadt.ukp.inception.export.JsonImportUtil.importTagSetFromJson;
import static de.tudarmstadt.ukp.inception.schema.exporters.TagsetImportExportUtils.importTagSetFromJson;

import java.io.IOException;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ private ExportedAnnotationLayer exportLayerDetails(
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());
Expand All @@ -153,7 +152,7 @@ private ExportedAnnotationLayer exportLayerDetails(
// Export features
var exFeatures = new ArrayList<ExportedAnnotationFeature>();
for (var feature : annotationService.listAnnotationFeature(aLayer)) {
ExportedAnnotationFeature exFeature = exportFeatureDetails(feature);
var exFeature = exportFeatureDetails(feature);
exFeatures.add(exFeature);

if (aFeatureToExFeature != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.tudarmstadt.ukp.inception.export;
package de.tudarmstadt.ukp.inception.schema.exporters;

import static de.tudarmstadt.ukp.clarin.webanno.model.OverlapMode.ANY_OVERLAP;
import static de.tudarmstadt.ukp.clarin.webanno.model.OverlapMode.OVERLAP_ONLY;
Expand Down Expand Up @@ -64,14 +64,14 @@ public static String exportLayerToJson(AnnotationSchemaService aSchemaService,
{
var exLayers = new ArrayList<ExportedAnnotationLayer>();

var exMainLayer = exportLayerDetails(null, null, layer, aSchemaService);
var exMainLayer = exportLayerDetails(layer, aSchemaService);
exLayers.add(exMainLayer);

// If the layer is attached to another layer, then we also have to export
// that, otherwise we would be missing it during re-import.
if (layer.getAttachType() != null) {
var attachLayer = layer.getAttachType();
var exAttachLayer = exportLayerDetails(null, null, attachLayer, aSchemaService);
var exAttachLayer = exportLayerDetails(attachLayer, aSchemaService);
exMainLayer
.setAttachType(new ExportedAnnotationLayerReference(exAttachLayer.getName()));
exLayers.add(exAttachLayer);
Expand Down Expand Up @@ -101,7 +101,7 @@ public static Map<String, String> getTagSetFromFile(String aLineSeparatedTags)
}

@Deprecated
private static void createTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Project aProject,
private static void importTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Project aProject,
AnnotationSchemaService aAnnotationService)
throws IOException
{
Expand All @@ -117,7 +117,7 @@ private static void createTagSet(TagSet aTagSet, ExportedTagSet aExTagSet, Proje
if (aAnnotationService.existsTag(exTag.getName(), aTagSet)) {
continue;
}
Tag tag = new Tag();
var tag = new Tag();
tag.setDescription(exTag.getDescription());
tag.setTagSet(aTagSet);
tag.setName(exTag.getName());
Expand Down Expand Up @@ -220,11 +220,11 @@ private static AnnotationLayer createLayer(AnnotationSchemaService annotationSer
TagSet tagSet = null;
if (exTagset != null && annotationService.existsTagSet(exTagset.getName(), project)) {
tagSet = annotationService.getTagSet(exTagset.getName(), project);
createTagSet(tagSet, exTagset, project, annotationService);
importTagSet(tagSet, exTagset, project, annotationService);
}
else if (exTagset != null) {
tagSet = new TagSet();
createTagSet(tagSet, exTagset, project, annotationService);
importTagSet(tagSet, exTagset, project, annotationService);
}
if (annotationService.existsFeature(exfeature.getName(), layer)) {
AnnotationFeature feature = annotationService.getFeature(exfeature.getName(),
Expand Down Expand Up @@ -284,10 +284,8 @@ else if (Token._TypeName.equals(aFeature.getLayer().getName())
}

@Deprecated
public static ExportedAnnotationLayer exportLayerDetails(
Map<AnnotationLayer, ExportedAnnotationLayer> aLayerToExLayer,
Map<AnnotationFeature, ExportedAnnotationFeature> aFeatureToExFeature,
AnnotationLayer aLayer, AnnotationSchemaService aAnnotationService)
public static ExportedAnnotationLayer exportLayerDetails(AnnotationLayer aLayer,
AnnotationSchemaService aAnnotationService)
{
var exLayer = new ExportedAnnotationLayer();
exLayer.setAllowStacking(aLayer.isAllowStacking());
Expand All @@ -303,15 +301,10 @@ public static ExportedAnnotationLayer exportLayerDetails(
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);
}

var exFeatures = new ArrayList<ExportedAnnotationFeature>();
for (var feature : aAnnotationService.listAnnotationFeature(aLayer)) {
var exFeature = new ExportedAnnotationFeature();
Expand Down Expand Up @@ -352,10 +345,8 @@ public static ExportedAnnotationLayer exportLayerDetails(
exTagSet.setTags(exportedTags);
exFeature.setTagSet(exTagSet);
}

exFeatures.add(exFeature);
if (aFeatureToExFeature != null) {
aFeatureToExFeature.put(feature, exFeature);
}
}

exLayer.setFeatures(exFeatures);
Expand Down
Loading
Loading