Search in sources :

Example 16 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, IOException {
    RepoModifyOptions modifyOptions = getModifyOptions();
    if (RepoModifyOptions.isExecuteIfNoChanges(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 17 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, 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()));
}
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 18 with LookupTableType

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

the class RLookupTable method copyFromJAXB.

public static void copyFromJAXB(LookupTableType jaxb, RLookupTable repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException, SchemaException {
    RObject.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
    repo.setName(RPolyString.copyFromJAXB(jaxb.getName()));
    List<LookupTableRowType> rows = jaxb.getRow();
    if (!rows.isEmpty()) {
        repo.setRows(new HashSet<>());
        for (LookupTableRowType row : rows) {
            RLookupTableRow rRow = RLookupTableRow.toRepo(repo, row);
            rRow.setTransient(generatorResult.isTransient(row.asPrismContainerValue()));
            repo.getRows().add(rRow);
        }
    }
}
Also used : RLookupTableRow(com.evolveum.midpoint.repo.sql.data.common.other.RLookupTableRow) LookupTableRowType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)

Example 19 with LookupTableType

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

the class RLookupTable method toJAXB.

@Override
public LookupTableType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    LookupTableType object = new LookupTableType();
    RUtil.revive(object, prismContext);
    RLookupTable.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)

Example 20 with LookupTableType

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

the class LookupTableTest method test108AddTableOverwriteExisting.

@Test
public void test108AddTableOverwriteExisting() throws Exception {
    PrismObject<LookupTableType> table = prismContext.parseObject(new File(TEST_DIR, "table-1.xml"));
    OperationResult result = new OperationResult("test108AddTableOverwriteExisting");
    // doesn't work without specifying OID
    table.setOid(tableOid);
    tableOid = repositoryService.addObject(table, RepoAddOptions.createOverwrite(), result);
    // rereading, as repo strips cases from the campaign (!)
    PrismObject<LookupTableType> expected = prismContext.parseObject(new File(TEST_DIR, "table-1.xml"));
    checkTable(tableOid, expected, 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)

Aggregations

LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)33 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)27 Test (org.testng.annotations.Test)27 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)26 Task (com.evolveum.midpoint.task.api.Task)23 LookupTableRowType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType)17 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)10 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)9 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)3 File (java.io.File)3 RLookupTableRow (com.evolveum.midpoint.repo.sql.data.common.other.RLookupTableRow)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)1 RepoModifyOptions (com.evolveum.midpoint.repo.api.RepoModifyOptions)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1