Skip to content

Commit

Permalink
dto mapper adjusts.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jul 22, 2024
1 parent 6004cdd commit 062658a
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@
package <%= entityAbsolutePackage %>.service.mapper
<%_
const uuidMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeUUID);
const byteMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeBytes);
const dtoRelationships = dtoReferences.filter(reference => reference.relationship && !reference.relationship.otherEntity.embedded).map(reference => reference.relationship);
let otherEntitiesFields = otherEntities
const getOriginalField = field => field.originalField || field;
const uuidMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeUUID);
const byteMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldTypeBytes);
const dtoRelationships = dtoReferences.filter(reference => reference.relationship && !reference.relationship.otherEntity.embedded).map(reference => reference.relationship);
let otherEntitiesFields = otherEntities
.filter(otherEntity => dtoRelationships.some(relationship => relationship.otherEntity === otherEntity))
.map(otherEntity =>
dtoRelationships
dtoRelationships
.filter(relationship => relationship.otherEntity == otherEntity)
.map(({relatedField, collection}) => ({otherEntity, relatedField, collection}))
)
.flat();
otherEntitiesFields.forEach(a => {
a.collection = a.collection || otherEntitiesFields.some(b => a.otherEntity === b.otherEntity && a.relatedField === b.relatedField && b.collection == true)
});
otherEntitiesFields = _.uniqWith(otherEntitiesFields, (a, b) => a.otherEntity === b.otherEntity && a.collection === b.collection && a.relatedField === b.relatedField);
otherEntitiesFields.forEach(a => {
a.collection = a.collection || otherEntitiesFields.some(b => a.otherEntity === b.otherEntity && getOriginalField(a.relatedField) === getOriginalField(b.relatedField) && b.collection === true)
});
otherEntitiesFields = this._.uniqWith(otherEntitiesFields, (a, b) => a.otherEntity === b.otherEntity && a.collection === b.collection && getOriginalField(a.relatedField) === getOriginalField(b.relatedField));
_%>
import <%= entityAbsoluteClass %>
Expand Down Expand Up @@ -121,7 +122,6 @@ interface <%= entityClass %>Mapper :
@Named("<%= mapperName %>")
@BeanMapping(ignoreByDefault = true)
<%_
for (const field of otherEntity.primaryKey.fields) {
Expand Down

0 comments on commit 062658a

Please sign in to comment.