<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.domain;

import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Represents a trade item identification using a classification system.
 */
@Entity
@Table(name = "trade_item_classifications", schema = "referencedata",
    uniqueConstraints = @UniqueConstraint(
        name = "unq_trade_item_classifications_system",
        columnNames = {"tradeitemid", "classificationsystem"}))
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, exclude = {"tradeItem"})
public class TradeItemClassification extends BaseEntity {

  @ManyToOne
  @Getter(AccessLevel.PRIVATE)
  private TradeItem tradeItem;

  @Getter
  @Setter
  private String classificationSystem;

  @Getter
  @Setter
  private String classificationId;

  /**
   * Constructs a classification for a trade item.
   * @param tradeItem the trade item this classification belongs to
   * @param classificationSystem the classification system
   * @param classificationId the id of the classification system
   */
  TradeItemClassification(TradeItem tradeItem, String classificationSystem,
                                 String classificationId) {
    this.tradeItem = tradeItem;
    this.classificationSystem = classificationSystem;
    this.classificationId = classificationId;
  }

  /**
   * Creates new instance of TradeItemClassification.
   */
  public static TradeItemClassification newInstance(Importer importer, TradeItem tradeItem) {
    TradeItemClassification classification = new TradeItemClassification();
    classification.classificationSystem = importer.getClassificationSystem();
    classification.classificationId = importer.getClassificationId();
    classification.tradeItem = tradeItem;
    return classification;
  }

  /**
   * Exports domain object to dto.
   */
  public void export(Exporter exporter) {
    exporter.setClassificationId(classificationId);
    exporter.setClassificationSystem(classificationSystem);
  }

  public interface Exporter {
    void setClassificationSystem(String classificationSystem);

    void setClassificationId(String classificationId);
  }<commit_msg>OLMIS:1696: add some more specific java docs<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.domain;

import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Represents a trade item identification using a classification system.
 */
@Entity
@Table(name = "trade_item_classifications", schema = "referencedata",
    uniqueConstraints = @UniqueConstraint(
        name = "unq_trade_item_classifications_system",
        columnNames = {"tradeitemid", "classificationsystem"}))
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, exclude = {"tradeItem"})
public class TradeItemClassification extends BaseEntity {

  @ManyToOne
  @Getter(AccessLevel.PRIVATE)
  private TradeItem tradeItem;

  @Getter
  @Setter
  private String classificationSystem;

  @Getter
  @Setter
  private String classificationId;

  /**
   * Constructs a classification for a trade item.
   * @param tradeItem the trade item this classification belongs to
   * @param classificationSystem the classification system
   * @param classificationId the id of the classification system
   */
  TradeItemClassification(TradeItem tradeItem, String classificationSystem,
                                 String classificationId) {
    this.tradeItem = tradeItem;
    this.classificationSystem = classificationSystem;
    this.classificationId = classificationId;
  }

  /**
   * Creates new instance based on data from {@link Importer}.
   *
   * @param importer instance of {@link Importer}.
   * @param tradeItem instance of {@link TradeItem} to be associated with TradeItemClassification.
   * @return new instance of TradeItemClassification.
   */
  public static TradeItemClassification newInstance(Importer importer, TradeItem tradeItem) {
    TradeItemClassification classification = new TradeItemClassification();
    classification.classificationSystem = importer.getClassificationSystem();
    classification.classificationId = importer.getClassificationId();
    classification.tradeItem = tradeItem;
    return classification;
  }

  /**
   * Export this object to the specified exporter (DTO).
   *
   * @param exporter exporter to export to.
   */
  public void export(Exporter exporter) {
    exporter.setClassificationId(classificationId);
    exporter.setClassificationSystem(classificationSystem);
  }

  public interface Exporter {
    void setClassificationSystem(String classificationSystem);

    void setClassificationId(String classificationId);
  }
{'fraction_non_alphanumeric': 0.06836461126005362, 'fraction_numerical': 0.002085195114685731, 'mean_word_length': 4.4682410423452765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4232898', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1653, 'n_words': 593}