Search in sources :

Example 36 with LookupTableType

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

the class QLookupTableMapping method appendLookupTableRows.

private void appendLookupTableRows(UUID ownerOid, LookupTableType base, GetOperationOptions rowOptions, JdbcSession session) {
    try {
        RelationalValueSearchQuery queryDef = rowOptions == null ? null : rowOptions.getRelationalValueSearchQuery();
        QLookupTableRowMapping rowMapping = QLookupTableRowMapping.get();
        QLookupTableRow alias = rowMapping.defaultAlias();
        BooleanExpression whereQuery = appendConditions(alias, alias.ownerOid.eq(ownerOid), queryDef);
        SQLQuery<MLookupTableRow> query = session.newQuery().from(alias).select(alias).where(whereQuery);
        query = pagingAndOrdering(query, queryDef, rowMapping, alias);
        List<MLookupTableRow> result = query.fetch();
        for (MLookupTableRow r : result) {
            LookupTableRowType lookupRow = new LookupTableRowType().key(r.key);
            if (r.labelOrig != null || r.labelNorm != null) {
                lookupRow.label(PolyString.toPolyStringType(new PolyString(r.labelOrig, r.labelNorm)));
            }
            lookupRow.lastChangeTimestamp(MiscUtil.asXMLGregorianCalendar(r.lastChangeTimestamp));
            lookupRow.value(r.value);
            lookupRow.asPrismContainerValue().setId(r.cid);
            base.getRow().add(lookupRow);
        }
    } catch (QueryException e) {
        throw new SystemException("Unable to fetch nested table rows", e);
    }
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression) QueryException(com.evolveum.midpoint.repo.sqlbase.QueryException) SystemException(com.evolveum.midpoint.util.exception.SystemException) RelationalValueSearchQuery(com.evolveum.midpoint.schema.RelationalValueSearchQuery) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Example 37 with LookupTableType

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

the class SqaleRepoAddDeleteObjectTest method test808LookupTable.

@Test
public void test808LookupTable() throws Exception {
    OperationResult result = createOperationResult();
    given("lookup table with a couple of rows");
    String objectName = "ltable" + getTestNumber();
    LookupTableType lookupTable = new LookupTableType().name(objectName).row(new LookupTableRowType().key("row1").value("value1").label("label-1").lastChangeTimestamp(MiscUtil.asXMLGregorianCalendar(1L))).row(new LookupTableRowType().key("row2").value("value2").lastChangeTimestamp(MiscUtil.asXMLGregorianCalendar(2L))).row(new LookupTableRowType().key("row3"));
    when("adding it to the repository");
    repositoryService.addObject(lookupTable.asPrismObject(), null, result);
    then("it is stored with its persisted trigger containers");
    assertThatOperationResult(result).isSuccess();
    QLookupTableRow ltRow = aliasFor(QLookupTableRow.class);
    List<MLookupTableRow> rows = select(ltRow, ltRow.ownerOid.eq(UUID.fromString(lookupTable.getOid())));
    assertThat(rows).hasSize(3);
    rows.sort(comparing(tr -> tr.cid));
    MLookupTableRow containerRow = rows.get(0);
    assertThat(containerRow.cid).isEqualTo(1);
    assertThat(containerRow.key).isEqualTo("row1");
    assertThat(containerRow.value).isEqualTo("value1");
    assertThat(containerRow.labelOrig).isEqualTo("label-1");
    assertThat(containerRow.labelNorm).isEqualTo("label1");
    assertThat(containerRow.lastChangeTimestamp).isEqualTo(Instant.ofEpochMilli(1));
    containerRow = rows.get(1);
    assertThat(containerRow.cid).isEqualTo(2);
    assertThat(containerRow.key).isEqualTo("row2");
    assertThat(containerRow.value).isEqualTo("value2");
    assertThat(containerRow.lastChangeTimestamp).isEqualTo(Instant.ofEpochMilli(2));
    containerRow = rows.get(2);
    assertThat(containerRow.cid).isEqualTo(3);
    assertThat(containerRow.key).isEqualTo("row3");
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 38 with LookupTableType

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

the class SqaleRepoLookupTableTest method test120LookupLanguagesGetByKeyExact.

@Test
public void test120LookupLanguagesGetByKeyExact() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_KEY).eq("sk_SK").end();
    PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 39 with LookupTableType

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

the class SqaleRepoLookupTableTest method test164LookupLanguagesDeleteRowFullId.

@Test
public void test164LookupLanguagesDeleteRowFullId() throws Exception {
    given();
    OperationResult result = createOperationResult();
    LookupTableRowType row = new LookupTableRowType();
    row.setKey("en_US");
    row.setValue("en");
    row.setLabel(PrismTestUtil.createPolyStringType("English (US)"));
    row.setId(1L);
    ObjectDelta<LookupTableType> delta = prismContext.deltaFactory().object().createModificationDeleteContainer(LookupTableType.class, LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row);
    when();
    repositoryService.modifyObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, delta.getModifications(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig());
    PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
    assertNotNull("Table container missing", tableContainer);
    assertEquals("Unexpected table container size", 5, tableContainer.size());
    assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)");
    assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish");
    assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish");
    assertLookupRow(tableContainer, "gi_GO", null, "Gobbledygook");
    assertLookupRow(tableContainer, "gi_HU", "gi", "Humbug");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 40 with LookupTableType

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

the class SqaleRepoLookupTableTest method test150LookupLanguagesAddRowFull.

@Test
public void test150LookupLanguagesAddRowFull() throws Exception {
    given();
    OperationResult result = createOperationResult();
    LookupTableRowType row = new LookupTableRowType();
    row.setKey("gi_GI");
    row.setValue("gi");
    row.setLabel(PrismTestUtil.createPolyStringType("Gibberish"));
    ObjectDelta<LookupTableType> delta = prismContext.deltaFactory().object().createModificationAddContainer(LookupTableType.class, LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, row);
    when();
    repositoryService.modifyObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, delta.getModifications(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig());
    PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
    assertNotNull("Table container missing", tableContainer);
    assertEquals("Unexpected table container size", 5, tableContainer.size());
    assertLookupRow(tableContainer, "en_US", "en", "English (US)");
    assertLookupRow(tableContainer, "en_PR", "en", "English (pirate)");
    assertLookupRow(tableContainer, "sk_SK", "sk", "Slovak");
    assertLookupRow(tableContainer, "tr_TR", "tr", "Turkish");
    assertLookupRow(tableContainer, "gi_GI", "gi", "Gibberish");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)29 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)19 GetOperationOptionsBuilder (com.evolveum.midpoint.schema.GetOperationOptionsBuilder)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 PropertyModel (org.apache.wicket.model.PropertyModel)5 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)4 InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)4 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)4 List (java.util.List)4 IModel (org.apache.wicket.model.IModel)4 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)3 Task (com.evolveum.midpoint.task.api.Task)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 File (java.io.File)3 QName (javax.xml.namespace.QName)3 Component (org.apache.wicket.Component)3 StandardLoggerType (com.evolveum.midpoint.gui.impl.page.admin.configuration.component.StandardLoggerType)2