private static void setUsedForDpodCommBought() { for (DPod se : rg.getInstances(DPod.class)) { if (se.isIsTemplate() || se.getParticipatesIn() == null || !se.getParticipatesIn().isMainMarket()) continue; float used = 0; for (Commodity comm : se.getCommoditiesBought()) { if (!comm.getConsumes().isEmpty()) { Commodity commSoldByProvider = comm.getConsumes().get(0); ServiceEntity provider = commSoldByProvider.getSoldBy(); for (VMTRootObject vmtObj : provider.getRef( getRelatedEntitiesRef(provider), AnalysisPackage.eINSTANCE.getServiceEntity())) { if (vmtObj instanceof VirtualMachine) { VirtualMachine vm = (VirtualMachine) vmtObj; float entityCommmodityUsed = 0; for (Commodity entityCommodity : vm.getCommoditiesBought()) { if (entityCommodity.eClass() == commAllocation2CommMap.get(comm.eClass())) { if (entityCommodity.getKey() != null && !comm.getKey().contains(entityCommodity.getKey())) continue; entityCommmodityUsed = entityCommodity.getUsed(); break; } } used += entityCommmodityUsed; } } comm.setUsed(used); used = 0; } else { logger.warn("The commodity " + comm.getDisplayName() + " is not consuming anything"); } } } }