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);
}
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);
}
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);
}
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());
}
}
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);
}
Aggregations