Search in sources :

Example 16 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class ModelEventImpl method getAllExecutedDeltas.

@Override
public List<ObjectDeltaOperation> getAllExecutedDeltas() {
    List<ObjectDeltaOperation> retval = new ArrayList<>(focusContext.getExecutedDeltas());
    for (Object o : modelContext.getProjectionContexts()) {
        ModelProjectionContext modelProjectionContext = (ModelProjectionContext) o;
        retval.addAll(modelProjectionContext.getExecutedDeltas());
    }
    return retval;
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ArrayList(java.util.ArrayList) ModelProjectionContext(com.evolveum.midpoint.model.api.context.ModelProjectionContext)

Example 17 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class ModelEventImpl method getFocusDeltas.

@Override
public List<ObjectDelta<AssignmentHolderType>> getFocusDeltas() {
    List<ObjectDelta<AssignmentHolderType>> retval = new ArrayList<>();
    Class c = modelContext.getFocusClass();
    if (c != null && AssignmentHolderType.class.isAssignableFrom(c)) {
        for (Object o : getFocusExecutedDeltas()) {
            ObjectDeltaOperation objectDeltaOperation = (ObjectDeltaOperation) o;
            // noinspection unchecked
            retval.add(objectDeltaOperation.getObjectDelta());
        }
    }
    return retval;
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ArrayList(java.util.ArrayList) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 18 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class SaveReportFileSupport method saveReportDataType.

private void saveReportDataType(String filePath, ReportType reportType, ReportDataWriter<? extends ExportedReportDataRow, ? extends ExportedReportHeaderRow> dataWriter, Task task, OperationResult parentResult) throws CommonException {
    String reportDataName = getNameOfExportedReportData(reportType, dataWriter.getType());
    ReportDataType reportDataType = new ReportDataType();
    reportService.getPrismContext().adopt(reportDataType);
    reportDataType.setFilePath(filePath);
    reportDataType.setReportRef(MiscSchemaUtil.createObjectReference(reportType.getOid(), ReportType.COMPLEX_TYPE));
    reportDataType.setName(new PolyStringType(reportDataName));
    if (reportType.getDescription() != null) {
        reportDataType.setDescription(reportType.getDescription() + " - " + dataWriter.getType());
    }
    if (dataWriter.getFileFormatConfiguration() != null) {
        reportDataType.setFileFormat(dataWriter.getFileFormatConfiguration().getType());
    }
    SearchResultList<PrismObject<NodeType>> nodes = reportService.getModelService().searchObjects(NodeType.class, reportService.getPrismContext().queryFor(NodeType.class).item(NodeType.F_NODE_IDENTIFIER).eq(task.getNode()).build(), null, task, parentResult);
    if (nodes == null || nodes.isEmpty()) {
        LOGGER.error("Could not found node for storing the report.");
        throw new ObjectNotFoundException("Could not find node where to save report");
    }
    if (nodes.size() > 1) {
        LOGGER.error("Found more than one node with ID {}.", task.getNode());
        throw new IllegalStateException("Found more than one node with ID " + task.getNode());
    }
    reportDataType.setNodeRef(ObjectTypeUtil.createObjectRef(nodes.iterator().next(), reportService.getPrismContext()));
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    ObjectDelta<ReportDataType> objectDelta = DeltaFactory.Object.createAddDelta(reportDataType.asPrismObject());
    deltas.add(objectDelta);
    OperationResult subResult = parentResult.createSubresult(OP_CREATE_REPORT_DATA);
    Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = reportService.getModelService().executeChanges(deltas, null, task, subResult);
    String reportDataOid = ObjectDeltaOperation.findAddDeltaOid(executedDeltas, reportDataType.asPrismObject());
    LOGGER.debug("Created report output with OID {}", reportDataOid);
    PrismReference reportDataRef = reportService.getPrismContext().getSchemaRegistry().findReferenceDefinitionByElementName(ReportConstants.REPORT_DATA_PROPERTY_NAME).instantiate();
    PrismReferenceValue refValue = reportService.getPrismContext().itemFactory().createReferenceValue(reportDataOid, ReportDataType.COMPLEX_TYPE);
    reportDataRef.getValues().add(refValue);
    task.setExtensionReference(reportDataRef);
    subResult.computeStatus();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 19 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class AuditTest method test200AuditDelta.

@Test
public void test200AuditDelta() {
    AuditEventRecord record = new AuditEventRecord();
    record.setChannel("http://midpoint.evolveum.com/xml/ns/public/common/channels-3#import");
    record.setEventIdentifier("1511974895961-0-1");
    record.setEventStage(AuditEventStage.EXECUTION);
    record.setEventType(AuditEventType.ADD_OBJECT);
    ObjectDeltaOperation<UserType> delta = new ObjectDeltaOperation<>();
    delta.setObjectDelta(prismContext.deltaFactory().object().createModificationAddReference(UserType.class, "1234", UserType.F_LINK_REF, "123"));
    record.addDelta(delta);
    delta = new ObjectDeltaOperation<>();
    delta.setObjectDelta(prismContext.deltaFactory().object().createModificationAddReference(UserType.class, "1234", UserType.F_LINK_REF, "124"));
    record.addDelta(delta);
    auditService.audit(record, new NullTaskImpl(), createOperationResult());
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) QAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.querymodel.QAuditEventRecord) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) MAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Test(org.testng.annotations.Test)

Example 20 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class CleanupTest method createObjectDeltaOperation.

private ObjectDeltaOperation<?> createObjectDeltaOperation(int i) throws Exception {
    ObjectDeltaOperation<UserType> delta = new ObjectDeltaOperation<>();
    delta.setExecutionResult(new OperationResult("asdf"));
    UserType user = new UserType();
    prismContext.adopt(user);
    PolyStringType name = new PolyStringType();
    name.setOrig("a" + i);
    name.setNorm("a" + i);
    user.setName(name);
    delta.setObjectDelta(DeltaFactory.Object.createAddDelta(user.asPrismObject()));
    return delta;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)51 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)15 Task (com.evolveum.midpoint.task.api.Task)12 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)11 Test (org.testng.annotations.Test)11 ArrayList (java.util.ArrayList)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 ModelService (com.evolveum.midpoint.model.api.ModelService)3 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 AuditEventType (com.evolveum.midpoint.audit.api.AuditEventType)2