Search in sources :

Example 1 with Metadata

use of io.gravitee.management.model.pagedresult.Metadata in project gravitee-management-rest-api by gravitee-io.

the class SubscriptionServiceImpl method getMetadata.

public Metadata getMetadata(List<SubscriptionEntity> subscriptions) {
    Metadata metadata = new Metadata();
    subscriptions.forEach(subscription -> {
        if (!metadata.containsKey(subscription.getApplication())) {
            ApplicationEntity applicationEntity = applicationService.findById(subscription.getApplication());
            metadata.put(subscription.getApplication(), "name", applicationEntity.getName());
        }
        if (!metadata.containsKey(subscription.getPlan())) {
            PlanEntity planEntity = planService.findById(subscription.getPlan());
            metadata.put(subscription.getPlan(), "name", planEntity.getName());
        }
        if (!metadata.containsKey(subscription.getApi())) {
            ApiEntity api = apiService.findById(subscription.getApi());
            metadata.put(subscription.getApi(), "name", api.getName());
        }
    });
    return metadata;
}
Also used : Metadata(io.gravitee.management.model.pagedresult.Metadata)

Example 2 with Metadata

use of io.gravitee.management.model.pagedresult.Metadata in project gravitee-management-rest-api by gravitee-io.

the class TaskServiceImpl method getMetadata.

public Metadata getMetadata(List<TaskEntity> tasks) {
    Metadata metadata = new Metadata();
    tasks.forEach(task -> {
        SubscriptionEntity subscription = (SubscriptionEntity) task.getData();
        if (!metadata.containsKey(subscription.getApplication())) {
            ApplicationEntity applicationEntity = applicationService.findById(subscription.getApplication());
            metadata.put(subscription.getApplication(), "name", applicationEntity.getName());
        }
        if (!metadata.containsKey(subscription.getPlan())) {
            PlanEntity planEntity = planService.findById(subscription.getPlan());
            String apiId = planEntity.getApis().iterator().next();
            ApiEntity api = apiService.findById(apiId);
            metadata.put(subscription.getPlan(), "name", planEntity.getName());
            metadata.put(subscription.getPlan(), "api", apiId);
            metadata.put(apiId, "name", api.getName());
        }
    });
    return metadata;
}
Also used : Metadata(io.gravitee.management.model.pagedresult.Metadata)

Aggregations

Metadata (io.gravitee.management.model.pagedresult.Metadata)2