<commit_before>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact <EMAIL>. 
 */

package org.openlmis.referencedata.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import org.openlmis.referencedata.domain.Facility;
import org.openlmis.referencedata.domain.FacilityOperator;
import org.openlmis.referencedata.domain.FacilityType;
import org.openlmis.referencedata.domain.GeographicZone;
import org.openlmis.referencedata.domain.SupportedProgram;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDate;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
@Setter
public class FacilityDto extends BaseDto implements Facility.Exporter, Facility.Importer {
  private String code;
  private String name;
  private String description;
  private GeographicZoneDto geographicZone;
  private FacilityTypeDto type;
  private FacilityOperatorDto operator;
  private Boolean active;
  private LocalDate goLiveDate;
  private LocalDate goDownDate;
  private String comment;
  private Boolean enabled;
  private Boolean openLmisAccessible;

  @Getter
  private Set<SupportedProgramDto> supportedPrograms;

  public FacilityDto(UUID id) {
    setId(id);
  }

  @Override
  public void setGeographicZone(GeographicZone geographicZone) {
    this.geographicZone = new GeographicZoneDto();
    geographicZone.export(this.geographicZone);
  }

  @Override
  public void setType(FacilityType type) {
    this.type = new FacilityTypeDto();
    type.export(this.type);

  }

  @Override
  public void setOperator(FacilityOperator operator) {
    this.operator = new FacilityOperatorDto();
    operator.export(this.operator);
  }

  @Override
  public void setSupportedPrograms(Set<SupportedProgram> supportedPrograms) {
    if (supportedPrograms != null) {
      this.supportedPrograms = supportedPrograms
          .stream()
          .map(supportedProgram -> {
            SupportedProgramDto supportedProgramDto = new SupportedProgramDto();
            supportedProgram.export(supportedProgramDto);

            return supportedProgramDto;
          })
          .collect(Collectors.toSet());
    }
  }
}
<commit_msg>OLMIS-1985: Do not ignore setting null as supported programs<commit_after>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact <EMAIL>. 
 */

package org.openlmis.referencedata.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import org.openlmis.referencedata.domain.Facility;
import org.openlmis.referencedata.domain.FacilityOperator;
import org.openlmis.referencedata.domain.FacilityType;
import org.openlmis.referencedata.domain.GeographicZone;
import org.openlmis.referencedata.domain.SupportedProgram;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDate;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;

@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
@Setter
public class FacilityDto extends BaseDto implements Facility.Exporter, Facility.Importer {
  private String code;
  private String name;
  private String description;
  private GeographicZoneDto geographicZone;
  private FacilityTypeDto type;
  private FacilityOperatorDto operator;
  private Boolean active;
  private LocalDate goLiveDate;
  private LocalDate goDownDate;
  private String comment;
  private Boolean enabled;
  private Boolean openLmisAccessible;

  @Getter
  private Set<SupportedProgramDto> supportedPrograms;

  public FacilityDto(UUID id) {
    setId(id);
  }

  @Override
  public void setGeographicZone(GeographicZone geographicZone) {
    this.geographicZone = new GeographicZoneDto();
    geographicZone.export(this.geographicZone);
  }

  @Override
  public void setType(FacilityType type) {
    this.type = new FacilityTypeDto();
    type.export(this.type);

  }

  @Override
  public void setOperator(FacilityOperator operator) {
    this.operator = new FacilityOperatorDto();
    operator.export(this.operator);
  }

  @Override
  public void setSupportedPrograms(Set<SupportedProgram> supportedPrograms) {
    if (supportedPrograms == null) {
      this.supportedPrograms = null;
    } else {
      this.supportedPrograms = supportedPrograms
          .stream()
          .map(supportedProgram -> {
            SupportedProgramDto supportedProgramDto = new SupportedProgramDto();
            supportedProgram.export(supportedProgramDto);

            return supportedProgramDto;
          })
          .collect(Collectors.toSet());
    }
  }
}

{'fraction_non_alphanumeric': 0.07178099633932834, 'fraction_numerical': 0.002228234919624383, 'mean_word_length': 4.329940627650552, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4228886', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1696, 'n_words': 529}