Skip to content

Commit

Permalink
Merge pull request #13 from danishjamal104/log-lvl
Browse files Browse the repository at this point in the history
Batch record parsing fixed
  • Loading branch information
avikganguly01 authored May 7, 2022
2 parents 50da016 + 4fd7435 commit bbc6c18
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
10 changes: 4 additions & 6 deletions src/main/java/hu/dpc/phee/operator/entity/batch/Batch.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hu.dpc.phee.operator.entity.batch;

import hu.dpc.phee.operator.entity.parent.AbstractPersistableCustom;
import org.eclipse.persistence.annotations.Index;

import javax.persistence.Column;
Expand All @@ -10,10 +11,7 @@

@Entity
@Table(name = "batches")
public class Batch {

@Id
private Long id;
public class Batch extends AbstractPersistableCustom<Long> {

@Column(name = "BATCH_ID")
private String batchId;
Expand Down Expand Up @@ -49,7 +47,7 @@ public class Batch {
private Long workflowKey;

@Column(name = "WORKFLOW_INSTANCE_KEY")
@Index(name = "idx_workflowInstanceKey")
@Index(name = "idx_batches_key")
private Long workflowInstanceKey;

@Column(name = "STARTED_AT")
Expand Down Expand Up @@ -176,4 +174,4 @@ public Date getCompletedAt() {
public void setCompletedAt(Date completedAt) {
this.completedAt = completedAt;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package hu.dpc.phee.operator.entity.batch;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;

public interface BatchRepository extends CrudRepository<Batch, Long> {
public interface BatchRepository extends JpaRepository<Batch, Long>, JpaSpecificationExecutor {

Batch findByWorkflowInstanceKey(Long workflowInstanceKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public void batchStarted(Long workflowInstanceKey, Long timestamp, String direct
if (batch.getStartedAt() == null) {
batch.setStartedAt(new Date(timestamp));
batchRepository.save(batch);
logger.debug("started in-flight batch {}", batch.getWorkflowInstanceKey());
logger.debug("saving batch {}", batch.getWorkflowInstanceKey());
} else {
logger.debug("transactionRequest {} already started at {}", workflowInstanceKey, batch.getStartedAt());
logger.debug("batch {} already started at {}", workflowInstanceKey, batch.getStartedAt());
}
}

Expand Down Expand Up @@ -56,6 +56,7 @@ public Batch getOrCreateBatch(Long workflowInstanceKey) {
batch = batchRepository.findByWorkflowInstanceKey(workflowInstanceKey);
if (batch == null) {
batch = new Batch(workflowInstanceKey);
logger.debug("started in-flight batch {}", batch.getWorkflowInstanceKey());
}
inflightBatches.put(workflowInstanceKey, batch);
}
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/hu/dpc/phee/operator/importer/VariableParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public VariableParser() {
transferParsers.put("partyLookupFspId", pair -> pair.getFirst().setPayeeDfspId(strip(pair.getSecond())));
transferParsers.put("initiatorFspId", pair -> pair.getFirst().setPayerDfspId(strip(pair.getSecond())));
transferParsers.put("channelRequest", pair -> parseChannelRequest(pair.getFirst(), pair.getSecond()));
transferParsers.put("errorInformation", pair -> parseErrorInformation(pair.getFirst(), pair.getSecond()));
transferParsers.put("batchId", pair -> pair.getFirst().setBatchId(pair.getSecond()));
transferParsers.put("errorInformation", pair -> {parseErrorInformation(pair.getFirst(), pair.getSecond());
parseTransferCreateFailed(pair.getFirst(), pair.getSecond());});
transferParsers.put("batchId", pair -> pair.getFirst().setBatchId(strip(pair.getSecond())));

transactionRequestParsers.put("authType", pair -> pair.getFirst().setAuthType(strip(pair.getSecond())));
transactionRequestParsers.put("transactionId", pair -> pair.getFirst().setTransactionId(strip(pair.getSecond())));
Expand All @@ -69,10 +70,10 @@ public VariableParser() {
transactionRequestParsers.put("transactionFailed", pair -> parseTransactionFailed(pair.getFirst(), pair.getSecond()));
transactionRequestParsers.put("transferSettlementFailed", pair -> parseSettlementFiled(pair.getFirst(), pair.getSecond()));

batchParsers.put("batchId", pair -> pair.getFirst().setBatchId(pair.getSecond()));
batchParsers.put("fileName", pair -> pair.getFirst().setRequestFile(pair.getSecond()));
batchParsers.put("requestId", pair -> pair.getFirst().setRequestFile(pair.getSecond()));
batchParsers.put("note", pair -> pair.getFirst().setNote(pair.getSecond()));
batchParsers.put("batchId", pair -> pair.getFirst().setBatchId(strip(pair.getSecond())));
batchParsers.put("fileName", pair -> pair.getFirst().setRequestFile(strip(pair.getSecond())));
batchParsers.put("requestId", pair -> pair.getFirst().setRequestId(strip(pair.getSecond())));
batchParsers.put("note", pair -> pair.getFirst().setNote(strip(pair.getSecond())));
}

public Map<String, Consumer<Pair<Transfer, String>>> getTransferParsers() {
Expand Down Expand Up @@ -195,7 +196,7 @@ private void parseChannelRequest(Transfer transfer, String jsonString) {
}

private void parseErrorInformation(Transfer transfer, String jsonString) {
transfer.setErrorInformation(jsonString);
transfer.setErrorInformation(strip(jsonString));
}

private void parseTransactionChannelRequest(TransactionRequest transactionRequest, String jsonString) {
Expand Down

0 comments on commit bbc6c18

Please sign in to comment.