void addToPrismContainer(PrismContainer<LensFocusContextType> lensFocusContextTypeContainer, boolean reduced) throws SchemaException { LensFocusContextType lensFocusContextType = lensFocusContextTypeContainer.createNewValue().asContainerable(); super.storeIntoLensElementContextType(lensFocusContextType, reduced); lensFocusContextType.setSecondaryDeltas(secondaryDeltas.toObjectDeltaWavesType()); }
private static void mergeExtensionContainers(Item<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> dstItem, PrismContainer<Containerable> srcExtension) throws SchemaException { if (dstItem == null) { return; } PrismContainer<AssignmentType> dstContainer = (PrismContainer<AssignmentType>) dstItem; if (srcExtension != null && !srcExtension.isEmpty()) { PrismContainer<?> dstExtensionContainer = dstContainer.findOrCreateContainer(AssignmentType.F_EXTENSION); PrismContainerValue<?> dstExtensionContainerValue = dstExtensionContainer.getValues().isEmpty() ? dstExtensionContainer.createNewValue() : dstExtensionContainer.getValue(); ObjectTypeUtil.mergeExtension(dstExtensionContainerValue, srcExtension.getValue()); } }
protected void addAssignment(PrismObject<UserType> user, Long id, String description) throws SchemaException { PrismContainer<AssignmentType> assignment = user.findOrCreateContainer(UserType.F_ASSIGNMENT); PrismContainerValue<AssignmentType> assignmentValue = assignment.createNewValue(); populateAssignmentValue(assignmentValue, id, description); }
@Test public void testContainerSimpleDiffModificationsNoChange() throws Exception { System.out.println("\n\n===[ testContainerSimpleDiffModificationsNoChange ]===\n"); // GIVEN PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismContainerDefinition<AssignmentType> assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainer<AssignmentType> ass1 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass1cval = ass1.createNewValue(); ass1cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah", PrismTestUtil.getPrismContext()); PrismContainer<AssignmentType> ass2 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass2cval = ass2.createNewValue(); ass2cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah", PrismTestUtil.getPrismContext()); // WHEN Collection<? extends ItemDelta> modifications = ass1.diffModifications(ass2); // THEN assertNotNull(modifications); System.out.println(DebugUtil.debugDump(modifications)); assertEquals("Unexpected number of midifications", 0, modifications.size()); ItemDeltaCollectionsUtil.checkConsistence(modifications); }
public <V extends PrismValue, D extends ItemDefinition, AH extends AssignmentHolderType> Source<V,D> constructDefaultSource(ObjectDeltaObject<AH> focusOdo) throws SchemaException { if (objectTemplateMappingType != null) { return null; } PrismObject<AH> focus = focusOdo.getAnyObject(); assignmentDef = focus.getDefinition().findContainerDefinition(FocusType.F_ASSIGNMENT); PrismContainer<AssignmentType> assignment = assignmentDef.instantiate(); assignmentType = assignment.createNewValue().asContainerable(); QName relation = null; AssignmentPropertiesSpecificationType assignmentProperties = autoassignMappingType.getAssignmentProperties(); if (assignmentProperties != null) { relation = assignmentProperties.getRelation(); assignmentType.getSubtype().addAll(assignmentProperties.getSubtype()); } assignmentType.targetRef(role.getOid(), role.asPrismObject().getDefinition().getTypeName(), relation); Source<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> source = new Source<>(assignment, null, assignment, FocusType.F_ASSIGNMENT); return (Source<V, D>) source; }
@Test public void testContainerValueDiffDesciptionNoPath() throws Exception { System.out.println("\n\n===[ testContainerValueDiffDesciptionNoPath ]===\n"); // GIVEN PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismContainerDefinition<AssignmentType> assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainer<AssignmentType> ass1 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass1cval = ass1.createNewValue(); ass1cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah", PrismTestUtil.getPrismContext()); PrismContainer<AssignmentType> ass2 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass2cval = ass2.createNewValue(); ass2cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "chamalalia patlama paprtala", PrismTestUtil.getPrismContext()); // WHEN Collection<? extends ItemDelta> modifications = ass1cval.diff(ass2cval); // THEN assertNotNull(modifications); System.out.println(DebugUtil.debugDump(modifications)); assertEquals("Unexpected number of midifications", 1, modifications.size()); PrismAsserts.assertPropertyReplace( modifications, ItemPath.create(UserType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION), "chamalalia patlama paprtala"); ItemDeltaCollectionsUtil.checkConsistence(modifications); }
long tsStart = System.nanoTime(); PrismContainerValue<AssignmentType> newValue = assignmentContainer.createNewValue();
@Test public void testContainerDiffModificationsDesciption() throws Exception { System.out.println("\n\n===[ testContainerDiffModificationsDesciption ]===\n"); // GIVEN PrismObjectDefinition<UserType> userDef = getUserTypeDefinition(); PrismContainerDefinition<AssignmentType> assignmentContDef = userDef.findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainer<AssignmentType> ass1 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass1cval = ass1.createNewValue(); ass1cval.setId(1L); ass1cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "blah blah", PrismTestUtil.getPrismContext()); PrismContainer<AssignmentType> ass2 = assignmentContDef.instantiate(); PrismContainerValue<AssignmentType> ass2cval = ass2.createNewValue(); ass2cval.setId(1L); ass2cval.setPropertyRealValue(AssignmentType.F_DESCRIPTION, "chamalalia patlama paprtala", PrismTestUtil.getPrismContext()); // WHEN Collection<? extends ItemDelta> modifications = ass1.diffModifications(ass2); // THEN assertNotNull(modifications); System.out.println(DebugUtil.debugDump(modifications)); assertEquals("Unexpected number of midifications", 1, modifications.size()); PrismAsserts.assertPropertyReplace( modifications, ItemPath.create(UserType.F_ASSIGNMENT, 1L, AssignmentType.F_DESCRIPTION), "chamalalia patlama paprtala"); ItemDeltaCollectionsUtil.checkConsistence(modifications); }
@Test public void test990AddResourceWithEmptyConnectorConfiguration() throws Exception { OperationResult result = new OperationResult("test990AddResourceWithEmptyConnectorConfiguration"); PrismObject<ResourceType> prismResource = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class).instantiate(); PolyStringType name = new PolyStringType(); name.setOrig("Test Resource"); name.setNorm("test resource"); prismResource.asObjectable().setName(name); prismResource .findOrCreateContainer(ResourceType.F_CONNECTOR_CONFIGURATION) .findOrCreateContainer(SchemaConstants.ICF_CONFIGURATION_PROPERTIES) .createNewValue(); System.out.println("Original data before saving: " + prismResource.debugDump()); String oid = repositoryService.addObject(prismResource, null, result); PrismObject<ResourceType> fetchedResource = repositoryService.getObject(ResourceType.class, oid, null, result); System.out.println("Original data after saving: " + prismResource.debugDump()); System.out.println("Fetched data: " + fetchedResource.debugDump()); AssertJUnit.assertEquals(prismResource, fetchedResource); }
@Test public void singleValuedItems() throws Exception { System.out.println("===[ singleValuedItems ]==="); UserType userBean = getPrismContext().createObjectable(UserType.class) .beginAssignment() .id(1L) .targetRef(new ObjectReferenceType().oid("123456").type(RoleType.COMPLEX_TYPE)) .end(); //noinspection unchecked PrismContainerValue<AssignmentType> assignmentPcv = userBean.getAssignment().get(0).asPrismContainerValue(); PrismContainer<Containerable> limitContentPc = assignmentPcv .findOrCreateContainer(AssignmentType.F_LIMIT_TARGET_CONTENT); PrismContainerValue<Containerable> val1 = limitContentPc.createNewValue(); val1.setId(1L); PrismContainerValue<Containerable> val2 = val1.clone(); val2.setId(2L); try { limitContentPc.add(val2); fail("unexpected success"); } catch (SchemaException e) { System.out.println("Got expected exception: " + e); } }
@Override public boolean handle(PrismObject<ShadowType> entitlementShadow) { PrismContainerValue<ShadowAssociationType> associationCVal = associationContainer.createNewValue(); associationCVal.asContainerable().setName(associationName); Collection<ResourceAttribute<?>> entitlementIdentifiers = ShadowUtil.getAllIdentifiers(entitlementShadow); try { ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, entitlementDef.toResourceAttributeContainerDefinition(), prismContext); associationCVal.add(identifiersContainer); identifiersContainer.getValue().addAll(Item.cloneCollection(entitlementIdentifiers)); // Remember the full shadow in user data. This is used later as an optimization to create the shadow in repo identifiersContainer.setUserData(ResourceObjectConverter.FULL_SHADOW_KEY, entitlementShadow); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Processed entitlement-to-subject association for account {} and entitlement {}", ShadowUtil.getHumanReadableName(resourceObject), ShadowUtil.getHumanReadableName(entitlementShadow)); } } catch (SchemaException e) { throw new TunnelException(e); } return true; } };
private void selectMatchingShadows(List<String> candidateShadowsOidList, PrismContainer<ShadowAssociationType> output, String resourceOid, ShadowKindType kind, String intent, QName assocName, ExpressionEvaluationContext params) throws SchemaException { S_AtomicFilterExit filter = prismContext.queryFor(ShadowType.class) .id(candidateShadowsOidList.toArray(new String[0])) .and().item(ShadowType.F_RESOURCE_REF).ref(resourceOid) .and().item(ShadowType.F_KIND).eq(kind); if (intent != null) { filter = filter.and().item(ShadowType.F_INTENT).eq(intent); } ObjectQuery query = filter.build(); ResultHandler<ShadowType> handler = (object, parentResult) -> { PrismContainerValue<ShadowAssociationType> newValue = output.createNewValue(); ShadowAssociationType shadowAssociationType = newValue.asContainerable(); shadowAssociationType.setName(assocName); toAssociation(object, shadowAssociationType); return true; }; try { objectResolver.searchIterative(ShadowType.class, query, createNoFetchCollection(), handler, params.getTask(), params.getResult()); } catch (CommonException e) { throw new SystemException("Couldn't search for relevant shadows: " + e.getMessage(), e); } }
LensContextType lensContextType = lensContextTypeContainer.createNewValue().asContainerable();
void addToPrismContainer(PrismContainer<LensProjectionContextType> lensProjectionContextTypeContainer, boolean reduced) throws SchemaException { LensProjectionContextType lensProjectionContextType = lensProjectionContextTypeContainer.createNewValue().asContainerable(); super.storeIntoLensElementContextType(lensProjectionContextType, reduced); lensProjectionContextType.setSyncDelta(syncDelta != null ? DeltaConvertor.toObjectDeltaType(syncDelta) : null); lensProjectionContextType.setSecondaryDelta(secondaryDelta != null ? DeltaConvertor.toObjectDeltaType(secondaryDelta) : null); lensProjectionContextType.setWave(wave); lensProjectionContextType.setResourceShadowDiscriminator(resourceShadowDiscriminator != null ? resourceShadowDiscriminator.toResourceShadowDiscriminatorType() : null); lensProjectionContextType.setFullShadow(fullShadow); lensProjectionContextType.setIsAssigned(isAssigned); lensProjectionContextType.setIsAssignedOld(isAssignedOld); lensProjectionContextType.setIsActive(isActive); lensProjectionContextType.setIsLegal(isLegal); lensProjectionContextType.setIsLegalOld(isLegalOld); lensProjectionContextType.setIsExists(isExists); lensProjectionContextType.setSynchronizationPolicyDecision(synchronizationPolicyDecision != null ? synchronizationPolicyDecision.toSynchronizationPolicyDecisionType() : null); lensProjectionContextType.setDoReconciliation(doReconciliation); lensProjectionContextType.setSynchronizationSituationDetected(synchronizationSituationDetected); lensProjectionContextType.setSynchronizationSituationResolved(synchronizationSituationResolved); if (!reduced) { lensProjectionContextType.setAccountPasswordPolicy(accountPasswordPolicy); } lensProjectionContextType.setSyncAbsoluteTrigger(syncAbsoluteTrigger); }
PrismContainer<PasswordHistoryEntryType> historyEntry = historyEntryDefinition.instantiate(); PrismContainerValue<PasswordHistoryEntryType> historyEntryValue = historyEntry.createNewValue();
valueAttribute.add(assocAttrPVal.clone()); PrismContainerValue<ShadowAssociationType> associationCVal = associationContainer.createNewValue(); associationCVal.asContainerable().setName(associationName); ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer(
PrismContainerValue<AssignmentType> assRedContainerValue = assignmentContainer.createNewValue(); PrismProperty<String> assRedDescriptionProperty = assRedContainerValue.findOrCreateProperty(USER_DESCRIPTION_QNAME); assRedDescriptionProperty.addRealValue("Assignment created out of the red");