Skip to content

Commit

Permalink
Merge branch 'master' into feature/password-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 8, 2022
2 parents bbeb5a5 + a3e9b10 commit 41ad158
Show file tree
Hide file tree
Showing 503 changed files with 18,696 additions and 11,091 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ node_modules/

# IDEA files
/.idea/
/.run/
*.iml

# Eclipse files
Expand Down
15 changes: 9 additions & 6 deletions config/initial-objects/270-object-collection-audit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@
<expression>
<script>
<code>
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.report.impl.ReportUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;
import com.evolveum.midpoint.schema.DeltaConvertor
import com.evolveum.midpoint.report.impl.ReportUtils
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType

ret = new ArrayList();
def input = input as List&lt;ObjectDeltaOperationType&gt;

def ret = []
for (ObjectDeltaOperationType deltaType : input) {
delta = DeltaConvertor.createObjectDeltaOperation(deltaType, prismContext);
ret.add(ReportUtils.printDelta(delta));
delta = DeltaConvertor.createObjectDeltaOperation(deltaType, prismContext)
ret.add(ReportUtils.printDelta(delta))
}

return ret
</code>
</script>
Expand Down
97 changes: 97 additions & 0 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,103 @@ $aa$);

-- changes for 4.7

-- Simulations
call apply_change(12, $aa$
ALTER TYPE ObjectType ADD VALUE IF NOT EXISTS 'SIMULATION_RESULT' AFTER 'SHADOW';
$aa);

call apply_change(13, $aa$
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_message_template
FOR EACH ROW EXECUTE FUNCTION insert_object_oid();
CREATE TRIGGER m_simulation_result_update_tr BEFORE UPDATE ON m_message_template
FOR EACH ROW EXECUTE FUNCTION before_update_object();
CREATE TRIGGER m_simulation_result_oid_delete_tr AFTER DELETE ON m_message_template
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 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),

-- 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,
objectType ObjectType,
nameOrig TEXT NOT NULL,
nameNorm TEXT NOT NULL,
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_simulation_result_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_simulation_result_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 baseline_delete_partition BEFORE DELETE ON m_simulation_result
FOR EACH ROW EXECUTE FUNCTION baseline_delete_partition();


$aa);


-- WRITE CHANGES ABOVE ^^
-- IMPORTANT: update apply_change number at the end of postgres-new.sql
-- to match the number used in the last change here!
7 changes: 0 additions & 7 deletions dist/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@
<outputFileNameMapping>ninja.jar</outputFileNameMapping>
<unpack>false</unpack>
</dependencySet>
<dependencySet>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*:*:*:bin:*</include>
</includes>
<unpack>true</unpack>
</dependencySet>
<dependencySet>
<outputDirectory>doc/samples</outputDirectory>
<includes>
Expand Down

0 comments on commit 41ad158

Please sign in to comment.