Skip to content
Snippets Groups Projects
Commit 96b0cf42 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Use format instead of type property for Content deserialization

While type works fine for deserialization from CouchDB, it is not part
of the public v3 API. The format property is available in both cases.
parent e042c0a2
No related merge requests found
...@@ -12,7 +12,8 @@ import java.util.Objects; ...@@ -12,7 +12,8 @@ import java.util.Objects;
@JsonTypeInfo( @JsonTypeInfo(
use = JsonTypeInfo.Id.MINIMAL_CLASS, use = JsonTypeInfo.Id.MINIMAL_CLASS,
include = JsonTypeInfo.As.PROPERTY, include = JsonTypeInfo.As.PROPERTY,
property = "type" property = "format",
visible = true
) )
public class Content extends Entity { public class Content extends Entity {
public enum Format { public enum Format {
......
...@@ -36,8 +36,12 @@ public class CouchDbDocumentModule extends SimpleModule { ...@@ -36,8 +36,12 @@ public class CouchDbDocumentModule extends SimpleModule {
context.setMixInAnnotations(Entity.class, CouchDbDocumentMixIn.class); context.setMixInAnnotations(Entity.class, CouchDbDocumentMixIn.class);
context.setMixInAnnotations(de.thm.arsnova.entities.migration.v2.Entity.class, CouchDbDocumentV2MixIn.class); context.setMixInAnnotations(de.thm.arsnova.entities.migration.v2.Entity.class, CouchDbDocumentV2MixIn.class);
context.registerSubtypes( context.registerSubtypes(
new NamedType(Content.class, Content.class.getSimpleName()), new NamedType(Content.class, Content.Format.TEXT.toString()),
new NamedType(ChoiceQuestionContent.class, ChoiceQuestionContent.class.getSimpleName()), new NamedType(Content.class, Content.Format.NUMBER.toString()),
new NamedType(ChoiceQuestionContent.class, Content.Format.CHOICE.toString()),
new NamedType(ChoiceQuestionContent.class, Content.Format.BINARY.toString()),
new NamedType(ChoiceQuestionContent.class, Content.Format.SCALE.toString()),
new NamedType(ChoiceQuestionContent.class, Content.Format.GRID.toString()),
new NamedType(Answer.class, Answer.class.getSimpleName()), new NamedType(Answer.class, Answer.class.getSimpleName()),
new NamedType(ChoiceAnswer.class, ChoiceAnswer.class.getSimpleName()), new NamedType(ChoiceAnswer.class, ChoiceAnswer.class.getSimpleName()),
new NamedType(TextAnswer.class, TextAnswer.class.getSimpleName())); new NamedType(TextAnswer.class, TextAnswer.class.getSimpleName()));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment