Search in sources :

Example 1 with ROExtDate

use of com.evolveum.midpoint.repo.sql.data.common.any.ROExtDate 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)

Aggregations

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 ROExtValue (com.evolveum.midpoint.repo.sql.data.common.any.ROExtValue)1 DtoTranslationException (com.evolveum.midpoint.repo.sql.util.DtoTranslationException)1 HashSet (java.util.HashSet)1