Search in sources :

Example 1 with InfoBoxType

use of com.evolveum.midpoint.web.component.box.InfoBoxType in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method createAvailabilityStatusInfoBoxModel.

private ReadOnlyModel<InfoBoxType> createAvailabilityStatusInfoBoxModel() {
    return new ReadOnlyModel<>(() -> {
        String messageKey = "PageResource.resource.availabilityUnknown";
        String backgroundColor = "bg-gray";
        String icon = "fa fa-question";
        ResourceType resource = getObjectDetailsModels().getObjectType();
        OperationalStateType operationalState = resource.getOperationalState();
        AdministrativeOperationalStateType administrativeOperationalState = resource.getAdministrativeOperationalState();
        boolean inMaintenance = false;
        if (administrativeOperationalState != null) {
            AdministrativeAvailabilityStatusType administrativeAvailabilityStatus = administrativeOperationalState.getAdministrativeAvailabilityStatus();
            if (administrativeAvailabilityStatus == AdministrativeAvailabilityStatusType.MAINTENANCE) {
                messageKey = "PageResource.resource.maintenance";
                backgroundColor = "bg-gray";
                icon = "fa fa-wrench";
                inMaintenance = true;
            }
        }
        if (operationalState != null && !inMaintenance) {
            AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
            if (lastAvailabilityStatus != null) {
                if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
                    messageKey = "PageResource.resource.up";
                    backgroundColor = "bg-green";
                    icon = "fa fa-power-off";
                } else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
                    backgroundColor = "bg-red";
                    messageKey = "PageResource.resource.down";
                    icon = "fa fa-ban";
                } else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
                    backgroundColor = "bg-yellow";
                    messageKey = "PageResource.resource.broken";
                    icon = "fa fa-warning";
                }
            }
        }
        InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, getPageBase().getString(messageKey));
        ConnectorType connectorType = getConnectorType(resource);
        if (connectorType == null) {
            // Connector not found. Probably bad connectorRef reference.
            infoBoxType.setNumber("--");
            infoBoxType.setDescription("--");
        } else {
            String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
            String connectorVersion = connectorType.getConnectorVersion();
            infoBoxType.setNumber(connectorName);
            infoBoxType.setDescription(connectorVersion);
        }
        return infoBoxType;
    });
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel)

Example 2 with InfoBoxType

use of com.evolveum.midpoint.web.component.box.InfoBoxType in project midpoint by Evolveum.

the class PageDashboard method getObjectInfoBoxTypeModel.

protected <O extends ObjectType> Model<InfoBoxType> getObjectInfoBoxTypeModel(Class<O> type, List<QName> items, Object eqObject, String bgColor, String icon, String keyPrefix, OperationResult result, Task task) {
    InfoBoxType infoBoxType = new InfoBoxType(bgColor, icon, getString(keyPrefix + ".label"));
    Integer totalCount = null;
    Integer activeCount = null;
    try {
        totalCount = getModelService().countObjects(type, null, null, task, result);
        if (totalCount == null) {
            totalCount = 0;
        }
        QName[] queryItems = new QName[items.size()];
        ObjectQuery query = getPrismContext().queryFor(type).item(items.toArray(queryItems)).eq(eqObject).build();
        activeCount = getModelService().countObjects(type, query, null, task, result);
        if (activeCount == null) {
            activeCount = 0;
        }
        infoBoxType.setNumber(activeCount + " " + getString(keyPrefix + ".number"));
        int progress = 0;
        if (totalCount != 0) {
            progress = activeCount * 100 / totalCount;
        }
        infoBoxType.setProgress(progress);
        infoBoxType.setDescription(totalCount + " " + getString(keyPrefix + ".total"));
    } catch (Exception e) {
        infoBoxType.setNumber("ERROR: " + e.getMessage());
    }
    customizationObjectInfoBoxType(infoBoxType, type, items, eqObject, bgColor, icon, keyPrefix, totalCount, activeCount, result, task);
    return new Model<>(infoBoxType);
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) QName(javax.xml.namespace.QName) Model(org.apache.wicket.model.Model) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 3 with InfoBoxType

use of com.evolveum.midpoint.web.component.box.InfoBoxType in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method createSchemaStatusInfo.

private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {
    String backgroundColor = "bg-gray";
    String icon = "fa fa-times";
    String numberMessage;
    String description = null;
    Integer progress = null;
    ResourceSchema refinedSchema;
    try {
        refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
        if (refinedSchema != null) {
            backgroundColor = "bg-purple";
            icon = "fa fa-cubes";
            // TODO is this correct?
            int numObjectTypes = refinedSchema.getObjectTypeDefinitions().size();
            int numAllDefinitions = refinedSchema.getObjectClassDefinitions().size() + numObjectTypes;
            numberMessage = numObjectTypes + " " + getPageBase().getString("PageResource.resource.objectTypes");
            if (numAllDefinitions != 0) {
                progress = numObjectTypes * 100 / numAllDefinitions;
                if (progress > 100) {
                    progress = 100;
                }
            }
            description = numAllDefinitions + " " + getPageBase().getString("PageResource.resource.schemaDefinitions");
        } else {
            numberMessage = getPageBase().getString("PageResource.resource.noSchema");
        }
    } catch (SchemaException e) {
        backgroundColor = "bg-danger";
        icon = "fa fa-warning";
        numberMessage = getPageBase().getString("PageResource.resource.schemaError");
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, getPageBase().getString("PageResource.resource.schema"));
    infoBoxType.setNumber(numberMessage);
    infoBoxType.setProgress(progress);
    infoBoxType.setDescription(description);
    Model<InfoBoxType> boxModel = new Model<>(infoBoxType);
    return new BasicInfoBoxPanel(ID_SCHEMA_STATUS, boxModel);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) BasicInfoBoxPanel(com.evolveum.midpoint.web.component.box.BasicInfoBoxPanel)

Example 4 with InfoBoxType

use of com.evolveum.midpoint.web.component.box.InfoBoxType in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method createLastAvailabilityStatusInfo.

private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
    String messageKey = "PageResource.resource.availabilityUnknown";
    String backgroundColor = "bg-gray";
    String icon = "fa fa-question";
    OperationalStateType operationalState = resource.getOperationalState();
    AdministrativeOperationalStateType administrativeOperationalState = resource.getAdministrativeOperationalState();
    boolean inMaintenance = false;
    if (administrativeOperationalState != null) {
        AdministrativeAvailabilityStatusType administrativeAvailabilityStatus = administrativeOperationalState.getAdministrativeAvailabilityStatus();
        if (administrativeAvailabilityStatus == AdministrativeAvailabilityStatusType.MAINTENANCE) {
            messageKey = "PageResource.resource.maintenance";
            backgroundColor = "bg-gray";
            icon = "fa fa-wrench";
            inMaintenance = true;
        }
    }
    if (operationalState != null && !inMaintenance) {
        AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
        if (lastAvailabilityStatus != null) {
            if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
                messageKey = "PageResource.resource.up";
                backgroundColor = "bg-green";
                icon = "fa fa-power-off";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
                backgroundColor = "bg-red";
                messageKey = "PageResource.resource.down";
                icon = "fa fa-ban";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
                backgroundColor = "bg-yellow";
                messageKey = "PageResource.resource.broken";
                icon = "fa fa-warning";
            }
        }
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, getPageBase().getString(messageKey));
    ConnectorType connectorType = getConnectorType(resource);
    if (connectorType == null) {
        // Connector not found. Probably bad connectorRef reference.
        infoBoxType.setNumber("--");
        infoBoxType.setDescription("--");
    } else {
        String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
        String connectorVersion = connectorType.getConnectorVersion();
        infoBoxType.setNumber(connectorName);
        infoBoxType.setDescription(connectorVersion);
    }
    Model<InfoBoxType> boxModel = new Model<>(infoBoxType);
    InfoBoxPanel lastAvailabilityStatus = new BasicInfoBoxPanel(ID_LAST_AVAILABILITY_STATUS, boxModel);
    lastAvailabilityStatus.setOutputMarkupId(true);
    return lastAvailabilityStatus;
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) BasicInfoBoxPanel(com.evolveum.midpoint.web.component.box.BasicInfoBoxPanel) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel) BasicInfoBoxPanel(com.evolveum.midpoint.web.component.box.BasicInfoBoxPanel)

Example 5 with InfoBoxType

use of com.evolveum.midpoint.web.component.box.InfoBoxType in project midpoint by Evolveum.

the class PageDashboard method createResourceInfoBoxPanel.

private Component createResourceInfoBoxPanel(OperationResult result, Task task) {
    InfoBoxType infoBoxType = new InfoBoxType("object-resource-bg", GuiStyleConstants.CLASS_OBJECT_RESOURCE_ICON, getString("PageDashboard.infobox.resources.label"));
    Integer totalCount;
    try {
        totalCount = getModelService().countObjects(ResourceType.class, null, null, task, result);
        if (totalCount == null) {
            totalCount = 0;
        }
        ObjectQuery query = QueryBuilder.queryFor(ResourceType.class, getPrismContext()).item(ResourceType.F_OPERATIONAL_STATE, OperationalStateType.F_LAST_AVAILABILITY_STATUS).eq(AvailabilityStatusType.UP).build();
        Integer activeCount = getModelService().countObjects(ResourceType.class, query, null, task, result);
        if (activeCount == null) {
            activeCount = 0;
        }
        infoBoxType.setNumber(activeCount + " " + getString("PageDashboard.infobox.resources.number"));
        int progress = 0;
        if (totalCount != 0) {
            progress = activeCount * 100 / totalCount;
        }
        infoBoxType.setProgress(progress);
        infoBoxType.setDescription(totalCount + " " + getString("PageDashboard.infobox.resources.total"));
    } catch (Exception e) {
        infoBoxType.setNumber("ERROR: " + e.getMessage());
    }
    Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
    return new InfoBoxPanel(ID_INFO_BOX_RESOURCES, boxModel, PageResources.class);
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) Model(org.apache.wicket.model.Model) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel)

Aggregations

InfoBoxType (com.evolveum.midpoint.web.component.box.InfoBoxType)12 Model (org.apache.wicket.model.Model)9 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)5 InfoBoxPanel (com.evolveum.midpoint.web.component.box.InfoBoxPanel)4 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)3 BasicInfoBoxPanel (com.evolveum.midpoint.web.component.box.BasicInfoBoxPanel)3 IModel (org.apache.wicket.model.IModel)3 ListModel (org.apache.wicket.model.util.ListModel)3 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 QName (javax.xml.namespace.QName)1