Search in sources :

Example 1 with LookupTableType

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;
}
Also used : ArrayList(java.util.ArrayList) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Example 2 with LookupTableType

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);
}
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 3 with LookupTableType

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);
}
Also used : RepoModifyOptions(com.evolveum.midpoint.repo.api.RepoModifyOptions) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)

Example 4 with LookupTableType

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);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test)

Example 5 with LookupTableType

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);
        }
    }
}
Also used : RLookupTableRow(com.evolveum.midpoint.repo.sql.data.common.other.RLookupTableRow) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) Query(org.hibernate.query.Query) RelationalValueSearchQuery(com.evolveum.midpoint.schema.RelationalValueSearchQuery) RelationalValueSearchQuery(com.evolveum.midpoint.schema.RelationalValueSearchQuery) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)

Aggregations

LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)39 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)27 Test (org.testng.annotations.Test)26 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)22 LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)16 GetOperationOptionsBuilder (com.evolveum.midpoint.schema.GetOperationOptionsBuilder)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 List (java.util.List)5 IModel (org.apache.wicket.model.IModel)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)4 InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)4 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Component (org.apache.wicket.Component)3 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 DisplayableValue (com.evolveum.midpoint.util.DisplayableValue)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2