use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.
the class BackendAffinityLabelHostResource method remove.
public Response remove() {
// First we need to check if the label contains the host:
Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
if (!label.getHosts().contains(guid)) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
// Remove the host from the label:
VDS entity = new VDS();
entity.setId(guid);
Label updatedLabel = new LabelBuilder(label).removeEntity(entity).build();
return performAction(ActionType.UpdateLabel, new LabelActionParameters(updatedLabel));
}
use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.
the class BackendAffinityLabelHostsResource method list.
@Override
public Hosts list() {
Hosts hosts = new Hosts();
List<Host> list = hosts.getHosts();
Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
label.getHosts().stream().map(BackendAffinityLabelHelper::makeHostLink).forEach(list::add);
return hosts;
}
use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.
the class BackendAffinityLabelVmsResource method list.
@Override
public Vms list() {
Vms vms = new Vms();
List<Vm> list = vms.getVms();
Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
label.getVms().stream().map(BackendAffinityLabelHelper::makeVmLink).forEach(list::add);
return vms;
}
use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.
the class AffinityLabelListWidget method createItems.
@Override
protected void createItems() {
List<Label> selectedLabels = getModel().getSelectedItems();
boolean noLabelsSelected = selectedLabels == null || selectedLabels.isEmpty();
if (noLabelsSelected) {
addNoLabelsMessage();
return;
}
itemList.clear();
Collections.sort(selectedLabels, new NameableComparator());
selectedLabels.forEach(label -> {
ItemListItem labelListItem = new ItemListItem();
labelListItem.init(label.getName());
labelListItem.getDeactivationAnchor().addClickHandler(event -> {
getModel().getSelectedItems().remove(label);
refreshItems();
});
itemList.add(labelListItem);
});
itemListPanel.add(itemList);
}
use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.
the class UpdateLabelCommand method executeCommand.
@Override
protected void executeCommand() {
Label label = labelDao.get(getLabelId());
Collection changedVms = CollectionUtils.disjunction(label.getVms(), getParameters().getLabel().getVms());
vmStaticDao.incrementDbGenerationForVms(new ArrayList<>(changedVms));
labelDao.update(getParameters().getLabel());
setActionReturnValue(getParameters().getLabel());
setSucceeded(true);
}
Aggregations