forked from Onlineberatung/onlineBeratung-agencyService
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from Onlineberatung/develop
[pull] develop from Onlineberatung:develop
- Loading branch information
Showing
10 changed files
with
288 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...n/java/de/caritas/cob/agencyservice/api/admin/service/agency/DataProtectionConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.caritas.cob.agencyservice.api.admin.service.agency; | ||
|
||
import de.caritas.cob.agencyservice.api.model.DataProtectionDTO; | ||
import de.caritas.cob.agencyservice.api.repository.agency.Agency.AgencyBuilder; | ||
import de.caritas.cob.agencyservice.api.repository.agency.DataProtectionResponsibleEntity; | ||
import de.caritas.cob.agencyservice.api.util.JsonConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class DataProtectionConverter { | ||
|
||
public void convertToEntity(DataProtectionDTO dataProtectionDTO, AgencyBuilder agencyBuilder) { | ||
if (dataProtectionDTO != null) { | ||
agencyBuilder.dataProtectionResponsibleEntity(convertEnums(dataProtectionDTO)); | ||
agencyBuilder.dataProtectionOfficerContactData( | ||
JsonConverter.convertToJson(dataProtectionDTO.getDataProtectionOfficerContact())); | ||
agencyBuilder.dataProtectionAgencyResponsibleContactData(JsonConverter.convertToJson( | ||
dataProtectionDTO.getAgencyDataProtectionResponsibleContact())); | ||
agencyBuilder.dataProtectionAlternativeContactData(JsonConverter.convertToJson( | ||
dataProtectionDTO.getAlternativeDataProtectionRepresentativeContact())); | ||
} else { | ||
nullifyDataProtectionAttributes(agencyBuilder); | ||
} | ||
} | ||
|
||
private static void nullifyDataProtectionAttributes(AgencyBuilder agencyBuilder) { | ||
agencyBuilder.dataProtectionResponsibleEntity(null); | ||
agencyBuilder.dataProtectionOfficerContactData(null); | ||
agencyBuilder.dataProtectionAgencyResponsibleContactData(null); | ||
agencyBuilder.dataProtectionAlternativeContactData(null); | ||
} | ||
|
||
private static DataProtectionResponsibleEntity convertEnums( | ||
DataProtectionDTO dataProtectionDTO) { | ||
var dataProtectionEntity = dataProtectionDTO.getDataProtectionResponsibleEntity(); | ||
if (dataProtectionEntity == null) { | ||
return null; | ||
} | ||
switch (dataProtectionEntity) { | ||
case AGENCY_RESPONSIBLE: | ||
return DataProtectionResponsibleEntity.AGENCY_RESPONSIBLE; | ||
case DATA_PROTECTION_OFFICER: | ||
return DataProtectionResponsibleEntity.DATA_PROTECTION_OFFICER; | ||
case ALTERNATIVE_REPRESENTATIVE: | ||
return DataProtectionResponsibleEntity.ALTERNATIVE_REPRESENTATIVE; | ||
default: | ||
throw new IllegalArgumentException( | ||
"DataProtectionResponsibleEntity not supported: " + dataProtectionEntity); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.