Search in sources :

Example 1 with GetObjectResult

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

the class SqlAuditServiceImpl method resolve.

private PrismObject resolve(Session session, String oid, String defaultName, RObjectType defaultType) throws SchemaException {
    if (oid == null) {
        return null;
    }
    Query query = session.getNamedQuery("get.object");
    query.setParameter("oid", oid);
    query.setResultTransformer(GetObjectResult.RESULT_STYLE.getResultTransformer());
    GetObjectResult object = (GetObjectResult) query.uniqueResult();
    PrismObject result;
    if (object != null) {
        String xml = RUtil.getXmlFromByteArray(object.getFullObject(), getConfiguration().isUseZip());
        result = getPrismContext().parserFor(xml).compat().parse();
    } else if (defaultType != null) {
        result = getPrismContext().createObject(defaultType.getJaxbClass());
        result.asObjectable().setName(PolyStringType.fromOrig(defaultName != null ? defaultName : oid));
        result.setOid(oid);
    } else {
        result = null;
    }
    return result;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) SQLQuery(org.hibernate.SQLQuery) Query(org.hibernate.Query) GetObjectResult(com.evolveum.midpoint.repo.sql.util.GetObjectResult)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)1 GetObjectResult (com.evolveum.midpoint.repo.sql.util.GetObjectResult)1 Query (org.hibernate.Query)1 SQLQuery (org.hibernate.SQLQuery)1