use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class RunReportPopupPanel method prepareAutoCompleteList.
private List<String> prepareAutoCompleteList(String input, LookupTableType lookupTable, JasperReportParameterDto param) {
List<String> values = new ArrayList<>();
if (lookupTable == null) {
return values;
}
List<LookupTableRowType> rows = createLookupTableRows(param, input);
if (rows == null) {
return values;
}
if (lookupTable.getRow() != null) {
lookupTable.getRow().addAll(rows);
}
for (LookupTableRowType row : rows) {
values.add(WebComponentUtil.getOrigStringFromPoly(row.getLabel()));
if (values.size() > AUTO_COMPLETE_BOX_SIZE) {
break;
}
}
return values;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType 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 {
expectedObject.setOid(oid);
// remove keys that will be replaced
if (replacedKeys != null) {
expectedObject.asObjectable().getRow().removeIf(row -> replacedKeys.contains(row.getKey()));
}
if (modifications != null) {
ItemDeltaCollectionsUtil.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);
assert row != null;
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()));
checkIncompleteFlag(oid, expectedObject, actualObject, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableTest method executeAndCheckModification.
protected void executeAndCheckModification(List<ItemDelta<?, ?>> modifications, OperationResult result, int versionDelta, List<String> keysWithGeneratedTimestamps, List<String> replacedKeys) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
RepoModifyOptions modifyOptions = getModifyOptions();
if (RepoModifyOptions.isForceReindex(modifyOptions) && versionDelta == 0) {
versionDelta = 1;
}
PrismObject<LookupTableType> before = getFullTable(tableOid, result);
repositoryService.modifyObject(LookupTableType.class, tableOid, modifications, modifyOptions, result);
checkTable(tableOid, result, before, modifications, Integer.parseInt(before.getVersion()) + versionDelta, keysWithGeneratedTimestamps, replacedKeys);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableTest method test105AddTableNonOverwriteExisting.
@Test(expectedExceptions = ObjectAlreadyExistsException.class)
public void test105AddTableNonOverwriteExisting() throws Exception {
PrismObject<LookupTableType> table = prismContext.parseObject(new File(TEST_DIR, "table-0.xml"));
OperationResult result = new OperationResult("test105AddTableNonOverwriteExisting");
repositoryService.addObject(table, null, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableHelper method updateLoadedLookupTable.
<T extends ObjectType> void updateLoadedLookupTable(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Session session) throws SchemaException {
if (!SelectorOptions.hasToLoadPath(LookupTableType.F_ROW, options)) {
return;
}
LOGGER.debug("Loading lookup table data.");
GetOperationOptions getOption = findLookupTableGetOption(options);
RelationalValueSearchQuery queryDef = getOption == null ? null : getOption.getRelationalValueSearchQuery();
Query query = setupLookupTableRowsQuery(session, queryDef, object.getOid());
if (queryDef != null && queryDef.getPaging() != null) {
ObjectPaging paging = queryDef.getPaging();
if (paging.getOffset() != null) {
query.setFirstResult(paging.getOffset());
}
if (paging.getMaxSize() != null) {
query.setMaxResults(paging.getMaxSize());
}
}
// noinspection unchecked
List<RLookupTableRow> rows = query.list();
if (CollectionUtils.isNotEmpty(rows)) {
LookupTableType lookup = (LookupTableType) object.asObjectable();
List<LookupTableRowType> jaxbRows = lookup.getRow();
for (RLookupTableRow row : rows) {
LookupTableRowType jaxbRow = row.toJAXB(prismContext);
jaxbRows.add(jaxbRow);
}
PrismContainer<LookupTableRowType> rowContainer = object.findContainer(LookupTableType.F_ROW);
rowContainer.setIncomplete(false);
} else {
PrismContainer<LookupTableRowType> rowContainer = object.findContainer(LookupTableType.F_ROW);
if (rowContainer != null) {
// just in case
rowContainer.clear();
rowContainer.setIncomplete(false);
}
}
}
Aggregations