protected Integer getWorkerThreadsCount(Task task) { PrismProperty<Integer> workerThreadsPrismProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS); if (workerThreadsPrismProperty != null && workerThreadsPrismProperty.getRealValue() != null) { return workerThreadsPrismProperty.getRealValue(); } else { return null; } }
private long parseLong(PrismProperty<?> prop) { Object realValue = prop.getRealValue(); if (realValue instanceof Long) { return (Long) realValue; } else if (realValue instanceof Integer) { return ((Integer) realValue); } else { throw new IllegalArgumentException("Cannot convert " + realValue.getClass() + " to long"); } }
private <T extends ObjectType> ObjectDelta<T> createDeltaFromTask(Task task) throws SchemaException { PrismProperty<ObjectDeltaType> objectDeltaType = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA); if (objectDeltaType != null && objectDeltaType.getRealValue() != null) { return DeltaConvertor.createObjectDelta(objectDeltaType.getRealValue(), prismContext); } else { return null; } }
public <T> T getPropertyRealValue(ItemPath propertyPath, Class<T> type) { PrismProperty<T> property = findProperty(propertyPath); if (property == null) { return null; } return property.getRealValue(type); }
@Override public <T> T getExtensionPropertyRealValue(QName propertyName) { PrismProperty<T> property = getExtensionProperty(propertyName); if (property == null || property.isEmpty()) { return null; } else { return property.getRealValue(); } }
public <T> T getPropertyRealValue(QName propertyName, Class<T> type) { PrismProperty<T> property = findProperty(ItemName.fromQName(propertyName)); if (property == null) { // when using sql repo, even non-existing properties do not have 'null' here return null; } return property.getRealValue(type); }
private String getNamePropertyStringValue() { PrismProperty<PolyString> nameProperty = getNameProperty(); if (nameProperty == null) { return null; } PolyString realValue = nameProperty.getRealValue(); if (realValue == null) { return null; } return realValue.getOrig(); }
public static String getSingleStringAttributeValue(PrismObject<ShadowType> shadow, QName attrName) { PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer == null) { return null; } PrismProperty<String> attribute = attributesContainer.findProperty(ItemName.fromQName(attrName)); if (attribute == null) { return null; } return attribute.getRealValue(); }
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 void validateName(PrismObject object) throws SchemaException { PrismProperty name = object.findProperty(ObjectType.F_NAME); if (name == null || ((PolyString) name.getRealValue()).isEmpty()) { throw new SchemaException("Attempt to add object without name."); } }
public PolyString getName() { PrismProperty<PolyString> nameProperty = getValue().findProperty(getNamePropertyElementName()); if (nameProperty == null) { return null; } return nameProperty.getRealValue(); }
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); }
protected <T> void assertPropertyEquals(QName propName, T expected) { PrismProperty<T> prop = getObject().findProperty(ItemName.fromQName(propName)); if (prop == null && expected == null) { return; } assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); T realValue = prop.getRealValue(); assertNotNull("No value in "+propName.getLocalPart()+" in "+desc(), realValue); assertEquals("Wrong "+propName.getLocalPart()+" in "+desc(), expected, realValue); }
protected void assertPolyStringProperty(QName propName, String expectedOrig) { PrismProperty<PolyString> prop = getObject().findProperty(ItemName.fromQName(propName)); assertNotNull("No "+propName.getLocalPart()+" in "+desc(), prop); PrismAsserts.assertEqualsPolyString("Wrong "+propName.getLocalPart()+" in "+desc(), expectedOrig, prop.getRealValue()); }
@Test public void testResolvePathStringProperty() throws Exception { final String TEST_NAME = "testResolvePathStringProperty"; System.out.println("\n===[ "+TEST_NAME+" ]===\n"); // GIVEN // WHEN PrismProperty<String> resolvedProperty = resolvePath("$user/description", TEST_NAME); // THEN assertEquals("Wrong resolved property value", "jack", resolvedProperty.getRealValue()); }
public static String retrieveUsualNamespacePrefix(ConnectorType connectorType) { if (connectorType.getExtension() != null) { PrismContainerValue<ExtensionType> ext = connectorType.getExtension().asPrismContainerValue(); PrismProperty<String> prefixProp = ext.findProperty(SchemaConstants.ICF_CONNECTOR_USUAL_NAMESPACE_PREFIX); if (prefixProp != null) { return prefixProp.getRealValue(); } } return null; }
@Test public void testFindAssignment2Construction() throws SchemaException, SAXException, IOException { final String TEST_NAME = "testFindAssignment2ConstructionHowto"; System.out.println("===[ "+TEST_NAME+" ]==="); // GIVEN ItemPath path = ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_2_ID, AssignmentType.F_ACCOUNT_CONSTRUCTION); // WHEN PrismProperty<AccountConstructionType> property = findUserProperty(path); // THEN assertEquals("Wrong property value (path="+path+")", "Just do it", property.getRealValue().getHowto()); }
protected String getIcfUid(PrismObject<ShadowType> shadow) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("Null attributes in "+shadow, attributesContainer); assertFalse("Empty attributes in "+shadow, attributesContainer.isEmpty()); PrismProperty<String> icfUidProp = attributesContainer.findProperty(new ItemName(SchemaConstants.NS_ICF_SCHEMA, "uid")); assertNotNull("No ICF name attribute in "+shadow, icfUidProp); return icfUidProp.getRealValue(); }
@Test public void searchShadowOwner() throws Exception { OperationResult result = new OperationResult("List owner"); //look for account owner PrismObject<UserType> user = repositoryService.searchShadowOwner("11223344", null, result); assertNotNull("No owner for account", user); PrismProperty name = user.findProperty(ObjectType.F_NAME); AssertJUnit.assertNotNull(name); AssertJUnit.assertEquals("atestuserX00003", ((PolyString) name.getRealValue()).getOrig()); }
protected XMLGregorianCalendar getLastScanTimestamp(String taskOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { PrismObject<TaskType> task = getTask(taskOid); display("Task", task); PrismContainer<?> taskExtension = task.getExtension(); assertNotNull("No task extension", taskExtension); PrismProperty<XMLGregorianCalendar> lastScanTimestampProp = taskExtension.findProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); assertNotNull("no lastScanTimestamp property", lastScanTimestampProp); return lastScanTimestampProp.getRealValue(); }