Search in sources :

Example 1 with InfoBoxPanel

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

the class ResourceDetailsTabPanel method createSchemaStatusInfo.

private InfoBoxPanel createSchemaStatusInfo(ResourceType resource) {
    String backgroundColor = "bg-gray";
    String icon = "fa-times";
    String numberMessage = null;
    String description = null;
    Integer progress = null;
    RefinedResourceSchema refinedSchema = null;
    try {
        refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
        if (refinedSchema != null) {
            backgroundColor = "bg-purple";
            icon = "fa-cubes";
            int numObjectTypes = 0;
            List<? extends RefinedObjectClassDefinition> refinedDefinitions = refinedSchema.getRefinedDefinitions();
            for (RefinedObjectClassDefinition refinedDefinition : refinedDefinitions) {
                if (refinedDefinition.getKind() != null) {
                    numObjectTypes++;
                }
            }
            int numAllDefinitions = refinedDefinitions.size();
            numberMessage = numObjectTypes + " " + parentPage.getString("PageResource.resource.objectTypes");
            if (numAllDefinitions != 0) {
                progress = numObjectTypes * 100 / numAllDefinitions;
                if (progress > 100) {
                    progress = 100;
                }
            }
            description = numAllDefinitions + " " + parentPage.getString("PageResource.resource.schemaDefinitions");
        } else {
            numberMessage = parentPage.getString("PageResource.resource.noSchema");
        }
    } catch (SchemaException e) {
        backgroundColor = "bg-danger";
        icon = "fa-warning";
        numberMessage = parentPage.getString("PageResource.resource.schemaError");
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString("PageResource.resource.schema"));
    infoBoxType.setNumber(numberMessage);
    infoBoxType.setProgress(progress);
    infoBoxType.setDescription(description);
    Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
    return new InfoBoxPanel(ID_SCHEMA_STATUS, boxModel);
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) 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) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel)

Example 2 with InfoBoxPanel

use of com.evolveum.midpoint.web.component.box.InfoBoxPanel 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-question";
    OperationalStateType operationalState = resource.getOperationalState();
    if (operationalState != null) {
        AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
        if (lastAvailabilityStatus != null) {
            if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
                messageKey = "PageResource.resource.up";
                backgroundColor = "bg-green";
                icon = "fa-power-off";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
                backgroundColor = "bg-red";
                messageKey = "PageResource.resource.down";
                icon = "fa-ban";
            } else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
                backgroundColor = "bg-yellow";
                messageKey = "PageResource.resource.broken";
                icon = "fa-warning";
            }
        }
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString(messageKey));
    ConnectorType connectorType = resource.getConnector();
    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>(infoBoxType);
    InfoBoxPanel lastAvailabilityStatus = new InfoBoxPanel(ID_LAST_AVAILABILITY_STATUS, boxModel);
    lastAvailabilityStatus.setOutputMarkupId(true);
    return lastAvailabilityStatus;
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationalStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType) 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) AvailabilityStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel)

Example 3 with InfoBoxPanel

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

the class ResourceDetailsTabPanel method createSourceTargetInfo.

private InfoBoxPanel createSourceTargetInfo(ResourceType resource) {
    String backgroundColor = "bg-aqua";
    SourceTarget sourceTarget = determineIfSourceOrTarget(resource);
    String numberKey = null;
    switch(sourceTarget) {
        case SOURCE:
            numberKey = "PageResource.resource.source";
            break;
        case TARGET:
            numberKey = "PageResource.resource.target";
            break;
        case SOURCE_TARGET:
            numberKey = "PageResource.resource.sourceAndTarget";
            break;
        default:
            backgroundColor = "bg-gray";
            numberKey = "PageResource.resource.noMappings";
            break;
    }
    InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, sourceTarget.getCssClass(), parentPage.getString("PageResource.resource.mappings"));
    infoBoxType.setNumber(parentPage.getString(numberKey));
    if (isSynchronizationDefined(resource)) {
        infoBoxType.setDescription(parentPage.getString("PageResource.resource.sync"));
    }
    Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
    return new InfoBoxPanel(ID_SOURCE_TARGET, boxModel);
}
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) InfoBoxPanel(com.evolveum.midpoint.web.component.box.InfoBoxPanel)

Example 4 with InfoBoxPanel

use of com.evolveum.midpoint.web.component.box.InfoBoxPanel 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)

Example 5 with InfoBoxPanel

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

the class PageDashboard method createFocusInfoBoxPanel.

private <F extends FocusType> InfoBoxPanel createFocusInfoBoxPanel(String id, Class<F> type, String bgColor, String icon, String keyPrefix, Class<? extends IRequestablePage> linkPage, OperationResult result, Task task) {
    InfoBoxType infoBoxType = new InfoBoxType(bgColor, icon, getString(keyPrefix + ".label"));
    Integer allCount;
    try {
        allCount = getModelService().countObjects(type, null, null, task, result);
        if (allCount == null) {
            allCount = 0;
        }
        ObjectQuery queryDisabled = QueryBuilder.queryFor(type, getPrismContext()).item(FocusType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS).eq(ActivationStatusType.DISABLED).build();
        Integer disabledCount = getModelService().countObjects(type, queryDisabled, null, task, result);
        if (disabledCount == null) {
            disabledCount = 0;
        }
        ObjectQuery queryArchived = QueryBuilder.queryFor(type, getPrismContext()).item(FocusType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS).eq(ActivationStatusType.ARCHIVED).build();
        Integer archivedCount = getModelService().countObjects(type, queryArchived, null, task, result);
        if (archivedCount == null) {
            archivedCount = 0;
        }
        int activeCount = allCount - disabledCount - archivedCount;
        int totalCount = allCount - archivedCount;
        infoBoxType.setNumber(activeCount + " " + getString(keyPrefix + ".number"));
        int progress = 0;
        if (totalCount != 0) {
            progress = activeCount * 100 / totalCount;
        }
        infoBoxType.setProgress(progress);
        StringBuilder descSb = new StringBuilder();
        descSb.append(totalCount).append(" ").append(getString(keyPrefix + ".total"));
        if (archivedCount != 0) {
            descSb.append(" ( + ").append(archivedCount).append(" ").append(getString(keyPrefix + ".archived")).append(")");
        }
        infoBoxType.setDescription(descSb.toString());
    } catch (Exception e) {
        infoBoxType.setNumber("ERROR: " + e.getMessage());
    }
    Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
    return new InfoBoxPanel(id, boxModel, linkPage);
}
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

InfoBoxPanel (com.evolveum.midpoint.web.component.box.InfoBoxPanel)6 InfoBoxType (com.evolveum.midpoint.web.component.box.InfoBoxType)6 Model (org.apache.wicket.model.Model)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 IModel (org.apache.wicket.model.IModel)3 ListModel (org.apache.wicket.model.util.ListModel)3 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AvailabilityStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType)1 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)1 OperationalStateType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalStateType)1