Search in sources :

Example 1 with ReportConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType in project midpoint by Evolveum.

the class ReportTypeUtil method applyDefinition.

public static void applyDefinition(PrismObject<ReportType> report, PrismContext prismContext) throws SchemaException {
    PrismContainer<ReportConfigurationType> configuration = report.findContainer(ReportType.F_CONFIGURATION);
    if (configuration == null) {
        //nothing to apply definitions on
        return;
    }
    PrismContainer xmlSchema = report.findContainer(ReportType.F_CONFIGURATION_SCHEMA);
    Element xmlSchemaElement = ObjectTypeUtil.findXsdElement(xmlSchema);
    if (xmlSchemaElement == null) {
        //no schema definition available
        throw new SchemaException("Couldn't find schema for configuration in report type " + report + ".");
    }
    PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext);
    PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema);
    if (definition == null) {
        //no definition found for container
        throw new SchemaException("Couldn't find definitions for report type " + report + ".");
    }
    configuration.applyDefinition(definition, true);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Element(org.w3c.dom.Element) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ReportConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType)

Example 2 with ReportConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType in project midpoint by Evolveum.

the class ReportTypeUtil method applyConfigurationDefinition.

public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext) throws SchemaException {
    PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext);
    PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema);
    if (definition == null) {
        //no definition found for container
        throw new SchemaException("Couldn't find definitions for report type " + report + ".");
    }
    Collection<ItemDelta> modifications = delta.getModifications();
    for (ItemDelta itemDelta : modifications) {
        if (itemDelta.hasCompleteDefinition()) {
            continue;
        }
        ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().tail());
        if (def != null) {
            itemDelta.applyDefinition(def);
        }
    }
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ReportConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType)

Aggregations

PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ReportConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportConfigurationType)2 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 Element (org.w3c.dom.Element)1