Skip to content

Commit 6beb1a3

Browse files
authored
Merge pull request #59 from dont-code/prj-enh
fix: support ManyToOne references types
2 parents 88fb242 + d475aa5 commit 6beb1a3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

apps/xt-host/projects/host/src/app/application-model-manager/application-model-manager.service.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class ApplicationModelManagerService {
3737
} else
3838
this.model = value;
3939

40+
this.ensureCompatibility (this.model);
4041
if (this.model?.content?.creation?.entities!=null){
4142
this.entityNames.set (Object.values(this.model?.content?.creation?.entities).map((entity) => entity.name));
4243
}else {
@@ -78,6 +79,21 @@ export class ApplicationModelManagerService {
7879
return ret;
7980
}
8081

82+
protected ensureCompatibility (entity: DcApplicationModel) {
83+
// Reference types may be declared as OneToMany instead of "ONE-TO-MANY", due to some limitation (bug ?) in the json schema
84+
for (const entity of this.model?.content?.creation.entities??[]) {
85+
if (entity.fields!=null) {
86+
for (const field of entity.fields) {
87+
if ((field.reference?.referenceType as any)=="OneToMany") {
88+
field.reference!.referenceType="ONE-TO-MANY";
89+
} else if ((field.reference?.referenceType as any)=="ManyToOne") {
90+
field.reference!.referenceType="MANY-TO-ONE";
91+
}
92+
}
93+
}
94+
}
95+
}
96+
8197
protected translate(type: string): string {
8298
switch (type) {
8399
case 'Date & Time':

0 commit comments

Comments
 (0)