private void checkSchemaHandlingObjectTypes(ResourceValidationContext ctx, SchemaHandlingType schemaHandling) { int i = 1; for (ResourceObjectTypeDefinitionType objectType : schemaHandling.getObjectType()) { ItemPath path = ItemPath.create(ResourceType.F_SCHEMA_HANDLING, SchemaHandlingType.F_OBJECT_TYPE, i); checkSchemaHandlingObjectType(ctx, path, objectType); i++; } }
private void checkNotEmpty(ResourceValidationContext ctx, ItemPath path, ResourceObjectTypeDefinitionType objectType, ResourceObjectAssociationType associationDef, Collection<?> values, QName name, String errorCode) { if (values == null || values.isEmpty()) { ctx.validationResult.add(Issue.Severity.ERROR, CAT_SCHEMA_HANDLING, errorCode, getString(CLASS_DOT + errorCode, getName(objectType), String.valueOf(associationDef.getRef())), ctx.resourceRef, ItemPath.create(path, name)); } }
private void checkNotEmpty(ResourceValidationContext ctx, ItemPath path, ResourceObjectTypeDefinitionType objectType, ResourceObjectAssociationType associationDef, Object object, QName name, String errorCode) { if (object == null) { ctx.validationResult.add(Issue.Severity.ERROR, CAT_SCHEMA_HANDLING, errorCode, getString(CLASS_DOT + errorCode, getName(objectType), String.valueOf(associationDef.getRef())), ctx.resourceRef, ItemPath.create(path, name)); } }
public static String getStageUri(Task task) { PrismObject<TaskType> taskType = task.getTaskPrismObject(); PrismProperty<String> stageType = taskType.findProperty(ItemPath.create(TaskType.F_STAGE, TaskStageType.F_STAGE)); if (stageType == null) { return ModelPublicConstants.RECONCILIATION_TASK_HANDLER_URI + "#execute"; } return stageType.getRealValue(); }
private PropertyDelta<?> createActivationPropDelta(QName attrName, ResourceAttributeDefinition attrDef, Object value) { if (isBlank(value)) { return prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attrName), attrDef); } else { return prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, attrName), attrDef, value); } }
private ItemDelta<?, ?> addExtensionReferenceAndPrepareDelta(QName itemName, PrismReferenceDefinition definition, Collection<? extends PrismReferenceValue> values) throws SchemaException { ItemDelta delta = deltaFactory().reference().create(ItemPath.create(TaskType.F_EXTENSION, itemName), definition); return addExtensionItemAndPrepareDeltaCommon(delta, values); }
public ObjectTreeDeltas retrieveResultingDeltas(Task task) throws SchemaException { PrismProperty<ObjectTreeDeltasType> deltaTypePrismProperty = task.getTaskPrismObject().findProperty(ItemPath.create(F_WORKFLOW_CONTEXT, F_PROCESSOR_SPECIFIC_STATE, F_RESULTING_DELTAS)); if (deltaTypePrismProperty == null) { return null; } return ObjectTreeDeltas.fromObjectTreeDeltasType(deltaTypePrismProperty.getRealValue(), prismContext); }
@Test public void testFindPolyStringOrig() throws SchemaException, SAXException, IOException { final String TEST_NAME = "testFindPolyStringOrig"; System.out.println("===[ "+TEST_NAME+" ]==="); // GIVEN ItemPath path = ItemPath.create(UserType.F_POLY_NAME, PolyString.F_ORIG); // WHEN Object found = findUser(path); // THEN assertEquals("Wrong property value (path="+path+")", USER_JACK_POLYNAME_ORIG, found); }
private void checkSchemaHandlingDuplicateObjectTypes(ResourceValidationContext ctx, SchemaHandlingType schemaHandling) { DuplicateObjectTypeDetector detector = new DuplicateObjectTypeDetector(schemaHandling); if (detector.hasDuplicates()) { ctx.validationResult.add(Issue.Severity.WARNING, CAT_SCHEMA_HANDLING, C_MULTIPLE_SCHEMA_HANDLING_DEFINITIONS, getString(CLASS_DOT + C_MULTIPLE_SCHEMA_HANDLING_DEFINITIONS, detector.getDuplicatesList()), ctx.resourceRef, ItemPath.create(ResourceType.F_SCHEMA_HANDLING, SchemaHandlingType.F_OBJECT_TYPE)); } }
@Test public void test120FindExtensionProperty() throws Exception { System.out.println("===[ test120FindExtensionProperty ]==="); PrismObject<UserType> jack = getJack(); ItemPath bar23 = ItemPath.create(UserType.F_EXTENSION, "bar23"); measure("findProperty(extension/bar23)", () -> jack.findProperty(bar23)); }
@Test public void test130FindExtensionItem() throws Exception { System.out.println("===[ test130FindExtensionItem ]==="); PrismObject<UserType> jack = getJack(); ItemPath bar23 = ItemPath.create(UserType.F_EXTENSION, "bar23"); measure("findItem(extension/bar23)", () -> jack.findItem(bar23)); }
@Test public void test220SetExtensionItemString() throws Exception { System.out.println("===[ test220SetExtensionItemString ]==="); PrismObject<UserType> jack = getJack(); ItemPath bar23 = ItemPath.create(UserType.F_EXTENSION, "bar23"); measure("findProperty(extension/bar23).setRealValue", () -> { jack.findProperty(bar23).setRealValue("jack_" + Math.random()); return 1; }); }
private <T> PropertyDelta<T> createShadowPropertyReplaceDelta(PrismObject<ShadowType> repoShadow, QName propName, T value) { PrismPropertyDefinition<T> def = repoShadow.getDefinition().findPropertyDefinition(ItemName.fromQName(propName)); PropertyDelta<T> delta = def.createEmptyDelta(ItemPath.create(propName)); if (value == null) { delta.setValueToReplace(); } else { delta.setRealValuesToReplace(value); } return delta; }
@Test public void testExtensionShort() throws Exception { Session session = getFactory().openSession(); QName valueName = new QName(NS_P, "shortType"); ItemDefinition def = getDefinition(GenericObjectType.class, ItemPath.create(ObjectType.F_EXTENSION, valueName)); AssertJUnit.assertNotNull(def); Element value = DOMUtil.createElement(DOMUtil.getDocument(), valueName); value.setTextContent("123"); Object realValue = RAnyConverter.getRealRepoValue(def, value, prismContext); AssertJUnit.assertEquals(123L, realValue); session.close(); }
@Test public void testExtensionFloat() throws Exception { Session session = getFactory().openSession(); QName valueName = new QName(NS_P, "floatType"); ItemDefinition def = getDefinition(GenericObjectType.class, ItemPath.create(ObjectType.F_EXTENSION, valueName)); AssertJUnit.assertNotNull(def); Element value = DOMUtil.createElement(DOMUtil.getDocument(), valueName); value.setTextContent("123.1"); Object realValue = RAnyConverter.getRealRepoValue(def, value, prismContext); AssertJUnit.assertEquals("123.1", realValue); session.close(); }
@Test public void test210ModifyCaseProperties() throws Exception { OperationResult result = new OperationResult("test210ModifyCaseProperties"); List<ItemDelta<?, ?>> modifications = new ArrayList<>(); ItemPath case1 = ItemPath.create(F_CASE, 1L); modifications.add(prismContext.deltaFactory().property().createModificationReplaceProperty(case1.append(F_CURRENT_STAGE_OUTCOME), campaignDef, SchemaConstants.MODEL_CERTIFICATION_OUTCOME_REDUCE)); modifications.add(prismContext.deltaFactory().property().createModificationReplaceProperty(case1.append(AccessCertificationCaseType.F_STAGE_NUMBER), campaignDef, 300)); executeAndCheckModification(modifications, result, 0); checksCountsStandard(result); }
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; }
private PropertyModificationOperation createDeleteAttributeChange(String propertyName, String propertyValue) { PrismProperty property = createProperty(propertyName, propertyValue); ItemPath propertyPath = ItemPath.create(ShadowType.F_ATTRIBUTES, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), propertyName)); PropertyDelta delta = prismContext.deltaFactory().property().create(propertyPath, property.getDefinition()); delta.addRealValuesToDelete(propertyValue); PropertyModificationOperation attributeModification = new PropertyModificationOperation(delta); return attributeModification; }
public static ItemDelta<?, ?> createExtensionDelta(PrismPropertyDefinition definition, Object realValue, PrismContext prismContext) { PrismProperty<Object> property = (PrismProperty<Object>) definition.instantiate(); property.setRealValue(realValue); return prismContext.deltaFactory().property() .createModificationReplaceProperty(ItemPath.create(TaskType.F_EXTENSION, property.getElementName()), definition, realValue); }
@Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); repoAddObjectFromFile(ROLE_UNIT_WORKER_FILE, RoleType.class, initResult); repoAddObjectFromFile(ROLE_UNIT_SLEEPER_FILE, RoleType.class, initResult); repoAddObjectFromFile(ROLE_UNIT_WALKER_FILE, RoleType.class, initResult); modifyObjectReplaceProperty(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), ItemPath.create(SystemConfigurationType.F_ROLE_MANAGEMENT, RoleManagementConfigurationType.F_AUTOASSIGN_ENABLED), initTask, initResult, Boolean.TRUE); }