Skip to content

Commit eecb5a4

Browse files
author
Philip Z
committed
fix: close audited bootstrap example gates
1 parent 51b3d84 commit eecb5a4

22 files changed

Lines changed: 456 additions & 75 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
python3 -m unittest discover -v
2626
python3 tools/error_catalog.py validate errors/catalog.yml
2727
- name: SpotBugs Check
28-
run: mvn spotbugs:check
28+
# Generated examples are verified by the dedicated Example Gate. They
29+
# intentionally do not inherit the runtime's SpotBugs build plugin.
30+
run: mvn spotbugs:check -pl '!examples/conformance/lib,!examples/conformance'
2931
- name: OWASP Dependency Check
3032
run: mvn org.owasp:dependency-check-maven:check

‎examples/conformance/lib/src/main/java/com/teaql/runtimeexampleconformanceservice/EntityMetaRegistry.java‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ private void registerPlatform() {
2424
.with("module", "Example")
2525
.with("module_key", "example");
2626

27-
PropertyDescriptor id =
27+
PropertyDescriptor id =
2828
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.ID_PROPERTY, Long.class)
2929
;
30-
PropertyDescriptor name =
30+
PropertyDescriptor name =
3131
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.NAME_PROPERTY, String.class)
3232
;
33-
PropertyDescriptor version =
33+
PropertyDescriptor version =
3434
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.VERSION_PROPERTY, Long.class)
3535
;
36+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.ID_PROPERTY).with("required", "true");
3637
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.ID_PROPERTY).with("isPassword", "false")
3738
.with("isVersion", "false")
3839
.with("oracle_sqlType", "number(11)")
@@ -49,6 +50,7 @@ private void registerPlatform() {
4950
.with("isTime", "false")
5051
.with("isText", "false");
5152

53+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.NAME_PROPERTY).with("required", "true");
5254
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.NAME_PROPERTY).with("isPassword", "false")
5355
.with("max", "100")
5456
.with("isVersion", "false")
@@ -65,6 +67,7 @@ private void registerPlatform() {
6567
.with("isTime", "false")
6668
.with("isText", "false");
6769

70+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.VERSION_PROPERTY).with("required", "true");
6871
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.platform.Platform.VERSION_PROPERTY).with("isPassword", "false")
6972
.with("isVersion", "true")
7073
.with("oracle_sqlType", "number(11)")
@@ -92,21 +95,22 @@ private void registerWorkItem() {
9295
.with("module", "Example")
9396
.with("module_key", "example");
9497

95-
PropertyDescriptor id =
98+
PropertyDescriptor id =
9699
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.ID_PROPERTY, Long.class)
97100
;
98-
PropertyDescriptor title =
101+
PropertyDescriptor title =
99102
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.TITLE_PROPERTY, String.class)
100103
;
101-
PropertyDescriptor description =
104+
PropertyDescriptor description =
102105
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.DESCRIPTION_PROPERTY, String.class)
103106
;
104-
PropertyDescriptor platform =
107+
PropertyDescriptor platform =
105108
entityDescriptor.addObjectProperty($factory, com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.PLATFORM_PROPERTY, com.teaql.runtimeexampleconformanceservice.platform.Platform.INTERNAL_TYPE, com.teaql.runtimeexampleconformanceservice.platform.Platform.WORK_ITEM_LIST_PROPERTY, com.teaql.runtimeexampleconformanceservice.platform.Platform.class)
106109
;
107-
PropertyDescriptor version =
110+
PropertyDescriptor version =
108111
entityDescriptor.addSimpleProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.VERSION_PROPERTY, Long.class)
109112
;
113+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.ID_PROPERTY).with("required", "true");
110114
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.ID_PROPERTY).with("isPassword", "false")
111115
.with("isVersion", "false")
112116
.with("oracle_sqlType", "number(11)")
@@ -123,6 +127,7 @@ private void registerWorkItem() {
123127
.with("isTime", "false")
124128
.with("isText", "false");
125129

130+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.TITLE_PROPERTY).with("required", "true");
126131
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.TITLE_PROPERTY).with("isPassword", "false")
127132
.with("max", "80")
128133
.with("isVersion", "false")
@@ -155,7 +160,9 @@ private void registerWorkItem() {
155160
.with("isTime", "false")
156161
.with("isText", "false");
157162

163+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.PLATFORM_PROPERTY).with("required", "true");
158164

165+
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.VERSION_PROPERTY).with("required", "true");
159166
entityDescriptor.findProperty(com.teaql.runtimeexampleconformanceservice.workitem.WorkItem.VERSION_PROPERTY).with("isPassword", "false")
160167
.with("isVersion", "true")
161168
.with("oracle_sqlType", "number(11)")
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package com.teaql.runtimeexampleconformanceservice;
22

3-
import com.teaql.runtimeexampleconformanceservice.platform.PlatformChecker;
4-
import com.teaql.runtimeexampleconformanceservice.workitem.WorkItemChecker;
5-
import io.teaql.core.RuntimeModule;
6-
7-
/** Passive generated manifest. Schema changes require an explicit ensureSchema call. */
3+
/** Passive generated manifest. Database changes require context.ensureSchema(). */
84
public final class GeneratedRuntimeModule {
9-
private static final RuntimeModule MODULE =
10-
RuntimeModule.of(new EntityMetaRegistry())
11-
.withCheckers(new PlatformChecker(), new WorkItemChecker());
5+
private static final io.teaql.core.RuntimeModule MODULE = io.teaql.core.RuntimeModule.of(new EntityMetaRegistry())
6+
.withCheckers(new com.teaql.runtimeexampleconformanceservice.platform.PlatformChecker(), new com.teaql.runtimeexampleconformanceservice.workitem.WorkItemChecker())
7+
.withBootstrap(GeneratedRuntimeModule::ensureGeneratedBootstrap);
128

13-
private GeneratedRuntimeModule() {
14-
}
9+
private GeneratedRuntimeModule() {}
10+
public static io.teaql.core.RuntimeModule module() { return MODULE; }
1511

16-
public static RuntimeModule module() {
17-
return MODULE;
18-
}
19-
}
12+
private static void ensureGeneratedBootstrap(io.teaql.core.UserContext context) {
13+
var domainRoots = Q.platforms().withIdIs(1L).comment("what: locate generated Domain Root").purpose("why: idempotent runtime bootstrap").executeForList(context);
14+
com.teaql.runtimeexampleconformanceservice.platform.Platform domainRoot;
15+
if (domainRoots.isEmpty()) {
16+
domainRoot = new com.teaql.runtimeexampleconformanceservice.platform.Platform();
17+
io.teaql.core.GeneratedSchemaBootstrap.initializeFixedId(context, domainRoot, 1L);
18+
domainRoot.updateName("Runtime Example");
19+
domainRoot.auditAs("create generated Domain Root Platform").save(context);
20+
} else { domainRoot = domainRoots.get(0); }
21+
context.withActiveRoot(new io.teaql.core.ContextEntityRef("Platform", domainRoot.getId()));
22+
}
23+
}

‎examples/conformance/lib/src/main/java/com/teaql/runtimeexampleconformanceservice/platform/Platform.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Platform addWorkItem(WorkItem workItem){
5151
}
5252

5353
this.workItemList.add(workItem);
54-
workItem.cacheRelation(WorkItem.PLATFORM_PROPERTY, this);
54+
workItem.updatePlatform(this);
5555
return this;
5656
}
5757

‎examples/conformance/lib/src/main/java/com/teaql/runtimeexampleconformanceservice/platform/PlatformChecker.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ public void doCheck(UserContext _context, Platform platform, ObjectLocation _par
2626
}
2727
if(platform.newItem()){
2828
}else if(platform.updateItem()){
29+
if(!platform.isPropertyLoaded("name")){
30+
invalidTypeCheck(_context, newLocation(_parentLocation, "name"), "Mutation requires a fully loaded entity");
31+
}
2932
}
30-
checkName(_context, platform.getProperty(Platform.NAME_PROPERTY), newLocation(_parentLocation, Platform.NAME_PROPERTY));
33+
checkName(_context, platform.getProperty(Platform.NAME_PROPERTY), newLocation(_parentLocation, "name"));
3134
for(int i = 0; platform.getWorkItemList() != null && i < platform.getWorkItemList().size(); i++){
3235
WorkItem workItem = platform.getWorkItemList().get(i);
33-
new WorkItemChecker().checkAndFix(_context, workItem, newLocation(_parentLocation, Platform.WORK_ITEM_LIST_PROPERTY, i));
36+
new WorkItemChecker().checkAndFix(_context, workItem, newLocation(_parentLocation, "work_item_list", i));
3437
}
3538
}
3639

‎examples/conformance/lib/src/main/java/com/teaql/runtimeexampleconformanceservice/platform/PlatformRequest.java‎

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ public PlatformRequest<T> optimizeForContinuousPageFetch(String namespace, int t
6868
return this;
6969
}
7070

71+
public PlatformRequest<T> optimizePaginationWithIdSet(){
72+
super.optimizePaginationWithIdSet();
73+
return this;
74+
}
75+
76+
public PlatformRequest<T> optimizePaginationWithIdSet(
77+
String namespace, int ttlSeconds, int maxIds){
78+
super.optimizePaginationWithIdSet(namespace, ttlSeconds, maxIds);
79+
return this;
80+
}
81+
82+
public PlatformRequest<T> topNProbeParentThreshold(int threshold){
83+
super.topNProbeParentThreshold(threshold);
84+
return this;
85+
}
86+
7187
public PlatformRequest<T> appendSearchCriteria(SearchCriteria searchCriteria){
7288
return (PlatformRequest<T>)super.appendSearchCriteria(searchCriteria);
7389
}
@@ -185,11 +201,19 @@ public SearchCriteria createIdCriteria(Operator operator, Object... values) {
185201
return createBasicSearchCriteria(Platform.ID_PROPERTY, operator, values);
186202
}
187203

188-
public PlatformRequest<T> withIdIs(Long id){
189-
return withId(Operator.EQUAL, id);
204+
public PlatformRequest<T> withIdIsNot(Long id){
205+
return withId(Operator.NOT_EQUAL, id);
190206
}
207+
191208
public PlatformRequest<T> withIdIn(Long... id){
192-
return withId(Operator.EQUAL, (Object[])id);
209+
return withId(Operator.IN, (Object[])id);
210+
}
211+
212+
public PlatformRequest<T> withIdNotIn(Long... id){
213+
return withId(Operator.NOT_IN, (Object[])id);
214+
}
215+
public PlatformRequest<T> withIdIs(Long id){
216+
return withId(Operator.EQUAL, id);
193217
}
194218

195219

@@ -217,6 +241,17 @@ public SearchCriteria createNameCriteria(Operator operator, Object... values) {
217241
return createBasicSearchCriteria(Platform.NAME_PROPERTY, operator, values);
218242
}
219243

244+
public PlatformRequest<T> withNameIsNot(String name){
245+
return withName(Operator.NOT_EQUAL, name);
246+
}
247+
248+
public PlatformRequest<T> withNameIn(String... name){
249+
return withName(Operator.IN, (Object[])name);
250+
}
251+
252+
public PlatformRequest<T> withNameNotIn(String... name){
253+
return withName(Operator.NOT_IN, (Object[])name);
254+
}
220255
public PlatformRequest<T> withNameGreaterThan(String name){
221256
return withName(Operator.GREATER_THAN, name);
222257
}
@@ -243,10 +278,22 @@ public PlatformRequest<T> withNameContaining(String name){
243278
return withName(Operator.CONTAIN, name);
244279
}
245280

281+
public PlatformRequest<T> withNameNotContaining(String name){
282+
return withName(Operator.NOT_CONTAIN, name);
283+
}
284+
285+
public PlatformRequest<T> withNameNotStartingWith(String name){
286+
return withName(Operator.NOT_BEGIN_WITH, name);
287+
}
288+
246289
public PlatformRequest<T> withNameEndingWith(String name){
247290
return withName(Operator.END_WITH, name);
248291
}
249292

293+
public PlatformRequest<T> withNameNotEndingWith(String name){
294+
return withName(Operator.NOT_END_WITH, name);
295+
}
296+
250297
public PlatformRequest<T> withNameIs(String name){
251298
return withName(Operator.EQUAL, name);
252299
}
@@ -280,6 +327,21 @@ public SearchCriteria createVersionCriteria(Operator operator, Object... values)
280327
return createBasicSearchCriteria(Platform.VERSION_PROPERTY, operator, values);
281328
}
282329

330+
public PlatformRequest<T> withVersionIs(Long version){
331+
return withVersion(Operator.EQUAL, version);
332+
}
333+
334+
public PlatformRequest<T> withVersionIsNot(Long version){
335+
return withVersion(Operator.NOT_EQUAL, version);
336+
}
337+
338+
public PlatformRequest<T> withVersionIn(Long... version){
339+
return withVersion(Operator.IN, (Object[])version);
340+
}
341+
342+
public PlatformRequest<T> withVersionNotIn(Long... version){
343+
return withVersion(Operator.NOT_IN, (Object[])version);
344+
}
283345
public PlatformRequest<T> withVersionGreaterThan(Long version){
284346
return withVersion(Operator.GREATER_THAN, version);
285347
}

‎examples/conformance/lib/src/main/java/com/teaql/runtimeexampleconformanceservice/workitem/WorkItemChecker.java‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ public void doCheck(UserContext _context, WorkItem workItem, ObjectLocation _par
2626
}
2727
if(workItem.newItem()){
2828
}else if(workItem.updateItem()){
29+
if(!workItem.isPropertyLoaded("title")){
30+
invalidTypeCheck(_context, newLocation(_parentLocation, "title"), "Mutation requires a fully loaded entity");
31+
}if(!workItem.isPropertyLoaded("description")){
32+
invalidTypeCheck(_context, newLocation(_parentLocation, "description"), "Mutation requires a fully loaded entity");
33+
}if(!workItem.isPropertyLoaded("platform")){
34+
invalidTypeCheck(_context, newLocation(_parentLocation, "platform"), "Mutation requires a fully loaded entity");
35+
}
2936
}
30-
checkTitle(_context, workItem.getProperty(WorkItem.TITLE_PROPERTY), newLocation(_parentLocation, WorkItem.TITLE_PROPERTY));
31-
checkDescription(_context, workItem.getProperty(WorkItem.DESCRIPTION_PROPERTY), newLocation(_parentLocation, WorkItem.DESCRIPTION_PROPERTY));
32-
checkPlatform(_context, workItem.getProperty(WorkItem.PLATFORM_PROPERTY), newLocation(_parentLocation, WorkItem.PLATFORM_PROPERTY));
37+
checkTitle(_context, workItem.getProperty(WorkItem.TITLE_PROPERTY), newLocation(_parentLocation, "title"));
38+
checkDescription(_context, workItem.getProperty(WorkItem.DESCRIPTION_PROPERTY), newLocation(_parentLocation, "description"));
39+
checkPlatform(_context, workItem.getProperty(WorkItem.PLATFORM_PROPERTY), newLocation(_parentLocation, "platform"));
3340
}
3441

3542
public void checkTitle(UserContext _context, String title, ObjectLocation _parentLocation){

0 commit comments

Comments
 (0)