Skip to content

Commit 42dae0f

Browse files
authored
Merge branch 'master' into master
2 parents 8b88259 + 305571f commit 42dae0f

File tree

11 files changed

+275
-136
lines changed

11 files changed

+275
-136
lines changed

src/main/java/io/asfjava/ui/core/logging/ASFUILogger.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
public final class ASFUILogger {
77

8-
private final static Logger LOGGER=LoggerFactory.getLogger("ASFUILogger");
9-
public static Logger getLogger(){
8+
private final static Logger LOGGER = LoggerFactory.getLogger("ASFUILogger");
9+
10+
public static Logger getLogger() {
1011
return LOGGER;
1112
}
12-
13+
1314
private ASFUILogger() {
1415
}
1516

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package io.asfjava.ui.core.logging;
22

33
public final class ErrorCode {
4-
public final static String ASF01="Failure when trying to load Generators";
5-
public final static String ASF02="Failure when trying to load Decorators";
6-
private ErrorCode(){
7-
8-
}
4+
public final static String ASF01 = "Failure when trying to load Generators";
5+
public final static String ASF02 = "Failure when trying to load Decorators";
6+
7+
private ErrorCode() {
8+
9+
}
910
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.asfjava.ui.core.schema;
2+
3+
import com.fasterxml.jackson.databind.BeanProperty;
4+
import com.fasterxml.jackson.module.jsonSchema.types.IntegerSchema;
5+
6+
class CustomIntegerSchema extends IntegerSchema {
7+
@Override
8+
public void enrichWithBeanProperty(BeanProperty beanProperty) {
9+
super.enrichWithBeanProperty(beanProperty);
10+
SchemaDecoratorUtil.get().decorate(beanProperty, this);
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
package io.asfjava.ui.core.schema;
22

33
import com.fasterxml.jackson.module.jsonSchema.factories.JsonSchemaFactory;
4+
import com.fasterxml.jackson.module.jsonSchema.types.IntegerSchema;
5+
import com.fasterxml.jackson.module.jsonSchema.types.NumberSchema;
46
import com.fasterxml.jackson.module.jsonSchema.types.StringSchema;
57

68
class CustomJsonSchemaFactory extends JsonSchemaFactory {
79
@Override
810
public StringSchema stringSchema() {
911
return new CustomStringSchema();
1012
}
13+
14+
@Override
15+
public NumberSchema numberSchema() {
16+
return new CustomNumberSchema();
17+
}
18+
19+
@Override
20+
public IntegerSchema integerSchema() {
21+
return new CustomIntegerSchema();
22+
}
1123
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.asfjava.ui.core.schema;
2+
3+
import com.fasterxml.jackson.databind.BeanProperty;
4+
import com.fasterxml.jackson.module.jsonSchema.types.NumberSchema;
5+
6+
class CustomNumberSchema extends NumberSchema {
7+
@Override
8+
public void enrichWithBeanProperty(BeanProperty beanProperty) {
9+
super.enrichWithBeanProperty(beanProperty);
10+
SchemaDecoratorUtil.get().decorate(beanProperty, this);
11+
}
12+
}

src/main/java/io/asfjava/ui/core/schema/CustomSchemaFactoryWrapper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
class CustomSchemaFactoryWrapper extends SchemaFactoryWrapper {
99

1010
private static class SFSchemaFactoryWrapperFactory extends WrapperFactory {
11-
@Override
12-
public SchemaFactoryWrapper getWrapper(SerializerProvider p) {
13-
SchemaFactoryWrapper wrapper = new CustomSchemaFactoryWrapper();
14-
if (p != null) {
15-
wrapper.setProvider(p);
16-
}
17-
return wrapper;
18-
}
1911

2012
@Override
2113
public SchemaFactoryWrapper getWrapper(SerializerProvider p, VisitorContext rvc) {
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
package io.asfjava.ui.core.schema;
22

3-
import java.lang.annotation.Annotation;
4-
53
import com.fasterxml.jackson.databind.BeanProperty;
64
import com.fasterxml.jackson.module.jsonSchema.types.StringSchema;
75

8-
import io.asfjava.ui.core.SchemaDecoratorFactory;
9-
106
class CustomStringSchema extends StringSchema {
117

128
@Override
139
public void enrichWithBeanProperty(BeanProperty beanProperty) {
1410
super.enrichWithBeanProperty(beanProperty);
15-
Iterable<Annotation> it = beanProperty.getMember().annotations();
16-
it.forEach(
17-
annotation -> SchemaDecoratorFactory.getInstance().getDecorator(annotation.annotationType().getName())
18-
.ifPresent(decorator -> decorator.customizeSchema(beanProperty, this)));
11+
SchemaDecoratorUtil.get().decorate(beanProperty, this);
1912
}
2013

2114
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.asfjava.ui.core.schema;
2+
3+
import java.lang.annotation.Annotation;
4+
5+
import com.fasterxml.jackson.databind.BeanProperty;
6+
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
7+
8+
import io.asfjava.ui.core.SchemaDecoratorFactory;
9+
10+
final class SchemaDecoratorUtil {
11+
12+
void decorate(BeanProperty beanProperty, JsonSchema simpleTypeSchema) {
13+
Iterable<Annotation> it = beanProperty.getMember().annotations();
14+
it.forEach(
15+
annotation -> SchemaDecoratorFactory.getInstance().getDecorator(annotation.annotationType().getName())
16+
.ifPresent(decorator -> decorator.customizeSchema(beanProperty, simpleTypeSchema)));
17+
}
18+
19+
static SchemaDecoratorUtil get() {
20+
if (instance == null) {
21+
instance = new SchemaDecoratorUtil();
22+
}
23+
return instance;
24+
}
25+
26+
private static SchemaDecoratorUtil instance;
27+
28+
private SchemaDecoratorUtil() {
29+
}
30+
}

src/main/java/io/asfjava/ui/core/schema/decorators/NumberSchemaDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.fasterxml.jackson.databind.BeanProperty;
44
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
5-
import com.fasterxml.jackson.module.jsonSchema.types.StringSchema;
5+
import com.fasterxml.jackson.module.jsonSchema.types.SimpleTypeSchema;
66

77
import io.asfjava.ui.core.form.Number;
88

@@ -12,7 +12,7 @@ public class NumberSchemaDecorator implements SchemaDecorator {
1212
public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
1313
Number annotation = property.getAnnotation(Number.class);
1414
if (annotation != null && annotation.title() != null) {
15-
((StringSchema) jsonschema).setTitle(annotation.title());
15+
((SimpleTypeSchema) jsonschema).setTitle(annotation.title());
1616
}
1717
}
1818

src/main/java/io/asfjava/ui/dto/UiForm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class UiForm implements Serializable {
1111
private ArrayNode form;
1212

1313
public UiForm(JsonSchema schema, ArrayNode form) {
14-
this.schema = schema;
15-
this.form = form;
14+
setSchema(schema);
15+
setForm(form);
1616
}
1717

1818
public JsonSchema getSchema() {

0 commit comments

Comments
 (0)