BJ-311: Add withdrawal session eventsink (#28)

BJ-311: Add withdrawal session eventsink
This commit is contained in:
Baikov Dmitrii 2018-11-26 17:55:46 +03:00 committed by GitHub
parent 07bbebfecb
commit 258920f871
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 2135 additions and 10 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>newway</artifactId>
<version>1.0.24-SNAPSHOT</version>
<version>1.0.25-SNAPSHOT</version>
<packaging>jar</packaging>
<name>newway</name>
@ -30,7 +30,7 @@
<db.schema>nw</db.schema>
<flyway.version>4.2.0</flyway.version>
<damsel.version>1.267-5711f53</damsel.version>
<fistful-proto.version>1.7-46b0949</fistful-proto.version>
<fistful-proto.version>1.8-37ccefb</fistful-proto.version>
</properties>
<dependencies>
@ -98,12 +98,12 @@
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>eventstock-client-damsel</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>eventstock-client-fistful</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.rbkmoney</groupId>

View File

@ -15,7 +15,8 @@ import java.io.IOException;
public class ApplicationConfig {
@Bean
public RepositorySrv.Iface dominantClient(@Value("${dmt.url}") Resource resource, @Value("${dmt.networkTimeout}") int networkTimeout) throws IOException {
public RepositorySrv.Iface dominantClient(@Value("${dmt.url}") Resource resource,
@Value("${dmt.networkTimeout}") int networkTimeout) throws IOException {
return new THSpawnClientBuilder()
.withNetworkTimeout(networkTimeout)
.withAddress(resource.getURI()).build(RepositorySrv.Iface.class);

View File

@ -177,4 +177,22 @@ public class EventStockConfig {
.build();
}
@Bean
public EventPublisher withdrawalSessionEventPublisher(
WithdrawalSessionEventStockHandler withdrawalSessionEventStockHandler,
@Value("${withdrawal_session.polling.url}") Resource resource,
@Value("${withdrawal_session.polling.delay}") int pollDelay,
@Value("${withdrawal_session.polling.retryDelay}") int retryDelay,
@Value("${withdrawal_session.polling.maxPoolSize}") int maxPoolSize
) throws IOException {
return new FistfulPollingEventPublisherBuilder()
.withWithdrawalSessionServiceAdapter()
.withURI(resource.getURI())
.withEventHandler(withdrawalSessionEventStockHandler)
.withMaxPoolSize(maxPoolSize)
.withEventRetryDelay(retryDelay)
.withPollDelay(pollDelay)
.build();
}
}

View File

@ -0,0 +1,17 @@
package com.rbkmoney.newway.dao.withdrawal_session.iface;
import com.rbkmoney.newway.dao.common.iface.GenericDao;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import com.rbkmoney.newway.exception.DaoException;
public interface WithdrawalSessionDao extends GenericDao {
Long getLastEventId() throws DaoException;
Long save(WithdrawalSession withdrawalSession) throws DaoException;
WithdrawalSession get(String sessionId) throws DaoException;
void updateNotCurrent(String sessionId) throws DaoException;
}

View File

@ -0,0 +1,64 @@
package com.rbkmoney.newway.dao.withdrawal_session.impl;
import com.rbkmoney.newway.dao.common.impl.AbstractGenericDao;
import com.rbkmoney.newway.dao.common.mapper.RecordRowMapper;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import com.rbkmoney.newway.domain.tables.records.WithdrawalSessionRecord;
import com.rbkmoney.newway.exception.DaoException;
import org.jooq.Query;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import static com.rbkmoney.newway.domain.tables.WithdrawalSession.WITHDRAWAL_SESSION;
@Component
public class WithdrawalSessionDaoImpl extends AbstractGenericDao implements WithdrawalSessionDao {
private final RowMapper<WithdrawalSession> withdrawalSessionRowMapper;
@Autowired
public WithdrawalSessionDaoImpl(@Qualifier("dataSource") DataSource dataSource) {
super(dataSource);
withdrawalSessionRowMapper = new RecordRowMapper<>(WITHDRAWAL_SESSION, WithdrawalSession.class);
}
@Override
public Long getLastEventId() throws DaoException {
Query query = getDslContext().select(DSL.max(WITHDRAWAL_SESSION.EVENT_ID)).from(WITHDRAWAL_SESSION);
return fetchOne(query, Long.class);
}
@Override
public Long save(WithdrawalSession withdrawalSession) throws DaoException {
WithdrawalSessionRecord record = getDslContext().newRecord(WITHDRAWAL_SESSION, withdrawalSession);
Query query = getDslContext().insertInto(WITHDRAWAL_SESSION).set(record).returning(WITHDRAWAL_SESSION.ID);
GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
executeOneWithReturn(query, keyHolder);
return keyHolder.getKey().longValue();
}
@Override
public WithdrawalSession get(String sessionId) throws DaoException {
Query query = getDslContext().selectFrom(WITHDRAWAL_SESSION)
.where(WITHDRAWAL_SESSION.WITHDRAWAL_SESSION_ID.eq(sessionId)
.and(WITHDRAWAL_SESSION.CURRENT));
return fetchOne(query, withdrawalSessionRowMapper);
}
@Override
public void updateNotCurrent(String sessionId) throws DaoException {
Query query = getDslContext().update(WITHDRAWAL_SESSION).set(WITHDRAWAL_SESSION.CURRENT, false)
.where(WITHDRAWAL_SESSION.WITHDRAWAL_SESSION_ID.eq(sessionId)
.and(WITHDRAWAL_SESSION.CURRENT));
executeOne(query);
}
}

View File

@ -36,6 +36,7 @@ import com.rbkmoney.newway.domain.tables.TermSetHierarchy;
import com.rbkmoney.newway.domain.tables.Terminal;
import com.rbkmoney.newway.domain.tables.Wallet;
import com.rbkmoney.newway.domain.tables.Withdrawal;
import com.rbkmoney.newway.domain.tables.WithdrawalSession;
import com.rbkmoney.newway.domain.tables.records.AdjustmentRecord;
import com.rbkmoney.newway.domain.tables.records.CalendarRecord;
import com.rbkmoney.newway.domain.tables.records.CashFlowRecord;
@ -69,6 +70,7 @@ import com.rbkmoney.newway.domain.tables.records.TermSetHierarchyRecord;
import com.rbkmoney.newway.domain.tables.records.TerminalRecord;
import com.rbkmoney.newway.domain.tables.records.WalletRecord;
import com.rbkmoney.newway.domain.tables.records.WithdrawalRecord;
import com.rbkmoney.newway.domain.tables.records.WithdrawalSessionRecord;
import javax.annotation.Generated;
@ -129,6 +131,7 @@ public class Keys {
public static final Identity<TerminalRecord, Long> IDENTITY_TERMINAL = Identities0.IDENTITY_TERMINAL;
public static final Identity<WalletRecord, Long> IDENTITY_WALLET = Identities0.IDENTITY_WALLET;
public static final Identity<WithdrawalRecord, Long> IDENTITY_WITHDRAWAL = Identities0.IDENTITY_WITHDRAWAL;
public static final Identity<WithdrawalSessionRecord, Long> IDENTITY_WITHDRAWAL_SESSION = Identities0.IDENTITY_WITHDRAWAL_SESSION;
// -------------------------------------------------------------------------
// UNIQUE and PRIMARY KEY definitions
@ -167,6 +170,7 @@ public class Keys {
public static final UniqueKey<TerminalRecord> TERMINAL_PKEY = UniqueKeys0.TERMINAL_PKEY;
public static final UniqueKey<WalletRecord> WALLET_PKEY = UniqueKeys0.WALLET_PKEY;
public static final UniqueKey<WithdrawalRecord> WITHDRAWAL_PKEY = UniqueKeys0.WITHDRAWAL_PKEY;
public static final UniqueKey<WithdrawalSessionRecord> WITHDRAWAL_SESSION_PK = UniqueKeys0.WITHDRAWAL_SESSION_PK;
// -------------------------------------------------------------------------
// FOREIGN KEY definitions
@ -215,6 +219,7 @@ public class Keys {
public static Identity<TerminalRecord, Long> IDENTITY_TERMINAL = createIdentity(Terminal.TERMINAL, Terminal.TERMINAL.ID);
public static Identity<WalletRecord, Long> IDENTITY_WALLET = createIdentity(Wallet.WALLET, Wallet.WALLET.ID);
public static Identity<WithdrawalRecord, Long> IDENTITY_WITHDRAWAL = createIdentity(Withdrawal.WITHDRAWAL, Withdrawal.WITHDRAWAL.ID);
public static Identity<WithdrawalSessionRecord, Long> IDENTITY_WITHDRAWAL_SESSION = createIdentity(WithdrawalSession.WITHDRAWAL_SESSION, WithdrawalSession.WITHDRAWAL_SESSION.ID);
}
private static class UniqueKeys0 extends AbstractKeys {
@ -251,6 +256,7 @@ public class Keys {
public static final UniqueKey<TerminalRecord> TERMINAL_PKEY = createUniqueKey(Terminal.TERMINAL, "terminal_pkey", Terminal.TERMINAL.ID);
public static final UniqueKey<WalletRecord> WALLET_PKEY = createUniqueKey(Wallet.WALLET, "wallet_pkey", Wallet.WALLET.ID);
public static final UniqueKey<WithdrawalRecord> WITHDRAWAL_PKEY = createUniqueKey(Withdrawal.WITHDRAWAL, "withdrawal_pkey", Withdrawal.WITHDRAWAL.ID);
public static final UniqueKey<WithdrawalSessionRecord> WITHDRAWAL_SESSION_PK = createUniqueKey(WithdrawalSession.WITHDRAWAL_SESSION, "withdrawal_session_pk", WithdrawalSession.WITHDRAWAL_SESSION.ID);
}
private static class ForeignKeys0 extends AbstractKeys {

View File

@ -37,6 +37,7 @@ import com.rbkmoney.newway.domain.tables.TermSetHierarchy;
import com.rbkmoney.newway.domain.tables.Terminal;
import com.rbkmoney.newway.domain.tables.Wallet;
import com.rbkmoney.newway.domain.tables.Withdrawal;
import com.rbkmoney.newway.domain.tables.WithdrawalSession;
import java.util.ArrayList;
import java.util.Arrays;
@ -63,7 +64,7 @@ import org.jooq.impl.SchemaImpl;
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Nw extends SchemaImpl {
private static final long serialVersionUID = -7498482;
private static final long serialVersionUID = -1494886574;
/**
* The reference instance of <code>nw</code>
@ -235,6 +236,11 @@ public class Nw extends SchemaImpl {
*/
public final Withdrawal WITHDRAWAL = com.rbkmoney.newway.domain.tables.Withdrawal.WITHDRAWAL;
/**
* The table <code>nw.withdrawal_session</code>.
*/
public final WithdrawalSession WITHDRAWAL_SESSION = com.rbkmoney.newway.domain.tables.WithdrawalSession.WITHDRAWAL_SESSION;
/**
* No further instances allowed
*/
@ -292,7 +298,8 @@ public class Nw extends SchemaImpl {
Sequences.TERM_SET_HIERARCHY_ID_SEQ,
Sequences.TERMINAL_ID_SEQ,
Sequences.WALLET_ID_SEQ,
Sequences.WITHDRAWAL_ID_SEQ);
Sequences.WITHDRAWAL_ID_SEQ,
Sequences.WITHDRAWAL_SESSION_ID_SEQ);
}
@Override
@ -336,6 +343,7 @@ public class Nw extends SchemaImpl {
TermSetHierarchy.TERM_SET_HIERARCHY,
Terminal.TERMINAL,
Wallet.WALLET,
Withdrawal.WITHDRAWAL);
Withdrawal.WITHDRAWAL,
WithdrawalSession.WITHDRAWAL_SESSION);
}
}

View File

@ -187,4 +187,9 @@ public class Sequences {
* The sequence <code>nw.withdrawal_id_seq</code>
*/
public static final Sequence<Long> WITHDRAWAL_ID_SEQ = new SequenceImpl<Long>("withdrawal_id_seq", Nw.NW, org.jooq.impl.SQLDataType.BIGINT.nullable(false));
/**
* The sequence <code>nw.withdrawal_session_id_seq</code>
*/
public static final Sequence<Long> WITHDRAWAL_SESSION_ID_SEQ = new SequenceImpl<Long>("withdrawal_session_id_seq", Nw.NW, org.jooq.impl.SQLDataType.BIGINT.nullable(false));
}

View File

@ -37,6 +37,7 @@ import com.rbkmoney.newway.domain.tables.TermSetHierarchy;
import com.rbkmoney.newway.domain.tables.Terminal;
import com.rbkmoney.newway.domain.tables.Wallet;
import com.rbkmoney.newway.domain.tables.Withdrawal;
import com.rbkmoney.newway.domain.tables.WithdrawalSession;
import javax.annotation.Generated;
@ -218,4 +219,9 @@ public class Tables {
* The table <code>nw.withdrawal</code>.
*/
public static final Withdrawal WITHDRAWAL = com.rbkmoney.newway.domain.tables.Withdrawal.WITHDRAWAL;
/**
* The table <code>nw.withdrawal_session</code>.
*/
public static final WithdrawalSession WITHDRAWAL_SESSION = com.rbkmoney.newway.domain.tables.WithdrawalSession.WITHDRAWAL_SESSION;
}

View File

@ -0,0 +1,90 @@
/*
* This file is generated by jOOQ.
*/
package com.rbkmoney.newway.domain.enums;
import com.rbkmoney.newway.domain.Nw;
import javax.annotation.Generated;
import org.jooq.Catalog;
import org.jooq.EnumType;
import org.jooq.Schema;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.6"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public enum BankCardPaymentSystem implements EnumType {
visa("visa"),
mastercard("mastercard"),
visaelectron("visaelectron"),
maestro("maestro"),
forbrugsforeningen("forbrugsforeningen"),
dankort("dankort"),
amex("amex"),
dinersclub("dinersclub"),
discover("discover"),
unionpay("unionpay"),
jcb("jcb"),
nspkmir("nspkmir");
private final String literal;
private BankCardPaymentSystem(String literal) {
this.literal = literal;
}
/**
* {@inheritDoc}
*/
@Override
public Catalog getCatalog() {
return getSchema() == null ? null : getSchema().getCatalog();
}
/**
* {@inheritDoc}
*/
@Override
public Schema getSchema() {
return Nw.NW;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "bank_card_payment_system";
}
/**
* {@inheritDoc}
*/
@Override
public String getLiteral() {
return literal;
}
}

View File

@ -0,0 +1,72 @@
/*
* This file is generated by jOOQ.
*/
package com.rbkmoney.newway.domain.enums;
import com.rbkmoney.newway.domain.Nw;
import javax.annotation.Generated;
import org.jooq.Catalog;
import org.jooq.EnumType;
import org.jooq.Schema;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.6"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public enum WithdrawalSessionStatus implements EnumType {
active("active"),
success("success"),
failed("failed");
private final String literal;
private WithdrawalSessionStatus(String literal) {
this.literal = literal;
}
/**
* {@inheritDoc}
*/
@Override
public Catalog getCatalog() {
return getSchema() == null ? null : getSchema().getCatalog();
}
/**
* {@inheritDoc}
*/
@Override
public Schema getSchema() {
return Nw.NW;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "withdrawal_session_status";
}
/**
* {@inheritDoc}
*/
@Override
public String getLiteral() {
return literal;
}
}

View File

@ -0,0 +1,275 @@
/*
* This file is generated by jOOQ.
*/
package com.rbkmoney.newway.domain.tables;
import com.rbkmoney.newway.domain.Keys;
import com.rbkmoney.newway.domain.Nw;
import com.rbkmoney.newway.domain.enums.BankCardPaymentSystem;
import com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus;
import com.rbkmoney.newway.domain.tables.records.WithdrawalSessionRecord;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Generated;
import org.jooq.Field;
import org.jooq.Identity;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.UniqueKey;
import org.jooq.impl.TableImpl;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.6"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class WithdrawalSession extends TableImpl<WithdrawalSessionRecord> {
private static final long serialVersionUID = 1576349985;
/**
* The reference instance of <code>nw.withdrawal_session</code>
*/
public static final WithdrawalSession WITHDRAWAL_SESSION = new WithdrawalSession();
/**
* The class holding records for this type
*/
@Override
public Class<WithdrawalSessionRecord> getRecordType() {
return WithdrawalSessionRecord.class;
}
/**
* The column <code>nw.withdrawal_session.id</code>.
*/
public final TableField<WithdrawalSessionRecord, Long> ID = createField("id", org.jooq.impl.SQLDataType.BIGINT.nullable(false).defaultValue(org.jooq.impl.DSL.field("nextval('nw.withdrawal_session_id_seq'::regclass)", org.jooq.impl.SQLDataType.BIGINT)), this, "");
/**
* The column <code>nw.withdrawal_session.event_id</code>.
*/
public final TableField<WithdrawalSessionRecord, Long> EVENT_ID = createField("event_id", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.event_created_at</code>.
*/
public final TableField<WithdrawalSessionRecord, LocalDateTime> EVENT_CREATED_AT = createField("event_created_at", org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.event_occured_at</code>.
*/
public final TableField<WithdrawalSessionRecord, LocalDateTime> EVENT_OCCURED_AT = createField("event_occured_at", org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.sequence_id</code>.
*/
public final TableField<WithdrawalSessionRecord, Integer> SEQUENCE_ID = createField("sequence_id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.withdrawal_session_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> WITHDRAWAL_SESSION_ID = createField("withdrawal_session_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.withdrawal_session_status</code>.
*/
public final TableField<WithdrawalSessionRecord, WithdrawalSessionStatus> WITHDRAWAL_SESSION_STATUS = createField("withdrawal_session_status", org.jooq.util.postgres.PostgresDataType.VARCHAR.asEnumDataType(com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus.class), this, "");
/**
* The column <code>nw.withdrawal_session.provider_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> PROVIDER_ID = createField("provider_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.withdrawal_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> WITHDRAWAL_ID = createField("withdrawal_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.destination_name</code>.
*/
public final TableField<WithdrawalSessionRecord, String> DESTINATION_NAME = createField("destination_name", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.destination_card_token</code>.
*/
public final TableField<WithdrawalSessionRecord, String> DESTINATION_CARD_TOKEN = createField("destination_card_token", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.destination_card_payment_system</code>.
*/
public final TableField<WithdrawalSessionRecord, BankCardPaymentSystem> DESTINATION_CARD_PAYMENT_SYSTEM = createField("destination_card_payment_system", org.jooq.util.postgres.PostgresDataType.VARCHAR.asEnumDataType(com.rbkmoney.newway.domain.enums.BankCardPaymentSystem.class), this, "");
/**
* The column <code>nw.withdrawal_session.destination_card_bin</code>.
*/
public final TableField<WithdrawalSessionRecord, String> DESTINATION_CARD_BIN = createField("destination_card_bin", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.destination_card_masked_pan</code>.
*/
public final TableField<WithdrawalSessionRecord, String> DESTINATION_CARD_MASKED_PAN = createField("destination_card_masked_pan", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.amount</code>.
*/
public final TableField<WithdrawalSessionRecord, Long> AMOUNT = createField("amount", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.currency_code</code>.
*/
public final TableField<WithdrawalSessionRecord, String> CURRENCY_CODE = createField("currency_code", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.sender_party_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> SENDER_PARTY_ID = createField("sender_party_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.sender_provider_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> SENDER_PROVIDER_ID = createField("sender_provider_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.sender_class_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> SENDER_CLASS_ID = createField("sender_class_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.sender_contract_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> SENDER_CONTRACT_ID = createField("sender_contract_id", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.receiver_party_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> RECEIVER_PARTY_ID = createField("receiver_party_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.receiver_provider_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> RECEIVER_PROVIDER_ID = createField("receiver_provider_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.receiver_class_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> RECEIVER_CLASS_ID = createField("receiver_class_id", org.jooq.impl.SQLDataType.VARCHAR.nullable(false), this, "");
/**
* The column <code>nw.withdrawal_session.receiver_contract_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> RECEIVER_CONTRACT_ID = createField("receiver_contract_id", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.adapter_state</code>.
*/
public final TableField<WithdrawalSessionRecord, String> ADAPTER_STATE = createField("adapter_state", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.tran_info_id</code>.
*/
public final TableField<WithdrawalSessionRecord, String> TRAN_INFO_ID = createField("tran_info_id", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.tran_info_timestamp</code>.
*/
public final TableField<WithdrawalSessionRecord, LocalDateTime> TRAN_INFO_TIMESTAMP = createField("tran_info_timestamp", org.jooq.impl.SQLDataType.LOCALDATETIME, this, "");
/**
* The column <code>nw.withdrawal_session.tran_info_json</code>.
*/
public final TableField<WithdrawalSessionRecord, String> TRAN_INFO_JSON = createField("tran_info_json", org.jooq.impl.SQLDataType.VARCHAR, this, "");
/**
* The column <code>nw.withdrawal_session.wtime</code>.
*/
public final TableField<WithdrawalSessionRecord, LocalDateTime> WTIME = createField("wtime", org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.field("timezone('utc'::text, now())", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "");
/**
* The column <code>nw.withdrawal_session.current</code>.
*/
public final TableField<WithdrawalSessionRecord, Boolean> CURRENT = createField("current", org.jooq.impl.SQLDataType.BOOLEAN.nullable(false).defaultValue(org.jooq.impl.DSL.field("true", org.jooq.impl.SQLDataType.BOOLEAN)), this, "");
/**
* Create a <code>nw.withdrawal_session</code> table reference
*/
public WithdrawalSession() {
this("withdrawal_session", null);
}
/**
* Create an aliased <code>nw.withdrawal_session</code> table reference
*/
public WithdrawalSession(String alias) {
this(alias, WITHDRAWAL_SESSION);
}
private WithdrawalSession(String alias, Table<WithdrawalSessionRecord> aliased) {
this(alias, aliased, null);
}
private WithdrawalSession(String alias, Table<WithdrawalSessionRecord> aliased, Field<?>[] parameters) {
super(alias, null, aliased, parameters, "");
}
/**
* {@inheritDoc}
*/
@Override
public Schema getSchema() {
return Nw.NW;
}
/**
* {@inheritDoc}
*/
@Override
public Identity<WithdrawalSessionRecord, Long> getIdentity() {
return Keys.IDENTITY_WITHDRAWAL_SESSION;
}
/**
* {@inheritDoc}
*/
@Override
public UniqueKey<WithdrawalSessionRecord> getPrimaryKey() {
return Keys.WITHDRAWAL_SESSION_PK;
}
/**
* {@inheritDoc}
*/
@Override
public List<UniqueKey<WithdrawalSessionRecord>> getKeys() {
return Arrays.<UniqueKey<WithdrawalSessionRecord>>asList(Keys.WITHDRAWAL_SESSION_PK);
}
/**
* {@inheritDoc}
*/
@Override
public WithdrawalSession as(String alias) {
return new WithdrawalSession(alias, this);
}
/**
* Rename this table
*/
@Override
public WithdrawalSession rename(String name) {
return new WithdrawalSession(name, null);
}
}

View File

@ -0,0 +1,668 @@
/*
* This file is generated by jOOQ.
*/
package com.rbkmoney.newway.domain.tables.pojos;
import com.rbkmoney.newway.domain.enums.BankCardPaymentSystem;
import com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus;
import java.io.Serializable;
import java.time.LocalDateTime;
import javax.annotation.Generated;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.6"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class WithdrawalSession implements Serializable {
private static final long serialVersionUID = 1345427918;
private Long id;
private Long eventId;
private LocalDateTime eventCreatedAt;
private LocalDateTime eventOccuredAt;
private Integer sequenceId;
private String withdrawalSessionId;
private WithdrawalSessionStatus withdrawalSessionStatus;
private String providerId;
private String withdrawalId;
private String destinationName;
private String destinationCardToken;
private BankCardPaymentSystem destinationCardPaymentSystem;
private String destinationCardBin;
private String destinationCardMaskedPan;
private Long amount;
private String currencyCode;
private String senderPartyId;
private String senderProviderId;
private String senderClassId;
private String senderContractId;
private String receiverPartyId;
private String receiverProviderId;
private String receiverClassId;
private String receiverContractId;
private String adapterState;
private String tranInfoId;
private LocalDateTime tranInfoTimestamp;
private String tranInfoJson;
private LocalDateTime wtime;
private Boolean current;
public WithdrawalSession() {}
public WithdrawalSession(WithdrawalSession value) {
this.id = value.id;
this.eventId = value.eventId;
this.eventCreatedAt = value.eventCreatedAt;
this.eventOccuredAt = value.eventOccuredAt;
this.sequenceId = value.sequenceId;
this.withdrawalSessionId = value.withdrawalSessionId;
this.withdrawalSessionStatus = value.withdrawalSessionStatus;
this.providerId = value.providerId;
this.withdrawalId = value.withdrawalId;
this.destinationName = value.destinationName;
this.destinationCardToken = value.destinationCardToken;
this.destinationCardPaymentSystem = value.destinationCardPaymentSystem;
this.destinationCardBin = value.destinationCardBin;
this.destinationCardMaskedPan = value.destinationCardMaskedPan;
this.amount = value.amount;
this.currencyCode = value.currencyCode;
this.senderPartyId = value.senderPartyId;
this.senderProviderId = value.senderProviderId;
this.senderClassId = value.senderClassId;
this.senderContractId = value.senderContractId;
this.receiverPartyId = value.receiverPartyId;
this.receiverProviderId = value.receiverProviderId;
this.receiverClassId = value.receiverClassId;
this.receiverContractId = value.receiverContractId;
this.adapterState = value.adapterState;
this.tranInfoId = value.tranInfoId;
this.tranInfoTimestamp = value.tranInfoTimestamp;
this.tranInfoJson = value.tranInfoJson;
this.wtime = value.wtime;
this.current = value.current;
}
public WithdrawalSession(
Long id,
Long eventId,
LocalDateTime eventCreatedAt,
LocalDateTime eventOccuredAt,
Integer sequenceId,
String withdrawalSessionId,
WithdrawalSessionStatus withdrawalSessionStatus,
String providerId,
String withdrawalId,
String destinationName,
String destinationCardToken,
BankCardPaymentSystem destinationCardPaymentSystem,
String destinationCardBin,
String destinationCardMaskedPan,
Long amount,
String currencyCode,
String senderPartyId,
String senderProviderId,
String senderClassId,
String senderContractId,
String receiverPartyId,
String receiverProviderId,
String receiverClassId,
String receiverContractId,
String adapterState,
String tranInfoId,
LocalDateTime tranInfoTimestamp,
String tranInfoJson,
LocalDateTime wtime,
Boolean current
) {
this.id = id;
this.eventId = eventId;
this.eventCreatedAt = eventCreatedAt;
this.eventOccuredAt = eventOccuredAt;
this.sequenceId = sequenceId;
this.withdrawalSessionId = withdrawalSessionId;
this.withdrawalSessionStatus = withdrawalSessionStatus;
this.providerId = providerId;
this.withdrawalId = withdrawalId;
this.destinationName = destinationName;
this.destinationCardToken = destinationCardToken;
this.destinationCardPaymentSystem = destinationCardPaymentSystem;
this.destinationCardBin = destinationCardBin;
this.destinationCardMaskedPan = destinationCardMaskedPan;
this.amount = amount;
this.currencyCode = currencyCode;
this.senderPartyId = senderPartyId;
this.senderProviderId = senderProviderId;
this.senderClassId = senderClassId;
this.senderContractId = senderContractId;
this.receiverPartyId = receiverPartyId;
this.receiverProviderId = receiverProviderId;
this.receiverClassId = receiverClassId;
this.receiverContractId = receiverContractId;
this.adapterState = adapterState;
this.tranInfoId = tranInfoId;
this.tranInfoTimestamp = tranInfoTimestamp;
this.tranInfoJson = tranInfoJson;
this.wtime = wtime;
this.current = current;
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getEventId() {
return this.eventId;
}
public void setEventId(Long eventId) {
this.eventId = eventId;
}
public LocalDateTime getEventCreatedAt() {
return this.eventCreatedAt;
}
public void setEventCreatedAt(LocalDateTime eventCreatedAt) {
this.eventCreatedAt = eventCreatedAt;
}
public LocalDateTime getEventOccuredAt() {
return this.eventOccuredAt;
}
public void setEventOccuredAt(LocalDateTime eventOccuredAt) {
this.eventOccuredAt = eventOccuredAt;
}
public Integer getSequenceId() {
return this.sequenceId;
}
public void setSequenceId(Integer sequenceId) {
this.sequenceId = sequenceId;
}
public String getWithdrawalSessionId() {
return this.withdrawalSessionId;
}
public void setWithdrawalSessionId(String withdrawalSessionId) {
this.withdrawalSessionId = withdrawalSessionId;
}
public WithdrawalSessionStatus getWithdrawalSessionStatus() {
return this.withdrawalSessionStatus;
}
public void setWithdrawalSessionStatus(WithdrawalSessionStatus withdrawalSessionStatus) {
this.withdrawalSessionStatus = withdrawalSessionStatus;
}
public String getProviderId() {
return this.providerId;
}
public void setProviderId(String providerId) {
this.providerId = providerId;
}
public String getWithdrawalId() {
return this.withdrawalId;
}
public void setWithdrawalId(String withdrawalId) {
this.withdrawalId = withdrawalId;
}
public String getDestinationName() {
return this.destinationName;
}
public void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
public String getDestinationCardToken() {
return this.destinationCardToken;
}
public void setDestinationCardToken(String destinationCardToken) {
this.destinationCardToken = destinationCardToken;
}
public BankCardPaymentSystem getDestinationCardPaymentSystem() {
return this.destinationCardPaymentSystem;
}
public void setDestinationCardPaymentSystem(BankCardPaymentSystem destinationCardPaymentSystem) {
this.destinationCardPaymentSystem = destinationCardPaymentSystem;
}
public String getDestinationCardBin() {
return this.destinationCardBin;
}
public void setDestinationCardBin(String destinationCardBin) {
this.destinationCardBin = destinationCardBin;
}
public String getDestinationCardMaskedPan() {
return this.destinationCardMaskedPan;
}
public void setDestinationCardMaskedPan(String destinationCardMaskedPan) {
this.destinationCardMaskedPan = destinationCardMaskedPan;
}
public Long getAmount() {
return this.amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public String getCurrencyCode() {
return this.currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
public String getSenderPartyId() {
return this.senderPartyId;
}
public void setSenderPartyId(String senderPartyId) {
this.senderPartyId = senderPartyId;
}
public String getSenderProviderId() {
return this.senderProviderId;
}
public void setSenderProviderId(String senderProviderId) {
this.senderProviderId = senderProviderId;
}
public String getSenderClassId() {
return this.senderClassId;
}
public void setSenderClassId(String senderClassId) {
this.senderClassId = senderClassId;
}
public String getSenderContractId() {
return this.senderContractId;
}
public void setSenderContractId(String senderContractId) {
this.senderContractId = senderContractId;
}
public String getReceiverPartyId() {
return this.receiverPartyId;
}
public void setReceiverPartyId(String receiverPartyId) {
this.receiverPartyId = receiverPartyId;
}
public String getReceiverProviderId() {
return this.receiverProviderId;
}
public void setReceiverProviderId(String receiverProviderId) {
this.receiverProviderId = receiverProviderId;
}
public String getReceiverClassId() {
return this.receiverClassId;
}
public void setReceiverClassId(String receiverClassId) {
this.receiverClassId = receiverClassId;
}
public String getReceiverContractId() {
return this.receiverContractId;
}
public void setReceiverContractId(String receiverContractId) {
this.receiverContractId = receiverContractId;
}
public String getAdapterState() {
return this.adapterState;
}
public void setAdapterState(String adapterState) {
this.adapterState = adapterState;
}
public String getTranInfoId() {
return this.tranInfoId;
}
public void setTranInfoId(String tranInfoId) {
this.tranInfoId = tranInfoId;
}
public LocalDateTime getTranInfoTimestamp() {
return this.tranInfoTimestamp;
}
public void setTranInfoTimestamp(LocalDateTime tranInfoTimestamp) {
this.tranInfoTimestamp = tranInfoTimestamp;
}
public String getTranInfoJson() {
return this.tranInfoJson;
}
public void setTranInfoJson(String tranInfoJson) {
this.tranInfoJson = tranInfoJson;
}
public LocalDateTime getWtime() {
return this.wtime;
}
public void setWtime(LocalDateTime wtime) {
this.wtime = wtime;
}
public Boolean getCurrent() {
return this.current;
}
public void setCurrent(Boolean current) {
this.current = current;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final WithdrawalSession other = (WithdrawalSession) obj;
if (id == null) {
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (eventId == null) {
if (other.eventId != null)
return false;
}
else if (!eventId.equals(other.eventId))
return false;
if (eventCreatedAt == null) {
if (other.eventCreatedAt != null)
return false;
}
else if (!eventCreatedAt.equals(other.eventCreatedAt))
return false;
if (eventOccuredAt == null) {
if (other.eventOccuredAt != null)
return false;
}
else if (!eventOccuredAt.equals(other.eventOccuredAt))
return false;
if (sequenceId == null) {
if (other.sequenceId != null)
return false;
}
else if (!sequenceId.equals(other.sequenceId))
return false;
if (withdrawalSessionId == null) {
if (other.withdrawalSessionId != null)
return false;
}
else if (!withdrawalSessionId.equals(other.withdrawalSessionId))
return false;
if (withdrawalSessionStatus == null) {
if (other.withdrawalSessionStatus != null)
return false;
}
else if (!withdrawalSessionStatus.equals(other.withdrawalSessionStatus))
return false;
if (providerId == null) {
if (other.providerId != null)
return false;
}
else if (!providerId.equals(other.providerId))
return false;
if (withdrawalId == null) {
if (other.withdrawalId != null)
return false;
}
else if (!withdrawalId.equals(other.withdrawalId))
return false;
if (destinationName == null) {
if (other.destinationName != null)
return false;
}
else if (!destinationName.equals(other.destinationName))
return false;
if (destinationCardToken == null) {
if (other.destinationCardToken != null)
return false;
}
else if (!destinationCardToken.equals(other.destinationCardToken))
return false;
if (destinationCardPaymentSystem == null) {
if (other.destinationCardPaymentSystem != null)
return false;
}
else if (!destinationCardPaymentSystem.equals(other.destinationCardPaymentSystem))
return false;
if (destinationCardBin == null) {
if (other.destinationCardBin != null)
return false;
}
else if (!destinationCardBin.equals(other.destinationCardBin))
return false;
if (destinationCardMaskedPan == null) {
if (other.destinationCardMaskedPan != null)
return false;
}
else if (!destinationCardMaskedPan.equals(other.destinationCardMaskedPan))
return false;
if (amount == null) {
if (other.amount != null)
return false;
}
else if (!amount.equals(other.amount))
return false;
if (currencyCode == null) {
if (other.currencyCode != null)
return false;
}
else if (!currencyCode.equals(other.currencyCode))
return false;
if (senderPartyId == null) {
if (other.senderPartyId != null)
return false;
}
else if (!senderPartyId.equals(other.senderPartyId))
return false;
if (senderProviderId == null) {
if (other.senderProviderId != null)
return false;
}
else if (!senderProviderId.equals(other.senderProviderId))
return false;
if (senderClassId == null) {
if (other.senderClassId != null)
return false;
}
else if (!senderClassId.equals(other.senderClassId))
return false;
if (senderContractId == null) {
if (other.senderContractId != null)
return false;
}
else if (!senderContractId.equals(other.senderContractId))
return false;
if (receiverPartyId == null) {
if (other.receiverPartyId != null)
return false;
}
else if (!receiverPartyId.equals(other.receiverPartyId))
return false;
if (receiverProviderId == null) {
if (other.receiverProviderId != null)
return false;
}
else if (!receiverProviderId.equals(other.receiverProviderId))
return false;
if (receiverClassId == null) {
if (other.receiverClassId != null)
return false;
}
else if (!receiverClassId.equals(other.receiverClassId))
return false;
if (receiverContractId == null) {
if (other.receiverContractId != null)
return false;
}
else if (!receiverContractId.equals(other.receiverContractId))
return false;
if (adapterState == null) {
if (other.adapterState != null)
return false;
}
else if (!adapterState.equals(other.adapterState))
return false;
if (tranInfoId == null) {
if (other.tranInfoId != null)
return false;
}
else if (!tranInfoId.equals(other.tranInfoId))
return false;
if (tranInfoTimestamp == null) {
if (other.tranInfoTimestamp != null)
return false;
}
else if (!tranInfoTimestamp.equals(other.tranInfoTimestamp))
return false;
if (tranInfoJson == null) {
if (other.tranInfoJson != null)
return false;
}
else if (!tranInfoJson.equals(other.tranInfoJson))
return false;
if (wtime == null) {
if (other.wtime != null)
return false;
}
else if (!wtime.equals(other.wtime))
return false;
if (current == null) {
if (other.current != null)
return false;
}
else if (!current.equals(other.current))
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
result = prime * result + ((this.eventId == null) ? 0 : this.eventId.hashCode());
result = prime * result + ((this.eventCreatedAt == null) ? 0 : this.eventCreatedAt.hashCode());
result = prime * result + ((this.eventOccuredAt == null) ? 0 : this.eventOccuredAt.hashCode());
result = prime * result + ((this.sequenceId == null) ? 0 : this.sequenceId.hashCode());
result = prime * result + ((this.withdrawalSessionId == null) ? 0 : this.withdrawalSessionId.hashCode());
result = prime * result + ((this.withdrawalSessionStatus == null) ? 0 : this.withdrawalSessionStatus.hashCode());
result = prime * result + ((this.providerId == null) ? 0 : this.providerId.hashCode());
result = prime * result + ((this.withdrawalId == null) ? 0 : this.withdrawalId.hashCode());
result = prime * result + ((this.destinationName == null) ? 0 : this.destinationName.hashCode());
result = prime * result + ((this.destinationCardToken == null) ? 0 : this.destinationCardToken.hashCode());
result = prime * result + ((this.destinationCardPaymentSystem == null) ? 0 : this.destinationCardPaymentSystem.hashCode());
result = prime * result + ((this.destinationCardBin == null) ? 0 : this.destinationCardBin.hashCode());
result = prime * result + ((this.destinationCardMaskedPan == null) ? 0 : this.destinationCardMaskedPan.hashCode());
result = prime * result + ((this.amount == null) ? 0 : this.amount.hashCode());
result = prime * result + ((this.currencyCode == null) ? 0 : this.currencyCode.hashCode());
result = prime * result + ((this.senderPartyId == null) ? 0 : this.senderPartyId.hashCode());
result = prime * result + ((this.senderProviderId == null) ? 0 : this.senderProviderId.hashCode());
result = prime * result + ((this.senderClassId == null) ? 0 : this.senderClassId.hashCode());
result = prime * result + ((this.senderContractId == null) ? 0 : this.senderContractId.hashCode());
result = prime * result + ((this.receiverPartyId == null) ? 0 : this.receiverPartyId.hashCode());
result = prime * result + ((this.receiverProviderId == null) ? 0 : this.receiverProviderId.hashCode());
result = prime * result + ((this.receiverClassId == null) ? 0 : this.receiverClassId.hashCode());
result = prime * result + ((this.receiverContractId == null) ? 0 : this.receiverContractId.hashCode());
result = prime * result + ((this.adapterState == null) ? 0 : this.adapterState.hashCode());
result = prime * result + ((this.tranInfoId == null) ? 0 : this.tranInfoId.hashCode());
result = prime * result + ((this.tranInfoTimestamp == null) ? 0 : this.tranInfoTimestamp.hashCode());
result = prime * result + ((this.tranInfoJson == null) ? 0 : this.tranInfoJson.hashCode());
result = prime * result + ((this.wtime == null) ? 0 : this.wtime.hashCode());
result = prime * result + ((this.current == null) ? 0 : this.current.hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("WithdrawalSession (");
sb.append(id);
sb.append(", ").append(eventId);
sb.append(", ").append(eventCreatedAt);
sb.append(", ").append(eventOccuredAt);
sb.append(", ").append(sequenceId);
sb.append(", ").append(withdrawalSessionId);
sb.append(", ").append(withdrawalSessionStatus);
sb.append(", ").append(providerId);
sb.append(", ").append(withdrawalId);
sb.append(", ").append(destinationName);
sb.append(", ").append(destinationCardToken);
sb.append(", ").append(destinationCardPaymentSystem);
sb.append(", ").append(destinationCardBin);
sb.append(", ").append(destinationCardMaskedPan);
sb.append(", ").append(amount);
sb.append(", ").append(currencyCode);
sb.append(", ").append(senderPartyId);
sb.append(", ").append(senderProviderId);
sb.append(", ").append(senderClassId);
sb.append(", ").append(senderContractId);
sb.append(", ").append(receiverPartyId);
sb.append(", ").append(receiverProviderId);
sb.append(", ").append(receiverClassId);
sb.append(", ").append(receiverContractId);
sb.append(", ").append(adapterState);
sb.append(", ").append(tranInfoId);
sb.append(", ").append(tranInfoTimestamp);
sb.append(", ").append(tranInfoJson);
sb.append(", ").append(wtime);
sb.append(", ").append(current);
sb.append(")");
return sb.toString();
}
}

View File

@ -0,0 +1,514 @@
/*
* This file is generated by jOOQ.
*/
package com.rbkmoney.newway.domain.tables.records;
import com.rbkmoney.newway.domain.enums.BankCardPaymentSystem;
import com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus;
import com.rbkmoney.newway.domain.tables.WithdrawalSession;
import java.time.LocalDateTime;
import javax.annotation.Generated;
import org.jooq.Record1;
import org.jooq.impl.UpdatableRecordImpl;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.9.6"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class WithdrawalSessionRecord extends UpdatableRecordImpl<WithdrawalSessionRecord> {
private static final long serialVersionUID = -1547180933;
/**
* Setter for <code>nw.withdrawal_session.id</code>.
*/
public void setId(Long value) {
set(0, value);
}
/**
* Getter for <code>nw.withdrawal_session.id</code>.
*/
public Long getId() {
return (Long) get(0);
}
/**
* Setter for <code>nw.withdrawal_session.event_id</code>.
*/
public void setEventId(Long value) {
set(1, value);
}
/**
* Getter for <code>nw.withdrawal_session.event_id</code>.
*/
public Long getEventId() {
return (Long) get(1);
}
/**
* Setter for <code>nw.withdrawal_session.event_created_at</code>.
*/
public void setEventCreatedAt(LocalDateTime value) {
set(2, value);
}
/**
* Getter for <code>nw.withdrawal_session.event_created_at</code>.
*/
public LocalDateTime getEventCreatedAt() {
return (LocalDateTime) get(2);
}
/**
* Setter for <code>nw.withdrawal_session.event_occured_at</code>.
*/
public void setEventOccuredAt(LocalDateTime value) {
set(3, value);
}
/**
* Getter for <code>nw.withdrawal_session.event_occured_at</code>.
*/
public LocalDateTime getEventOccuredAt() {
return (LocalDateTime) get(3);
}
/**
* Setter for <code>nw.withdrawal_session.sequence_id</code>.
*/
public void setSequenceId(Integer value) {
set(4, value);
}
/**
* Getter for <code>nw.withdrawal_session.sequence_id</code>.
*/
public Integer getSequenceId() {
return (Integer) get(4);
}
/**
* Setter for <code>nw.withdrawal_session.withdrawal_session_id</code>.
*/
public void setWithdrawalSessionId(String value) {
set(5, value);
}
/**
* Getter for <code>nw.withdrawal_session.withdrawal_session_id</code>.
*/
public String getWithdrawalSessionId() {
return (String) get(5);
}
/**
* Setter for <code>nw.withdrawal_session.withdrawal_session_status</code>.
*/
public void setWithdrawalSessionStatus(WithdrawalSessionStatus value) {
set(6, value);
}
/**
* Getter for <code>nw.withdrawal_session.withdrawal_session_status</code>.
*/
public WithdrawalSessionStatus getWithdrawalSessionStatus() {
return (WithdrawalSessionStatus) get(6);
}
/**
* Setter for <code>nw.withdrawal_session.provider_id</code>.
*/
public void setProviderId(String value) {
set(7, value);
}
/**
* Getter for <code>nw.withdrawal_session.provider_id</code>.
*/
public String getProviderId() {
return (String) get(7);
}
/**
* Setter for <code>nw.withdrawal_session.withdrawal_id</code>.
*/
public void setWithdrawalId(String value) {
set(8, value);
}
/**
* Getter for <code>nw.withdrawal_session.withdrawal_id</code>.
*/
public String getWithdrawalId() {
return (String) get(8);
}
/**
* Setter for <code>nw.withdrawal_session.destination_name</code>.
*/
public void setDestinationName(String value) {
set(9, value);
}
/**
* Getter for <code>nw.withdrawal_session.destination_name</code>.
*/
public String getDestinationName() {
return (String) get(9);
}
/**
* Setter for <code>nw.withdrawal_session.destination_card_token</code>.
*/
public void setDestinationCardToken(String value) {
set(10, value);
}
/**
* Getter for <code>nw.withdrawal_session.destination_card_token</code>.
*/
public String getDestinationCardToken() {
return (String) get(10);
}
/**
* Setter for <code>nw.withdrawal_session.destination_card_payment_system</code>.
*/
public void setDestinationCardPaymentSystem(BankCardPaymentSystem value) {
set(11, value);
}
/**
* Getter for <code>nw.withdrawal_session.destination_card_payment_system</code>.
*/
public BankCardPaymentSystem getDestinationCardPaymentSystem() {
return (BankCardPaymentSystem) get(11);
}
/**
* Setter for <code>nw.withdrawal_session.destination_card_bin</code>.
*/
public void setDestinationCardBin(String value) {
set(12, value);
}
/**
* Getter for <code>nw.withdrawal_session.destination_card_bin</code>.
*/
public String getDestinationCardBin() {
return (String) get(12);
}
/**
* Setter for <code>nw.withdrawal_session.destination_card_masked_pan</code>.
*/
public void setDestinationCardMaskedPan(String value) {
set(13, value);
}
/**
* Getter for <code>nw.withdrawal_session.destination_card_masked_pan</code>.
*/
public String getDestinationCardMaskedPan() {
return (String) get(13);
}
/**
* Setter for <code>nw.withdrawal_session.amount</code>.
*/
public void setAmount(Long value) {
set(14, value);
}
/**
* Getter for <code>nw.withdrawal_session.amount</code>.
*/
public Long getAmount() {
return (Long) get(14);
}
/**
* Setter for <code>nw.withdrawal_session.currency_code</code>.
*/
public void setCurrencyCode(String value) {
set(15, value);
}
/**
* Getter for <code>nw.withdrawal_session.currency_code</code>.
*/
public String getCurrencyCode() {
return (String) get(15);
}
/**
* Setter for <code>nw.withdrawal_session.sender_party_id</code>.
*/
public void setSenderPartyId(String value) {
set(16, value);
}
/**
* Getter for <code>nw.withdrawal_session.sender_party_id</code>.
*/
public String getSenderPartyId() {
return (String) get(16);
}
/**
* Setter for <code>nw.withdrawal_session.sender_provider_id</code>.
*/
public void setSenderProviderId(String value) {
set(17, value);
}
/**
* Getter for <code>nw.withdrawal_session.sender_provider_id</code>.
*/
public String getSenderProviderId() {
return (String) get(17);
}
/**
* Setter for <code>nw.withdrawal_session.sender_class_id</code>.
*/
public void setSenderClassId(String value) {
set(18, value);
}
/**
* Getter for <code>nw.withdrawal_session.sender_class_id</code>.
*/
public String getSenderClassId() {
return (String) get(18);
}
/**
* Setter for <code>nw.withdrawal_session.sender_contract_id</code>.
*/
public void setSenderContractId(String value) {
set(19, value);
}
/**
* Getter for <code>nw.withdrawal_session.sender_contract_id</code>.
*/
public String getSenderContractId() {
return (String) get(19);
}
/**
* Setter for <code>nw.withdrawal_session.receiver_party_id</code>.
*/
public void setReceiverPartyId(String value) {
set(20, value);
}
/**
* Getter for <code>nw.withdrawal_session.receiver_party_id</code>.
*/
public String getReceiverPartyId() {
return (String) get(20);
}
/**
* Setter for <code>nw.withdrawal_session.receiver_provider_id</code>.
*/
public void setReceiverProviderId(String value) {
set(21, value);
}
/**
* Getter for <code>nw.withdrawal_session.receiver_provider_id</code>.
*/
public String getReceiverProviderId() {
return (String) get(21);
}
/**
* Setter for <code>nw.withdrawal_session.receiver_class_id</code>.
*/
public void setReceiverClassId(String value) {
set(22, value);
}
/**
* Getter for <code>nw.withdrawal_session.receiver_class_id</code>.
*/
public String getReceiverClassId() {
return (String) get(22);
}
/**
* Setter for <code>nw.withdrawal_session.receiver_contract_id</code>.
*/
public void setReceiverContractId(String value) {
set(23, value);
}
/**
* Getter for <code>nw.withdrawal_session.receiver_contract_id</code>.
*/
public String getReceiverContractId() {
return (String) get(23);
}
/**
* Setter for <code>nw.withdrawal_session.adapter_state</code>.
*/
public void setAdapterState(String value) {
set(24, value);
}
/**
* Getter for <code>nw.withdrawal_session.adapter_state</code>.
*/
public String getAdapterState() {
return (String) get(24);
}
/**
* Setter for <code>nw.withdrawal_session.tran_info_id</code>.
*/
public void setTranInfoId(String value) {
set(25, value);
}
/**
* Getter for <code>nw.withdrawal_session.tran_info_id</code>.
*/
public String getTranInfoId() {
return (String) get(25);
}
/**
* Setter for <code>nw.withdrawal_session.tran_info_timestamp</code>.
*/
public void setTranInfoTimestamp(LocalDateTime value) {
set(26, value);
}
/**
* Getter for <code>nw.withdrawal_session.tran_info_timestamp</code>.
*/
public LocalDateTime getTranInfoTimestamp() {
return (LocalDateTime) get(26);
}
/**
* Setter for <code>nw.withdrawal_session.tran_info_json</code>.
*/
public void setTranInfoJson(String value) {
set(27, value);
}
/**
* Getter for <code>nw.withdrawal_session.tran_info_json</code>.
*/
public String getTranInfoJson() {
return (String) get(27);
}
/**
* Setter for <code>nw.withdrawal_session.wtime</code>.
*/
public void setWtime(LocalDateTime value) {
set(28, value);
}
/**
* Getter for <code>nw.withdrawal_session.wtime</code>.
*/
public LocalDateTime getWtime() {
return (LocalDateTime) get(28);
}
/**
* Setter for <code>nw.withdrawal_session.current</code>.
*/
public void setCurrent(Boolean value) {
set(29, value);
}
/**
* Getter for <code>nw.withdrawal_session.current</code>.
*/
public Boolean getCurrent() {
return (Boolean) get(29);
}
// -------------------------------------------------------------------------
// Primary key information
// -------------------------------------------------------------------------
/**
* {@inheritDoc}
*/
@Override
public Record1<Long> key() {
return (Record1) super.key();
}
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
/**
* Create a detached WithdrawalSessionRecord
*/
public WithdrawalSessionRecord() {
super(WithdrawalSession.WITHDRAWAL_SESSION);
}
/**
* Create a detached, initialised WithdrawalSessionRecord
*/
public WithdrawalSessionRecord(Long id, Long eventId, LocalDateTime eventCreatedAt, LocalDateTime eventOccuredAt, Integer sequenceId, String withdrawalSessionId, WithdrawalSessionStatus withdrawalSessionStatus, String providerId, String withdrawalId, String destinationName, String destinationCardToken, BankCardPaymentSystem destinationCardPaymentSystem, String destinationCardBin, String destinationCardMaskedPan, Long amount, String currencyCode, String senderPartyId, String senderProviderId, String senderClassId, String senderContractId, String receiverPartyId, String receiverProviderId, String receiverClassId, String receiverContractId, String adapterState, String tranInfoId, LocalDateTime tranInfoTimestamp, String tranInfoJson, LocalDateTime wtime, Boolean current) {
super(WithdrawalSession.WITHDRAWAL_SESSION);
set(0, id);
set(1, eventId);
set(2, eventCreatedAt);
set(3, eventOccuredAt);
set(4, sequenceId);
set(5, withdrawalSessionId);
set(6, withdrawalSessionStatus);
set(7, providerId);
set(8, withdrawalId);
set(9, destinationName);
set(10, destinationCardToken);
set(11, destinationCardPaymentSystem);
set(12, destinationCardBin);
set(13, destinationCardMaskedPan);
set(14, amount);
set(15, currencyCode);
set(16, senderPartyId);
set(17, senderProviderId);
set(18, senderClassId);
set(19, senderContractId);
set(20, receiverPartyId);
set(21, receiverProviderId);
set(22, receiverClassId);
set(23, receiverContractId);
set(24, adapterState);
set(25, tranInfoId);
set(26, tranInfoTimestamp);
set(27, tranInfoJson);
set(28, wtime);
set(29, current);
}
}

View File

@ -24,6 +24,7 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
private final EventPublisher depositEventPublisher;
private final EventPublisher sourceEventPublisher;
private final EventPublisher destinationEventPublisher;
private final EventPublisher withdrawalSessionEventPublisher;
private final PartyManagementService partyManagementService;
private final InvoicingService invoicingService;
@ -34,6 +35,7 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
private final SourceService sourceService;
private final DestinationService destinationService;
private final DepositService depositService;
private final WithdrawalSessionService withdrawalSessionService;
@Value("${bm.pollingEnabled}")
private boolean pollingEnabled;
@ -47,6 +49,8 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
EventPublisher sourceEventPublisher,
EventPublisher destinationEventPublisher,
EventPublisher depositEventPublisher,
EventPublisher withdrawalSessionEventPublisher,
PartyManagementService partyManagementService,
InvoicingService invoicingService,
PayoutService payoutService,
@ -55,7 +59,8 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
WithdrawalService withdrawalService,
SourceService sourceService,
DestinationService destinationService,
DepositService depositService) {
DepositService depositService,
WithdrawalSessionService withdrawalSessionService) {
this.partyManagementEventPublisher = partyManagementEventPublisher;
this.invoicingEventPublisher = invoicingEventPublisher;
this.payoutEventPublisher = payoutEventPublisher;
@ -65,6 +70,7 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
this.depositEventPublisher = depositEventPublisher;
this.sourceEventPublisher = sourceEventPublisher;
this.destinationEventPublisher = destinationEventPublisher;
this.withdrawalSessionEventPublisher = withdrawalSessionEventPublisher;
this.partyManagementService = partyManagementService;
this.invoicingService = invoicingService;
@ -75,6 +81,7 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
this.sourceService = sourceService;
this.destinationService = destinationService;
this.depositService = depositService;
this.withdrawalSessionService = withdrawalSessionService;
}
@Override
@ -89,7 +96,8 @@ public class OnStart implements ApplicationListener<ApplicationReadyEvent> {
destinationEventPublisher.subscribe(buildSubscriberConfig(destinationService.getLastEventId()));
depositEventPublisher.subscribe(buildSubscriberConfig(depositService.getLastEventId()));
withdrawalEventPublisher.subscribe(buildSubscriberConfig(withdrawalService.getLastEventId()));
}
withdrawalSessionEventPublisher.subscribe(buildSubscriberConfig(withdrawalSessionService.getLastEventId()));
}
}
private SubscriberConfig buildSubscriberConfig(Optional<Long> lastEventIdOptional) {

View File

@ -0,0 +1,33 @@
package com.rbkmoney.newway.poller.event_stock;
import com.rbkmoney.eventstock.client.EventAction;
import com.rbkmoney.eventstock.client.EventHandler;
import com.rbkmoney.fistful.withdrawal_session.SinkEvent;
import com.rbkmoney.newway.service.WithdrawalSessionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class WithdrawalSessionEventStockHandler implements EventHandler<SinkEvent> {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WithdrawalSessionService withdrawalSessionService;
public WithdrawalSessionEventStockHandler(WithdrawalSessionService withdrawalSessionService) {
this.withdrawalSessionService = withdrawalSessionService;
}
@Override
public EventAction handle(SinkEvent sinkEvent, String subsKey) {
try {
withdrawalSessionService.handleEvents(sinkEvent, sinkEvent.getPayload());
} catch (RuntimeException e) {
log.error("Error when polling withdrawal session event with id={}", sinkEvent.getId(), e);
return EventAction.DELAYED_RETRY;
}
return EventAction.CONTINUE;
}
}

View File

@ -0,0 +1,8 @@
package com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session;
import com.rbkmoney.fistful.withdrawal_session.Change;
import com.rbkmoney.fistful.withdrawal_session.SinkEvent;
import com.rbkmoney.newway.poller.event_stock.Handler;
public abstract class AbstractWithdrawalSessionHandler implements Handler<Change, SinkEvent> {
}

View File

@ -0,0 +1,73 @@
package com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session;
import com.rbkmoney.fistful.base.BankCard;
import com.rbkmoney.fistful.base.Cash;
import com.rbkmoney.fistful.withdrawal_session.*;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.domain.enums.BankCardPaymentSystem;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import static com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus.active;
@Component
public class WithdrawalSessionCreatedHandler extends AbstractWithdrawalSessionHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WithdrawalSessionDao withdrawalSessionDao;
private final Filter filter;
public WithdrawalSessionCreatedHandler(WithdrawalSessionDao withdrawalSessionDao) {
this.withdrawalSessionDao = withdrawalSessionDao;
this.filter = new PathConditionFilter(new PathConditionRule("created", new IsNullCondition().not()));
}
@Override
public void handle(Change change, SinkEvent event) {
log.info("Start withdrawal session created handling (eventId={}, sessionId={})", event.getId(), event.getSource());
WithdrawalSession withdrawalSession = new WithdrawalSession();
withdrawalSession.setEventId(event.getId());
withdrawalSession.setSequenceId(event.getPayload().getSequence());
withdrawalSession.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
withdrawalSession.setEventOccuredAt(TypeUtil.stringToLocalDateTime(event.getPayload().getOccuredAt()));
Session session = change.getCreated();
withdrawalSession.setWithdrawalSessionId(event.getSource());
withdrawalSession.setProviderId(session.getProvider());
withdrawalSession.setWithdrawalSessionStatus(active);
Withdrawal withdrawal = session.getWithdrawal();
withdrawalSession.setWithdrawalId(withdrawal.getId());
withdrawalSession.setDestinationName(withdrawal.getDestination().getName());
BankCard bankCard = withdrawal.getDestination().getResource().getBankCard();
withdrawalSession.setDestinationCardToken(bankCard.getToken());
withdrawalSession.setDestinationCardBin(bankCard.getBin());
withdrawalSession.setDestinationCardMaskedPan(bankCard.getMaskedPan());
withdrawalSession.setDestinationCardPaymentSystem(BankCardPaymentSystem.valueOf(bankCard.getPaymentSystem().name()));
Cash cash = withdrawal.getCash();
withdrawalSession.setAmount(cash.getAmount());
withdrawalSession.setCurrencyCode(cash.getCurrency().getSymbolicCode());
Long id = withdrawalSessionDao.save(withdrawalSession);
log.info("Withdrawal session have been saved: id={}, eventId={}, sessionId={}",
id, event.getId(), event.getSource());
}
@Override
public Filter<Change> getFilter() {
return filter;
}
}

View File

@ -0,0 +1,64 @@
package com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session;
import com.rbkmoney.fistful.withdrawal_session.Change;
import com.rbkmoney.fistful.withdrawal_session.SinkEvent;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.domain.enums.WithdrawalSessionStatus;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Component
public class WithdrawalSessionFinishedHandler extends AbstractWithdrawalSessionHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WithdrawalSessionDao withdrawalSessionDao;
private final Filter filter;
public WithdrawalSessionFinishedHandler(WithdrawalSessionDao withdrawalSessionDao) {
this.withdrawalSessionDao = withdrawalSessionDao;
this.filter = new PathConditionFilter(new PathConditionRule("finished", new IsNullCondition().not()));
}
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void handle(Change change, SinkEvent event) {
log.info("Start withdrawal session next state handling (eventId={}, sessionId={})",
event.getId(), event.getSource());
WithdrawalSession withdrawalSession = withdrawalSessionDao.get(event.getSource());
withdrawalSession.setId(null);
withdrawalSession.setWtime(null);
withdrawalSession.setEventId(event.getId());
withdrawalSession.setSequenceId(event.getPayload().getSequence());
withdrawalSession.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
withdrawalSession.setEventOccuredAt(TypeUtil.stringToLocalDateTime(event.getPayload().getOccuredAt()));
withdrawalSession.setWithdrawalSessionId(event.getSource());
if (change.getFinished().isSetFailed()) {
withdrawalSession.setWithdrawalSessionStatus(WithdrawalSessionStatus.failed);
} else if (change.getFinished().isSetSuccess()) {
withdrawalSession.setWithdrawalSessionStatus(WithdrawalSessionStatus.success);
}
withdrawalSessionDao.updateNotCurrent(event.getSource());
long id = withdrawalSessionDao.save(withdrawalSession);
log.info("Withdrawal session state have been changed (Id={}, eventId={}, sourceId={}, status={})",
id, event.getId(), event.getSource(), withdrawalSession.getWithdrawalSessionStatus());
}
@Override
public Filter<Change> getFilter() {
return filter;
}
}

View File

@ -0,0 +1,59 @@
package com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session;
import com.rbkmoney.fistful.withdrawal_session.Change;
import com.rbkmoney.fistful.withdrawal_session.SinkEvent;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import com.rbkmoney.newway.util.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Component
public class WithdrawalSessionNextStateHandler extends AbstractWithdrawalSessionHandler {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WithdrawalSessionDao withdrawalSessionDao;
private final Filter filter;
public WithdrawalSessionNextStateHandler(WithdrawalSessionDao withdrawalSessionDao) {
this.withdrawalSessionDao = withdrawalSessionDao;
this.filter = new PathConditionFilter(new PathConditionRule("next_state", new IsNullCondition().not()));
}
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void handle(Change change, SinkEvent event) {
log.info("Start adapter state for withdrawal session handling (eventId={}, sessionId={})",
event.getId(), event.getSource());
WithdrawalSession withdrawalSession = withdrawalSessionDao.get(event.getSource());
withdrawalSession.setId(null);
withdrawalSession.setWtime(null);
withdrawalSession.setEventId(event.getId());
withdrawalSession.setSequenceId(event.getPayload().getSequence());
withdrawalSession.setEventCreatedAt(TypeUtil.stringToLocalDateTime(event.getCreatedAt()));
withdrawalSession.setEventOccuredAt(TypeUtil.stringToLocalDateTime(event.getPayload().getOccuredAt()));
withdrawalSession.setWithdrawalSessionId(event.getSource());
withdrawalSession.setAdapterState(JsonUtil.tBaseToJsonString(change.getNextState()));
withdrawalSessionDao.updateNotCurrent(event.getSource());
Long id = withdrawalSessionDao.save(withdrawalSession);
log.info("Adapter state for withdrawal session have been changed (id={}, eventId={}, sourceId={})",
id, event.getId(), event.getSource());
}
@Override
public Filter<Change> getFilter() {
return filter;
}
}

View File

@ -21,6 +21,7 @@ public class DominantService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final DominantDao dominantDao;
private final List<DominantHandler> handlers;
public DominantService(DominantDao dominantDao, List<DominantHandler> handlers) {

View File

@ -20,6 +20,7 @@ public class InvoicingService implements EventService<Event, EventPayload> {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final InvoiceDao invoiceDao;
private final List<AbstractInvoicingHandler> invoicingHandlers;
public InvoicingService(InvoiceDao invoiceDao, List<AbstractInvoicingHandler> invoicingHandlers) {

View File

@ -20,6 +20,7 @@ public class PartyManagementService implements EventService<Event, EventPayload>
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final PartyDao partyDao;
private final List<AbstractPartyManagementHandler> partyManagementHandlers;
public PartyManagementService(PartyDao partyDao, List<AbstractPartyManagementHandler> partyManagementHandlers) {

View File

@ -0,0 +1,50 @@
package com.rbkmoney.newway.service;
import com.rbkmoney.fistful.withdrawal_session.Event;
import com.rbkmoney.fistful.withdrawal_session.SinkEvent;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.exception.DaoException;
import com.rbkmoney.newway.poller.event_stock.impl.withdrawal_session.AbstractWithdrawalSessionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
@Service
public class WithdrawalSessionService implements EventService<SinkEvent, Event> {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final WithdrawalSessionDao withdrawalSessionDao;
private final List<AbstractWithdrawalSessionHandler> withdrawalSessionHandlers;
public WithdrawalSessionService(WithdrawalSessionDao withdrawalSessionDao,
List<AbstractWithdrawalSessionHandler> withdrawalSessionHandlers) {
this.withdrawalSessionDao = withdrawalSessionDao;
this.withdrawalSessionHandlers = withdrawalSessionHandlers;
}
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void handleEvents(SinkEvent sinkEvent, Event payload) {
payload.getChanges().forEach(
cc -> withdrawalSessionHandlers.forEach(ph -> {
if (ph.accept(cc)) {
ph.handle(cc, sinkEvent);
}
}));
}
@Override
public Optional<Long> getLastEventId() throws DaoException {
Optional<Long> lastEventId = Optional.ofNullable(withdrawalSessionDao.getLastEventId());
log.info("Last withdrawal session eventId={}", lastEventId);
return lastEventId;
}
}

View File

@ -72,6 +72,12 @@ withdrawal:
delay: 10000
retryDelay: 1000
maxPoolSize: 1
withdrawal_session:
polling:
url: http://wapi:8022/v1/eventsink/withdrawal_session
delay: 10000
retryDelay: 1000
maxPoolSize: 1
dmt:
url: http://dominant:8022/v1/domain/repository
networkTimeout: 5000

View File

@ -0,0 +1,48 @@
/**
* Создание необходимых структур для сессий в БД
*/
CREATE TYPE nw.BANK_CARD_PAYMENT_SYSTEM AS ENUM ('visa', 'mastercard', 'visaelectron', 'maestro',
'forbrugsforeningen', 'dankort', 'amex', 'dinersclub',
'discover', 'unionpay', 'jcb', 'nspkmir');
CREATE TYPE nw.WITHDRAWAL_SESSION_STATUS AS ENUM ('active', 'success', 'failed');
CREATE TABLE nw.withdrawal_session (
id BIGSERIAL NOT NULL,
event_id BIGINT NOT NULL,
event_created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
event_occured_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
sequence_id INT NOT NULL,
withdrawal_session_id CHARACTER VARYING NOT NULL,
withdrawal_session_status WITHDRAWAL_SESSION_STATUS NOT NULL,
provider_id CHARACTER VARYING NOT NULL,
withdrawal_id CHARACTER VARYING NOT NULL,
destination_name CHARACTER VARYING NOT NULL,
destination_card_token CHARACTER VARYING NOT NULL,
destination_card_payment_system BANK_CARD_PAYMENT_SYSTEM NULL,
destination_card_bin CHARACTER VARYING NULL,
destination_card_masked_pan CHARACTER VARYING NULL,
amount BIGINT NOT NULL,
currency_code CHARACTER VARYING NOT NULL,
sender_party_id CHARACTER VARYING NOT NULL,
sender_provider_id CHARACTER VARYING NOT NULL,
sender_class_id CHARACTER VARYING NOT NULL,
sender_contract_id CHARACTER VARYING NULL,
receiver_party_id CHARACTER VARYING NOT NULL,
receiver_provider_id CHARACTER VARYING NOT NULL,
receiver_class_id CHARACTER VARYING NOT NULL,
receiver_contract_id CHARACTER VARYING NULL,
adapter_state CHARACTER VARYING NULL,
tran_info_id CHARACTER VARYING NULL,
tran_info_timestamp TIMESTAMP WITHOUT TIME ZONE NULL,
tran_info_json CHARACTER VARYING NULL,
wtime TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT (now() at time zone 'utc'),
current BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT withdrawal_session_PK PRIMARY KEY (id)
);
CREATE INDEX withdrawal_session_event_id_idx ON nw.withdrawal_session (event_id);
CREATE INDEX withdrawal_session_event_created_at_idx ON nw.withdrawal_session (event_created_at);
CREATE INDEX withdrawal_session_event_occured_at_idx ON nw.withdrawal_session (event_occured_at);
CREATE INDEX withdrawal_session_id_idx ON nw.withdrawal_session (withdrawal_session_id);

View File

@ -0,0 +1,29 @@
package com.rbkmoney.newway.dao.withdrawal_session.impl;
import com.rbkmoney.newway.AbstractIntegrationTest;
import com.rbkmoney.newway.dao.withdrawal_session.iface.WithdrawalSessionDao;
import com.rbkmoney.newway.domain.tables.pojos.WithdrawalSession;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static io.github.benas.randombeans.api.EnhancedRandom.random;
import static junit.framework.TestCase.assertNull;
import static org.junit.Assert.assertEquals;
public class WithdrawalSessionDaoImplTest extends AbstractIntegrationTest {
@Autowired
private WithdrawalSessionDao withdrawalSessionDao;
@Test
public void test() {
WithdrawalSession withdrawalSession = random(WithdrawalSession.class);
withdrawalSession.setCurrent(true);
Long id = withdrawalSessionDao.save(withdrawalSession);
withdrawalSession.setId(id);
assertEquals(withdrawalSession, withdrawalSessionDao.get(withdrawalSession.getWithdrawalSessionId()));
withdrawalSessionDao.updateNotCurrent(withdrawalSession.getWithdrawalSessionId());
assertNull(withdrawalSessionDao.get(withdrawalSession.getWithdrawalSessionId()));
}
}