|
@@ -24,21 +24,23 @@ class HydraNormalizer {
|
|
|
const iriEncodedFields =
|
|
const iriEncodedFields =
|
|
|
Object.getPrototypeOf(entity).constructor.getIriEncodedFields()
|
|
Object.getPrototypeOf(entity).constructor.getIriEncodedFields()
|
|
|
|
|
|
|
|
|
|
+ const data = _.cloneDeep(entity)
|
|
|
|
|
+
|
|
|
for (const field in iriEncodedFields) {
|
|
for (const field in iriEncodedFields) {
|
|
|
- const value = entity[field]
|
|
|
|
|
|
|
+ const value = data[field]
|
|
|
const targetEntity = iriEncodedFields[field].entity
|
|
const targetEntity = iriEncodedFields[field].entity
|
|
|
|
|
|
|
|
if (_.isArray(value)) {
|
|
if (_.isArray(value)) {
|
|
|
- entity[field] = value.map((id: number) => {
|
|
|
|
|
|
|
+ data[field] = value.map((id: number) => {
|
|
|
return UrlUtils.makeIRI(targetEntity, id)
|
|
return UrlUtils.makeIRI(targetEntity, id)
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- entity[field] =
|
|
|
|
|
|
|
+ data[field] =
|
|
|
value !== null ? UrlUtils.makeIRI(targetEntity, value) : null
|
|
value !== null ? UrlUtils.makeIRI(targetEntity, value) : null
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return entity.$toJson()
|
|
|
|
|
|
|
+ return data.$toJson()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|