public static <T> Collection<PrismPropertyValue<T>> createCollection(PrismContext prismContext, Collection<T> realValueCollection) { Collection<PrismPropertyValue<T>> pvalCol = new ArrayList<>(realValueCollection.size()); for (T realValue: realValueCollection) { pvalCol.add(prismContext.itemFactory().createPropertyValue(realValue)); } return pvalCol; }
public static <T> Collection<PrismPropertyValue<T>> createCollection(PrismContext prismContext, T[] realValueArray) { Collection<PrismPropertyValue<T>> pvalCol = new ArrayList<>(realValueArray.length); for (T realValue: realValueArray) { pvalCol.add(prismContext.itemFactory().createPropertyValue(realValue)); } return pvalCol; }
public static <T> Collection<PrismPropertyValue<T>> wrap(PrismContext prismContext, @NotNull Collection<T> realValues) { return realValues.stream() .map(val -> prismContext.itemFactory().createPropertyValue(val)) .collect(Collectors.toList()); }
@SafeVarargs public static <T> PrismPropertyValue<T>[] wrap(PrismContext prismContext, T... realValues) { //noinspection unchecked return Arrays.stream(realValues) .map(val -> prismContext.itemFactory().createPropertyValue(val)) .toArray(PrismPropertyValue[]::new); }
public static <X> Collection<PrismPropertyValue<X>> toPrismPropertyValues(PrismContext prismContext, X... realValues) { Collection<PrismPropertyValue<X>> pvalues = new ArrayList<>(realValues.length); for (X val: realValues) { PrismUtil.recomputeRealValue(val, prismContext); PrismPropertyValue<X> pval = prismContext.itemFactory().createPropertyValue(val); pvalues.add(pval); } return pvalues; }
@Override public <O extends Objectable> ObjectDelta<O> createModificationDeleteReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for (int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationDeleteReference(type, oid, propertyName, referenceValues); }
private <T> RawType[] rawize(QName attrName, PrismContext prismContext, T[] expectedValues) { RawType[] raws = new RawType[expectedValues.length]; for(int i = 0; i < expectedValues.length; i++) { raws[i] = new RawType(prismContext.itemFactory().createPropertyValue(expectedValues[i]), attrName, prismContext); } return raws; }
@Override public <O extends Objectable> ObjectDelta<O> createModificationAddReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for(int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationAddReference(type, oid, propertyName, referenceValues); }
private static void addRealValue(Item<PrismValue, ItemDefinition> extensionItem, Object value, PrismContext prismContext) throws SchemaException { if (value != null) { extensionItem.add(prismContext.itemFactory().createValue(value).clone()); } }
private RefFilter createResourceRefFilter(String oid) throws SchemaException { PrismContext prismContext = context.getPrismContext(); List<PrismReferenceValue> values = new ArrayList<>(); if (oid != null) { values.add(prismContext.itemFactory().createReferenceValue(oid, ResourceType.COMPLEX_TYPE)); } SchemaRegistry registry = prismContext.getSchemaRegistry(); PrismReferenceDefinition def = registry.findItemDefinitionByFullPath(ShadowType.class, PrismReferenceDefinition.class, ShadowType.F_RESOURCE_REF); return prismContext.queryFactory().createReferenceEqual(ShadowType.F_RESOURCE_REF, def, values); }
public static <T,X> PrismPropertyValue<X> convertPropertyValue(PrismPropertyValue<T> srcVal, PrismPropertyDefinition<T> srcDef, PrismPropertyDefinition<X> targetDef, PrismContext prismContext) { if (targetDef.getTypeName().equals(srcDef.getTypeName())) { return (PrismPropertyValue<X>) srcVal; } else { Class<X> expectedJavaType = XsdTypeMapper.toJavaType(targetDef.getTypeName()); X convertedRealValue = JavaTypeConverter.convert(expectedJavaType, srcVal.getValue()); return prismContext.itemFactory().createPropertyValue(convertedRealValue); } }
private void resetFailedLogins(LensFocusContext<UserType> focusContext, AbstractCredentialType credentialTypeNew, ItemPath path) throws SchemaException{ if (credentialTypeNew != null) { Integer failedLogins = credentialTypeNew.getFailedLogins(); if (failedLogins != null && failedLogins != 0) { PrismPropertyDefinition<Integer> failedLoginsDef = getFailedLoginsDefinition(); PropertyDelta<Integer> failedLoginsDelta = failedLoginsDef.createEmptyDelta(path); failedLoginsDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(0, OriginType.USER_POLICY, null)); focusContext.swallowToProjectionWaveSecondaryDelta(failedLoginsDelta); } } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmptyParameters() { PrismPropertyValue<String> value = getPrismContext().itemFactory().createPropertyValue(input); value = filter.apply(value); AssertJUnit.assertEquals(expected, value.getValue()); }
private static PrismReferenceValue getAuditTarget(ObjectDelta<? extends ObjectType> delta, PrismContext prismContext) { PrismReferenceValue targetRef = prismContext.itemFactory().createReferenceValue(delta.getOid()); targetRef.setTargetType(ObjectTypes.getObjectType(delta.getObjectTypeClass()).getTypeQName()); if (delta.isAdd()) { targetRef.setObject(delta.getObjectToAdd()); } return targetRef; }
protected PrismContainerValue<AssignmentType> createAssignmentValue(Long id, String description) throws SchemaException { PrismContainerDefinition<AssignmentType> assignmentDef = getUserTypeDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); PrismContainerValue<AssignmentType> assignmentValue = getPrismContext().itemFactory().createContainerValue(); populateAssignmentValue(assignmentValue, id, description); return assignmentValue; }
@Test(expectedExceptions = IllegalArgumentException.class) public void testValueInElementBadParameters() { List<Object> parameters = createBadParameters(); filter.setParameters(parameters); PrismPropertyValue<String> value = getPrismContext().itemFactory().createPropertyValue(input); value = filter.apply(value); AssertJUnit.assertEquals(expected, value.getValue()); }
@Test public void testValue() { List<Object> parameters = createGoodParameters(); filter.setParameters(parameters); PrismPropertyValue<String> value = getPrismContext().itemFactory().createPropertyValue(input); value = filter.apply(value); AssertJUnit.assertEquals(expected, value.getValue()); }
private void collectMembership(ObjectReferenceType targetRef, QName relation, EvaluationContext ctx) { PrismReferenceValue refVal = prismContext.itemFactory().createReferenceValue(); refVal.setOid(targetRef.getOid()); refVal.setTargetType(targetRef.getType()); refVal.setRelation(relation); refVal.setTargetName(targetRef.getTargetName()); Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(targetRef.getType()).getClassDefinition(); collectMembershipRefVal(refVal, targetClass, relation, targetRef, ctx); }
private <F extends FocusType> void unlink(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationDeleteReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }
private <F extends FocusType> void link(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationAddReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }