Erweiterung: InternePerson kann ohne SalutationUUID und PersonTypeId angelegt werden
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java b/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java
index 3df3ca4..3adad52 100644
--- a/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java
+++ b/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java
@@ -21,6 +21,7 @@
import org.eclipse.openk.contactbasedata.mapper.InternalPersonMapper;
import org.eclipse.openk.contactbasedata.model.*;
import org.eclipse.openk.contactbasedata.repository.*;
+import org.eclipse.openk.contactbasedata.viewmodel.ExternalPersonDto;
import org.eclipse.openk.contactbasedata.viewmodel.InternalPersonDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@@ -102,15 +103,24 @@
}
private void setFromInternalPersonDto( TblInternalPerson destTblInternalPerson, InternalPersonDto sourceDto ) {
- RefSalutation salutationUpdated = salutationRepository
- .findByUuid(sourceDto.getSalutationUuid())
- .orElseThrow(() -> new NotFoundException("salutation.uuid.not.existing"));
- RefPersonType personTypeUpdated = personTypeRepository
- .findByUuid(sourceDto.getPersonTypeUuid())
- .orElseThrow(() -> new NotFoundException("person.type.uuid.not.existing"));
- destTblInternalPerson.setSalutation(salutationUpdated);
- destTblInternalPerson.setRefPersonType(personTypeUpdated);
+ if( sourceDto.getSalutationUuid() != null ) {
+ destTblInternalPerson.setSalutation( salutationRepository
+ .findByUuid(sourceDto.getSalutationUuid())
+ .orElseThrow(() -> new NotFoundException("salutation.uuid.not.existing")));
+ }
+ else {
+ destTblInternalPerson.setSalutation(null);
+ }
+
+ if( sourceDto.getPersonTypeUuid() != null ) {
+ destTblInternalPerson.setRefPersonType( personTypeRepository
+ .findByUuid(sourceDto.getPersonTypeUuid())
+ .orElseThrow(() -> new NotFoundException("person.type.uuid.not.existing")));
+ }
+ else {
+ destTblInternalPerson.setRefPersonType(null);
+ }
destTblInternalPerson.getContact().setNote(sourceDto.getContactNote());
}