Search in sources :

Example 1 with ApiSummaryItem

use of org.ovirt.engine.api.model.ApiSummaryItem in project ovirt-engine by oVirt.

the class V3ApiSummaryOutAdapter method adapt.

@Override
public V3ApiSummary adapt(ApiSummary from) {
    V3ApiSummary to = new V3ApiSummary();
    if (from.isSetHosts()) {
        ApiSummaryItem fromHosts = from.getHosts();
        V3Hosts toHosts = new V3Hosts();
        if (fromHosts.isSetTotal()) {
            toHosts.setTotal(fromHosts.getTotal().longValue());
        }
        if (fromHosts.isSetActive()) {
            toHosts.setActive(fromHosts.getActive().longValue());
        }
        to.setHosts(toHosts);
    }
    if (from.isSetStorageDomains()) {
        ApiSummaryItem fromSds = from.getStorageDomains();
        V3StorageDomains toSds = new V3StorageDomains();
        if (fromSds.isSetTotal()) {
            toSds.setTotal(fromSds.getTotal().longValue());
        }
        if (fromSds.isSetActive()) {
            toSds.setActive(fromSds.getActive().longValue());
        }
        to.setStorageDomains(toSds);
    }
    if (from.isSetUsers()) {
        ApiSummaryItem fromUsers = from.getUsers();
        V3Users toUsers = new V3Users();
        if (fromUsers.isSetTotal()) {
            toUsers.setTotal(fromUsers.getTotal().longValue());
        }
        if (fromUsers.isSetActive()) {
            toUsers.setActive(fromUsers.getActive().longValue());
        }
        to.setUsers(toUsers);
    }
    if (from.isSetVms()) {
        ApiSummaryItem fromVms = from.getVms();
        V3VMs toVms = new V3VMs();
        if (fromVms.isSetTotal()) {
            toVms.setTotal(fromVms.getTotal().longValue());
        }
        if (fromVms.isSetActive()) {
            toVms.setActive(fromVms.getActive().longValue());
        }
        to.setVMs(toVms);
    }
    return to;
}
Also used : ApiSummaryItem(org.ovirt.engine.api.model.ApiSummaryItem) V3ApiSummary(org.ovirt.engine.api.v3.types.V3ApiSummary) V3Hosts(org.ovirt.engine.api.v3.types.V3Hosts) V3Users(org.ovirt.engine.api.v3.types.V3Users) V3VMs(org.ovirt.engine.api.v3.types.V3VMs) V3StorageDomains(org.ovirt.engine.api.v3.types.V3StorageDomains)

Example 2 with ApiSummaryItem

use of org.ovirt.engine.api.model.ApiSummaryItem in project ovirt-engine by oVirt.

the class BackendApiResource method makeSummaryItem.

private ApiSummaryItem makeSummaryItem(Map<String, Integer> values, String totalKey, String activeKey) {
    Integer totalValue = values.get(totalKey);
    Integer activeValue = values.get(activeKey);
    if (totalValue == null && activeValue == null) {
        return null;
    }
    ApiSummaryItem item = new ApiSummaryItem();
    if (totalValue != null) {
        item.setTotal(totalValue);
    }
    if (activeValue != null) {
        item.setActive(activeValue);
    }
    return item;
}
Also used : ApiSummaryItem(org.ovirt.engine.api.model.ApiSummaryItem)

Aggregations

ApiSummaryItem (org.ovirt.engine.api.model.ApiSummaryItem)2 V3ApiSummary (org.ovirt.engine.api.v3.types.V3ApiSummary)1 V3Hosts (org.ovirt.engine.api.v3.types.V3Hosts)1 V3StorageDomains (org.ovirt.engine.api.v3.types.V3StorageDomains)1 V3Users (org.ovirt.engine.api.v3.types.V3Users)1 V3VMs (org.ovirt.engine.api.v3.types.V3VMs)1