Просмотр исходного кода

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

tags/2.0.1
Jonathan Cobb 4 лет назад
Родитель
Сommit
0f56ce9ff5
5 измененных файлов: 10 добавлений и 40 удалений
  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 Просмотреть файл

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

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 */
@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 */
@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
* "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
@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;
/** 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(); }
@@ -208,7 +203,6 @@ public class EntityConfig {

updateWithAnnotation(clazz, clazz.getAnnotation(ECType.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeList.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeSearch.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeCreate.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeUpdate.class));
updateWithAnnotation(clazz.getAnnotation(ECTypeDelete.class));
@@ -265,17 +259,6 @@ public class EntityConfig {
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! */
private EntityConfig updateWithAnnotation(ECTypeCreate annotation) {
if (annotation == null) return this;


+ 2
- 2
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeCreate.java Просмотреть файл

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

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
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 Просмотреть файл

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

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

+ 0
- 13
wizard-common/src/main/java/org/cobbzilla/wizard/model/entityconfig/annotations/ECTypeSearch.java Просмотреть файл

@@ -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 Просмотреть файл

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

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

Загрузка…
Отмена
Сохранить