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()));
}
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);
}
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));
}
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
}
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);
}
}
Aggregations