Search in sources :

Example 11 with InfoBoxType

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

the class ResourceDetailsTabPanel method createSchemaStatusInfoBoxModel.

private ReadOnlyModel<InfoBoxType> createSchemaStatusInfoBoxModel() {
    return new ReadOnlyModel<>(() -> {
        String backgroundColor = "bg-gray";
        String icon = "fa fa-times";
        String numberMessage;
        String description = null;
        Integer progress = null;
        ResourceSchema refinedSchema;
        try {
            refinedSchema = getObjectDetailsModels().getRefinedSchema();
            if (refinedSchema != null) {
                backgroundColor = "bg-purple";
                icon = "fa fa-cubes";
                // TODO is this correct?
                int numObjectTypes = refinedSchema.getObjectTypeDefinitions().size();
                int numAllDefinitions = numObjectTypes + refinedSchema.getObjectClassDefinitions().size();
                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);
        return infoBoxType;
    });
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel)

Example 12 with InfoBoxType

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

the class ResourceDetailsTabPanel method createSourceTargetInfoBoxModel.

private ReadOnlyModel<InfoBoxType> createSourceTargetInfoBoxModel() {
    return new ReadOnlyModel<>(() -> {
        PrismObjectWrapper<ResourceType> resource = getObjectDetailsModels().getObjectWrapper();
        String backgroundColor = "bg-aqua";
        SourceTarget sourceTarget = determineIfSourceOrTarget(resource);
        String numberKey;
        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(), getPageBase().getString("PageResource.resource.mappings"));
        infoBoxType.setNumber(getPageBase().getString(numberKey));
        if (isSynchronizationDefined(resource)) {
            infoBoxType.setDescription(getPageBase().getString("PageResource.resource.sync"));
        }
        return infoBoxType;
    });
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel)

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