public static PrismPropertyDefinition<Boolean> createConditionOutputDefinition(PrismContext prismContext) { return prismContext.definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN); } }
@PostConstruct private void initialize() { // this call must not be in the constructor, because prismContext is not yet initialized at that moment objectclassPropertyDefinition = prismContext.definitionFactory().createPropertyDefinition(ModelConstants.OBJECTCLASS_PROPERTY_NAME, DOMUtil.XSD_QNAME); taskManager.registerHandler(HANDLER_URI, this); }
@PostConstruct private void initialize() { filenamePropertyDefinition = prismContext.definitionFactory().createPropertyDefinition(ModelConstants.FILENAME_PROPERTY_NAME, DOMUtil.XSD_STRING); // must not be in the constructor, because prismContext is null at that time taskManager.registerHandler(HANDLER_URI, this); }
private List<NotificationMessageType> evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition<NotificationMessageType> resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, NotificationMessageType.COMPLEX_TYPE); Expression<PrismPropertyValue<NotificationMessageType>,PrismPropertyDefinition<NotificationMessageType>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple<PrismPropertyValue<NotificationMessageType>> exprResult = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, params, task, result); return exprResult.getZeroSet().stream().map(PrismPropertyValue::getValue).collect(Collectors.toList()); } }
public static PrismPropertyValue<Boolean> evaluateCondition(ExpressionVariables variables, ExpressionType expressionType, ExpressionFactory expressionFactory, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { ItemDefinition outputDefinition = expressionFactory.getPrismContext().definitionFactory().createPropertyDefinition( ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN); return (PrismPropertyValue<Boolean>) evaluateExpression(variables, outputDefinition, expressionType, expressionFactory, shortDesc, task, parentResult); }
private void evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition<String> resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING); Expression<PrismPropertyValue<String>,PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result); }
private PrismPropertyDefinition<String> getIcfNameDefinition() { return prismContext.definitionFactory().createPropertyDefinition(SchemaConstants.ICFS_NAME, DOMUtil.XSD_STRING); }
@SuppressWarnings("SameParameterValue") private <T> List<T> evaluateExpression(Class<T> resultClass, ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { QName xsdType = XsdTypeMapper.toXsdType(resultClass); QName resultName = new QName(SchemaConstants.NS_C, "result"); PrismPropertyDefinition<T> resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, xsdType); Expression<PrismPropertyValue<T>,PrismPropertyDefinition<T>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple<PrismPropertyValue<T>> exprResult = ModelExpressionThreadLocalHolder.evaluateExpressionInContext(expression, params, task, result); List<T> retval = new ArrayList<>(); for (PrismPropertyValue<T> item : exprResult.getZeroSet()) { retval.add(item.getValue()); } return retval; }
private List<String> evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { QName resultName = new QName(SchemaConstants.NS_C, "result"); MutablePrismPropertyDefinition<String> resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, DOMUtil.XSD_STRING); resultDef.setMaxOccurs(-1); Expression<PrismPropertyValue<String>,PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result); ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result); PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, params, task, result); List<String> retval = new ArrayList<>(); for (PrismPropertyValue<String> item : exprResult.getZeroSet()) { retval.add(item.getValue()); } return retval; }
private PrismPropertyDefinition<String> def(String name) { return getPrismContext().definitionFactory().createPropertyDefinition(new QName(NS_FOO, name), DOMUtil.XSD_STRING); }
private <T> PrismProperty<T> createTokenProperty(T object) { QName type = XsdTypeMapper.toXsdType(object.getClass()); //noinspection unchecked MutablePrismPropertyDefinition<T> propDef = prismContext.definitionFactory().createPropertyDefinition(SchemaConstants.SYNC_TOKEN, type); propDef.setDynamic(true); propDef.setMaxOccurs(1); propDef.setIndexed(false); // redundant, as dynamic extension items are not indexed by default PrismProperty<T> property = propDef.instantiate(); property.addRealValue(object); return property; }
private <T> List<PrismPropertyValue<T>> evaluateExpression(ScriptExpressionEvaluatorType scriptType, QName typeName, boolean scalar, ExpressionVariables variables, String shortDesc, OperationResult opResult) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { MutableItemDefinition outputDefinition = PrismTestUtil.getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, typeName); if (!scalar) { outputDefinition.setMaxOccurs(-1); } return evaluateExpression(scriptType, outputDefinition, variables, shortDesc, opResult); }
private PropertyDelta<String> createUselessStringDelta(String newVal) { PropertyDelta<String> uselessStringDelta = prismContext.deltaFactory().property().createModificationReplaceProperty( ItemPath.create(ResourceType.F_CONNECTOR_CONFIGURATION, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME, DummyResourceContoller.CONNECTOR_DUMMY_USELESS_STRING_QNAME), prismContext.definitionFactory().createPropertyDefinition(DummyResourceContoller.CONNECTOR_DUMMY_USELESS_STRING_QNAME, DOMUtil.XSD_STRING), newVal); return uselessStringDelta; }
@Test public void testValueElementsRoundtripString() throws Exception { final String TEST_NAME = "testValueElementsRoundtripString"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_STRING); propDef.setMaxOccurs(-1); PrismProperty<String> origProperty = propDef.instantiate(); origProperty.addRealValue("FOO"); origProperty.addRealValue("BAR"); doRoundtrip(origProperty, propDef, prismContext); }
@Test public void testMatchEqualMultivalue() throws Exception { PrismObject<UserType> user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML); MutablePrismPropertyDefinition<?> def = getPrismContext().definitionFactory().createPropertyDefinition(new QName("indexedString"), DOMUtil.XSD_STRING); ObjectFilter filter = getPrismContext().queryFor(UserType.class) .item(ItemPath.create(UserType.F_EXTENSION, "indexedString"), def).eq("alpha") .buildFilter(); boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry); AssertJUnit.assertTrue("filter does not match object", match); }
@Test public void testValueElementsRoundtripInt() throws Exception { final String TEST_NAME = "testValueElementsRoundtripInt"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); MutablePrismPropertyDefinition propDef = prismContext.definitionFactory().createPropertyDefinition(PROP_NAME, DOMUtil.XSD_INT); propDef.setMaxOccurs(-1); PrismProperty<Integer> origProperty = propDef.instantiate(); origProperty.addRealValue(42); origProperty.addRealValue(123); origProperty.addRealValue(321); doRoundtrip(origProperty, propDef, prismContext); }
private ObjectDelta<ResourceType> createConfigurationPropertyDelta(QName elementQName, String newValue) { ItemPath propPath = getConfigurationPropertyPath(elementQName); PrismPropertyDefinition<String> propDef = prismContext.definitionFactory().createPropertyDefinition(IntegrationTestTools.RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME, DOMUtil.XSD_STRING); PropertyDelta<String> propDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(propPath, propDef, newValue); ObjectDelta<ResourceType> resourceDelta = prismContext.deltaFactory().object() .createModifyDelta(RESOURCE_DUMMY_OID, propDelta, ResourceType.class); display("Resource delta", resourceDelta); return resourceDelta; }
@Test public void test144ModifyAccountAttributeDifferent() throws Exception { final String TEST_NAME = "test144ModifyAccountAttributeDifferent"; TestUtil.displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); assertNotNull("account-attribute was not imported in previous tests", accountOid); PrismPropertyDefinition<String> definition = prismContext.definitionFactory().createPropertyDefinition(SchemaConstants.ICFS_NAME, DOMUtil.XSD_STRING); List<ItemDelta<?, ?>> itemDeltas = prismContext.deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME), definition) .replace("account-new") .asItemDeltas(); repositoryService.modifyObject(ShadowType.class, accountOid, itemDeltas, getModifyOptions(), result); PrismObject<ShadowType> afterModify = repositoryService.getObject(ShadowType.class, accountOid, null, result); AssertJUnit.assertNotNull(afterModify); ShadowType afterFirstModifyType = afterModify.asObjectable(); System.out.println("shadow: " + afterModify.debugDump()); }
protected PrismObject<ShadowType> getParsedShadowBefore(PrismContext prismContext) throws SchemaException, IOException { PrismObject<ShadowType> oldObject = getRawShadowBefore(prismContext); // resolve rawtypes ObjectDeltaType objectChange = oldObject.asObjectable().getObjectChange(); for (ItemDeltaType itemDeltaType : objectChange.getItemDelta()) { for (RawType rawType : itemDeltaType.getValue()) { rawType.getParsedItem( prismContext.definitionFactory().createPropertyDefinition(itemDeltaType.getPath().getItemPath().lastName(), rawType.getXnode().getTypeQName())); } } return oldObject; }
private void prepareItemDefinitions() { DefinitionFactory factory = prismContext.definitionFactory(); fooDefinition = extItemDictionary.createOrFindItemDefinition(factory.createPropertyDefinition(FOO_QNAME, DOMUtil.XSD_STRING), false); shoeSizeDefinition = extItemDictionary.createOrFindItemDefinition(factory.createPropertyDefinition(SHOE_SIZE_QNAME, DOMUtil.XSD_INT), false); a1Definition = extItemDictionary.createOrFindItemDefinition(factory.createPropertyDefinition(A1_QNAME, DOMUtil.XSD_STRING), false); stringTypeDefinition = extItemDictionary.findItemByDefinition(factory.createPropertyDefinition(STRING_TYPE_QNAME, DOMUtil.XSD_STRING)); intTypeDefinition = extItemDictionary.findItemByDefinition(factory.createPropertyDefinition(INT_TYPE_QNAME, DOMUtil.XSD_INT)); longTypeDefinition = extItemDictionary.findItemByDefinition(factory.createPropertyDefinition(LONG_TYPE_QNAME, DOMUtil.XSD_LONG)); weaponDefinition = extItemDictionary.createOrFindItemDefinition(factory.createPropertyDefinition(WEAPON_QNAME, DOMUtil.XSD_STRING), false); overrideActivationDefinition = extItemDictionary.createOrFindItemDefinition(factory.createPropertyDefinition(OVERRIDE_ACTIVATION_QNAME, ACTIVATION_STATUS_TYPE_QNAME), false); skipAutogenerationDefinition = extItemDictionary.findItemByDefinition(factory.createPropertyDefinition(SKIP_AUTOGENERATION_QNAME, DOMUtil.XSD_BOOLEAN)); }