Skip to content

Commit

Permalink
Initial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Jun 19, 2024
1 parent e09f8ec commit 8d79298
Show file tree
Hide file tree
Showing 91 changed files with 1,072 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,32 @@
@AutoValue
public abstract class EntityFormDescriptor {


public static final String PROJECT_ID = "projectId";

public static final String FORM_ID = "formId";

public static final String FORM_DESCRIPTOR = "formDescriptor";

public static final String SELECTOR_CRITERIA = "formSelectorCriteria";

public static final String PURPOSE = "purpose";


@JsonCreator
public static EntityFormDescriptor valueOf(@JsonProperty(PROJECT_ID) @Nonnull ProjectId projectId,
@JsonProperty(FORM_ID) @Nonnull FormId formId,
@JsonProperty(FORM_DESCRIPTOR) @Nonnull FormDescriptor newDescriptor,
@JsonProperty(PURPOSE) @Nonnull FormPurpose purpose,
@JsonProperty(SELECTOR_CRITERIA) @Nonnull RootCriteria newSelectorCriteria) {
public static EntityFormDescriptor valueOf(@JsonProperty(PropertyNames.PROJECT_ID) @Nonnull ProjectId projectId,
@JsonProperty(PropertyNames.FORM_ID) @Nonnull FormId formId,
@JsonProperty(PropertyNames.FORM) @Nonnull FormDescriptor newDescriptor,
@JsonProperty(PropertyNames.PURPOSE) @Nonnull FormPurpose purpose,
@JsonProperty(PropertyNames.CRITERIA) @Nonnull RootCriteria newSelectorCriteria) {
return new AutoValue_EntityFormDescriptor(projectId, formId, newDescriptor, purpose, newSelectorCriteria);
}

@Nonnull
@JsonProperty(PROJECT_ID)
@JsonProperty(PropertyNames.PROJECT_ID)
public abstract ProjectId getProjectId();

@Nonnull
@JsonProperty(FORM_ID)
@JsonProperty(PropertyNames.FORM_ID)
public abstract FormId getFormId();

@Nonnull
@JsonProperty(FORM_DESCRIPTOR)
@JsonProperty(PropertyNames.FORM)
public abstract FormDescriptor getDescriptor();

@Nonnull
@JsonProperty(PURPOSE)
@JsonProperty(PropertyNames.PURPOSE)
public abstract FormPurpose getPurpose();

@Nonnull
@JsonProperty(SELECTOR_CRITERIA)
@JsonProperty(PropertyNames.CRITERIA)
public abstract RootCriteria getSelectorCriteria();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import edu.stanford.protege.webprotege.common.ProjectId;
import edu.stanford.protege.webprotege.criteria.CompositeRootCriteria;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ private FormDescriptor() {
}

@JsonCreator
public FormDescriptor(@JsonProperty("id") FormId id,
@JsonProperty("label") LanguageMap label,
@JsonProperty("fields") List<FormFieldDescriptor> formFieldDescriptors,
@JsonProperty("subjectFactoryDescriptor") Optional<FormSubjectFactoryDescriptor> subjectFactoryDescriptor) {
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.elements = new ArrayList<>(formFieldDescriptors);
Expand All @@ -62,19 +62,23 @@ public FormDescriptor withFields(Predicate<FormFieldDescriptor> test) {
return new FormDescriptor(formId, label, filteredFields, getSubjectFactoryDescriptor());
}

@JsonProperty(PropertyNames.ID)
public FormId getFormId() {
return formId;
}

@JsonProperty(PropertyNames.LABEL)
public LanguageMap getLabel() {
return label;
}

@JsonProperty(PropertyNames.SUBJECT_FACTORY)
@Nonnull
public Optional<FormSubjectFactoryDescriptor> getSubjectFactoryDescriptor() {
return Optional.ofNullable(subjectFactoryDescriptor);
}

@JsonProperty(PropertyNames.FIELDS)
public List<FormFieldDescriptor> getFields() {
return elements;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.stanford.protege.webprotege.forms;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.*;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import edu.stanford.protege.webprotege.common.LanguageMap;
Expand All @@ -18,25 +17,30 @@
public abstract class FormDescriptorDto {

@JsonCreator
public static FormDescriptorDto get(@JsonProperty("formId") @Nonnull FormId formId,
@JsonProperty("label") @Nonnull LanguageMap label,
@JsonProperty("fields") @Nonnull ImmutableList<FormFieldDescriptorDto> fields,
@JsonProperty("formSubjectFactoryDescriptor") @Nullable FormSubjectFactoryDescriptor subjectFactoryDescriptor) {
public static FormDescriptorDto get(@JsonProperty(PropertyNames.ID) @Nonnull FormId formId,
@JsonProperty(PropertyNames.LABEL) @Nonnull LanguageMap label,
@JsonProperty(PropertyNames.FIELDS) @Nonnull ImmutableList<FormFieldDescriptorDto> fields,
@JsonProperty(PropertyNames.SUBJECT_FACTORY) @Nullable FormSubjectFactoryDescriptor subjectFactoryDescriptor) {
return new AutoValue_FormDescriptorDto(formId, label, fields, subjectFactoryDescriptor);
}

@JsonProperty(PropertyNames.ID)
@Nonnull
public abstract FormId getFormId();

@Nonnull
@JsonProperty(PropertyNames.LABEL)
public abstract LanguageMap getLabel();

@Nonnull
@JsonProperty(PropertyNames.FIELDS)
public abstract ImmutableList<FormFieldDescriptorDto> getFields();

@Nullable
@JsonProperty(PropertyNames.SUBJECT_FACTORY)
protected abstract FormSubjectFactoryDescriptor getFormSubjectFactoryDescriptorInternal();

@JsonIgnore
public Optional<FormSubjectFactoryDescriptor> getFormSubjectFactoryDescriptor() {
return Optional.ofNullable(getFormSubjectFactoryDescriptorInternal());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,26 @@
@AutoValue
public abstract class FormDescriptorRecord implements Comparable<FormDescriptorRecord> {

public static final String PROJECT_ID = "projectId";

public static final String FORM_DESCRIPTOR = "formDescriptor";

public static final String ORDINAL = "ordinal";

private static final Comparator<FormDescriptorRecord> comparingByOrdinal = Comparator.comparing(FormDescriptorRecord::getOrdinal);

@JsonCreator
public static FormDescriptorRecord get(@JsonProperty(PROJECT_ID) @Nonnull ProjectId projectId,
@JsonProperty(FORM_DESCRIPTOR) FormDescriptor formDescriptor,
@JsonProperty(ORDINAL) Integer ordinal) {
public static FormDescriptorRecord get(@JsonProperty(PropertyNames.PROJECT_ID) @Nonnull ProjectId projectId,
@JsonProperty(PropertyNames.FORM) FormDescriptor formDescriptor,
@JsonProperty(PropertyNames.ORDINAL) Integer ordinal) {
return new AutoValue_FormDescriptorRecord(projectId,
formDescriptor == null ? FormDescriptor.empty(FormId.generate()) : formDescriptor,
ordinal == null ? 0 : ordinal);
}

@JsonProperty(PROJECT_ID)
@JsonProperty(PropertyNames.PROJECT_ID)
@Nonnull
public abstract ProjectId getProjectId();

@JsonProperty(FORM_DESCRIPTOR)
@JsonProperty(PropertyNames.FORM)
@Nonnull
public abstract FormDescriptor getFormDescriptor();

@JsonProperty(ORDINAL)
@JsonProperty(PropertyNames.ORDINAL)
@Nonnull
public abstract Integer getOrdinal();

Expand Down
18 changes: 6 additions & 12 deletions src/main/java/edu/stanford/protege/webprotege/forms/FormGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,23 @@

public abstract class FormGroup {

public static final String ID = "id";

public static final String DESCRIPTION = "description";

public static final String FORM_IDS = "formIds";

@JsonCreator
@Nonnull
public static FormGroup get(@Nonnull @JsonProperty(ID) FormGroupId formGroupId,
@Nonnull @JsonProperty(DESCRIPTION) String description,
@Nonnull @JsonProperty(FORM_IDS) ImmutableList<FormId> formIds) {
public static FormGroup get(@Nonnull @JsonProperty(PropertyNames.ID) FormGroupId formGroupId,
@Nonnull @JsonProperty(PropertyNames.DESCRIPTION) String description,
@Nonnull @JsonProperty(PropertyNames.FORMS) ImmutableList<FormId> formIds) {
return new AutoValue_FormGroup(formGroupId, description, formIds);
}

@JsonProperty(ID)
@JsonProperty(PropertyNames.ID)
@Nonnull
public abstract FormGroupId getId();

@JsonProperty(DESCRIPTION)
@JsonProperty(PropertyNames.DESCRIPTION)
@Nonnull
public abstract String getDescription();

@JsonProperty(FORM_IDS)
@JsonProperty(PropertyNames.FORMS)
@Nonnull
public abstract ImmutableList<FormId> getFormIds();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
* 2020-04-22
*/
@JsonTypeName("FormPageRequest")
public record FormPageRequest(FormId formId,
FormSubject subject,
FormRegionId regionId,
SourceType sourceType,
PageRequest pageRequest) {
public record FormPageRequest(@JsonProperty(PropertyNames.FORM_ID) FormId formId,
@JsonProperty(PropertyNames.SUBJECT) FormSubject subject,
@JsonProperty(PropertyNames.REGION_ID) FormRegionId regionId,
@JsonProperty(PropertyNames.SOURCE_TYPE) SourceType sourceType,
@JsonProperty(PropertyNames.PAGE_REQUEST) PageRequest pageRequest) {

public static final int DEFAULT_PAGE_SIZE = 10;

@JsonCreator
@Nonnull
public static FormPageRequest get(@JsonProperty("formId") @Nonnull FormId formId,
@JsonProperty("subject") @Nonnull FormSubject subject,
@JsonProperty("regionId") @Nonnull FormRegionId formFieldId,
@JsonProperty("sourceType") @Nonnull SourceType sourceType,
@JsonProperty("pageRequest") @Nonnull PageRequest pageRequest) {
public static FormPageRequest get(@JsonProperty(PropertyNames.FORM_ID) @Nonnull FormId formId,
@JsonProperty(PropertyNames.SUBJECT) @Nonnull FormSubject subject,
@JsonProperty(PropertyNames.REGION_ID) @Nonnull FormRegionId formFieldId,
@JsonProperty(PropertyNames.SOURCE_TYPE) @Nonnull SourceType sourceType,
@JsonProperty(PropertyNames.PAGE_REQUEST) @Nonnull PageRequest pageRequest) {
return new FormPageRequest(formId, subject, formFieldId, sourceType, pageRequest);
}

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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import edu.stanford.protege.webprotege.common.PageRequest;
import edu.stanford.protege.webprotege.forms.data.FormSubject;
Expand All @@ -16,22 +17,26 @@
public abstract class FormRegionPageRequest {

@Nonnull
public static FormRegionPageRequest get(@Nonnull FormSubject subject,
@Nonnull FormRegionId formRegionId,
@Nonnull FormPageRequest.SourceType sourceType,
@Nonnull PageRequest pageRequest) {
public static FormRegionPageRequest get(@JsonProperty(PropertyNames.SUBJECT) @Nonnull FormSubject subject,
@JsonProperty(PropertyNames.REGION_ID) @Nonnull FormRegionId formRegionId,
@JsonProperty(PropertyNames.SOURCE_TYPE) @Nonnull FormPageRequest.SourceType sourceType,
@JsonProperty(PropertyNames.PAGE_REQUEST) @Nonnull PageRequest pageRequest) {
return new AutoValue_FormRegionPageRequest(subject, formRegionId, sourceType, pageRequest);
}

@Nonnull
@JsonProperty(PropertyNames.SUBJECT)
public abstract FormSubject getSubject();

@Nonnull
@JsonProperty(PropertyNames.REGION_ID)
public abstract FormRegionId getFieldId();

@Nonnull
@JsonProperty(PropertyNames.SOURCE_TYPE)
public abstract FormPageRequest.SourceType getSourceType();

@Nonnull
@JsonProperty(PropertyNames.PAGE_REQUEST)
public abstract PageRequest getPageRequest();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
public abstract class FormSubjectFactoryDescriptor {

@JsonCreator
public static FormSubjectFactoryDescriptor get(@Nonnull @JsonProperty("entityType") EntityType entityType,
@Nullable @JsonProperty("parent") OWLClass parent,
@Nonnull @JsonProperty("targetOntologyIri") Optional<IRI> targetOntologyIri) {
public static FormSubjectFactoryDescriptor get(@Nonnull @JsonProperty(PropertyNames.ENTITY_TYPE) EntityType entityType,
@Nullable @JsonProperty(PropertyNames.PARENT) OWLClass parent,
@Nonnull @JsonProperty(PropertyNames.TARGET_ONTOLOGY_IRI) Optional<IRI> targetOntologyIri) {
return new AutoValue_FormSubjectFactoryDescriptor(entityType, parent, targetOntologyIri.orElse(null));
}

Expand All @@ -33,6 +33,7 @@ public static String getDefaultGeneratedNamePattern() {
}

@Nonnull
@JsonProperty("entityType")
public abstract EntityType<?> getEntityType();

/**
Expand All @@ -45,14 +46,16 @@ public Optional<OWLClass> getParent() {
return Optional.ofNullable(getParentInternal());
}

@JsonProperty("parent")
@JsonProperty(PropertyNames.PARENT)
@Nullable
protected abstract OWLClass getParentInternal();

@Nullable
@JsonProperty(PropertyNames.TARGET_ONTOLOGY_IRI)
protected abstract IRI getTargetOntologyIriInternal();

@Nonnull
@JsonIgnore
public Optional<IRI> getTargetOntologyIri() {
return Optional.ofNullable(getTargetOntologyIriInternal());
}
Expand Down
Loading

0 comments on commit 8d79298

Please sign in to comment.