Search in sources :

Example 1 with Erratum

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");
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) HashMap(java.util.HashMap) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) Erratum(org.ovirt.engine.core.common.businessentities.Erratum) AbstractIconTypeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn)

Example 2 with Erratum

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);
                }
            });
        }
    };
}
Also used : AbstractErrataListModel(org.ovirt.engine.ui.uicommonweb.models.AbstractErrataListModel) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) Handler(com.google.gwt.view.client.SelectionChangeEvent.Handler) PlaceTransitionHandler(org.ovirt.engine.ui.common.presenter.PlaceTransitionHandler) Erratum(org.ovirt.engine.core.common.businessentities.Erratum) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 3 with Erratum

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);
    }
}
Also used : ErrataCount(org.ovirt.engine.core.common.businessentities.ErrataCount) Erratum(org.ovirt.engine.core.common.businessentities.Erratum)

Example 4 with Erratum

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;
}
Also used : KatelloErratum(org.ovirt.engine.api.model.KatelloErratum) Erratum(org.ovirt.engine.core.common.businessentities.Erratum)

Example 5 with 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;
}
Also used : KatelloErratum(org.ovirt.engine.api.model.KatelloErratum) Erratum(org.ovirt.engine.core.common.businessentities.Erratum)

Aggregations

Erratum (org.ovirt.engine.core.common.businessentities.Erratum)14 KatelloErratum (org.ovirt.engine.api.model.KatelloErratum)6 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 HTML (com.google.gwt.user.client.ui.HTML)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 Handler (com.google.gwt.view.client.SelectionChangeEvent.Handler)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ErrataCount (org.ovirt.engine.core.common.businessentities.ErrataCount)1 PlaceTransitionHandler (org.ovirt.engine.ui.common.presenter.PlaceTransitionHandler)1 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)1 AbstractIconTypeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn)1 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)1 AbstractErrataListModel (org.ovirt.engine.ui.uicommonweb.models.AbstractErrataListModel)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1