Search in sources :

Example 1 with LookupTableRowType

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

the class TextPopupPanel method prepareAutoCompleteList.

private List<String> prepareAutoCompleteList(String input) {
    List<String> values = new ArrayList<>();
    if (lookup == null || lookup.asObjectable().getRow() == null) {
        return values;
    }
    List<LookupTableRowType> rows = new ArrayList<>();
    rows.addAll(lookup.asObjectable().getRow());
    Collections.sort(rows, new Comparator<LookupTableRowType>() {

        @Override
        public int compare(LookupTableRowType o1, LookupTableRowType o2) {
            String s1 = WebComponentUtil.getOrigStringFromPoly(o1.getLabel());
            String s2 = WebComponentUtil.getOrigStringFromPoly(o2.getLabel());
            return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
        }
    });
    for (LookupTableRowType row : rows) {
        String rowLabel = WebComponentUtil.getOrigStringFromPoly(row.getLabel());
        if (StringUtils.isEmpty(input) || rowLabel.toLowerCase().startsWith(input.toLowerCase())) {
            values.add(rowLabel);
        }
        if (values.size() > MAX_ITEMS) {
            break;
        }
    }
    return values;
}
Also used : LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Example 2 with LookupTableRowType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType 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 3 with LookupTableRowType

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

the class TestParseLookupTable method assertRow.

private void assertRow(PrismContainerValue<LookupTableRowType> tableContainerValue, String key, String value, PolyStringType label, XMLGregorianCalendar lastChangeTimestamp) {
    LookupTableRowType row = tableContainerValue.asContainerable();
    assertEquals("wrong key", key, row.getKey());
    assertEquals("wrong value", value, row.getValue());
    assertEquals("wrong label", label, row.getLabel());
    assertEquals("wrong lastChangeTimestamp", lastChangeTimestamp, row.getLastChangeTimestamp());
}
Also used : LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Example 4 with LookupTableRowType

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

the class TestEditSchema method test170LookupLanguagesReplaceRows.

@Test
public void test170LookupLanguagesReplaceRows() throws Exception {
    final String TEST_NAME = "test170LookupLanguagesReplaceRows";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    LookupTableRowType row1 = new LookupTableRowType();
    row1.setKey("ja_JA");
    row1.setValue("ja");
    row1.setLabel(PrismTestUtil.createPolyStringType("Jabber"));
    LookupTableRowType row2 = new LookupTableRowType();
    row2.setKey("ja_MJ");
    row2.setValue("ja");
    row2.setLabel(PrismTestUtil.createPolyStringType("Mumbojumbo"));
    LookupTableRowType row3 = new LookupTableRowType();
    // existing key
    row3.setKey("en_PR");
    row3.setValue("en1");
    row3.setLabel(PrismTestUtil.createPolyStringType("English (pirate1)"));
    ObjectDelta<LookupTableType> delta = ObjectDelta.createModificationReplaceContainer(LookupTableType.class, LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, prismContext, row1, row2, row3);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    IntegrationTestTools.display("Languages", lookup);
    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", 3, tableContainer.size());
    assertLookupRow(tableContainer, "ja_JA", "ja", "Jabber");
    assertLookupRow(tableContainer, "ja_MJ", "ja", "Mumbojumbo");
    assertLookupRow(tableContainer, "en_PR", "en1", "English (pirate1)");
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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) Test(org.testng.annotations.Test)

Example 5 with LookupTableRowType

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

the class TestEditSchema method test162LookupLanguagesDeleteRowFullNoId.

/**
     * @throws Exception
     */
@Test
public void test162LookupLanguagesDeleteRowFullNoId() throws Exception {
    final String TEST_NAME = "test162LookupLanguagesDeleteRowFullNoId";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    LookupTableRowType row = new LookupTableRowType();
    row.setKey("sk_SK");
    row.setValue("sk");
    row.setLabel(PrismTestUtil.createPolyStringType("Slovak"));
    ObjectDelta<LookupTableType> delta = ObjectDelta.createModificationDeleteContainer(LookupTableType.class, LOOKUP_LANGUAGES_OID, LookupTableType.F_ROW, prismContext, row);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    IntegrationTestTools.display("Languages", lookup);
    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", 6, tableContainer.size());
    assertLookupRow(tableContainer, "en_US", "en", "English (US)");
    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");
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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) Test(org.testng.annotations.Test)

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