Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/search-refa…
Browse files Browse the repository at this point in the history
…ctoring

* origin/master: (48 commits)
  fix saving of application role by wizard
  Do cosmetic code improvements
  Synchronized postgres-new.sql with postgres-update.sql
  Make change 13 in upgrade script idempotent+forced
  Adapt TestCorrelationDuringResourceLifecycle
  Add OpenDJ correlation tests to TestFirstSteps
  provenance/mappingSpec->mappingSpecification rename
  adding basic implementation for application role wizard
  Add OpenDJ to TestFirstSteps
  Expand TestFirstSteps
  Added PK reference to processed object in DB schema.
  Add first parts of TestFirstSteps
  Adapt TestThresholdsStoryLiveSyncSimulate
  Add some documentation
  Ignore mappings with non-matching LC state
  Ignore object templates with non-matching LC state
  Treat no-resource projection contexts
  added missing enum values for simulation result + translation (audit viewer was broken)
  Add dev mode for roles and assignments/inducements
  scenes hopefully completely removed, work in progress
  ...
  • Loading branch information
katkav committed Dec 16, 2022
2 parents e845484 + 46eea8e commit 5de94bd
Show file tree
Hide file tree
Showing 513 changed files with 13,204 additions and 5,353 deletions.
42 changes: 22 additions & 20 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,17 @@ $aa$);
-- Simulations
call apply_change(12, $aa$
ALTER TYPE ObjectType ADD VALUE IF NOT EXISTS 'SIMULATION_RESULT' AFTER 'SHADOW';
$aa);
ALTER TYPE ContainerType ADD VALUE IF NOT EXISTS 'SIMULATION_RESULT_PROCESSED_OBJECT' AFTER 'OPERATION_EXECUTION';
$aa$);

call apply_change(13, $aa$
-- TODO delete before release
DROP TABLE IF EXISTS m_simulation_result CASCADE;
DROP TABLE IF EXISTS m_simulation_result_processed_object_default CASCADE;
DROP TABLE IF EXISTS m_simulation_result_processed_object CASCADE;
DROP TYPE IF EXISTS ObjectProcessingStateType;
-- TODO end of the block

CREATE TABLE m_simulation_result (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('SIMULATION_RESULT') STORED
Expand All @@ -183,39 +191,36 @@ CREATE TABLE m_simulation_result (
)
INHERITS (m_object);

CREATE TRIGGER m_simulation_result_oid_insert_tr BEFORE INSERT ON m_message_template
CREATE TRIGGER m_simulation_result_oid_insert_tr BEFORE INSERT ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION insert_object_oid();
CREATE TRIGGER m_simulation_result_update_tr BEFORE UPDATE ON m_message_template
CREATE TRIGGER m_simulation_result_update_tr BEFORE UPDATE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION before_update_object();
CREATE TRIGGER m_simulation_result_oid_delete_tr AFTER DELETE ON m_message_template
CREATE TRIGGER m_simulation_result_oid_delete_tr AFTER DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION delete_object_oid();

CREATE TYPE ObjectProcessingStateType AS ENUM ('UNMODIFIED', 'ADDED', 'MODIFIED', 'DELETED' );

ALTER TYPE ContainerType ADD VALUE IF NOT EXISTS 'SIMULATION_RESULT_PROCESSED_OBJECT' AFTER 'OPERATION_EXECUTION';
CREATE TYPE ObjectProcessingStateType AS ENUM ('UNMODIFIED', 'ADDED', 'MODIFIED', 'DELETED');

CREATE TABLE m_simulation_result_processed_object (
-- Default OID value is covered by INSERT triggers. No PK defined on abstract tables.
-- Owner does not have to be the direct parent of the container.
ownerOid UUID NOT NULL,
-- use like this on the concrete table:
-- ownerOid UUID NOT NULL REFERENCES m_object_oid(oid),
ownerOid UUID NOT NULL REFERENCES m_simulation_result(oid) ON DELETE CASCADE,

-- Container ID, unique in the scope of the whole object (owner).
-- While this provides it for sub-tables we will repeat this for clarity, it's part of PK.
cid BIGINT NOT NULL,
containerType ContainerType GENERATED ALWAYS AS ('SIMULATION_RESULT_PROCESSED_OBJECT') STORED
CHECK (containerType = 'SIMULATION_RESULT_PROCESSED_OBJECT'),
oid UUID NOT NULL,
oid UUID,
objectType ObjectType,
nameOrig TEXT NOT NULL,
nameNorm TEXT NOT NULL,
nameOrig TEXT,
nameNorm TEXT,
state ObjectProcessingStateType,
metricIdentifiers TEXT[],
fullObject BYTEA,
objectBefore BYTEA,
objectAfter BYTEA,


PRIMARY KEY (ownerOid, cid)
) PARTITION BY LIST(ownerOid);
Expand All @@ -227,7 +232,7 @@ CREATE OR REPLACE FUNCTION m_simulation_result_create_partition() RETURNS trigge
DECLARE
partition TEXT;
BEGIN
partition := 'm_simulation_result_processed_object_' || REPLACE(new.oid::text,'-','_');
partition := 'm_sr_processed_object_' || REPLACE(new.oid::text,'-','_');
IF new.partitioned AND NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been created %',partition;
EXECUTE 'CREATE TABLE ' || partition || ' partition of ' || 'm_simulation_result_processed_object' || ' for values in (''' || new.oid|| ''');';
Expand All @@ -240,16 +245,14 @@ LANGUAGE plpgsql;
CREATE TRIGGER m_simulation_result_create_partition AFTER INSERT ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION m_simulation_result_create_partition();



--- Trigger which deletes processed objects partition when whole simulation is deleted

CREATE OR REPLACE FUNCTION m_simulation_result_delete_partition() RETURNS trigger AS
$BODY$
DECLARE
partition TEXT;
BEGIN
partition := 'm_simulation_result_processed_object_' || REPLACE(OLD.oid::text,'-','_');
partition := 'm_sr_processed_object_' || REPLACE(OLD.oid::text,'-','_');
IF OLD.partitioned AND EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been deleted %',partition;
EXECUTE 'DROP TABLE IF EXISTS ' || partition || ';';
Expand All @@ -259,11 +262,10 @@ CREATE OR REPLACE FUNCTION m_simulation_result_delete_partition() RETURNS trigge
$BODY$
LANGUAGE plpgsql;

CREATE TRIGGER baseline_delete_partition BEFORE DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION baseline_delete_partition();

CREATE TRIGGER m_simulation_result_delete_partition BEFORE DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION m_simulation_result_delete_partition();

$aa);
$aa$, true); -- TODO remove `true` before M2 or before RC1! (Also, the first 3 table drops)


-- WRITE CHANGES ABOVE ^^
Expand Down
90 changes: 90 additions & 0 deletions config/sql/native-new/postgres-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CREATE TYPE ContainerType AS ENUM (
'INDUCEMENT',
'LOOKUP_TABLE_ROW',
'OPERATION_EXECUTION',
'SIMULATION_RESULT_PROCESSED_OBJECT',
'TRIGGER');

-- NOTE: Keep in sync with the same enum in postgres-new-audit.sql!
Expand Down Expand Up @@ -77,6 +78,7 @@ CREATE TYPE ObjectType AS ENUM (
'SEQUENCE',
'SERVICE',
'SHADOW',
'SIMULATION_RESULT',
'SYSTEM_CONFIGURATION',
'TASK',
'USER',
Expand Down Expand Up @@ -1865,6 +1867,94 @@ CREATE INDEX m_operation_execution_timestamp_idx ON m_operation_execution (times
-- TODO: index for status is questionable, don't we want WHERE status = ... to another index instead?
-- endregion


-- region Simulations Support

CREATE TABLE m_simulation_result (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('SIMULATION_RESULT') STORED
CHECK (objectType = 'SIMULATION_RESULT'),
partitioned boolean
)
INHERITS (m_object);

CREATE TRIGGER m_simulation_result_oid_insert_tr BEFORE INSERT ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION insert_object_oid();
CREATE TRIGGER m_simulation_result_update_tr BEFORE UPDATE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION before_update_object();
CREATE TRIGGER m_simulation_result_oid_delete_tr AFTER DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION delete_object_oid();

CREATE TYPE ObjectProcessingStateType AS ENUM ('UNMODIFIED', 'ADDED', 'MODIFIED', 'DELETED');

CREATE TABLE m_simulation_result_processed_object (
-- Default OID value is covered by INSERT triggers. No PK defined on abstract tables.
-- Owner does not have to be the direct parent of the container.
-- use like this on the concrete table:
-- ownerOid UUID NOT NULL REFERENCES m_object_oid(oid),
ownerOid UUID NOT NULL REFERENCES m_simulation_result(oid) ON DELETE CASCADE,

-- Container ID, unique in the scope of the whole object (owner).
-- While this provides it for sub-tables we will repeat this for clarity, it's part of PK.
cid BIGINT NOT NULL,
containerType ContainerType GENERATED ALWAYS AS ('SIMULATION_RESULT_PROCESSED_OBJECT') STORED
CHECK (containerType = 'SIMULATION_RESULT_PROCESSED_OBJECT'),
oid UUID,
objectType ObjectType,
nameOrig TEXT,
nameNorm TEXT,
state ObjectProcessingStateType,
metricIdentifiers TEXT[],
fullObject BYTEA,
objectBefore BYTEA,
objectAfter BYTEA,

PRIMARY KEY (ownerOid, cid)
) PARTITION BY LIST(ownerOid);

CREATE TABLE m_simulation_result_processed_object_default PARTITION OF m_simulation_result_processed_object DEFAULT;

CREATE OR REPLACE FUNCTION m_simulation_result_create_partition() RETURNS trigger AS
$BODY$
DECLARE
partition TEXT;
BEGIN
partition := 'm_sr_processed_object_' || REPLACE(new.oid::text,'-','_');
IF new.partitioned AND NOT EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been created %',partition;
EXECUTE 'CREATE TABLE ' || partition || ' partition of ' || 'm_simulation_result_processed_object' || ' for values in (''' || new.oid|| ''');';
END IF;
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql;

CREATE TRIGGER m_simulation_result_create_partition AFTER INSERT ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION m_simulation_result_create_partition();

--- Trigger which deletes processed objects partition when whole simulation is deleted

CREATE OR REPLACE FUNCTION m_simulation_result_delete_partition() RETURNS trigger AS
$BODY$
DECLARE
partition TEXT;
BEGIN
partition := 'm_sr_processed_object_' || REPLACE(OLD.oid::text,'-','_');
IF OLD.partitioned AND EXISTS(SELECT relname FROM pg_class WHERE relname=partition) THEN
RAISE NOTICE 'A partition has been deleted %',partition;
EXECUTE 'DROP TABLE IF EXISTS ' || partition || ';';
END IF;
RETURN OLD;
END;
$BODY$
LANGUAGE plpgsql;

CREATE TRIGGER m_simulation_result_delete_partition BEFORE DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION m_simulation_result_delete_partition();


-- endregion

-- region Extension support
-- Catalog table of known indexed extension items.
-- While itemName and valueType are both Q-names they are not cached via m_uri because this
Expand Down
10 changes: 10 additions & 0 deletions gui/admin-gui/src/frontend/scss/midpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1774,3 +1774,13 @@ th.debug-list-buttons {
}
}
}

@each $breakpoint in map-keys($grid-breakpoints) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@include media-breakpoint-up($breakpoint, $grid-breakpoints) {

.col#{$infix}-2\.4 {
@include make-col(2.4, $grid-columns);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
package com.evolveum.midpoint.gui.api.component.delta;

import com.evolveum.midpoint.model.api.visualizer.Visualization;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
Expand All @@ -18,8 +16,8 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.result.OperationResultPopupPanel;
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.model.api.visualizer.Visualization;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand All @@ -30,8 +28,8 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.prism.show.SceneDto;
import com.evolveum.midpoint.web.component.prism.show.ScenePanel;
import com.evolveum.midpoint.web.component.prism.show.VisualizationDto;
import com.evolveum.midpoint.web.component.prism.show.VisualizationPanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
Expand Down Expand Up @@ -100,26 +98,26 @@ public IModel<?> getBody() {
new PropertyModel<>(getModel(), ObjectDeltaOperationType.F_OBJECT_NAME.getLocalPart()));
objectName.setOutputMarkupId(true);
objectDeltaOperationMarkup.add(objectName);
final SceneDto sceneDto;
final VisualizationDto visualizationDto;
try {
sceneDto = loadSceneForDelta();
visualizationDto = loadVisualizationForDelta();
} catch (SchemaException | ExpressionEvaluationException e) {
OperationResult result = new OperationResult(ObjectDeltaOperationPanel.class.getName() + ".loadSceneForDelta");
result.recordFatalError(createStringResource("ObjectDeltaOperationPanel.message.fetchOrVisualize.fatalError", e.getMessage()).getString(), e);
parentPage.showResult(result);
throw parentPage.redirectBackViaRestartResponseException();
}
IModel<SceneDto> deltaModel = new IModel<SceneDto>() {
IModel<VisualizationDto> deltaModel = new IModel<>() {
private static final long serialVersionUID = 1L;

public SceneDto getObject() {
return sceneDto;
public VisualizationDto getObject() {
return visualizationDto;
}

};
ScenePanel deltaPanel = new ScenePanel(ID_DELTA_PANEL, deltaModel, true) {
VisualizationPanel deltaPanel = new VisualizationPanel(ID_DELTA_PANEL, deltaModel, true) {
@Override
public void headerOnClickPerformed(AjaxRequestTarget target, IModel<SceneDto> model) {
public void headerOnClickPerformed(AjaxRequestTarget target, IModel<VisualizationDto> model) {
super.headerOnClickPerformed(target, model);
// model.getObject().setMinimized(!model.getObject().isMinimized());
target.add(ObjectDeltaOperationPanel.this);
Expand Down Expand Up @@ -163,8 +161,8 @@ private String getBoxCssClass() {

}

private SceneDto loadSceneForDelta() throws SchemaException, ExpressionEvaluationException {
Visualization scene;
private VisualizationDto loadVisualizationForDelta() throws SchemaException, ExpressionEvaluationException {
Visualization visualization;

ObjectDelta<? extends ObjectType> delta;
ObjectDeltaType deltaType = getModel().getObject().getObjectDelta();
Expand All @@ -176,17 +174,17 @@ private SceneDto loadSceneForDelta() throws SchemaException, ExpressionEvaluatio
throw e;
}
try {
scene = parentPage.getModelInteractionService().visualizeDelta(delta, true, getIncludeOriginalObject(),
visualization = parentPage.getModelInteractionService().visualizeDelta(delta, true, getIncludeOriginalObject(),
parentPage.createSimpleTask(ID_PARAMETERS_DELTA),
new OperationResult(ID_PARAMETERS_DELTA));
} catch (SchemaException | ExpressionEvaluationException e) {
LoggingUtils.logException(LOGGER, "SchemaException while visualizing delta:\n{}",
e, DebugUtil.debugDump(delta));
throw e;
}
SceneDto deltaSceneDto = new SceneDto(scene);
deltaSceneDto.setMinimized(true);
return deltaSceneDto;
VisualizationDto visualizationDto = new VisualizationDto(visualization);
visualizationDto.setMinimized(true);
return visualizationDto;

}

Expand All @@ -201,7 +199,7 @@ private void showFullResultsPerformed(AjaxRequestTarget target) {
}

private IModel<OperationResult> createOperationResultModel() {
return new ReadOnlyModel<>(() -> {
return () -> {
if (getModelObject() == null) {
return null;
}
Expand All @@ -210,6 +208,6 @@ private IModel<OperationResult> createOperationResultModel() {
return null;
}
return OperationResult.createOperationResult(executionResult);
});
};
}
}

0 comments on commit 5de94bd

Please sign in to comment.