Search in sources :

Example 11 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition 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 12 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class ResourceContentResourcePanel method createAttributeDefinitionList.

private <T extends ObjectType> Map<ItemPath, ItemDefinition> createAttributeDefinitionList() {
    Map<ItemPath, ItemDefinition> map = new HashMap<>();
    RefinedObjectClassDefinition ocDef = null;
    try {
        if (getKind() != null) {
            ocDef = getDefinitionByKind();
        } else if (getObjectClass() != null) {
            ocDef = getDefinitionByObjectClass();
        }
    } catch (SchemaException e) {
        warn("Could not get determine object class definition");
        return map;
    }
    if (ocDef == null) {
        return map;
    }
    ItemPath attributePath = new ItemPath(ShadowType.F_ATTRIBUTES);
    for (ItemDefinition def : (List<ItemDefinition>) ocDef.getDefinitions()) {
        if (!(def instanceof PrismPropertyDefinition) && !(def instanceof PrismReferenceDefinition)) {
            continue;
        }
        map.put(new ItemPath(attributePath, def.getName()), def);
    }
    return map;
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) HashMap(java.util.HashMap) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) List(java.util.List) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Example 13 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class LensUtil method refineProjectionIntent.

public static String refineProjectionIntent(ShadowKindType kind, String intent, ResourceType resource, PrismContext prismContext) throws SchemaException {
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext);
    RefinedObjectClassDefinition rObjClassDef = refinedSchema.getRefinedDefinition(kind, intent);
    if (rObjClassDef == null) {
        throw new SchemaException("No projection definition for kind=" + kind + " intent=" + intent + " in " + resource);
    }
    return rObjClassDef.getIntent();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema)

Example 14 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class LensUtil method needsFullShadowForCredentialProcessing.

public static boolean needsFullShadowForCredentialProcessing(LensProjectionContext projCtx) throws SchemaException {
    RefinedObjectClassDefinition refinedProjDef = projCtx.getStructuralObjectClassDefinition();
    if (refinedProjDef == null) {
        return false;
    }
    List<MappingType> outboundMappingType = refinedProjDef.getPasswordOutbound();
    if (outboundMappingType == null) {
        return false;
    }
    for (MappingType mappingType : outboundMappingType) {
        if (mappingType.getStrength() == MappingStrengthType.STRONG || mappingType.getStrength() == MappingStrengthType.WEAK) {
            return true;
        }
    }
    return false;
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)

Example 15 with RefinedObjectClassDefinition

use of com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition in project midpoint by Evolveum.

the class Construction method debugDump.

@Override
public String debugDump(int indent) {
    StringBuilder sb = new StringBuilder();
    DebugUtil.debugDumpLabel(sb, "Construction", indent);
    if (refinedObjectClassDefinition == null) {
        sb.append(" (no object class definition)");
        if (getConstructionType() != null && getConstructionType().getResourceRef() != null) {
            // should
            // be
            // always
            // the
            // case
            sb.append("\n");
            DebugUtil.debugDumpLabel(sb, "resourceRef / kind / intent", indent + 1);
            sb.append(" ");
            sb.append(ObjectTypeUtil.toShortString(getConstructionType().getResourceRef()));
            sb.append(" / ");
            sb.append(getConstructionType().getKind());
            sb.append(" / ");
            sb.append(getConstructionType().getIntent());
        }
    } else {
        sb.append(refinedObjectClassDefinition.getShadowDiscriminator());
    }
    if (getConstructionType() != null && getConstructionType().getStrength() == ConstructionStrengthType.WEAK) {
        sb.append(" weak");
    }
    sb.append("\n");
    DebugUtil.debugDumpWithLabel(sb, "isValid", isValid(), indent + 1);
    sb.append("\n");
    DebugUtil.debugDumpLabel(sb, "auxiliary object classes", indent + 1);
    if (auxiliaryObjectClassDefinitions == null) {
        sb.append(" (null)");
    } else if (auxiliaryObjectClassDefinitions.isEmpty()) {
        sb.append(" (empty)");
    } else {
        for (RefinedObjectClassDefinition auxiliaryObjectClassDefinition : auxiliaryObjectClassDefinitions) {
            sb.append("\n");
            DebugUtil.indentDebugDump(sb, indent + 2);
            sb.append(auxiliaryObjectClassDefinition.getTypeName());
        }
    }
    if (getConstructionType() != null && getConstructionType().getDescription() != null) {
        sb.append("\n");
        DebugUtil.debugDumpLabel(sb, "description", indent + 1);
        sb.append(" ").append(getConstructionType().getDescription());
    }
    if (attributeMappings != null && !attributeMappings.isEmpty()) {
        sb.append("\n");
        DebugUtil.debugDumpLabel(sb, "attribute mappings", indent + 1);
        for (Mapping mapping : attributeMappings) {
            sb.append("\n");
            sb.append(mapping.debugDump(indent + 2));
        }
    }
    if (associationMappings != null && !associationMappings.isEmpty()) {
        sb.append("\n");
        DebugUtil.debugDumpLabel(sb, "association mappings", indent + 1);
        for (Mapping mapping : associationMappings) {
            sb.append("\n");
            sb.append(mapping.debugDump(indent + 2));
        }
    }
    if (getAssignmentPath() != null) {
        sb.append("\n");
        sb.append(getAssignmentPath().debugDump(indent + 1));
    }
    return sb.toString();
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) Mapping(com.evolveum.midpoint.model.common.mapping.Mapping)

Aggregations

RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)72 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)33 QName (javax.xml.namespace.QName)28 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)20 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)17 RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)12 PrismObject (com.evolveum.midpoint.prism.PrismObject)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 Task (com.evolveum.midpoint.task.api.Task)8 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)8 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)7 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 SystemException (com.evolveum.midpoint.util.exception.SystemException)7 Collection (java.util.Collection)7 RefinedAssociationDefinition (com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition)6