Search in sources :

Example 1 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryOkHttpImpl method search.

@Override
public Observable<Page<NamespaceInfo>> search(NamespaceSearchCriteria criteria) {
    String ownerAddress = toDto(criteria.getOwnerAddress());
    NamespaceRegistrationTypeEnum registrationType = criteria.getRegistrationType() == null ? null : NamespaceRegistrationTypeEnum.fromValue(criteria.getRegistrationType().getValue());
    String level0 = criteria.getLevel0();
    AliasTypeEnum aliasType = criteria.getAliasType() == null ? null : AliasTypeEnum.fromValue(criteria.getAliasType().getValue());
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Callable<NamespacePage> callback = () -> getClient().searchNamespaces(ownerAddress, registrationType, level0, aliasType, pageSize, pageNumber, offset, order);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toNamespaceInfo).collect(Collectors.toList()))));
}
Also used : Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) NamespacePage(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespacePage) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) MosaicsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO) NamespaceRepository(io.nem.symbol.sdk.api.NamespaceRepository) Callable(java.util.concurrent.Callable) MosaicIds(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicIds) NamespaceNameDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceNameDTO) ArrayList(java.util.ArrayList) AccountsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountsNamesDTO) MapperUtils.toNamespaceId(io.nem.symbol.core.utils.MapperUtils.toNamespaceId) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) MosaicNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicNamesDTO) NamespaceDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceDTO) NamespaceRegistrationTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceRegistrationTypeEnum) ObjectUtils(org.apache.commons.lang3.ObjectUtils) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceInfoDTO) MosaicAlias(io.nem.symbol.sdk.model.namespace.MosaicAlias) Observable(io.reactivex.Observable) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) AliasTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.AliasTypeEnum) MapperUtils(io.nem.symbol.core.utils.MapperUtils) Alias(io.nem.symbol.sdk.model.namespace.Alias) Addresses(io.nem.symbol.sdk.openapi.okhttp_gson.model.Addresses) NamespaceName(io.nem.symbol.sdk.model.namespace.NamespaceName) ApiClient(io.nem.symbol.sdk.openapi.okhttp_gson.invoker.ApiClient) MosaicNames(io.nem.symbol.sdk.model.mosaic.MosaicNames) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) EmptyAlias(io.nem.symbol.sdk.model.namespace.EmptyAlias) Collectors(java.util.stream.Collectors) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceRegistrationType(io.nem.symbol.sdk.model.namespace.NamespaceRegistrationType) AccountNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountNamesDTO) List(java.util.List) NamespaceRoutesApi(io.nem.symbol.sdk.openapi.okhttp_gson.api.NamespaceRoutesApi) AliasType(io.nem.symbol.sdk.model.namespace.AliasType) Optional(java.util.Optional) Address(io.nem.symbol.sdk.model.account.Address) NamespaceIds(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceIds) Page(io.nem.symbol.sdk.api.Page) AddressAlias(io.nem.symbol.sdk.model.namespace.AddressAlias) AliasTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.AliasTypeEnum) NamespacePage(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespacePage) NamespaceRegistrationTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.NamespaceRegistrationTypeEnum)

Example 2 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryOkHttpImpl method searchMosaicResolutionStatements.

@Override
public Observable<Page<MosaicResolutionStatement>> searchMosaicResolutionStatements(ResolutionStatementSearchCriteria criteria) {
    BigInteger height = criteria.getHeight();
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Callable<ResolutionStatementPage> callback = () -> getClient().searchMosaicResolutionStatements(height, pageSize, pageNumber, offset, order);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createMosaicResolutionStatementFromDto).collect(Collectors.toList()))));
}
Also used : BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum) ReceiptRoutesApi(io.nem.symbol.sdk.openapi.okhttp_gson.api.ReceiptRoutesApi) ApiClient(io.nem.symbol.sdk.openapi.okhttp_gson.invoker.ApiClient) Callable(java.util.concurrent.Callable) Collectors(java.util.stream.Collectors) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptType(io.nem.symbol.sdk.model.receipt.ReceiptType) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage) List(java.util.List) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Page(io.nem.symbol.sdk.api.Page) BigInteger(java.math.BigInteger) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage)

Example 3 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryOkHttpImpl method searchReceipts.

@Override
public Observable<Page<TransactionStatement>> searchReceipts(TransactionStatementSearchCriteria criteria) {
    BigInteger height = criteria.getHeight();
    BigInteger fromHeight = criteria.getFromHeight();
    BigInteger toHeight = criteria.getToHeight();
    List<ReceiptTypeEnum> receiptTypes = toDto(criteria.getReceiptTypes());
    String recipientAddress = toDto(criteria.getRecipientAddress());
    String senderAddress = toDto(criteria.getSenderAddress());
    String targetAddress = toDto(criteria.getTargetAddress());
    String artifactId = criteria.getArtifactId();
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    Callable<TransactionStatementPage> callback = () -> getClient().searchReceipts(height, fromHeight, toHeight, receiptTypes, recipientAddress, senderAddress, targetAddress, artifactId, pageSize, pageNumber, offset, order);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createTransactionStatement).collect(Collectors.toList()))));
}
Also used : BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum) ReceiptRoutesApi(io.nem.symbol.sdk.openapi.okhttp_gson.api.ReceiptRoutesApi) ApiClient(io.nem.symbol.sdk.openapi.okhttp_gson.invoker.ApiClient) Callable(java.util.concurrent.Callable) Collectors(java.util.stream.Collectors) Order(io.nem.symbol.sdk.openapi.okhttp_gson.model.Order) TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptType(io.nem.symbol.sdk.model.receipt.ReceiptType) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) ResolutionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.ResolutionStatementPage) List(java.util.List) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) Page(io.nem.symbol.sdk.api.Page) TransactionStatementPage(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionStatementPage) BigInteger(java.math.BigInteger) ReceiptTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.ReceiptTypeEnum)

Example 4 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class MetadataRepositoryVertxImpl method search.

@Override
public Observable<Page<Metadata>> search(MetadataSearchCriteria criteria) {
    String sourceAddress = toDto(criteria.getSourceAddress());
    String targetAddress = toDto(criteria.getTargetAddress());
    String scopedMetadataKey = toDto(criteria.getScopedMetadataKey());
    String targetId = criteria.getTargetId();
    MetadataTypeEnum metadataType = criteria.getMetadataType() == null ? null : MetadataTypeEnum.fromValue(criteria.getMetadataType().getValue());
    String offset = criteria.getOffset();
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    Order order = toDto(criteria.getOrder());
    Consumer<Handler<AsyncResult<MetadataPage>>> callback = handler -> getClient().searchMetadataEntries(sourceAddress, targetAddress, scopedMetadataKey, targetId, metadataType, pageSize, pageNumber, offset, order, handler);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toMetadata).collect(Collectors.toList()))));
}
Also used : MetadataTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.MetadataTypeEnum) BigInteger(java.math.BigInteger) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) MapperUtils(io.nem.symbol.core.utils.MapperUtils) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) ConvertUtils(io.nem.symbol.core.utils.ConvertUtils) MetadataType(io.nem.symbol.sdk.model.metadata.MetadataType) MetadataTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.MetadataTypeEnum) Collectors(java.util.stream.Collectors) MetadataRepository(io.nem.symbol.sdk.api.MetadataRepository) MetadataEntryDTO(io.nem.symbol.sdk.openapi.vertx.model.MetadataEntryDTO) MetadataInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.MetadataInfoDTO) Consumer(java.util.function.Consumer) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) ObjectUtils(org.apache.commons.lang3.ObjectUtils) MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) MetadataPage(io.nem.symbol.sdk.openapi.vertx.model.MetadataPage) Observable(io.reactivex.Observable) BigInteger(java.math.BigInteger) MetadataRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.MetadataRoutesApiImpl) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) Metadata(io.nem.symbol.sdk.model.metadata.Metadata) MetadataRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.MetadataRoutesApi) Page(io.nem.symbol.sdk.api.Page) MetadataPage(io.nem.symbol.sdk.openapi.vertx.model.MetadataPage) Handler(io.vertx.core.Handler)

Example 5 with Page

use of io.nem.symbol.sdk.api.Page in project nem2-sdk-java by nemtech.

the class AccountRepositoryVertxImpl method search.

@Override
public Observable<Page<AccountInfo>> search(AccountSearchCriteria criteria) {
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    AccountOrderByEnum orderBy = criteria.getOrderBy() == null ? null : AccountOrderByEnum.fromValue(criteria.getOrderBy().getValue());
    String mosaicId = criteria.getMosaicId() == null ? null : criteria.getMosaicId().getIdAsHex();
    Consumer<Handler<AsyncResult<AccountPage>>> callback = (handler) -> getClient().searchAccounts(pageSize, pageNumber, offset, order, orderBy, mosaicId, handler);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toAccountInfo).collect(Collectors.toList()))));
}
Also used : Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountOrderByEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountOrderByEnum) AccountDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountDTO) AccountOrderByEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountOrderByEnum) MapperUtils.toMosaicId(io.nem.symbol.core.utils.MapperUtils.toMosaicId) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) AccountType(io.nem.symbol.sdk.model.account.AccountType) SupplementalPublicKeysDTO(io.nem.symbol.sdk.openapi.vertx.model.SupplementalPublicKeysDTO) MapperUtils.toAddress(io.nem.symbol.core.utils.MapperUtils.toAddress) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountInfoDTO) ObjectUtils(org.apache.commons.lang3.ObjectUtils) AccountRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApi) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) ActivityBucket(io.nem.symbol.sdk.model.account.ActivityBucket) Observable(io.reactivex.Observable) AsyncResult(io.vertx.core.AsyncResult) AccountPage(io.nem.symbol.sdk.openapi.vertx.model.AccountPage) AccountIds(io.nem.symbol.sdk.openapi.vertx.model.AccountIds) ResolvedMosaic(io.nem.symbol.sdk.model.mosaic.ResolvedMosaic) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) List(java.util.List) SupplementalAccountKeys(io.nem.symbol.sdk.model.account.SupplementalAccountKeys) PublicKey(io.nem.symbol.core.crypto.PublicKey) AccountLinkPublicKeyDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO) AccountLinkVotingKey(io.nem.symbol.sdk.model.account.AccountLinkVotingKey) Address(io.nem.symbol.sdk.model.account.Address) AccountRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApiImpl) Handler(io.vertx.core.Handler) Collections(java.util.Collections) Page(io.nem.symbol.sdk.api.Page) AccountPage(io.nem.symbol.sdk.openapi.vertx.model.AccountPage) Handler(io.vertx.core.Handler)

Aggregations

Page (io.nem.symbol.sdk.api.Page)26 BigInteger (java.math.BigInteger)18 Observable (io.reactivex.Observable)17 Collectors (java.util.stream.Collectors)17 List (java.util.List)13 ApiClient (io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient)10 Order (io.nem.symbol.sdk.openapi.vertx.model.Order)10 AsyncResult (io.vertx.core.AsyncResult)10 Handler (io.vertx.core.Handler)10 Consumer (java.util.function.Consumer)10 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)9 ObjectUtils (org.apache.commons.lang3.ObjectUtils)9 Test (org.junit.jupiter.api.Test)9 MetadataSearchCriteria (io.nem.symbol.sdk.api.MetadataSearchCriteria)8 MapperUtils (io.nem.symbol.core.utils.MapperUtils)7 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)7 ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)7 Address (io.nem.symbol.sdk.model.account.Address)7 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)7 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)7