File tree Expand file tree Collapse file tree
apps/xt-host/projects/host/src/app/application-model-manager Expand file tree Collapse file tree Original file line number Diff line number Diff 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' :
You can’t perform that action at this time.
0 commit comments