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;
}
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;
}
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();
}
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());
}
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;
}
Aggregations