Search in sources :

Example 16 with ResourceObjectTypeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method addSelectedAccountPerformed.

private void addSelectedAccountPerformed(AjaxRequestTarget target, List<ResourceType> newResources) {
    getPageBase().hideMainPopup(target);
    if (newResources.isEmpty()) {
        warn(getString("pageUser.message.noResourceSelected"));
        return;
    }
    for (ResourceType resource : newResources) {
        try {
            ShadowType shadow = new ShadowType();
            ObjectReferenceType resourceRef = new ObjectReferenceType();
            resourceRef.asReferenceValue().setObject(resource.asPrismObject());
            shadow.setResourceRef(resourceRef);
            ResourceType usedResource = resource;
            ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource.asPrismObject(), LayerType.PRESENTATION);
            if (refinedSchema == null) {
                Task task = getPageBase().createSimpleTask(FocusPersonasTabPanel.class.getSimpleName() + ".loadResource");
                OperationResult result = task.getResult();
                PrismObject<ResourceType> loadedResource = WebModelServiceUtils.loadObject(ResourceType.class, resource.getOid(), getPageBase(), task, result);
                result.recomputeStatus();
                refinedSchema = ResourceSchemaFactory.getCompleteSchema(loadedResource, LayerType.PRESENTATION);
                if (refinedSchema == null) {
                    error(getString("pageAdminFocus.message.couldntCreateAccountNoSchema", resource.getName()));
                    continue;
                }
                // shadow.setResource(loadedResource.asObjectable());
                usedResource = loadedResource.asObjectable();
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Refined schema for {}\n{}", resource, refinedSchema.debugDump());
            }
            ResourceObjectTypeDefinition accountDefinition = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
            if (accountDefinition == null) {
                error(getString("pageAdminFocus.message.couldntCreateAccountNoAccountSchema", resource.getName()));
                continue;
            }
            // shadow.asPrismContainer().findOrCreateContainer(ShadowType.F_ATTRIBUTES).applyDefinition(accountDefinition.toResourceAttributeContainerDefinition());
            QName objectClass = accountDefinition.getObjectClassDefinition().getTypeName();
            ObjectReferenceType usedResourceRef = new ObjectReferenceType();
            usedResourceRef.asReferenceValue().setObject(usedResource.asPrismObject());
            shadow.setResourceRef(usedResourceRef);
            shadow.setObjectClass(objectClass);
            shadow.setIntent(accountDefinition.getIntent());
            shadow.setKind(accountDefinition.getKind());
            getPrismContext().adopt(shadow);
            Task task = getPageBase().createSimpleTask(OPERATION_ADD_ACCOUNT);
            PrismObjectWrapperFactory<ShadowType> factory = getPageBase().getRegistry().getObjectWrapperFactory(shadow.asPrismContainer().getDefinition());
            WrapperContext context = new WrapperContext(task, task.getResult());
            ShadowWrapper wrapperNew = (ShadowWrapper) factory.createObjectWrapper(shadow.asPrismContainer(), ItemStatus.ADDED, context);
            if (task.getResult() != null && !WebComponentUtil.isSuccessOrHandledError(task.getResult())) {
                showResult(task.getResult(), false);
            }
            wrapperNew.setProjectionStatus(UserDtoStatus.ADD);
            projectionModel.getObject().add(wrapperNew);
        } catch (Exception ex) {
            error(getString("pageAdminFocus.message.couldntCreateAccount", resource.getName(), ex.getMessage()));
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create account", ex);
        }
    }
    target.add(getMultivalueContainerListPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)

Example 17 with ResourceObjectTypeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.

the class SynchronizationContext method getIntent.

public String getIntent() throws SchemaException {
    if (!hasApplicablePolicy()) {
        return SchemaConstants.INTENT_UNKNOWN;
    }
    if (intent == null) {
        ResourceSchema schema = ResourceSchemaFactory.getCompleteSchema(resource);
        ResourceObjectDefinition def = schema.findObjectDefinition(getKind(), null);
        if (def instanceof ResourceObjectTypeDefinition) {
            // TODO ???
            intent = ((ResourceObjectTypeDefinition) def).getIntent();
        }
    }
    return intent;
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)

Example 18 with ResourceObjectTypeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.

the class SynchronizationContext method findObjectTypeDefinition.

ResourceObjectTypeDefinition findObjectTypeDefinition() throws SchemaException {
    ResourceSchema refinedResourceSchema = ResourceSchemaFactory.getCompleteSchema(resource);
    ShadowKindType kind = getKind();
    // FIXME this hacking
    String intent = getIntent();
    if (kind == null || kind == ShadowKindType.UNKNOWN) {
        // nothing to look for
        return null;
    }
    if (SchemaConstants.INTENT_UNKNOWN.equals(intent)) {
        intent = null;
    }
    // FIXME the cast
    return (ResourceObjectTypeDefinition) refinedResourceSchema.findObjectDefinition(kind, intent);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)

Example 19 with ResourceObjectTypeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.

the class SynchronizationServiceImpl method processTag.

private <F extends FocusType> void processTag(SynchronizationContext<F> syncCtx, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
    PrismObject<ShadowType> applicableShadow = syncCtx.getShadowedResourceObject();
    if (applicableShadow.asObjectable().getTag() != null) {
        return;
    }
    ResourceObjectTypeDefinition rOcd = syncCtx.findObjectTypeDefinition();
    if (rOcd == null) {
        // We probably do not have kind/intent yet.
        return;
    }
    ResourceObjectMultiplicityType multiplicity = rOcd.getObjectMultiplicity();
    if (!RefinedDefinitionUtil.isMultiaccount(multiplicity)) {
        return;
    }
    String tag = synchronizationExpressionsEvaluator.generateTag(multiplicity, applicableShadow, syncCtx.getResource(), syncCtx.getSystemConfiguration(), "tag expression for " + applicableShadow, syncCtx.getTask(), result);
    LOGGER.debug("SYNCHRONIZATION: TAG generated: {}", tag);
    syncCtx.setTag(tag);
}
Also used : ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)

Example 20 with ResourceObjectTypeDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition in project midpoint by Evolveum.

the class TestDummyExtra method assertSchemaSanity.

@Override
protected void assertSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) throws Exception {
    // schema is extended, displayOrders are changed
    dummyResourceCtl.assertDummyResourceSchemaSanityExtended(resourceSchema, resourceType, false, 20);
    ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
    ResourceObjectTypeDefinition accountRDef = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
    Collection<ResourceAssociationDefinition> associationDefinitions = accountRDef.getAssociationDefinitions();
    assertEquals("Wrong number of association defs", 3, associationDefinitions.size());
    ResourceAssociationDefinition crewAssociationDef = accountRDef.findAssociationDefinition(ASSOCIATION_CREW_NAME);
    assertNotNull("No definition for crew association", crewAssociationDef);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)

Aggregations

ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)32 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)14 QName (javax.xml.namespace.QName)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 ArrayList (java.util.ArrayList)5 Test (org.testng.annotations.Test)5 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)3 List (java.util.List)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 Definition (com.evolveum.midpoint.prism.Definition)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 ResourceAssociationDefinition (com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 NotNull (org.jetbrains.annotations.NotNull)2 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)1