import common model description reference change
This commit is contained in:
parent
5ffc07979f
commit
90ed403376
|
@ -1612,18 +1612,30 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
if (model == null)
|
||||
return null;
|
||||
|
||||
if (this.conventionService.isNullOrEmpty(model.getLabel()) && this.conventionService.isNullOrEmpty(model.getReference())) throw new MyApplicationException("Reference without label and reference id ");
|
||||
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class);
|
||||
|
||||
if (!this.conventionService.isNullOrEmpty(model.getLabel())) query = query.like(model.getLabel());
|
||||
if (!this.conventionService.isNullOrEmpty(model.getReference())) query = query.references(model.getReference());
|
||||
|
||||
ReferenceEntity referenceEntity = query.first();
|
||||
|
||||
ReferencePersist persist = new ReferencePersist();
|
||||
|
||||
persist.setId(model.getId());
|
||||
persist.setLabel(model.getLabel());
|
||||
persist.setDescription(model.getDescription());
|
||||
persist.setReference(model.getReference());
|
||||
persist.setAbbreviation(model.getAbbreviation());
|
||||
persist.setSource(model.getSource());
|
||||
switch (model.getSourceType()){
|
||||
case Internal -> persist.setSourceType(ReferenceSourceType.Internal);
|
||||
case External -> persist.setSourceType(ReferenceSourceType.External);
|
||||
default -> throw new MyApplicationException("Unrecognized Type " + model.getSourceType().getValue());
|
||||
if (referenceEntity == null) {
|
||||
persist.setLabel(model.getLabel());
|
||||
persist.setReference(model.getReference());
|
||||
persist.setSource("internal");
|
||||
persist.setSourceType(ReferenceSourceType.Internal);
|
||||
} else {
|
||||
persist.setId(referenceEntity.getId());
|
||||
persist.setLabel(referenceEntity.getLabel());
|
||||
persist.setReference(referenceEntity.getReference());
|
||||
persist.setSource(referenceEntity.getSource());
|
||||
persist.setSourceType(referenceEntity.getSourceType());
|
||||
persist.setAbbreviation(referenceEntity.getAbbreviation());
|
||||
persist.setDescription(referenceEntity.getDescription());
|
||||
persist.setHash(this.conventionService.hashValue(referenceEntity.getUpdatedAt()));
|
||||
}
|
||||
|
||||
return persist;
|
||||
|
|
Loading…
Reference in New Issue