| ... |
... |
@@ -22,16 +22,8 @@ package fr.ird.observe.dto.decoration; |
|
22
|
22
|
* #L%
|
|
23
|
23
|
*/
|
|
24
|
24
|
|
|
25
|
|
-import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
26
|
|
-import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
|
27
|
|
-import fr.ird.observe.dto.reference.DataDtoReference;
|
|
28
|
|
-import fr.ird.observe.dto.reference.DtoReference;
|
|
29
|
|
-import fr.ird.observe.dto.reference.ReferentialDtoReference;
|
|
30
|
25
|
import fr.ird.observe.dto.referential.ReferentialLocale;
|
|
31
|
|
-import org.nuiton.decorator.Decorator;
|
|
32
|
|
-import org.nuiton.decorator.DecoratorProvider;
|
|
33
|
|
-
|
|
34
|
|
-import java.util.Objects;
|
|
|
26
|
+import fr.ird.observe.spi.model.initializer.ObserveGlobalModelInitializer;
|
|
35
|
27
|
|
|
36
|
28
|
|
|
37
|
29
|
/**
|
| ... |
... |
@@ -40,60 +32,23 @@ import java.util.Objects; |
|
40
|
32
|
* @author Tony Chemit - dev@tchemit.fr
|
|
41
|
33
|
* @since 1.3
|
|
42
|
34
|
*/
|
|
43
|
|
-public class DecoratorService extends DecoratorProvider {
|
|
|
35
|
+public class DecoratorService extends DecoratorServiceSupport<DecoratorServiceInitializer> {
|
|
44
|
36
|
|
|
45
|
37
|
public static final String HAULING_IDENTIFIER = "haulingIdentifier";
|
|
46
|
38
|
public static final String TRIP_CONTEXT = "Trip";
|
|
47
|
39
|
public static final String WITH_URL = "WithUrl";
|
|
48
|
40
|
|
|
49
|
|
- private final DecoratorServiceInitializer initializer;
|
|
50
|
|
- private ReferentialLocale referentialLocale;
|
|
51
|
|
-
|
|
52
|
41
|
public DecoratorService(ReferentialLocale referentialLocale) {
|
|
53
|
|
- this.referentialLocale = Objects.requireNonNull(referentialLocale);
|
|
54
|
|
- this.initializer = new DecoratorServiceInitializer(this);
|
|
55
|
|
- loadDecorators();
|
|
56
|
|
- }
|
|
57
|
|
-
|
|
58
|
|
- public ReferentialLocale getReferentialLocale() {
|
|
59
|
|
- return referentialLocale;
|
|
60
|
|
- }
|
|
61
|
|
-
|
|
62
|
|
- public void setReferentialLocale(ReferentialLocale referentialLocale) {
|
|
63
|
|
- this.referentialLocale = referentialLocale;
|
|
|
42
|
+ super(referentialLocale);
|
|
64
|
43
|
}
|
|
65
|
44
|
|
|
66
|
45
|
@Override
|
|
67
|
|
- protected void loadDecorators() {
|
|
68
|
|
- if (referentialLocale == null) {
|
|
69
|
|
- // on n'enregistre pas les décorateur tant que la locale n'est pas
|
|
70
|
|
- // positionnée
|
|
71
|
|
- return;
|
|
72
|
|
- }
|
|
73
|
|
- DecoratorServiceInitializer.run(initializer);
|
|
74
|
|
- }
|
|
75
|
|
-
|
|
76
|
|
- public <T extends ReferentialDtoReference> ReferentialReferenceDecorator<T> getReferentialReferenceDecorator(Class<T> referenceType) {
|
|
77
|
|
- return (ReferentialReferenceDecorator) getDecoratorByType(referenceType);
|
|
|
46
|
+ protected DecoratorServiceInitializer createDecoratorServiceInitializer() {
|
|
|
47
|
+ return new DecoratorServiceInitializer(this);
|
|
78
|
48
|
}
|
|
79
|
49
|
|
|
80
|
|
- public <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> referenceType) {
|
|
81
|
|
- return (DataReferenceDecorator) getDecoratorByType(referenceType);
|
|
82
|
|
- }
|
|
83
|
|
-
|
|
84
|
|
- public <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> referenceType, String context) {
|
|
85
|
|
- return (DataReferenceDecorator) getDecoratorByType(referenceType, context);
|
|
86
|
|
- }
|
|
87
|
|
-
|
|
88
|
|
- public <R extends DtoReference> Decorator<R> getReferenceDecorator(Class<R> referenceType) {
|
|
89
|
|
- Decorator<R> decorator;
|
|
90
|
|
-
|
|
91
|
|
- if (DataDtoReference.class.isAssignableFrom(referenceType)) {
|
|
92
|
|
- decorator = getDataReferenceDecorator((Class) referenceType);
|
|
93
|
|
- } else {
|
|
94
|
|
- decorator = getReferentialReferenceDecorator((Class) referenceType);
|
|
95
|
|
- }
|
|
96
|
|
-
|
|
97
|
|
- return decorator;
|
|
|
50
|
+ @Override
|
|
|
51
|
+ protected void init(DecoratorServiceInitializer initializer) {
|
|
|
52
|
+ ObserveGlobalModelInitializer.run(initializer);
|
|
98
|
53
|
}
|
|
99
|
54
|
}
|