Search in sources :

Example 16 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.

the class LookupTableTest method checkTable.

private void checkTable(String oid, OperationResult result, PrismObject<LookupTableType> expectedObject, List<ItemDelta<?, ?>> modifications, int expectedVersion, List<String> keysWithNewGeneratedTimestamps, List<String> replacedKeys) throws SchemaException, ObjectNotFoundException, IOException {
    expectedObject.setOid(oid);
    // remove keys that will be replaced
    if (replacedKeys != null) {
        Iterator<LookupTableRowType> iterator = expectedObject.asObjectable().getRow().iterator();
        while (iterator.hasNext()) {
            if (replacedKeys.contains(iterator.next().getKey())) {
                iterator.remove();
            }
        }
    }
    if (modifications != null) {
        ItemDelta.applyTo(modifications, expectedObject);
    }
    LOGGER.trace("Expected object = \n{}", expectedObject.debugDump());
    PrismObject<LookupTableType> actualObject = getFullTable(oid, result);
    LOGGER.trace("Actual object from repo = \n{}", actualObject.debugDump());
    // before comparison, check and remove generated timestamps
    if (keysWithNewGeneratedTimestamps != null) {
        for (String key : keysWithNewGeneratedTimestamps) {
            LookupTableRowType row = findRow(actualObject, key, true);
            checkCurrentTimestamp(row);
            row.setLastChangeTimestamp(null);
            LookupTableRowType rowExp = findRow(expectedObject, key, false);
            if (rowExp != null) {
                rowExp.setLastChangeTimestamp(null);
            }
        }
    }
    PrismAsserts.assertEquivalent("Table is not as expected", expectedObject, actualObject);
    AssertJUnit.assertEquals("Incorrect version", expectedVersion, Integer.parseInt(actualObject.getVersion()));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)

Example 17 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.

the class LookupTableTest method test226AddKeylessRow.

@Test(expectedExceptions = SchemaException.class)
public void test226AddKeylessRow() throws Exception {
    OperationResult result = new OperationResult("test226AddKeylessRow");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW).add(new LookupTableRowType()).asItemDeltas();
    repositoryService.modifyObject(LookupTableType.class, tableOid, modifications, null, result);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test)

Example 18 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.

the class LookupTableTest method test265ReplaceRowsNewId.

@Test
public void test265ReplaceRowsNewId() throws Exception {
    OperationResult result = new OperationResult("test265ReplaceRowsNewId");
    LookupTableRowType rowNoId = new LookupTableRowType(prismContext);
    rowNoId.setKey("key new plus");
    rowNoId.setValue("value now plus");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW).replace(rowNoId).asItemDeltas();
    executeAndCheckModification(modifications, result, 0, keysOf(rowNoId));
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test)

Example 19 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.

the class LookupTableTest method test245AddDuplicateRows.

@Test
public void test245AddDuplicateRows() throws Exception {
    OperationResult result = new OperationResult("test245AddDuplicateRows");
    LookupTableRowType rowNoId = new LookupTableRowType(prismContext);
    rowNoId.setKey("key new");
    rowNoId.setValue("value new NEW");
    LookupTableRowType row4 = new LookupTableRowType(prismContext);
    row4.setId(4L);
    row4.setKey("key 4");
    row4.setValue("value 4 NEW");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW).add(rowNoId, row4).asItemDeltas();
    executeAndCheckModification(modifications, result, 0, keysOf(rowNoId, row4), keysOf(rowNoId, row4));
// beware, ID for row4 was re-generated -- using client-provided IDs is not recommended anyway
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test)

Example 20 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType in project midpoint by Evolveum.

the class LookupPropertyModel method setObject.

@Override
public void setObject(T object) {
    final String expression = propertyExpression();
    PropertyResolverConverter prc;
    prc = new PropertyResolverConverter(Application.get().getConverterLocator(), Session.get().getLocale());
    if (object instanceof String) {
        String label = (String) object;
        String key;
        if (StringUtils.isBlank(label)) {
            PropertyResolver.setValue(expression, getInnermostModelOrObject(), null, prc);
        } else {
            if (!isStrict || lookupTable == null) {
                // set default value from input and overwrite later if key is found
                PropertyResolver.setValue(expression, getInnermostModelOrObject(), label, prc);
            }
            if (lookupTable != null) {
                for (LookupTableRowType row : lookupTable.getRow()) {
                    if (label.equals(WebComponentUtil.getOrigStringFromPoly(row.getLabel()))) {
                        key = row.getKey();
                        PropertyResolver.setValue(expression, getInnermostModelOrObject(), key, prc);
                    }
                }
            }
        }
    } else if (object == null) {
        PropertyResolver.setValue(expression, getInnermostModelOrObject(), object, prc);
    }
}
Also used : PropertyResolverConverter(org.apache.wicket.core.util.lang.PropertyResolverConverter) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Aggregations

LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)34 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)23 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)23 Test (org.testng.annotations.Test)22 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 Task (com.evolveum.midpoint.task.api.Task)14 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)10 RLookupTableRow (com.evolveum.midpoint.repo.sql.data.common.other.RLookupTableRow)4 ArrayList (java.util.ArrayList)3 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 QName (javax.xml.namespace.QName)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1