Search in sources :

Example 1 with Order

use of no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order in project testnorge by navikt.

the class OrderServiceV2 method getStatus.

public Status getStatus(Long id) {
    var entity = repository.findById(id);
    if (entity.isEmpty()) {
        return Status.NOT_FOUND;
    }
    var order = entity.get();
    if (order.getBatchId() != null) {
        return getStatusFromBatchId(new Order(order));
    }
    if (order.getBuildId() == null) {
        return Status.ADDING_TO_QUEUE;
    }
    var build = jenkinsConsumer.getBuild(order.getBuildId()).blockOptional();
    if (build.isEmpty()) {
        return Status.IN_QUEUE_WAITING_TO_START;
    }
    if (build.get().getResult() != null && build.get().getResult().equals("FAILURE")) {
        return Status.FAILED;
    }
    var content = jenkinsConsumer.getBuildLog(order.getBuildId()).blockOptional();
    if (content.isEmpty()) {
        return Status.IN_QUEUE_WAITING_TO_START;
    }
    try {
        var batchId = findIDFromLog(content.get());
        order.setBatchId(batchId);
    } catch (Exception e) {
        log.warn("Klarer ikke å finne batch id fra Jenkins loggen.", e);
        return Status.RUNNING;
    }
    repository.save(order);
    return getStatusFromBatchId(new Order(order));
}
Also used : Order(no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order)

Example 2 with Order

use of no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order in project testnorge by navikt.

the class OrderServiceV2 method save.

public Order save(Order order) {
    OrderEntity saved = repository.save(order.toEntity());
    if (saved.getBuildId() == null) {
        log.info("Finner build id for ordre {} med uuid {}...", saved.getId(), saved.getUuid());
        var retryConfig = new RetryConfig.Builder().setRetryAttempts(60 * 5).setSleepSeconds(2).build();
        retryService.execute(retryConfig, () -> {
            var buildId = jenkinsConsumer.getBuildId(order.getQueueId()).block();
            saved.setBuildId(buildId);
            repository.save(saved);
            log.info("Build id er satt for ordre {} med uuid {}.", saved.getId(), saved.getUuid());
        });
    }
    return new Order(saved);
}
Also used : Order(no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order) OrderEntity(no.nav.testnav.apps.organisasjonbestillingservice.repository.v2.entity.OrderEntity) RetryConfig(no.nav.testnav.apps.organisasjonbestillingservice.retry.RetryConfig)

Example 3 with Order

use of no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order in project googleads-java-lib by googleads.

the class ApproveOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order to approve.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long orderId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select an order.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", orderId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d will be approved.%n", i++, order.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of orders to be approved: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202108.ApproveOrders action = new com.google.api.ads.admanager.axis.v202108.ApproveOrders();
        // Perform action.
        UpdateResult result = orderService.performOrderAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of orders approved: %d%n", result.getNumChanges());
        } else {
            System.out.println("No orders were approved.");
        }
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202108.Order) OrderPage(com.google.api.ads.admanager.axis.v202108.OrderPage) OrderServiceInterface(com.google.api.ads.admanager.axis.v202108.OrderServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202108.UpdateResult)

Example 4 with Order

use of no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method updateDestinationCountryCode.

public int updateDestinationCountryCode(int orderIdToUpdate, CountryCode destinationCountryCode, Order.QualityLevel qualityLevel, boolean useTrackedShipping) {
    Pwinty pwinty = getPwinty(environment);
    System.out.println(pwinty.getOrder(orderIdToUpdate));
    Order order = pwinty.getOrder(orderIdToUpdate);
    order = order.createCloneWithDestinationCountryCode(destinationCountryCode, qualityLevel, useTrackedShipping);
    System.out.println(order);
    System.out.println(pwinty.getOrder(order.getId()));
    System.out.println("**** NOTE: ORDER NUMBER HAS NOW CHANGED !! ****");
    System.out.println("New order number is : " + order.getId());
    return order.getId();
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Example 5 with Order

use of no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order in project pwinty-java-sdk by OddPrints.

the class OrderUpdater method display.

public void display(int orderId) {
    Pwinty pwinty = getPwinty(environment);
    Order order = pwinty.getOrder(orderId);
    System.out.println(order);
}
Also used : Order(uk.co.mattburns.pwinty.v2_3.Order) Pwinty(uk.co.mattburns.pwinty.v2_3.Pwinty)

Aggregations

Order (uk.co.mattburns.pwinty.v2_3.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_3.Pwinty)7 Order (uk.co.mattburns.pwinty.v2_6.Order)7 Pwinty (uk.co.mattburns.pwinty.v2_6.Pwinty)7 Order (com.google.api.ads.admanager.axis.v202108.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202111.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202202.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202202.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202205.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)5 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 OrderPage (com.google.api.ads.admanager.axis.v202108.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202111.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202202.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202205.OrderPage)4