Search in sources :

Example 1 with EmbeddedTransactionInfoDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO in project nem2-sdk-java by nemtech.

the class AbstractTransactionMapper method mapToFactoryFromDto.

@Override
public TransactionFactory<T> mapToFactoryFromDto(Object object) {
    if (object instanceof EmbeddedTransactionInfoDTO) {
        EmbeddedTransactionInfoDTO transactionInfoDTO = (EmbeddedTransactionInfoDTO) object;
        TransactionInfo transactionInfo = createTransactionInfo(transactionInfoDTO.getMeta(), transactionInfoDTO.getId());
        return createFactory(transactionInfo, transactionInfoDTO.getTransaction());
    }
    TransactionInfoDTO transactionInfoDTO = this.jsonHelper.convert(object, TransactionInfoDTO.class);
    TransactionInfo transactionInfo = createTransactionInfo(transactionInfoDTO.getMeta(), transactionInfoDTO.getId());
    return createFactory(transactionInfo, transactionInfoDTO.getTransaction());
}
Also used : TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) EmbeddedTransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO) TransactionInfo(io.nem.symbol.sdk.model.transaction.TransactionInfo) EmbeddedTransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO)

Example 2 with EmbeddedTransactionInfoDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO in project nem2-sdk-java by nemtech.

the class AbstractTransactionMapper method mapToDto.

@Override
public Object mapToDto(Transaction transaction, Boolean embedded) {
    if (transaction.getTransactionInfo().flatMap(TransactionInfo::getAggregateHash).isPresent() || Boolean.TRUE.equals(embedded)) {
        EmbeddedTransactionInfoDTO dto = new EmbeddedTransactionInfoDTO();
        dto.setMeta(createTransactionInfoEmbedded(transaction));
        dto.setId(transaction.getRecordId().orElse(null));
        dto.setTransaction(mapTransaction(transaction, true));
        return dto;
    } else {
        TransactionInfoDTO dto = new TransactionInfoDTO();
        dto.setMeta(createTransactionInfo(transaction));
        dto.setId(transaction.getRecordId().orElse(null));
        dto.setTransaction(mapTransaction(transaction, false));
        return dto;
    }
}
Also used : TransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO) EmbeddedTransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO) TransactionInfo(io.nem.symbol.sdk.model.transaction.TransactionInfo) EmbeddedTransactionInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO)

Aggregations

TransactionInfo (io.nem.symbol.sdk.model.transaction.TransactionInfo)2 EmbeddedTransactionInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.EmbeddedTransactionInfoDTO)2 TransactionInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO)2