Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/support-4.4' into s…
Browse files Browse the repository at this point in the history
…upport-4.4
  • Loading branch information
skublik committed Jan 27, 2022
2 parents f837dbb + 7183b1c commit 46575e2
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ public String getObject() {
WebComponentUtil.getDisplayNameOrName(((Objectable)val.getSourceValue()).asPrismObject());
}
}
return getModelObject() != null ? getModelObject().getText() : null;
String textValue = getModelObject() != null ? getModelObject().getText() : null;
if (textValue != null && textValue.isEmpty()) {
textValue = createStringResource("SceneItemLinePanel.emptyLabel").getString();
}
return textValue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ <h3><div wicket:id="repositoryQueryLabel"/></h3>
</div>
</div>
<div class="col-md-6">
<h3><wicket:message key="PageRepositoryQuery.hibernateQuery"/></h3>
<textarea wicket:id="editorHibernate"></textarea>
<h4><wicket:message key="PageRepositoryQuery.hibernateParameters"/></h4>
<p class="small" wicket:id="hibernateParametersNote" />
<textarea wicket:id="hibernateParameters"></textarea>
<h3><div wicket:id="queryLabel"/></h3>
<textarea wicket:id="queryEditor"></textarea>
<h4>
<wicket:message key="PageRepositoryQuery.hibernateParameters"/>
</h4>
<p class="small" wicket:id="hibernateParametersNote"/>
<textarea wicket:id="parameters"></textarea>
<div class="form-group" style="margin-top: 15px">
<a class="btn btn-primary" wicket:id="executeHibernate"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public class PageRepositoryQuery extends PageAdminConfiguration {
private static final String ID_USE_IN_OBJECT_LIST = "useInObjectList";
private static final String ID_EXECUTE_HIBERNATE = "executeHibernate";
private static final String ID_EDITOR_MIDPOINT = "editorMidPoint";
private static final String ID_EDITOR_HIBERNATE = "editorHibernate";
private static final String ID_HIBERNATE_PARAMETERS = "hibernateParameters";
private static final String ID_QUERY_EDITOR = "queryEditor";
private static final String ID_QUERY_LABEL = "queryLabel";
private static final String ID_PARAMETERS = "parameters";
private static final String ID_RESULT_LABEL = "resultLabel";
private static final String ID_RESULT_TEXT = "resultText";
private static final String ID_QUERY_SAMPLE = "querySample";
Expand Down Expand Up @@ -204,14 +205,17 @@ protected void onUpdate(AjaxRequestTarget target) {
editorMidPoint.setResizeToMaxHeight(false);
mainForm.add(editorMidPoint);

AceEditor editorHibernate = new AceEditor(ID_EDITOR_HIBERNATE, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_QUERY));
Label queryLabel = new Label(ID_QUERY_LABEL, createQueryLabelModel());
mainForm.add(queryLabel);

AceEditor editorHibernate = new AceEditor(ID_QUERY_EDITOR, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_QUERY));
editorHibernate.setHeight(300);
editorHibernate.setResizeToMaxHeight(false);
editorHibernate.setReadonly(!isAdmin);
editorHibernate.setMode(null);
mainForm.add(editorHibernate);

AceEditor hibernateParameters = new AceEditor(ID_HIBERNATE_PARAMETERS, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_PARAMETERS));
AceEditor hibernateParameters = new AceEditor(ID_PARAMETERS, new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_PARAMETERS));
hibernateParameters.setReadonly(true);
hibernateParameters.setHeight(100);
hibernateParameters.setResizeToMaxHeight(false);
Expand Down Expand Up @@ -265,7 +269,7 @@ protected void onSubmit(AjaxRequestTarget target) {
};
midPointQueryButtonBar.add(executeMidPoint);

AjaxSubmitButton compileMidPoint = new AjaxSubmitButton(ID_COMPILE_MIDPOINT, createStringResource("PageRepositoryQuery.button.translate")) {
AjaxSubmitButton compileMidPoint = new AjaxSubmitButton(ID_COMPILE_MIDPOINT, createCompileMidpointLabelModel()) {
@Override
protected void onError(AjaxRequestTarget target) {
target.add(getFeedbackPanel());
Expand Down Expand Up @@ -400,6 +404,14 @@ public boolean isVisible() {

}

private IModel<String> createCompileMidpointLabelModel() {
return isNativeRepo() ? createStringResource("PageRepositoryQuery.button.translate.SQL") : createStringResource("PageRepositoryQuery.button.translate");
}

private IModel<String> createQueryLabelModel() {
return isNativeRepo() ? createStringResource("PageRepositoryQuery.sqlQuery") : createStringResource("PageRepositoryQuery.hibernateQuery");
}

private void useInObjectListPerformed(AjaxRequestTarget target) {
final RepoQueryDto dto = model.getObject();
String queryText = dto.getMidPointQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function initEditor(textAreaId, readonly, resize, height, minHeight, mode) {
});

//add editor to global map, so we can find it later
if ($.aceEditors === undefined) {
$.aceEditors = {}
}
$.aceEditors[editorId] = editor;

//todo handle readonly for text area [lazyman] add "disabled" class to .ace_scroller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class ImportActivityRun

@Override
public @NotNull ActivityReportingCharacteristics createReportingCharacteristics() {
return new ActivityReportingCharacteristics()
return super.createReportingCharacteristics()
.actionsExecutedStatisticsSupported(true)
.synchronizationStatisticsSupported(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void beforeResourceObjectsReconciliation(
XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar();
reconState.setWorkStateItemRealValues(F_RESOURCE_OBJECTS_RECONCILIATION_START_TIMESTAMP, now);
reconState.flushPendingTaskModifications(result);
LOGGER.info("Set recon start timestamp to {}", now);
LOGGER.debug("Set recon start timestamp to {}", now);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean doesRequireDirectRepositoryAccess() {

@Override
public @NotNull ActivityReportingCharacteristics createReportingCharacteristics() {
return new ActivityReportingCharacteristics()
return super.createReportingCharacteristics()
.actionsExecutedStatisticsSupported(true)
.synchronizationStatisticsSupported(false);
// TODO We will eventually want to provide sync statistics even for this part, in order to see transitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void beforeRun(OperationResult result) throws CommonException, ActivityRu

@Override
public @NotNull ActivityReportingCharacteristics createReportingCharacteristics() {
return new ActivityReportingCharacteristics()
return super.createReportingCharacteristics()
.actionsExecutedStatisticsSupported(true)
.synchronizationStatisticsSupported(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public LiveSyncActivityRun(

@Override
public @NotNull ActivityReportingCharacteristics createReportingCharacteristics() {
return new ActivityReportingCharacteristics()
return super.createReportingCharacteristics()
.determineOverallSizeDefault(ActivityOverallItemCountingOptionType.NEVER)
.bucketCompletionLoggingDefault(NONE) // To avoid log noise.
.actionsExecutedStatisticsSupported(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,20 @@ protected void assertNewPropagationTask() throws Exception {
OperationResult result = createOperationResult("assertNewPropagationTask");
PrismObject<TaskType> propTask = repositoryService.getObject(TaskType.class, getPropagationTaskOid(), null, result);
display("Propagation task (new)", propTask);
SearchFilterType filterType = propTask.asObjectable().getObjectRef().getFilter();
SearchFilterType filterType = propTask.asObjectable()
.getActivity()
.getWork()
.getMultiPropagation()
.getResources()
.getQuery()
.getFilter();
displayDumpable("Propagation task filter", filterType);
assertFalse("Empty filter in propagation task", FilterUtil.isFilterEmpty(filterType));
}

@Override
protected void assertFinishedPropagationTask(Task finishedTask, OperationResultStatusType expectedStatus) {
super.assertFinishedPropagationTask(finishedTask, expectedStatus);
SearchFilterType filterType = finishedTask.getObjectRefOrClone().getFilter();
displayDumpable("Propagation task filter", filterType);

assertEquals("Unexpected propagation task progress", 1, finishedTask.getLegacyProgress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,28 @@ void logBucketCompletion(boolean complete) {
current.getAverageTime(), current.getAverageWallClockTime(end), current.getThroughput(end));
}

String overallBrief = String.format(Locale.US, "Overall: processed %,d objects in %.1f seconds, got %,d errors. Real progress: %,d.",
overall.getItemsProcessed(), ActivityItemProcessingStatisticsUtil.toSeconds(overall.getWallClockTime()),
overall.getErrors(), overall.getProgress());
Long wallClockTime = overall.getWallClockTime();

// Wall-clock time information is not available e.g. for activities with persistent state (like LiveSync)
boolean hasWallClockTime = wallClockTime != null && wallClockTime > 0;

String wallClockTimeString;
if (hasWallClockTime) {
wallClockTimeString = String.format(Locale.US, " in %.1f seconds", ActivityItemProcessingStatisticsUtil.toSeconds(wallClockTime));
} else {
wallClockTimeString = "";
}
String overallBrief = String.format(Locale.US,
"Overall: processed %,d objects%s, got %,d errors. Real progress: %,d.",
overall.getItemsProcessed(), wallClockTimeString, overall.getErrors(), overall.getProgress());
if (overall.getItemsProcessed() > 0) {
overallBrief += String.format(Locale.US, " Average processing time for one object: %,.1f milliseconds. "
+ "Wall clock average: %,.1f milliseconds, throughput: %,.1f items per minute.",
overall.getAverageTime(), overall.getAverageWallClockTime(),
overall.getThroughput());
overallBrief += String.format(Locale.US,
" Average processing time for one object: %,.1f milliseconds.", overall.getAverageTime());
if (hasWallClockTime && overall.getAverageWallClockTime() != null) {
overallBrief += String.format(Locale.US,
" Wall clock average: %,.1f milliseconds, throughput: %,.1f items per minute.",
overall.getAverageWallClockTime(), overall.getThroughput());
}
}

String mainMessageAddition = "\n" + currentBrief + "\n" + overallBrief;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -21,7 +21,6 @@
import com.evolveum.midpoint.audit.api.AuditEventStage;
import com.evolveum.midpoint.audit.api.AuditEventType;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext;
import com.evolveum.midpoint.repo.sqale.SqaleUtils;
Expand Down Expand Up @@ -144,7 +143,7 @@ public AuditEventRecordType toSchemaObject(MAuditEventRecord row) {
.message(row.message);

mapDeltas(record, row.deltas);
mapChangedItems(record, row.changedItemPaths);
// Changed items are only for searching, we don't want to reconstruct them, they are even "canonicalized".
mapRefValues(record, row.refValues);
mapProperties(record, row.properties);
mapResourceOids(record, row.resourceOids);
Expand All @@ -161,17 +160,6 @@ private void mapDeltas(AuditEventRecordType record, Collection<MAuditDelta> delt
}
}

private void mapChangedItems(AuditEventRecordType record, String[] changedItemPaths) {
if (changedItemPaths == null) {
return;
}

for (String changedItemPath : changedItemPaths) {
ItemPath itemPath = ItemPath.create(changedItemPath);
record.getChangedItem().add(new ItemPathType(itemPath));
}
}

private void mapRefValues(
AuditEventRecordType record, Map<String, List<MAuditRefValue>> refValues) {
if (refValues == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -985,8 +985,10 @@ public void test300SearchReturnsMappedToManyAttributes() throws SchemaException
AuditEventRecordPropertyType prop1 = record1.getProperty().get(0);
assertThat(prop1.getName()).isEqualTo("prop1");
assertThat(prop1.getValue()).containsExactly("val1");
// Changed items are not returned, they are used for query only and can be found in deltas.
// Also, they may be stored in wrong format (e.g. "canonicalized").
assertThat(record1.getChangedItem()).isNullOrEmpty();
// for other attributes we just use the size check, fetch mechanism is similar
assertThat(record1.getChangedItem()).hasSize(4);
assertThat(record1.getDelta()).hasSize(3)
.allMatch(d -> d.getObjectDelta() != null);
assertThat(record1.getReference()).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2020 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -949,8 +949,10 @@ public void test300SearchReturnsMappedToManyAttributes() throws SchemaException
AuditEventRecordPropertyType prop1 = record1.getProperty().get(0);
assertThat(prop1.getName()).isEqualTo("prop1");
assertThat(prop1.getValue()).containsExactly("val1");
// Changed items are not returned, they are used for query only and can be found in deltas.
// Also, they may be stored in wrong format (e.g. "canonicalized").
assertThat(record1.getChangedItem()).isNullOrEmpty();
// for other attributes we just use the size check, fetch mechanism is similar
assertThat(record1.getChangedItem()).hasSize(4);
assertThat(record1.getDelta()).hasSize(3)
.allMatch(d -> d.getObjectDelta() != null);
assertThat(record1.getReference()).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -10,7 +10,6 @@
import static com.evolveum.midpoint.repo.sql.audit.querymodel.QAuditEventRecord.TABLE_NAME;
import static com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType.*;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -25,7 +24,6 @@
import com.evolveum.midpoint.audit.api.AuditEventStage;
import com.evolveum.midpoint.audit.api.AuditEventType;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.repo.sql.audit.beans.MAuditDelta;
import com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord;
Expand All @@ -47,7 +45,6 @@
import com.evolveum.midpoint.xml.ns._public.common.audit_3.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

/**
Expand Down Expand Up @@ -159,7 +156,6 @@ protected QAuditEventRecord newAliasInstance(String alias) {
public AuditEventRecordType toSchemaObject(MAuditEventRecord row) {
AuditEventRecordType record = mapSimpleAttributes(row);
mapDeltas(record, row.deltas);
mapChangedItems(record, row.changedItemPaths);
mapRefValues(record, row.refValues);
mapProperties(record, row.properties);
mapResourceOids(record, row.resourceOids);
Expand Down Expand Up @@ -213,17 +209,6 @@ private void mapDeltas(AuditEventRecordType record, List<MAuditDelta> deltas) {
}
}

private void mapChangedItems(AuditEventRecordType record, Collection<String> changedItemPaths) {
if (changedItemPaths == null) {
return;
}

for (String changedItemPath : changedItemPaths) {
ItemPath itemPath = ItemPath.create(changedItemPath);
record.getChangedItem().add(new ItemPathType(itemPath));
}
}

private void mapRefValues(
AuditEventRecordType record, Map<String, List<MAuditRefValue>> refValues) {
if (refValues == null) {
Expand Down

0 comments on commit 46575e2

Please sign in to comment.