Skip to content

Commit

Permalink
Update form serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Jun 19, 2024
1 parent 2cfa3de commit ca68d11
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-gwt-ui</artifactId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion webprotege-gwt-ui-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-gwt-ui</artifactId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>webprotege-gwt-ui-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion webprotege-gwt-ui-server-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>webprotege-gwt-ui</artifactId>
<groupId>edu.stanford.protege</groupId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ public void shouldDeserialize() throws IOException {
assertEquals(deserializedObject.getId().getId(), "66bf9c2b-d50c-43d9-adbd-61b94151750d");
}

private static final String SERIALIZATION = "{\t\t\t\"id\": {\n" + "\t\t\t\t\"type\": \"GridColumnId\",\n" + "\t\t\t\t\"id\": \"66bf9c2b-d50c-43d9-adbd-61b94151750d\"\n" + "\t\t\t},\n" + "\t\t\t\"optionality\": \"REQUIRED\",\n" + "\t\t\t\"repeatability\": \"NON_REPEATABLE\",\n" + "\t\t\t\"label\": {\n" + "\t\t\t\t\"en\": \"Label\"\n" + "\t\t\t},\n" + "\t\t\t\"formControlDescriptor\": {\n" + "\t\t\t\t\"type\": \"TextControlDescriptorDto\",\n" + "\t\t\t\t\"descriptor\": {\n" + "\t\t\t\t\t\"type\": \"TEXT\",\n" + "\t\t\t\t\t\"placeholder\": {\n" + "\t\t\t\t\t},\n" + "\t\t\t\t\t\"stringType\": \"SIMPLE_STRING\",\n" + "\t\t\t\t\t\"lineMode\": \"SINGLE_LINE\",\n" + "\t\t\t\t\t\"pattern\": \"\",\n" + "\t\t\t\t\t\"patternViolationErrorMessage\": {\n" + "\t\t\t\t\t},\n" + "\t\t\t\t\t\"specificLangTag\": \"\"\n" + "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"owlBinding\": {\n" + "\t\t\t\t\"type\": \"PROPERTY\",\n" + "\t\t\t\t\"property\": {\n" + "\t\t\t\t\t\"@type\": \"AnnotationProperty\",\n" + "\t\t\t\t\t\"iri\": \"http://who.int/icd#label\"\n" + "\t\t\t\t},\n" + "\t\t\t\t\"valuesCriteria\": {\n" + "\t\t\t\t\t\"match\": \"CompositeCriteria\",\n" + "\t\t\t\t\t\"multiMatchType\": \"ALL\",\n" + "\t\t\t\t\t\"criteria\": [\n" + "\t\t\t\t\t\t{\n" + "\t\t\t\t\t\t\t\"match\": \"AnyValue\"\n" + "\t\t\t\t\t\t}\n" + "\t\t\t\t\t]\n" + "\t\t\t\t}\n" + "\t\t\t}\n" + "\t\t}";
private static final String SERIALIZATION = "{\t\t\t\"id\": {\n" + "\t\t\t\t\"type\": \"GridColumnId\",\n" + "\t\t\t\t\"id\": \"66bf9c2b-d50c-43d9-adbd-61b94151750d\"\n" + "\t\t\t},\n" + "\t\t\t\"optionality\": \"REQUIRED\",\n" + "\t\t\t\"repeatability\": \"NON_REPEATABLE\",\n" + "\t\t\t\"label\": {\n" + "\t\t\t\t\"en\": \"Label\"\n" + "\t\t\t},\n" + "\t\t\t\"control\": {\n" + "\t\t\t\t\"type\": \"TextControlDescriptorDto\",\n" + "\t\t\t\t\"control\": {\n" + "\t\t\t\t\t\"type\": \"TEXT\",\n" + "\t\t\t\t\t\"placeholder\": {\n" + "\t\t\t\t\t},\n" + "\t\t\t\t\t\"stringType\": \"SIMPLE_STRING\",\n" + "\t\t\t\t\t\"lineMode\": \"SINGLE_LINE\",\n" + "\t\t\t\t\t\"pattern\": \"\",\n" + "\t\t\t\t\t\"patternViolationErrorMessage\": {\n" + "\t\t\t\t\t},\n" + "\t\t\t\t\t\"specificLangTag\": \"\"\n" + "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"owlBinding\": {\n" + "\t\t\t\t\"type\": \"PROPERTY\",\n" + "\t\t\t\t\"property\": {\n" + "\t\t\t\t\t\"@type\": \"AnnotationProperty\",\n" + "\t\t\t\t\t\"iri\": \"http://who.int/icd#label\"\n" + "\t\t\t\t},\n" + "\t\t\t\t\"valuesCriteria\": {\n" + "\t\t\t\t\t\"match\": \"CompositeCriteria\",\n" + "\t\t\t\t\t\"multiMatchType\": \"ALL\",\n" + "\t\t\t\t\t\"criteria\": [\n" + "\t\t\t\t\t\t{\n" + "\t\t\t\t\t\t\t\"match\": \"AnyValue\"\n" + "\t\t\t\t\t\t}\n" + "\t\t\t\t\t]\n" + "\t\t\t\t}\n" + "\t\t\t}\n" + "\t\t}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void shouldSerializeAndDeserialize() throws IOException {
LanguageMap.of("en", "The sub form"),
singletonList(
FormFieldDescriptor.get(
FormFieldId.get(UUID.randomUUID().toString()),
FormFieldId.get("12345678-1234-1234-1234-123456789def"),
OwlPropertyBinding.get(new OWLObjectPropertyImpl(
OWLRDFVocabulary.RDFS_LABEL.getIRI()),
null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"fields": [
{
"id": "2b16a436-28da-4d47-b25e-a9fbb876deb6",
"id": "12345678-1234-1234-1234-123456789def",
"owlBinding": {
"type": "PROPERTY",
"property": {
Expand Down Expand Up @@ -40,6 +40,6 @@
}
],
"subjectFactory": null,
"formId": "12345678-1234-1234-1234-123456789abc"
"id": "12345678-1234-1234-1234-123456789abc"
}
}
2 changes: 1 addition & 1 deletion webprotege-gwt-ui-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-gwt-ui</artifactId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>webprotege-gwt-ui-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion webprotege-gwt-ui-shared-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>webprotege-gwt-ui</artifactId>
<groupId>edu.stanford.protege</groupId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion webprotege-gwt-ui-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-gwt-ui</artifactId>
<version>5.0.15</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>webprotege-gwt-ui-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public FormDescriptor(@JsonProperty(PropertyNames.ID) FormId id,
@JsonProperty(PropertyNames.LABEL) LanguageMap label,
@JsonProperty(PropertyNames.FIELDS) List<FormFieldDescriptor> formFieldDescriptors,
@JsonProperty(PropertyNames.SUBJECT_FACTORY) Optional<FormSubjectFactoryDescriptor> subjectFactoryDescriptor) {
this.formId = id;
this.label = label;
this.formId = checkNotNull(id);
this.label = checkNotNull(label);
this.elements = new ArrayList<>(formFieldDescriptors);
this.subjectFactoryDescriptor = subjectFactoryDescriptor.orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,4 @@ public interface PropertyNames {
String FORM = "form";

String FIELD = "field";

String CONTROL_DATA = "controlData";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public abstract class FormFieldData implements IsSerializable {

public static FormFieldData get(@JsonProperty(PropertyNames.FIELD) @Nonnull FormFieldDescriptor descriptor,
@JsonProperty(PropertyNames.CONTROL_DATA) @Nonnull Page<FormControlData> formControlData) {
@JsonProperty(PropertyNames.DATA) @Nonnull Page<FormControlData> formControlData) {
return new AutoValue_FormFieldData(descriptor, formControlData);
}

Expand All @@ -31,7 +31,7 @@ public static FormFieldData get(@JsonProperty(PropertyNames.FIELD) @Nonnull Form
/**
* Gets the page of form control values for this field.
*/
@JsonProperty(PropertyNames.CONTROL_DATA)
@JsonProperty(PropertyNames.DATA)
@Nonnull
public abstract Page<FormControlData> getFormControlData();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.stanford.bmir.protege.web.shared.form.data;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import edu.stanford.bmir.protege.web.shared.form.PropertyNames;
Expand All @@ -17,17 +16,19 @@ public abstract class FormFieldDataDto {
@JsonCreator
@Nonnull
public static FormFieldDataDto get(@JsonProperty(PropertyNames.FIELD) @Nonnull FormFieldDescriptorDto descriptor,
@JsonProperty(PropertyNames.CONTROL_DATA) @Nonnull Page<FormControlDataDto> formControlData) {
@JsonProperty(PropertyNames.DATA) @Nonnull Page<FormControlDataDto> formControlData) {
return new AutoValue_FormFieldDataDto(descriptor, formControlData);
}

@Nonnull
@JsonProperty(PropertyNames.FIELD)
public abstract FormFieldDescriptorDto getFormFieldDescriptor();

/**
* Gets the page of form control values for this field.
*/
@Nonnull
@JsonProperty(PropertyNames.DATA)
public abstract Page<FormControlDataDto> getFormControlData();

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public abstract class GridCellData {

public static GridCellData get(@JsonProperty(PropertyNames.COLUMN_ID) @Nonnull GridColumnId columnId,
@JsonProperty(PropertyNames.CONTROL_DATA) @Nullable Page<FormControlData> values) {
@JsonProperty(PropertyNames.DATA) @Nullable Page<FormControlData> values) {
return new AutoValue_GridCellData(columnId, values);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static MultiChoiceControlDescriptor get(@JsonProperty(PropertyNames.CHOIC
}

@Nonnull
@JsonProperty(PropertyNames.DEFAULT_CHOICE)
@JsonProperty(PropertyNames.CHOICES_SOURCE)
public abstract ChoiceListSourceDescriptor getSource();

@Nonnull
Expand All @@ -51,6 +51,7 @@ public static String getType() {

@Nonnull
@Override
@JsonIgnore
public String getAssociatedType() {
return TYPE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class TextControlDescriptor implements FormControlDescriptor {
private TextControlDescriptor() {
}

@JsonCreator
public TextControlDescriptor(@JsonProperty(PropertyNames.PLACEHOLDER) @Nonnull LanguageMap placeholder,
@JsonProperty(PropertyNames.STRING_TYPE) @Nonnull StringType stringType,
@JsonProperty(PropertyNames.SPECIFIC_LANG_TAG) @Nonnull String specificLangTag,
Expand Down Expand Up @@ -129,7 +130,7 @@ public LanguageMap getPlaceholder() {
}

@Nonnull
@JsonProperty(PropertyNames.SOURCE_TYPE)
@JsonProperty(PropertyNames.STRING_TYPE)
public StringType getStringType() {
return stringType;
}
Expand Down

0 comments on commit ca68d11

Please sign in to comment.