Merge pull request #10 from mgeiss/develop

refactored case parameters using id instead of created on
diff --git a/service/src/main/java/io/mifos/individuallending/internal/mapper/CaseParametersMapper.java b/service/src/main/java/io/mifos/individuallending/internal/mapper/CaseParametersMapper.java
index 663bfbd..a0f4983 100644
--- a/service/src/main/java/io/mifos/individuallending/internal/mapper/CaseParametersMapper.java
+++ b/service/src/main/java/io/mifos/individuallending/internal/mapper/CaseParametersMapper.java
@@ -15,14 +15,11 @@
  */
 package io.mifos.individuallending.internal.mapper;
 
-import io.mifos.individuallending.internal.repository.CaseParametersEntity;
 import io.mifos.individuallending.api.v1.domain.caseinstance.CaseParameters;
+import io.mifos.individuallending.internal.repository.CaseParametersEntity;
 import io.mifos.portfolio.api.v1.domain.PaymentCycle;
 import io.mifos.portfolio.api.v1.domain.TermRange;
 
-import java.time.Clock;
-import java.time.LocalDateTime;
-
 /**
  * @author Myrle Krantz
  */
@@ -42,7 +39,6 @@
     ret.setPaymentCycleAlignmentDay(instance.getPaymentCycle().getAlignmentDay());
     ret.setPaymentCycleAlignmentWeek(instance.getPaymentCycle().getAlignmentWeek());
     ret.setPaymentCycleAlignmentMonth(instance.getPaymentCycle().getAlignmentMonth());
-    ret.setCreatedOn(LocalDateTime.now(Clock.systemUTC()));
 
     return ret;
   }
diff --git a/service/src/main/java/io/mifos/individuallending/internal/repository/CaseParametersEntity.java b/service/src/main/java/io/mifos/individuallending/internal/repository/CaseParametersEntity.java
index 6f18336..91f260f 100644
--- a/service/src/main/java/io/mifos/individuallending/internal/repository/CaseParametersEntity.java
+++ b/service/src/main/java/io/mifos/individuallending/internal/repository/CaseParametersEntity.java
@@ -15,11 +15,15 @@
  */
 package io.mifos.individuallending.internal.repository;
 
-import io.mifos.core.mariadb.util.LocalDateTimeConverter;
-
-import javax.persistence.*;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
 import java.math.BigDecimal;
-import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
 
 /**
@@ -68,10 +72,6 @@
   @Column(name = "pay_cycle_align_month")
   private Integer paymentCycleAlignmentMonth;
 
-  @Column(name = "created_on")
-  @Convert(converter = LocalDateTimeConverter.class)
-  private LocalDateTime createdOn;
-
   public CaseParametersEntity() {
   }
 
@@ -170,12 +170,4 @@
   public void setPaymentCycleAlignmentMonth(Integer paymentCycleAlignmentMonth) {
     this.paymentCycleAlignmentMonth = paymentCycleAlignmentMonth;
   }
-
-  public LocalDateTime getCreatedOn() {
-    return this.createdOn;
-  }
-
-  public void setCreatedOn(final LocalDateTime createdOn) {
-    this.createdOn = createdOn;
-  }
 }
diff --git a/service/src/main/java/io/mifos/individuallending/internal/service/CaseParametersService.java b/service/src/main/java/io/mifos/individuallending/internal/service/CaseParametersService.java
index c7a4a6e..1a48f2b 100644
--- a/service/src/main/java/io/mifos/individuallending/internal/service/CaseParametersService.java
+++ b/service/src/main/java/io/mifos/individuallending/internal/service/CaseParametersService.java
@@ -16,16 +16,16 @@
 package io.mifos.individuallending.internal.service;
 
 import com.google.gson.Gson;
+import io.mifos.individuallending.api.v1.domain.caseinstance.CaseParameters;
 import io.mifos.individuallending.internal.mapper.CaseParametersMapper;
 import io.mifos.individuallending.internal.repository.CaseParametersEntity;
 import io.mifos.individuallending.internal.repository.CaseParametersRepository;
+import io.mifos.portfolio.api.v1.domain.Case;
+import io.mifos.portfolio.api.v1.domain.CasePage;
 import io.mifos.portfolio.service.ServiceConstants;
 import io.mifos.portfolio.service.internal.mapper.CaseMapper;
 import io.mifos.portfolio.service.internal.repository.CaseEntity;
 import io.mifos.portfolio.service.internal.repository.CaseRepository;
-import io.mifos.individuallending.api.v1.domain.caseinstance.CaseParameters;
-import io.mifos.portfolio.api.v1.domain.Case;
-import io.mifos.portfolio.api.v1.domain.CasePage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.domain.Page;
@@ -70,7 +70,7 @@
           final int pageIndex,
           final int size)
   {
-    final Pageable pageRequest = new PageRequest(pageIndex, size, Sort.Direction.DESC, "createdOn");
+    final Pageable pageRequest = new PageRequest(pageIndex, size, Sort.Direction.DESC, "id");
 
     final Page<CaseParametersEntity> ret = caseParametersRepository.findByCustomerIdentifier(customerIdentifier, pageRequest);
 
diff --git a/service/src/main/resources/db/migrations/mariadb/V2__add_created_on_to_bastet_il_cases.sql b/service/src/main/resources/db/migrations/mariadb/V2__add_created_on_to_bastet_il_cases.sql
deleted file mode 100644
index 38d82e4..0000000
--- a/service/src/main/resources/db/migrations/mariadb/V2__add_created_on_to_bastet_il_cases.sql
+++ /dev/null
@@ -1,22 +0,0 @@
---
--- Copyright 2017 The Mifos Initiative.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
---    http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-ALTER TABLE bastet_il_cases ADD COLUMN created_on TIMESTAMP(3) NULL;
-
-UPDATE bastet_il_cases bic INNER JOIN bastet_cases bc ON (bic.case_id = bc.id) SET bic.created_on = bc.created_on where bic.created_on IS NULL;
-
-ALTER TABLE bastet_il_cases MODIFY COLUMN created_on TIMESTAMP(3) NOT NULL;
-