Skip to content

Commit

Permalink
Merge pull request #1491 from manviraheja1/Dev-2.0
Browse files Browse the repository at this point in the history
added search API for fielstroe search
  • Loading branch information
deepikaarora88 authored Oct 24, 2024
2 parents 65b844a + 37e9982 commit 2fc17ea
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.egov.dx.web.models.Transaction;
import org.egov.dx.web.models.TransactionCriteria;
Expand Down Expand Up @@ -31,6 +32,18 @@ public List<Transaction> fetchTransactions(TransactionCriteria transactionCriter
log.debug(query);
return jdbcTemplate.query(query, params.toArray(), rowMapper);
}

public List<Transaction> fetchSignedFile(Transaction transaction) {
List<Object> params = new ArrayList<>();
String consumerCode = transaction.getConsumerCode();
String module = transaction.getModule();
TransactionCriteria transactionCriteria = new TransactionCriteria();
transactionCriteria.setModule(module);
transactionCriteria.setConsumerCode(consumerCode);
String query = transactionQueryBuilder.getEsignedFileQueryByConsumerCode(transactionCriteria, params);
log.debug(query);
return jdbcTemplate.query(query, params.toArray(), rowMapper);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -117,7 +118,7 @@ public String processPDF(RequestInfoWrapper requestInfoWrapper) throws IOExcepti
.setDocURL(requestInfoWrapper.getTransaction().getPdfUrl())//for v3 only pdf view purpose
.setLocation("") // reason or signed (optional)
.setReason("") //(optional)
.setSignedBy("Manvi") //(mandatory)
.setSignedBy("NIUA") //(mandatory)
.setCoSign(true)
.setAppearanceType(eSign.AppearanceType.StandardSignature)
.setPageTobeSigned(eSign.PageTobeSigned.First)
Expand All @@ -144,7 +145,7 @@ public String processPDF(RequestInfoWrapper requestInfoWrapper) throws IOExcepti

// Obtain the gateway parameter
eSignServiceReturn serviceReturn = eSignObj.getGatewayParameter(
inputList, "Manvi", (txnId+"-"+ requestInfoWrapper.getTransaction().getModule()) , configurations.getRedirectUrl(),configurations.getRedirectUrl(), configurations.getTempFolder(), eSign.eSignAPIVersion.V2, eSign.AuthMode.OTP);
inputList, "NIUA", (txnId+"-"+ requestInfoWrapper.getTransaction().getModule()) , configurations.getRedirectUrl(),configurations.getRedirectUrl(), configurations.getTempFolder(), eSign.eSignAPIVersion.V2, eSign.AuthMode.OTP);

String gatewayParam = serviceReturn.getGatewayParameter();
String gatewayURL = "https://authenticate.sandbox.emudhra.com/AadhaareSign.jsp"; // Adjust if needed
Expand Down Expand Up @@ -257,5 +258,16 @@ public List<Transaction> getTransactions(TransactionCriteria transactionCriteria
throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store");
}
}

public List<Transaction> getSignedFilestore(RequestInfo requestInfo, Transaction transaction) {
{
try {
return transactionRepository.fetchSignedFile(transaction);
} catch (DataAccessException e) {
log.error("Unable to fetch data from the database for criteria: " + transaction.toString(), e);
throw new CustomException("FETCH_TXNS_FAILED", "Unable to fetch transactions from store");
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,29 @@

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.egov.common.contract.response.ResponseInfo;
import org.egov.dx.service.eSignService;
import org.egov.dx.util.Configurations;
import org.egov.dx.web.models.RequestInfoWrapper;
import org.egov.dx.web.models.ResponseInfoFactory;
import org.egov.dx.web.models.Transaction;
import org.egov.dx.web.models.TransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder;

Expand Down Expand Up @@ -104,5 +112,18 @@ public ResponseEntity<Object> getEsignedPDF(HttpServletRequest request, HttpServ
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
}
}


@RequestMapping(value = "/filestoreId/v1/_search", method = RequestMethod.POST)
public ResponseEntity<TransactionResponse> searchSignedFilestore(@RequestBody RequestInfoWrapper requestInfoWrapper, @RequestParam Map<String, String> params) {

List<Transaction> transactions = esignService.getSignedFilestore(requestInfoWrapper.getRequestInfo(), requestInfoWrapper.getTransaction());
ResponseInfo responseInfo=ResponseInfoFactory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), null);

TransactionResponse response = new TransactionResponse(responseInfo, transactions);

return new ResponseEntity<>(response, HttpStatus.OK);

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ public class TransactionCriteria {
private String tenantId;

private String txnId;

private String module;

private String consumerCode;

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public String getTransactionSearchQueryByTxnId(TransactionCriteria transactionCr
return query;
}


public String getEsignedFileQueryByConsumerCode(TransactionCriteria transactionCriteria, List<Object> preparedStmtList) {
String query = buildQuery(transactionCriteria, preparedStmtList);
query = addOrderByClause(query);
return query;
}
private String buildQuery(TransactionCriteria transactionCriteria, List<Object> preparedStmtList) {
StringBuilder builder = new StringBuilder(TransactionQueryBuilder.SEARCH_TXN_SQL);
Map<String, Object> queryParams = new HashMap<>();
Expand All @@ -33,6 +39,14 @@ private String buildQuery(TransactionCriteria transactionCriteria, List<Object>
queryParams.put("tlf.txn_id", transactionCriteria.getTxnId());
}

if (!Objects.isNull(transactionCriteria.getConsumerCode())) {
queryParams.put("tlf.consumerCode", transactionCriteria.getConsumerCode());
}

if (!Objects.isNull(transactionCriteria.getModule())) {
queryParams.put("tlf.module", transactionCriteria.getModule());
}

if (!queryParams.isEmpty()) {

builder.append(" WHERE ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;
import org.egov.dx.web.models.Transaction;
import org.springframework.validation.annotation.Validated;
import org.egov.common.contract.response.ResponseInfo;

import javax.validation.Valid;
import java.util.List;
Expand Down

0 comments on commit 2fc17ea

Please sign in to comment.