<commit_before>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2013 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.pod.repository.mapper;

import org.apache.ibatis.annotations.*;
import org.openlmis.pod.domain.OrderPOD;
import org.openlmis.pod.domain.OrderPODLineItem;
import org.openlmis.rnr.domain.Rnr;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface PODMapper {

  @Insert(
    {"INSERT INTO pod_line_items ", "(podId, productCode, quantityReceived, quantityShipped, productName, dispensingUnit, packsToShip, fullSupply,", "productCategory, productCategoryDisplayOrder, productDisplayOrder, createdBy, modifiedBy, createdDate, modifiedDate) VALUES ", "(#{podId}, #{productCode}, #{quantityReceived}, #{quantityShipped}, #{productName}, #{dispensingUnit}, #{packsToShip}, #{fullSupply},", "#{productCategory}, #{productCategoryDisplayOrder}, #{productDisplayOrder}, #{createdBy}, #{modifiedBy}, DEFAULT, DEFAULT)"})
  @Options(useGeneratedKeys = true)
  void insertPODLineItem(OrderPODLineItem orderPodLineItem);

  @Select(
    "SELECT * FROM pod_line_items WHERE podId = #{podId} ORDER BY productCategoryDisplayOrder, LOWER(productCategory), productDisplayOrder NULLS LAST, LOWER(productCode)")
  List<OrderPODLineItem> getPODLineItemsByPODId(Long podId);

  @Insert(
    {"INSERT INTO pod (orderId, facilityId, programId, periodId, receivedDate, createdBy, modifiedBy) VALUES ", "(#{orderId}, #{facilityId}, #{programId}, #{periodId}, DEFAULT, #{createdBy}, #{modifiedBy} )"})
  @Options(useGeneratedKeys = true)
  void insertPOD(OrderPOD orderPod);

  @Select({"SELECT * FROM pod WHERE id = #{id}"})
  @Results({
    @Result(column = "id", property = "id"),
    @Result(property = "podLineItems", javaType = List.class, column = "id", many = @Many(select = "org.openlmis.pod.repository.mapper.PODMapper.getPODLineItemsByPODId"))
  })
  OrderPOD getPODById(Long id);

  @Select({"SELECT PLI.* FROM pod_line_items PLI INNER JOIN pod P ON PLI.podId = P.id ",
    "WHERE P.facilityId = #{requisition.facility.id} ",
    "AND P.programId = #{requisition.program.id} ",
    "AND P.createdDate >= #{startDate} ",
    "AND PLI.productCode = #{productCode}",
    "ORDER BY p.createdDate DESC LIMIT #{n}"})
  List<OrderPODLineItem> getNPodLineItems(@Param("productCode") String productCode,
                                          @Param("requisition") Rnr requisition,
                                          @Param("n") Integer n,
                                          @Param("startDate") Date startDate);

  @Select({"SELECT * FROM pod WHERE orderId = #{orderId}"})
  @Results(value = {@Result(column = "id", property = "id"), @Result(property = "podLineItems", javaType = List.class,
    column = "id",
    many = @Many(select = "org.openlmis.pod.repository.mapper.PODMapper.getPODLineItemsByPODId")),})
  OrderPOD getPODByOrderId(Long orderId);

  @Update({"UPDATE pod SET modifiedBy = #{modifiedBy} WHERE id = #{id}"})
  void update(OrderPOD orderPOD);

  @Update(
    {"UPDATE pod_line_items SET quantityReceived = #{quantityReceived}, notes = #{notes}, modifiedBy = #{modifiedBy} WHERE id = #{id}"})
  void updateLineItem(OrderPODLineItem lineItem);
}<commit_msg>|#1318| Updating modified date with save<commit_after>/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2013 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.pod.repository.mapper;

import org.apache.ibatis.annotations.*;
import org.openlmis.pod.domain.OrderPOD;
import org.openlmis.pod.domain.OrderPODLineItem;
import org.openlmis.rnr.domain.Rnr;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface PODMapper {

  @Insert(
    {"INSERT INTO pod_line_items ", "(podId, productCode, quantityReceived, quantityShipped, productName, dispensingUnit, packsToShip, fullSupply,", "productCategory, productCategoryDisplayOrder, productDisplayOrder, createdBy, modifiedBy, createdDate, modifiedDate) VALUES ", "(#{podId}, #{productCode}, #{quantityReceived}, #{quantityShipped}, #{productName}, #{dispensingUnit}, #{packsToShip}, #{fullSupply},", "#{productCategory}, #{productCategoryDisplayOrder}, #{productDisplayOrder}, #{createdBy}, #{modifiedBy}, DEFAULT, DEFAULT)"})
  @Options(useGeneratedKeys = true)
  void insertPODLineItem(OrderPODLineItem orderPodLineItem);

  @Select(
    "SELECT * FROM pod_line_items WHERE podId = #{podId} ORDER BY productCategoryDisplayOrder, LOWER(productCategory), productDisplayOrder NULLS LAST, LOWER(productCode)")
  List<OrderPODLineItem> getPODLineItemsByPODId(Long podId);

  @Insert(
    {"INSERT INTO pod (orderId, facilityId, programId, periodId, receivedDate, createdBy, modifiedBy) VALUES ", "(#{orderId}, #{facilityId}, #{programId}, #{periodId}, DEFAULT, #{createdBy}, #{modifiedBy} )"})
  @Options(useGeneratedKeys = true)
  void insertPOD(OrderPOD orderPod);

  @Select({"SELECT * FROM pod WHERE id = #{id}"})
  @Results({
    @Result(column = "id", property = "id"),
    @Result(property = "podLineItems", javaType = List.class, column = "id", many = @Many(select = "org.openlmis.pod.repository.mapper.PODMapper.getPODLineItemsByPODId"))
  })
  OrderPOD getPODById(Long id);

  @Select({"SELECT PLI.* FROM pod_line_items PLI INNER JOIN pod P ON PLI.podId = P.id ",
    "WHERE P.facilityId = #{requisition.facility.id} ",
    "AND P.programId = #{requisition.program.id} ",
    "AND P.createdDate >= #{startDate} ",
    "AND PLI.productCode = #{productCode}",
    "ORDER BY p.createdDate DESC LIMIT #{n}"})
  List<OrderPODLineItem> getNPodLineItems(@Param("productCode") String productCode,
                                          @Param("requisition") Rnr requisition,
                                          @Param("n") Integer n,
                                          @Param("startDate") Date startDate);

  @Select({"SELECT * FROM pod WHERE orderId = #{orderId}"})
  @Results(value = {@Result(column = "id", property = "id"), @Result(property = "podLineItems", javaType = List.class,
    column = "id",
    many = @Many(select = "org.openlmis.pod.repository.mapper.PODMapper.getPODLineItemsByPODId")),})
  OrderPOD getPODByOrderId(Long orderId);

  @Update({"UPDATE pod SET modifiedBy = #{modifiedBy}, modifiedDate = DEFAULT WHERE id = #{id}"})
  void update(OrderPOD orderPOD);

  @Update(
    {"UPDATE pod_line_items SET quantityReceived = #{quantityReceived}, notes = #{notes}, modifiedBy = #{modifiedBy}, modifiedDate = DEFAULT WHERE id = #{id}"})
  void updateLineItem(OrderPODLineItem lineItem);
}
{'fraction_non_alphanumeric': 0.12353159391616174, 'fraction_numerical': 0.001731173488314579, 'mean_word_length': 4.655944055944056, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7324223', 'n_tokens_mistral': 2361, 'n_tokens_neox': 2305, 'n_words': 695}