Selaa lähdekoodia

remove ECTypeSearch, add defaults to ECTypeCreate/Update/Delete methods

tags/2.0.1
Jonathan Cobb 4 vuotta sitten
vanhempi
commit
0f56ce9ff5
5 muutettua tiedostoa jossa 10 lisäystä ja 40 poistoa
  1. +6
    -23
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityConfig.java
  2. +2
    -2
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeCreate.java
  3. +1
    -1
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeDelete.java
  4. +0
    -13
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeSearch.java
  5. +1
    -1
      wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeUpdate.java

+ 6
- 23
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/EntityConfig.java Näytä tiedosto

@@ -124,21 +124,16 @@ public class EntityConfig {


private String uriPrefix = ""; private String uriPrefix = "";


/** The HTTP method to use when creating a new entity. Default value: `PUT` */
@Getter @Setter private String createMethod = "PUT";
/** The HTTP method to use when creating a new entity. Default value: null (disabled) */
@Getter @Setter private String createMethod;
/** The API endpoint to use when creating a new entity. Default value: none */ /** The API endpoint to use when creating a new entity. Default value: none */
@Getter @Setter private String createUri; @Getter @Setter private String createUri;


/** The HTTP method to use when updating an entity. Default value: `POST` */
@Getter @Setter private String updateMethod = "POST";
/** The HTTP method to use when updating an entity. Default value: null (disabled) */
@Getter @Setter private String updateMethod;
/** The API endpoint to use when updating an entity. Default value: none */ /** The API endpoint to use when updating an entity. Default value: none */
@Getter @Setter private String updateUri; @Getter @Setter private String updateUri;


/** The HTTP method to use when searching entities. Default value: `POST` */
@Getter @Setter private String searchMethod = "POST";
/** The API endpoint to use when searching entities. Default value: none */
@Getter @Setter private String searchUri;

/** /**
* After using the `searchUri` to obtain some entities, the `searchFields` tells which fields should be * After using the `searchUri` to obtain some entities, the `searchFields` tells which fields should be
* "columns" in the resulting data table. Fields not listed in `searchFields` will not be shown. * "columns" in the resulting data table. Fields not listed in `searchFields` will not be shown.
@@ -151,8 +146,8 @@ public class EntityConfig {
// AbstractEntityConfigsResource populates this, if the entity supports SQL queries // AbstractEntityConfigsResource populates this, if the entity supports SQL queries
@Getter @Setter private SqlViewField[] sqlViewFields; @Getter @Setter private SqlViewField[] sqlViewFields;


/** The HTTP method to use when deleting an entity. Default value: `DELETE` */
@Getter @Setter private String deleteMethod = "DELETE";
/** The HTTP method to use when deleting an entity. Default value: null (disabled) */
@Getter @Setter private String deleteMethod;
@Setter private String deleteUri; @Setter private String deleteUri;
/** The API endpoint to use when deleting an entity. Default value: Default value: the value of `updateUri` */ /** The API endpoint to use when deleting an entity. Default value: Default value: the value of `updateUri` */
public String getDeleteUri() { return !empty(deleteUri) ? deleteUri : getUpdateUri(); } public String getDeleteUri() { return !empty(deleteUri) ? deleteUri : getUpdateUri(); }
@@ -208,7 +203,6 @@ public class EntityConfig {


updateWithAnnotation(clazz, clazz.getAnnotation(ECType.class)); updateWithAnnotation(clazz, clazz.getAnnotation(ECType.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeList.class)); updateWithAnnotation(clazz.getAnnotation(ECTypeList.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeSearch.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeCreate.class)); updateWithAnnotation(clazz.getAnnotation(ECTypeCreate.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeUpdate.class)); updateWithAnnotation(clazz.getAnnotation(ECTypeUpdate.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeDelete.class)); updateWithAnnotation(clazz.getAnnotation(ECTypeDelete.class));
@@ -265,17 +259,6 @@ public class EntityConfig {
return this; return this;
} }


/** Update properties with values from the given annotation. Doesn't override existing non-empty values! */
private EntityConfig updateWithAnnotation(ECTypeSearch annotation) {
if (annotation == null) return this;

if (empty(searchFields)) setSearchFields(Arrays.asList(annotation.fields()));
if (empty(searchMethod)) setSearchMethod(annotation.method());
if (empty(searchUri)) setSearchUri((annotation.uri().startsWith(":") ? "" : uriPrefix) + annotation.uri());

return this;
}

/** Update properties with values from the given annotation. Doesn't override existing non-empty values! */ /** Update properties with values from the given annotation. Doesn't override existing non-empty values! */
private EntityConfig updateWithAnnotation(ECTypeCreate annotation) { private EntityConfig updateWithAnnotation(ECTypeCreate annotation) {
if (annotation == null) return this; if (annotation == null) return this;


+ 2
- 2
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeCreate.java Näytä tiedosto

@@ -7,6 +7,6 @@ import java.lang.annotation.Target;


@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
public @interface ECTypeCreate { public @interface ECTypeCreate {
String method() default "";
String uri();
String method() default "PUT";
String uri() default "";
} }

+ 1
- 1
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeDelete.java Näytä tiedosto

@@ -7,6 +7,6 @@ import java.lang.annotation.Target;


@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
public @interface ECTypeDelete { public @interface ECTypeDelete {
String method() default "";
String method() default "DELETE";
String uri(); String uri();
} }

+ 0
- 13
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeSearch.java Näytä tiedosto

@@ -1,13 +0,0 @@
package org.cobbzilla.wizard.model.entityconfig.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
public @interface ECTypeSearch {
String[] fields() default {};
String method() default "";
String uri();
}

+ 1
- 1
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeUpdate.java Näytä tiedosto

@@ -7,6 +7,6 @@ import java.lang.annotation.Target;


@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
public @interface ECTypeUpdate { public @interface ECTypeUpdate {
String method() default "";
String method() default "POST";
String uri(); String uri();
} }

Ladataan…
Peruuta
Tallenna