Search in sources :

Example 31 with Containerable

use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.

the class ProvenanceMetadataPanel method createMetadataDetailsPanel.

private void createMetadataDetailsPanel(ListItem<PrismContainerValueWrapper<ProvenanceMetadataType>> provenanceListItem, ListItem<PrismContainerValueWrapper<ValueMetadataType>> valueMetadataListItem) {
    WebMarkupContainer panel = createAcquisitionPanel(PrismContainerWrapperModel.fromContainerValueWrapper(provenanceListItem.getModel(), ProvenanceMetadataType.F_ACQUISITION));
    provenanceListItem.add(panel);
    ToggleIconButton<Void> showMore = createShowMoreButton(provenanceListItem.getModel());
    provenanceListItem.add(showMore);
    IModel<PrismContainerWrapper<Containerable>> detailsModel = createDetailsModel(valueMetadataListItem.getModel());
    Label label = new Label(ID_YIELD_HEADER, createDetailsDescriptionModel(detailsModel));
    provenanceListItem.add(label);
    label.add(new VisibleBehaviour(() -> provenanceListItem.getModelObject().isShowEmpty()));
    MetadataContainerPanel<Containerable> defaultPanel = createDefaultPanel(detailsModel, provenanceListItem.getModel());
    defaultPanel.add(new VisibleBehaviour(() -> !getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
    provenanceListItem.add(defaultPanel);
    ItemPanelSettings settings = getSettings().copy();
    settings.setVisibilityHandler(w -> createItemVisibilityBehavior(w));
    ValueMetadataPanel<ValueMetadataType, PrismContainerValueWrapper<ValueMetadataType>> valueMetadataPanel = new ValueMetadataPanel<>(ID_VALUE_METADATA_DETAILS, valueMetadataListItem.getModel(), settings);
    valueMetadataPanel.add(new VisibleBehaviour(() -> getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
    provenanceListItem.add(valueMetadataPanel);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) Label(org.apache.wicket.markup.html.basic.Label) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Containerable(com.evolveum.midpoint.prism.Containerable) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 32 with Containerable

use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.

the class CollectionProcessor method compileObjectCollectionView.

private void compileObjectCollectionView(CompiledObjectCollectionView existingView, CollectionRefSpecificationType baseCollectionSpec, @NotNull ObjectCollectionType objectCollectionType, Class<? extends Containerable> targetTypeClass, Task task, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, ObjectNotFoundException {
    if (targetTypeClass == null) {
        if (existingView.getContainerType() == null) {
            QName targetTypeQName = objectCollectionType.getType();
            if (targetTypeQName == null) {
                throw new SchemaException("Target container type not specified in " + objectCollectionType);
            }
            targetTypeClass = ObjectTypes.getObjectTypeClassIfKnown(targetTypeQName);
            if (targetTypeClass == null) {
                PrismContainerDefinition<Containerable> def = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetTypeQName);
                if (def == null) {
                    throw new IllegalArgumentException("Unsupported container type " + targetTypeQName);
                }
                targetTypeClass = def.getTypeClass();
            }
            existingView.setContainerType(targetTypeQName);
        } else {
            QName targetTypeQName = existingView.getContainerType();
            targetTypeClass = ObjectTypes.getObjectTypeClass(targetTypeQName);
        }
    }
    // Used for help text in search panel
    if (objectCollectionType.getDescription() != null) {
        existingView.setObjectCollectionDescription(objectCollectionType.getDescription());
    }
    // hierarchy. It makes no sense to compile all domain specs from the entire hierarchy just to throw that out.
    if (!existingView.hasDomain()) {
        CollectionRefSpecificationType domainSpec = objectCollectionType.getDomain();
        if (domainSpec != null) {
            CompiledObjectCollectionView domainView = new CompiledObjectCollectionView();
            compileObjectCollectionView(domainView, domainSpec, targetTypeClass, task, result);
            if (domainView.getFilter() == null) {
                // We have domain specification, but compilation produced no filter. Which means that the domain is "all"
                // Explicitly set "all" filter here. We want to avoid confusion between no domain spec and "all" domain spec.
                existingView.setDomainFilter(prismContext.queryFactory().createAll());
            } else {
                existingView.setDomainFilter(domainView.getFilter());
            }
            existingView.setDomainOptions(domainView.getOptions());
        }
    }
    SearchFilterType collectionFilterType = objectCollectionType.getFilter();
    ObjectFilter collectionFilter;
    if (collectionFilterType != null) {
        collectionFilter = prismContext.getQueryConverter().parseFilter(collectionFilterType, targetTypeClass);
    } else {
        collectionFilter = null;
    }
    List<SelectorOptions<GetOperationOptions>> collectionOptions = GetOperationOptionsUtil.optionsBeanToOptions(objectCollectionType.getGetOptions());
    CollectionRefSpecificationType baseCollectionSpecFromCollection = objectCollectionType.getBaseCollection();
    if (baseCollectionSpecFromCollection == null && baseCollectionSpec == null) {
        existingView.setFilter(collectionFilter);
        existingView.setOptions(collectionOptions);
    } else {
        if (baseCollectionSpecFromCollection == null || baseCollectionSpec == null) {
            compileBaseCollectionSpec(collectionFilter, existingView, collectionOptions, baseCollectionSpec == null ? baseCollectionSpecFromCollection : baseCollectionSpec, targetTypeClass, task, result);
        } else {
            compileObjectCollectionView(existingView, baseCollectionSpecFromCollection, targetTypeClass, task, result);
            ObjectFilter baseFilterFromCollection = existingView.getFilter();
            Collection<SelectorOptions<GetOperationOptions>> baseOptionFromCollection = existingView.getOptions();
            compileObjectCollectionView(existingView, baseCollectionSpec, targetTypeClass, task, result);
            ObjectFilter baseFilter = existingView.getFilter();
            ObjectFilter combinedFilter = ObjectQueryUtil.filterAnd(baseFilterFromCollection, baseFilter, prismContext);
            combinedFilter = ObjectQueryUtil.filterAnd(combinedFilter, collectionFilter, prismContext);
            existingView.setFilter(combinedFilter);
            GetOperationOptionsBuilder optionsBuilder = schemaService.getOperationOptionsBuilder().setFrom(baseOptionFromCollection);
            optionsBuilder.mergeFrom(existingView.getOptions());
            optionsBuilder.mergeFrom(collectionOptions);
            existingView.setOptions(optionsBuilder.build());
        }
    }
    compileView(existingView, objectCollectionType.getDefaultView(), false);
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 33 with Containerable

use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.

the class TestAsyncUpdate method test004Configuration.

@Test
public void test004Configuration() throws Exception {
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    // WHEN
    resource = provisioningService.getObject(ResourceType.class, RESOURCE_ASYNC_OID, null, task, result);
    PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
    assertNotNull("No configuration container", configurationContainer);
    PrismContainerDefinition<?> confContDef = configurationContainer.getDefinition();
    assertNotNull("No configuration container definition", confContDef);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Containerable(com.evolveum.midpoint.prism.Containerable) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Example 34 with Containerable

use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.

the class ProvisioningTestUtil method checkRepoShadow.

public static void checkRepoShadow(PrismObject<ShadowType> repoShadow, ShadowKindType kind, Integer expectedNumberOfAttributes) {
    ShadowType repoShadowType = repoShadow.asObjectable();
    assertNotNull("No OID in repo shadow " + repoShadow, repoShadowType.getOid());
    assertNotNull("No name in repo shadow " + repoShadow, repoShadowType.getName());
    assertNotNull("No objectClass in repo shadow " + repoShadow, repoShadowType.getObjectClass());
    assertEquals("Wrong kind in repo shadow " + repoShadow, kind, repoShadowType.getKind());
    PrismContainer<Containerable> attributesContainer = repoShadow.findContainer(ShadowType.F_ATTRIBUTES);
    assertNotNull("No attributes in repo shadow " + repoShadow, attributesContainer);
    Collection<Item<?, ?>> attributes = attributesContainer.getValue().getItems();
    assertFalse("Empty attributes in repo shadow " + repoShadow, attributes.isEmpty());
    if (expectedNumberOfAttributes != null) {
        assertEquals("Unexpected number of attributes in repo shadow " + repoShadow, (int) expectedNumberOfAttributes, attributes.size());
    }
}
Also used : Item(com.evolveum.midpoint.prism.Item) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 35 with Containerable

use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.

the class TestMapping method test530DeleteAssignmentByIdWithMegaMappings.

/**
 * MID-4863 + MID-7057
 */
@Test
public void test530DeleteAssignmentByIdWithMegaMappings() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    InternalMonitor.reset();
    InternalMonitor.setTrace(InternalCounters.PRISM_OBJECT_CLONE_COUNT, true);
    final String userName = "test530";
    UserType user = new UserType(prismContext).name(userName).beginAssignment().targetRef(ROLE_SUPERUSER_OID, RoleType.COMPLEX_TYPE).<UserType>end().beginAssignment().beginConstruction().resourceRef(RESOURCE_DUMMY_MEGA_OUTBOUND.oid, ResourceType.COMPLEX_TYPE).<AssignmentType>end().end();
    String oid = addObject(user.asPrismObject(), null, task, result);
    PrismObject<UserType> userCreated = assertUser(oid, "after creation").display().assertAssignments(2).assertLinks(1, 0).getObject();
    DummyAccount account = assertDummyAccount(RESOURCE_DUMMY_MEGA_OUTBOUND_NAME, userName);
    assertThat(account.getAttributeValue("a-single-0555")).as("attribute value").isEqualTo(userName);
    when();
    AssignmentType roleAssignment = findAssignment(userCreated, ROLE_SUPERUSER_OID, SchemaConstants.ORG_DEFAULT);
    assertNotNull("role assignment not found", roleAssignment);
    PrismContainerValue<Containerable> roleAssignmentIdOnlyPcv = prismContext.itemFactory().createContainerValue();
    roleAssignmentIdOnlyPcv.setId(roleAssignment.getId());
    ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).delete(roleAssignmentIdOnlyPcv).asObjectDeltaCast(oid);
    rememberCounter(InternalCounters.PRISM_OBJECT_CLONE_COUNT);
    executeChanges(delta, null, task, result);
    then();
    assertSuccess(result);
    // we will be happy to get a number significantly lower than ~2000 (2x1000 mappings)
    assertCounterIncrement(InternalCounters.PRISM_OBJECT_CLONE_COUNT, 0, 100);
    assertUser(oid, "after assignment deletion").display().assertAssignments(1).assertLinks(1, 0);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Containerable(com.evolveum.midpoint.prism.Containerable) Test(org.testng.annotations.Test)

Aggregations

Containerable (com.evolveum.midpoint.prism.Containerable)42 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ArrayList (java.util.ArrayList)12 Test (org.testng.annotations.Test)10 Task (com.evolveum.midpoint.task.api.Task)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 Collection (java.util.Collection)6 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)5 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)5 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)5 QName (javax.xml.namespace.QName)5 IModel (org.apache.wicket.model.IModel)5 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)4 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)4 PrismPropertyWrapperColumn (com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn)4 Item (com.evolveum.midpoint.prism.Item)4 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 List (java.util.List)4