use of org.ovirt.engine.core.common.businessentities.Erratum in project ovirt-engine by oVirt.
the class ErrataTableView method initErrataGrid.
/**
* Setup the columns in the errata grid. This configuration is also used in MainEngineErrataView.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void initErrataGrid(HasColumns grid, boolean isEngineErrataView, final PlaceTransitionHandler transitionHandler) {
grid.enableColumnResizing();
AbstractIconTypeColumn<Erratum> errataTypeColumn = new AbstractIconTypeColumn<Erratum>() {
@Override
public IconType getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.BUGFIX.getColor()));
return IconType.BUG;
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.ENHANCEMENT.getColor()));
return IconType.PLUS_SQUARE;
} else if (erratum.getType() == ErrataType.SECURITY) {
getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.SECURITY.getColor()));
return IconType.WARNING;
}
return null;
}
};
errataTypeColumn.makeSortable(new ErrataTypeComparator());
// $NON-NLS-1$ //$NON-NLS-2$
grid.addColumn(errataTypeColumn, "", "30px");
AbstractTextColumn errataTypeTextColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getType() == ErrataType.BUGFIX) {
return constants.bug();
} else if (erratum.getType() == ErrataType.ENHANCEMENT) {
return constants.enhancement();
} else if (erratum.getType() == ErrataType.SECURITY) {
return constants.security();
}
return constants.unknown();
}
};
errataTypeTextColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataTypeTextColumn, constants.errataType(), "150px");
AbstractTextColumn<Erratum> errataSeverityColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
if (erratum.getSeverity() == ErrataSeverity.CRITICAL) {
return constants.critical();
} else if (erratum.getSeverity() == ErrataSeverity.IMPORTANT) {
return constants.important();
} else if (erratum.getSeverity() == ErrataSeverity.MODERATE) {
return constants.moderate();
}
return constants.unknown();
}
};
errataSeverityColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataSeverityColumn, constants.errataSeverity(), "150px");
AbstractFullDateTimeColumn<Erratum> dateIssuedColumn = new AbstractFullDateTimeColumn<Erratum>(false) {
@Override
protected Date getRawValue(Erratum erratum) {
return erratum.getIssued();
}
};
dateIssuedColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(dateIssuedColumn, constants.errataDateIssued(), "100px");
AbstractTextColumn<Erratum> errataIdColumn;
if (!isEngineErrataView) {
errataIdColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
} else {
errataIdColumn = new AbstractLinkColumn<Erratum>(new FieldUpdater<Erratum, String>() {
@Override
public void update(int index, Erratum erratum, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), erratum.getName());
// The link was clicked, now fire an event to switch to details.
transitionHandler.handlePlaceTransition(WebAdminApplicationPlaces.errataDetailsSubTabPlace, parameters);
}
}) {
@Override
public String getValue(Erratum erratum) {
return erratum.getId();
}
};
}
errataIdColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(errataIdColumn, constants.errataId(), "115px");
AbstractTextColumn<Erratum> titleColumn = new AbstractTextColumn<Erratum>() {
@Override
public String getValue(Erratum erratum) {
return erratum.getTitle();
}
};
titleColumn.makeSortable();
// $NON-NLS-1$
grid.addColumn(titleColumn, constants.errataTitle(), "290px");
}
use of org.ovirt.engine.core.common.businessentities.Erratum in project ovirt-engine by oVirt.
the class ErrataTableView method createErrataTable.
private void createErrataTable() {
errataTable = new EntityModelCellTable<AbstractErrataListModel>(false, true) {
// Override the addSelectionChangeHandler method to prevent a class cast exception. The EntityModelCellTable
// expect to be handed a list of EntityModels, but the ErrataListModel is returning a list of Erratums. If
// I rework the list model to return EntityModel<Erratum> I get another class cast exception on something
// that expects it to return a straight Erratum.
public void addSelectionChangeHandler() {
// Handle selection
getSelectionModel().addSelectionChangeHandler(new Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
if (errataListModel == null || errataListModel.getItems() == null) {
return;
}
SelectionModel<?> selectionModel = errataTable.getSelectionModel();
Erratum selectedObject = (Erratum) ((SingleSelectionModel<?>) selectionModel).getSelectedObject();
clearCurrentSelectedItems();
if (selectedObject != null) {
errataListModel.setSelectedItem(selectedObject);
}
}
private void clearCurrentSelectedItems() {
errataListModel.setSelectedItems(null);
errataListModel.setSelectedItem(null);
}
});
}
};
}
use of org.ovirt.engine.core.common.businessentities.Erratum in project ovirt-engine by oVirt.
the class KatelloProvider method addErrataCountForType.
private void addErrataCountForType(ErrataData errataData, Erratum.ErrataType errataType) {
Stream<Erratum> typedErrata = errataData.getErrata().stream().filter(erratum -> erratum.getType() == errataType);
long totalCount = typedErrata.count();
if (totalCount > 0) {
Map<Erratum.ErrataSeverity, Long> errataBySeverity = errataData.getErrata().stream().collect(Collectors.groupingBy(Erratum::getSeverityOrDefault, Collectors.counting()));
ErrataCount errataCount = new ErrataCount();
errataCount.setTotalCount((int) totalCount);
errataBySeverity.entrySet().forEach(entry -> errataCount.getCountBySeverity().put(entry.getKey(), entry.getValue().intValue()));
errataData.getErrataCounts().getErrataCountByType().put(errataType, errataCount);
}
}
use of org.ovirt.engine.core.common.businessentities.Erratum in project ovirt-engine by oVirt.
the class BackendHostKatelloErratumResourceTest method getEntity.
@Override
protected Erratum getEntity(int index) {
Erratum erratum = mock(Erratum.class);
when(erratum.getId()).thenReturn(GUIDS[index].toString());
when(erratum.getDescription()).thenReturn(DESCRIPTIONS[index]);
return erratum;
}
use of org.ovirt.engine.core.common.businessentities.Erratum in project ovirt-engine by oVirt.
the class BackendVmKatelloErrataResourceTest method getEntity.
@Override
protected Erratum getEntity(int index) {
Erratum erratum = mock(Erratum.class);
when(erratum.getId()).thenReturn(NAMES[index]);
when(erratum.getDescription()).thenReturn(DESCRIPTIONS[index]);
return erratum;
}
Aggregations