Search in sources :

Example 1 with ROExtValue

use of com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue in project midpoint by Evolveum.

the class RObject method copyFromJAXB.

public static void copyFromJAXB(PrismContainerValue containerValue, RObject repo, RepositoryContext repositoryContext, RObjectExtensionType ownerType) throws DtoTranslationException {
    RAnyConverter converter = new RAnyConverter(repositoryContext.prismContext);
    Set<RAnyValue> values = new HashSet<RAnyValue>();
    try {
        List<Item<?, ?>> items = containerValue.getItems();
        //TODO: is this ehought??should we try items without definitions??
        if (items != null) {
            for (Item item : items) {
                values.addAll(converter.convertToRValue(item, false));
            }
        }
    } catch (Exception ex) {
        throw new DtoTranslationException(ex.getMessage(), ex);
    }
    for (RAnyValue value : values) {
        ROExtValue ex = (ROExtValue) value;
        ex.setOwner(repo);
        ex.setOwnerType(ownerType);
        if (value instanceof ROExtDate) {
            repo.getDates().add(value);
        } else if (value instanceof ROExtLong) {
            repo.getLongs().add(value);
        } else if (value instanceof ROExtReference) {
            repo.getReferences().add(value);
        } else if (value instanceof ROExtString) {
            repo.getStrings().add(value);
        } else if (value instanceof ROExtPolyString) {
            repo.getPolys().add(value);
        } else if (value instanceof ROExtBoolean) {
            repo.getBooleans().add(value);
        }
    }
    repo.setStringsCount((short) repo.getStrings().size());
    repo.setDatesCount((short) repo.getDates().size());
    repo.setPolysCount((short) repo.getPolys().size());
    repo.setReferencesCount((short) repo.getReferences().size());
    repo.setLongsCount((short) repo.getLongs().size());
    repo.setBooleansCount((short) repo.getBooleans().size());
}
Also used : ROExtLong(com.evolveum.midpoint.repo.sql.data.common.any.ROExtLong) ROExtString(com.evolveum.midpoint.repo.sql.data.common.any.ROExtString) ROExtReference(com.evolveum.midpoint.repo.sql.data.common.any.ROExtReference) ROExtDate(com.evolveum.midpoint.repo.sql.data.common.any.ROExtDate) RAnyConverter(com.evolveum.midpoint.repo.sql.data.common.any.RAnyConverter) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) ROExtValue(com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue) Item(com.evolveum.midpoint.prism.Item) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) ROExtBoolean(com.evolveum.midpoint.repo.sql.data.common.any.ROExtBoolean) ROExtPolyString(com.evolveum.midpoint.repo.sql.data.common.any.ROExtPolyString) RAnyValue(com.evolveum.midpoint.repo.sql.data.common.any.RAnyValue) HashSet(java.util.HashSet)

Example 2 with ROExtValue

use of com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue in project midpoint by Evolveum.

the class ObjectExtensionUpdate method processExtensionValues.

@Override
void processExtensionValues(RAnyConverter.ValueType valueType, Collection<PrismEntityPair<RAnyValue<?>>> pairsFromDelta, RepositoryUpdater repositoryUpdater) {
    pairsFromDelta.forEach(item -> {
        ROExtValue val = (ROExtValue) item.getRepository();
        val.setOwner(object);
        val.setOwnerType(extensionType);
    });
    // noinspection Duplicates
    switch(valueType) {
        case BOOLEAN:
            repositoryUpdater.update(object.getBooleans(), pairsFromDelta);
            break;
        case DATE:
            repositoryUpdater.update(object.getDates(), pairsFromDelta);
            break;
        case LONG:
            repositoryUpdater.update(object.getLongs(), pairsFromDelta);
            break;
        case REFERENCE:
            repositoryUpdater.update(object.getReferences(), pairsFromDelta);
            break;
        case STRING:
            repositoryUpdater.update(object.getStrings(), pairsFromDelta);
            break;
        case POLY_STRING:
            repositoryUpdater.update(object.getPolys(), pairsFromDelta);
            break;
        default:
            throw new AssertionError("Wrong value type: " + valueType);
    }
}
Also used : ROExtValue(com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue)

Aggregations

ROExtValue (com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue)2 Item (com.evolveum.midpoint.prism.Item)1 RAnyConverter (com.evolveum.midpoint.repo.sql.data.common.any.RAnyConverter)1 RAnyValue (com.evolveum.midpoint.repo.sql.data.common.any.RAnyValue)1 ROExtBoolean (com.evolveum.midpoint.repo.sql.data.common.any.ROExtBoolean)1 ROExtDate (com.evolveum.midpoint.repo.sql.data.common.any.ROExtDate)1 ROExtLong (com.evolveum.midpoint.repo.sql.data.common.any.ROExtLong)1 ROExtPolyString (com.evolveum.midpoint.repo.sql.data.common.any.ROExtPolyString)1 ROExtReference (com.evolveum.midpoint.repo.sql.data.common.any.ROExtReference)1 ROExtString (com.evolveum.midpoint.repo.sql.data.common.any.ROExtString)1 DtoTranslationException (com.evolveum.midpoint.repo.sql.util.DtoTranslationException)1 HashSet (java.util.HashSet)1