Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add has-video-calls setting to agency #152

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion api/agencyadminservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ components:
deleteDate:
type: string
example: "2020-09-02T15:53:23"
hasVideoCalls:
type: boolean
nullable: false

PostcodeRangeDTO:
type: object
Expand Down Expand Up @@ -619,7 +622,9 @@ components:
type: integer
format: int64
example: 12

hasVideoCalls:
type: boolean
default: true

AgencyAdminFullResponseDTO:
type: object
Expand Down Expand Up @@ -682,6 +687,9 @@ components:
type: long
demographics:
$ref: '#/components/schemas/DemographicsDTO'
hasVideoCalls:
type: boolean
default: true

DemographicsDTO:
type: object
Expand Down
3 changes: 3 additions & 0 deletions api/agencyservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ components:
type: integer
format: int64
example: 12
hasVideoCalls:
type: boolean
default: true

FullAgencyResponseDTO:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static de.caritas.cob.agencyservice.api.exception.httpresponses.HttpStatusExceptionReason.AGENCY_IS_ALREADY_DEFAULT_AGENCY;
import static de.caritas.cob.agencyservice.api.exception.httpresponses.HttpStatusExceptionReason.AGENCY_IS_ALREADY_TEAM_AGENCY;
import static de.caritas.cob.agencyservice.api.model.AgencyTypeRequestDTO.AgencyTypeEnum.TEAM_AGENCY;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import de.caritas.cob.agencyservice.api.admin.service.agency.AgencyAdminFullResponseDTOBuilder;
Expand Down Expand Up @@ -104,6 +105,7 @@ public AgencyAdminFullResponseDTO createAgency(AgencyDTO agencyDTO) {
* @return an {@link Agency} instance
*/
private Agency fromAgencyDTO(AgencyDTO agencyDTO) {
var hasVideoCalls = agencyDTO.getHasVideoCalls();

var agencyBuilder = Agency.builder()
.dioceseId(agencyDTO.getDioceseId())
Expand All @@ -116,6 +118,7 @@ private Agency fromAgencyDTO(AgencyDTO agencyDTO) {
.consultingTypeId(agencyDTO.getConsultingType())
.url(agencyDTO.getUrl())
.isExternal(agencyDTO.getExternal())
.hasVideoCalls(isNull(hasVideoCalls) ? new AgencyDTO().getHasVideoCalls() : hasVideoCalls)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wir haben die Variable hasVideoCalls wie NonNullable definiert! Das heißt es wird immer den True value zurückgeben!

.createDate(LocalDateTime.now(ZoneOffset.UTC))
.updateDate(LocalDateTime.now(ZoneOffset.UTC));

Expand Down Expand Up @@ -151,6 +154,7 @@ public AgencyAdminFullResponseDTO updateAgency(Long agencyId, UpdateAgencyDTO up
}

private Agency mergeAgencies(Agency agency, UpdateAgencyDTO updateAgencyDTO) {
var hasVideoCalls = updateAgencyDTO.getHasVideoCalls();

var agencyBuilder = Agency.builder()
.id(agency.getId())
Expand All @@ -163,6 +167,7 @@ private Agency mergeAgencies(Agency agency, UpdateAgencyDTO updateAgencyDTO) {
.teamAgency(agency.isTeamAgency())
.url(updateAgencyDTO.getUrl())
.isExternal(updateAgencyDTO.getExternal())
.hasVideoCalls(isNull(hasVideoCalls) ? new UpdateAgencyDTO().getHasVideoCalls() : hasVideoCalls)
.createDate(agency.getCreateDate())
.updateDate(LocalDateTime.now(ZoneOffset.UTC))
.deleteDate(agency.getDeleteDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private AgencyAdminResponseDTO createAgency() {
.teamAgency(this.agency.isTeamAgency())
.url(this.agency.getUrl())
.external((this.agency.isExternal()))
.hasVideoCalls(agency.getHasVideoCalls())
.offline(this.agency.isOffline())
.topics(getTopics())
.createDate(String.valueOf(this.agency.getCreateDate()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ private Integer getPostCodeInteger() {
@Field
private Long tenantId;

@Column(nullable = false, columnDefinition = "bit default true")
private Boolean hasVideoCalls;

@Transient
public boolean hasAnyDemographicsAttributes() {
return getAgeTo() != null || getAgeFrom() != null || getGenders() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<include file="db/changelog/changeset/0009_agency_topic/0009_changeSet.xml"/>
<include file="db/changelog/changeset/0010_agency_demographics/0010_changeSet.xml"/>
<include file="db/changelog/changeset/0011_agency_demographics_gender_column_change/0011_changeSet.xml"/>
<include file="db/changelog/changeset/0012_agency_video_calls/0012_changeSet.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<include file="db/changelog/changeset/0009_agency_topic/0009_changeSet.xml"/>
<include file="db/changelog/changeset/0010_agency_demographics/0010_changeSet.xml"/>
<include file="db/changelog/changeset/0011_agency_demographics_gender_column_change/0011_changeSet.xml"/>
<include file="db/changelog/changeset/0012_agency_video_calls/0012_changeSet.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<include file="db/changelog/changeset/0009_agency_topic/0009_changeSet.xml"/>
<include file="db/changelog/changeset/0010_agency_demographics/0010_changeSet.xml"/>
<include file="db/changelog/changeset/0011_agency_demographics_gender_column_change/0011_changeSet.xml"/>
<include file="db/changelog/changeset/0012_agency_video_calls/0012_changeSet.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<include file="db/changelog/changeset/0009_agency_topic/0009_changeSet.xml"/>
<include file="db/changelog/changeset/0010_agency_demographics/0010_changeSet.xml"/>
<include file="db/changelog/changeset/0011_agency_demographics_gender_column_change/0011_changeSet.xml"/>
<include file="db/changelog/changeset/0012_agency_video_calls/0012_changeSet.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="OB-28" id="OB-28-agency_video_calls">
<sqlFile path="db/changelog/changeset/0012_agency_video_calls/agencyVideoCalls.sql" stripComments="true" />
<rollback>
<sqlFile path="db/changelog/changeset/0012_agency_video_calls/agencyVideoCalls-rollback.sql" stripComments="true" />
</rollback>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table agencyservice.agency
drop has_video_calls;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table agencyservice.agency
add has_video_calls bit default true not null after is_external;
Loading