Search in sources :

Example 26 with DtoTranslationException

use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.

the class RAssignmentExtension method fromJaxb.

private static void fromJaxb(PrismContainerValue<?> containerValue, RAssignmentExtension repo, RAssignmentExtensionType type, RepositoryContext repositoryContext) throws DtoTranslationException {
    RAnyConverter converter = new RAnyConverter(repositoryContext.prismContext, repositoryContext.extItemDictionary);
    Set<RAnyValue> values = new HashSet<>();
    try {
        for (Item item : containerValue.getItems()) {
            values.addAll(converter.convertToRValue(item, true, RObjectExtensionType.EXTENSION));
        }
    } catch (Exception ex) {
        throw new DtoTranslationException(ex.getMessage(), ex);
    }
    for (RAnyValue value : values) {
        ((RAExtValue) value).setAnyContainer(repo);
        ((RAExtValue) value).setExtensionType(type);
        if (value instanceof RAExtDate) {
            repo.getDates().add((RAExtDate) value);
        } else if (value instanceof RAExtLong) {
            repo.getLongs().add((RAExtLong) value);
        } else if (value instanceof RAExtReference) {
            repo.getReferences().add((RAExtReference) value);
        } else if (value instanceof RAExtString) {
            repo.getStrings().add((RAExtString) value);
        } else if (value instanceof RAExtPolyString) {
            repo.getPolys().add((RAExtPolyString) value);
        } else if (value instanceof RAExtBoolean) {
            repo.getBooleans().add((RAExtBoolean) value);
        }
    }
}
Also used : DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) Item(com.evolveum.midpoint.prism.Item) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) HashSet(java.util.HashSet)

Example 27 with DtoTranslationException

use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.

the class AssignmentMapper method map.

@Override
public RAssignment map(AssignmentType input, MapperContext context) {
    RAssignment ass = new RAssignment();
    ItemDelta delta = context.getDelta();
    ItemPath path = delta.getPath().namedSegmentsOnly();
    if (path.startsWithName(FocusType.F_ASSIGNMENT)) {
        ass.setAssignmentOwner(RAssignmentOwner.FOCUS);
    } else {
        ass.setAssignmentOwner(RAssignmentOwner.ABSTRACT_ROLE);
    }
    RObject owner = (RObject) context.getOwner();
    try {
        RAssignment.fromJaxb(input, ass, owner, context.getRepositoryContext());
    } catch (DtoTranslationException ex) {
        throw new SystemException("Couldn't translate assignment to entity", ex);
    }
    return ass;
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) RObject(com.evolveum.midpoint.repo.sql.data.common.RObject) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 28 with DtoTranslationException

use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.

the class TaskAutoScalingMapper method map.

@Override
public RTaskAutoScaling map(TaskAutoScalingType input, MapperContext context) {
    try {
        RTaskAutoScaling taskAutoScaling = new RTaskAutoScaling();
        RTaskAutoScaling.fromJaxb(input, taskAutoScaling);
        return taskAutoScaling;
    } catch (DtoTranslationException ex) {
        throw new SystemException("Couldn't translate TaskAutoScaling to entity", ex);
    }
}
Also used : DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) RTaskAutoScaling(com.evolveum.midpoint.repo.sql.data.common.embedded.RTaskAutoScaling) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 29 with DtoTranslationException

use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.

the class FocusActivationMapper method map.

@Override
public RFocusActivation map(ActivationType input, MapperContext context) {
    try {
        RFocusActivation activation = new RFocusActivation();
        RFocusActivation.fromJaxb(input, activation);
        return activation;
    } catch (DtoTranslationException ex) {
        throw new SystemException("Couldn't translate activation to entity", ex);
    }
}
Also used : DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) RFocusActivation(com.evolveum.midpoint.repo.sql.data.common.embedded.RFocusActivation)

Example 30 with DtoTranslationException

use of com.evolveum.midpoint.repo.sql.util.DtoTranslationException in project midpoint by Evolveum.

the class OperationalStateMapper method map.

@Override
public ROperationalState map(OperationalStateType input, MapperContext context) {
    try {
        ROperationalState rstate = new ROperationalState();
        ROperationalState.fromJaxb(input, rstate);
        return rstate;
    } catch (DtoTranslationException ex) {
        throw new SystemException("Couldn't translate operational state to entity", ex);
    }
}
Also used : ROperationalState(com.evolveum.midpoint.repo.sql.data.common.embedded.ROperationalState) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Aggregations

DtoTranslationException (com.evolveum.midpoint.repo.sql.util.DtoTranslationException)30 SystemException (com.evolveum.midpoint.util.exception.SystemException)11 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 Session (org.hibernate.Session)7 RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)6 Item (com.evolveum.midpoint.prism.Item)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)2 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 RAnyConverter (com.evolveum.midpoint.repo.sql.data.common.any.RAnyConverter)2 RAnyValue (com.evolveum.midpoint.repo.sql.data.common.any.RAnyValue)2 ROperationalState (com.evolveum.midpoint.repo.sql.data.common.embedded.ROperationalState)2 RAvailabilityStatus (com.evolveum.midpoint.repo.sql.data.common.enums.RAvailabilityStatus)2 QueryException (com.evolveum.midpoint.repo.sql.query.QueryException)2 PrismIdentifierGenerator (com.evolveum.midpoint.repo.sql.util.PrismIdentifierGenerator)2 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)2 SequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)2