Skip to content

Commit

Permalink
fixing forms
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Jun 24, 2024
1 parent e09f8ec commit 0c29f14
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>edu.stanford.protege</groupId>
<artifactId>webprotege-forms</artifactId>
<version>1.1.3</version>
<version>1.1.5</version>
<name>webprotege-forms</name>
<description>Data structures and request/responses for forms</description>
<properties>
Expand Down
137 changes: 137 additions & 0 deletions src/main/java/edu/stanford/protege/webprotege/forms/PropertyNames.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package edu.stanford.protege.webprotege.forms;

/**
* Matthew Horridge
* Stanford Center for Biomedical Informatics Research
* 2024-06-18
*/
public interface PropertyNames {

String DESCRIPTOR = "descriptor";

String CONTROL = "control";

String CRITERIA = "criteria";

String MATCH_TYPE = "matchType";

String ENTITY = "entity";

String DEPTH = "depth";

String SUBJECT = "subject";

String REGION_ID = "regionId";

String COLUMN_ID = "columnId";

String VALUES = "values";

String FILTER_STATE = "filterState";

String ROWS = "rows";

String ORDERING = "ordering";

String CELLS = "cells";

String IRI = "iri";

String LITERAL = "literal";

String VALUE = "value";

String CHOICE = "choice";

String LABEL = "label";

String PLACEHOLDER = "placeholder";

String CHOICES = "choices";

String ID = "id";

String OWL_BINDING = "owlBinding";

String FIELD_RUN = "fieldRun";

String REPEATABILITY = "repeatability";

String OPTIONALITY = "optionality";

String READ_ONLY = "readOnly";

String INITIAL_EXPANSIONS_STATE = "initialExpansionState";

String HELP = "help";

String DEPRECATION_STRATEGY = "deprecationStrategy";

String DIRECTION = "direction";

String COLUMNS = "columns";

String SUBJECT_FACTORY = "subjectFactory";

String CHOICES_SOURCE = "choicesSource";

String FORMAT = "format";

String RANGE = "range";

String WIDGET_TYPE = "widgetType";

String LENGTH = "length";

String LOWER_BOUND = "lowerBound";

String UPPER_BOUND = "upperBound";

String LOWER_BOUND_TYPE = "lowerBoundType";

String UPPER_BOUND_TYPE = "upperBoundType";

String PROPERTY = "property";

String DEFAULT_CHOICE = "defaultChoice";

String STRING_TYPE = "stringType";

String SPECIFIC_LANG_TAG = "specificLangTag";

String LINE_MODE = "lineMode";

String PATTERN = "pattern";

String PATTERN_VIOLATION_ERROR_MESSAGE = "patternViolationErrorMessage";

String PROJECT_ID = "projectId";

String FORM_ID = "formId";

String PURPOSE = "purpose";

String FIELDS = "fields";

String ORDINAL = "ordinal";

String DESCRIPTION = "description";

String FORMS = "forms";

String SOURCE_TYPE = "sourceType";

String PAGE_REQUEST = "pageRequest";

String ENTITY_TYPE = "entityType";

String PARENT = "parent";

String TARGET_ONTOLOGY_IRI = "targetOntologyIri";

String FORM = "form";

String DATA = "data";

String FIELD = "field";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class EntityNameControlData implements FormControlData {

@JsonCreator
public static EntityNameControlData get(@JsonProperty("descriptor") @Nonnull EntityNameControlDescriptor descriptor,
@JsonProperty("term") @Nullable OWLEntity entity) {
@JsonProperty("entity") @Nullable OWLEntity entity) {
return new AutoValue_EntityNameControlData(descriptor, entity);
}

Expand All @@ -39,6 +39,7 @@ public void accept(@Nonnull FormControlDataVisitor visitor) {
}

@Nonnull
@JsonProperty("descriptor")
public abstract EntityNameControlDescriptor getDescriptor();

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package edu.stanford.protege.webprotege.forms.data;

import com.fasterxml.jackson.annotation.*;
import com.google.auto.value.AutoValue;
import edu.stanford.protege.webprotege.common.Page;
import edu.stanford.protege.webprotege.forms.PropertyNames;
import edu.stanford.protege.webprotege.forms.field.GridColumnId;
import org.semanticweb.owlapi.model.OWLEntity;
import org.semanticweb.owlapi.model.OWLLiteral;
Expand All @@ -20,7 +22,9 @@

public abstract class GridCellData {

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

Expand Down Expand Up @@ -57,9 +61,11 @@ public int compareTo(GridCellData otherCellData) {
return 0;
}

@JsonProperty(PropertyNames.COLUMN_ID)
@Nonnull
public abstract GridColumnId getColumnId();

@JsonProperty(PropertyNames.VALUES)
@Nonnull
public abstract Page<FormControlData> getValues();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package edu.stanford.protege.webprotege.forms.data;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.*;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import edu.stanford.protege.webprotege.common.Page;
import edu.stanford.protege.webprotege.forms.PropertyNames;
import edu.stanford.protege.webprotege.forms.field.FormRegionOrdering;
import edu.stanford.protege.webprotege.forms.field.GridControlDescriptor;

Expand All @@ -19,10 +20,11 @@
@JsonTypeName("GridControlData")
public abstract class GridControlData implements ComplexFormControlValue {

@JsonCreator
@Nonnull
public static GridControlData get(@Nonnull GridControlDescriptor descriptor,
@Nonnull Page<GridRowData> rows,
@Nonnull ImmutableSet<FormRegionOrdering> ordering) {
public static GridControlData get(@JsonProperty(PropertyNames.DESCRIPTOR) @Nonnull GridControlDescriptor descriptor,
@JsonProperty(PropertyNames.ROWS) @Nonnull Page<GridRowData> rows,
@JsonProperty(PropertyNames.ORDERING) @Nonnull ImmutableSet<FormRegionOrdering> ordering) {
return new AutoValue_GridControlData(descriptor, rows, ordering);
}

Expand All @@ -36,12 +38,15 @@ public void accept(@Nonnull FormControlDataVisitor visitor) {
visitor.visit(this);
}

@JsonProperty(PropertyNames.DESCRIPTOR)
@Nonnull
public abstract GridControlDescriptor getDescriptor();

@JsonProperty(PropertyNames.ROWS)
@Nonnull
public abstract Page<GridRowData> getRows();

@JsonProperty(PropertyNames.ORDERING)
@Nonnull
public abstract ImmutableSet<FormRegionOrdering> getOrdering();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package edu.stanford.protege.webprotege.forms.data;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import edu.stanford.protege.webprotege.forms.PropertyNames;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -16,19 +20,24 @@

public abstract class GridRowData implements Comparable<GridRowData> {

public static GridRowData get(@Nullable FormEntitySubject subject, @Nonnull ImmutableList<GridCellData> cellData) {
@JsonCreator
public static GridRowData get(@JsonProperty(PropertyNames.SUBJECT) @Nullable FormEntitySubject subject,
@JsonProperty(PropertyNames.CELLS) @Nonnull ImmutableList<GridCellData> cellData) {
return new AutoValue_GridRowData(subject, cellData);
}


@JsonProperty(PropertyNames.SUBJECT)
@Nullable
protected abstract FormEntitySubject getSubjectInternal();

@JsonIgnore
@Nonnull
public Optional<FormEntitySubject> getSubject() {
return Optional.ofNullable(getSubjectInternal());
}

@JsonProperty(PropertyNames.CELLS)
@Nonnull
public abstract ImmutableList<GridCellData> getCells();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.stanford.protege.webprotege.forms.data;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.auto.value.AutoValue;
Expand All @@ -18,6 +19,8 @@
@JsonTypeName("MultiChoiceControlData")
public abstract class MultiChoiceControlData implements FormControlData {


@JsonCreator
public static MultiChoiceControlData get(@JsonProperty("descriptor") @Nonnull MultiChoiceControlDescriptor descriptor,
@JsonProperty("values") @Nonnull ImmutableList<PrimitiveFormControlData> values) {
return new AutoValue_MultiChoiceControlData(descriptor, values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public abstract class NumberControlData implements FormControlData {

@JsonCreator
public static NumberControlData get(@Nonnull NumberControlDescriptor descriptor, @Nullable OWLLiteral value) {
public static NumberControlData get(@Nonnull @JsonProperty("descriptor") NumberControlDescriptor descriptor, @JsonProperty("value") @Nullable OWLLiteral value) {
return new AutoValue_NumberControlData(descriptor, value);
}

Expand All @@ -38,6 +38,7 @@ public void accept(@Nonnull FormControlDataVisitor visitor) {
}

@Nonnull
@JsonProperty("descriptor")
public abstract NumberControlDescriptor getDescriptor();

@JsonProperty("value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void accept(@Nonnull FormControlDataVisitor visitor) {
}

@Nonnull
@JsonProperty("descriptor")
public abstract SingleChoiceControlDescriptor getDescriptor();

@JsonProperty("choice")
Expand Down

0 comments on commit 0c29f14

Please sign in to comment.