Search in sources :

Example 1 with MetadataPage

use of io.nem.symbol.sdk.openapi.vertx.model.MetadataPage 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 2 with MetadataPage

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

the class MetadataRepositoryVertxImplTest method getMetadataEntriesDTO.

private MetadataPage getMetadataEntriesDTO() {
    MetadataPage metadataPage = new MetadataPage();
    metadataPage.setPagination(new Pagination().pageNumber(1).pageSize(2));
    List<MetadataInfoDTO> data = new ArrayList<>();
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(10)), MetadataTypeEnum.NUMBER_0, null));
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(20)), MetadataTypeEnum.NUMBER_1, "11111"));
    data.add(createMetadataDto(ConvertUtils.toSize16Hex(BigInteger.valueOf(30)), MetadataTypeEnum.NUMBER_2, "22222"));
    metadataPage.setData(data);
    return metadataPage;
}
Also used : MetadataPage(io.nem.symbol.sdk.openapi.vertx.model.MetadataPage) Pagination(io.nem.symbol.sdk.openapi.vertx.model.Pagination) ArrayList(java.util.ArrayList) MetadataInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.MetadataInfoDTO)

Example 3 with MetadataPage

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

the class MetadataRepositoryVertxImplTest method search.

@Test
public void search() throws Exception {
    Address address = Address.generateRandom(networkType);
    MetadataPage dto = getMetadataEntriesDTO();
    mockRemoteCall(dto);
    List<Metadata> resultList = repository.search(new MetadataSearchCriteria().sourceAddress(address)).toFuture().get().getData();
    assertMetadataList(dto, resultList);
}
Also used : MetadataPage(io.nem.symbol.sdk.openapi.vertx.model.MetadataPage) MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) Metadata(io.nem.symbol.sdk.model.metadata.Metadata) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataPage (io.nem.symbol.sdk.openapi.vertx.model.MetadataPage)3 MetadataSearchCriteria (io.nem.symbol.sdk.api.MetadataSearchCriteria)2 Metadata (io.nem.symbol.sdk.model.metadata.Metadata)2 MetadataInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.MetadataInfoDTO)2 ConvertUtils (io.nem.symbol.core.utils.ConvertUtils)1 MapperUtils (io.nem.symbol.core.utils.MapperUtils)1 MetadataRepository (io.nem.symbol.sdk.api.MetadataRepository)1 Page (io.nem.symbol.sdk.api.Page)1 Address (io.nem.symbol.sdk.model.account.Address)1 MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)1 MetadataType (io.nem.symbol.sdk.model.metadata.MetadataType)1 MetadataRoutesApi (io.nem.symbol.sdk.openapi.vertx.api.MetadataRoutesApi)1 MetadataRoutesApiImpl (io.nem.symbol.sdk.openapi.vertx.api.MetadataRoutesApiImpl)1 ApiClient (io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient)1 MetadataEntryDTO (io.nem.symbol.sdk.openapi.vertx.model.MetadataEntryDTO)1 MetadataTypeEnum (io.nem.symbol.sdk.openapi.vertx.model.MetadataTypeEnum)1 Order (io.nem.symbol.sdk.openapi.vertx.model.Order)1 Pagination (io.nem.symbol.sdk.openapi.vertx.model.Pagination)1 Observable (io.reactivex.Observable)1 AsyncResult (io.vertx.core.AsyncResult)1