FINERACT-2218: Fix Type Mismatch in Survey Validation Query
This commit is contained in:
@@ -18,6 +18,18 @@
|
||||
*/
|
||||
package org.apache.fineract.spm.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Model representing a survey response option for internal mapping
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ResponseData {
|
||||
|
||||
private Long id;
|
||||
@@ -25,43 +37,4 @@ public class ResponseData {
|
||||
private Integer value;
|
||||
private Integer sequenceNo;
|
||||
|
||||
public ResponseData() {
|
||||
|
||||
}
|
||||
|
||||
public ResponseData(final Long id, final String text, final Integer value, final Integer sequenceNo) {
|
||||
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
this.sequenceNo = sequenceNo;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getSequenceNo() {
|
||||
return sequenceNo;
|
||||
}
|
||||
|
||||
public void setSequenceNo(Integer sequenceNo) {
|
||||
this.sequenceNo = sequenceNo;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.spm.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -27,11 +27,11 @@ import org.springframework.data.repository.query.Param;
|
||||
public interface SurveyRepository extends JpaRepository<Survey, Long> {
|
||||
|
||||
@Query("select s from Survey s where :pointInTime between s.validFrom and s.validTo")
|
||||
List<Survey> fetchActiveSurveys(@Param("pointInTime") LocalDateTime pointInTime);
|
||||
List<Survey> fetchActiveSurveys(@Param("pointInTime") LocalDate pointInTime);
|
||||
|
||||
@Query("select s from Survey s ")
|
||||
List<Survey> fetchAllSurveys();
|
||||
|
||||
@Query("select s from Survey s where s.key = :key and :pointInTime between s.validFrom and s.validTo")
|
||||
Survey findByKey(@Param("key") String key, @Param("pointInTime") LocalDateTime pointInTime);
|
||||
Survey findByKey(@Param("key") String key, @Param("pointInTime") LocalDate pointInTime);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SpmService {
|
||||
public List<Survey> fetchValidSurveys() {
|
||||
this.securityContext.authenticatedUser();
|
||||
|
||||
return this.surveyRepository.fetchActiveSurveys(DateUtils.getLocalDateTimeOfSystem());
|
||||
return this.surveyRepository.fetchActiveSurveys(DateUtils.getLocalDateOfTenant());
|
||||
}
|
||||
|
||||
public List<Survey> fetchAllSurveys() {
|
||||
@@ -61,7 +61,7 @@ public class SpmService {
|
||||
public Survey createSurvey(final Survey survey) {
|
||||
this.securityContext.authenticatedUser();
|
||||
this.surveyValidator.validate(survey);
|
||||
final Survey previousSurvey = this.surveyRepository.findByKey(survey.getKey(), DateUtils.getLocalDateTimeOfSystem());
|
||||
final Survey previousSurvey = this.surveyRepository.findByKey(survey.getKey(), DateUtils.getLocalDateOfTenant());
|
||||
|
||||
if (previousSurvey != null) {
|
||||
this.deactivateSurvey(previousSurvey.getId());
|
||||
|
||||
Reference in New Issue
Block a user