Skip to content

Commit

Permalink
Merge branch 'master' into feature/simulations
Browse files Browse the repository at this point in the history
# Conflicts:
#	model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/AssignmentCollector.java
  • Loading branch information
mederly committed Dec 6, 2022
2 parents 763216c + 42b12b6 commit 86cdafd
Show file tree
Hide file tree
Showing 35 changed files with 1,001 additions and 96 deletions.
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!
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import java.util.Locale;

import com.evolveum.midpoint.authentication.api.util.AuthUtil;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;

Expand Down Expand Up @@ -67,6 +69,7 @@ protected LocaleDescriptor getSelectedLocaleDescriptor() {
protected void changeLocale(AjaxRequestTarget target, LocaleDescriptor descriptor) {
LOGGER.info("Changing locale to {}.", descriptor.getLocale());
getSession().setLocale(descriptor.getLocale());
AuthUtil.getPrincipalUser().setPreferredLocale(descriptor.getLocale());
WebComponentUtil.getCompiledGuiProfile().setLocale(descriptor.getLocale());

target.add(getPage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.up'))
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.up'), false)
</code>
</script>
</expression>
Expand Down Expand Up @@ -109,7 +109,7 @@
<script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.failed'))
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.failed'), false)
</code>
</script>
</expression>
Expand Down Expand Up @@ -162,7 +162,7 @@
<script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.modifications'))
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.modifications'), false)
</code>
</script>
</expression>
Expand Down Expand Up @@ -204,7 +204,7 @@
<script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.runnable'))
return midpoint.translate(new SingleLocalizableMessageType().key('AdminDashboard.dataField.runnable'), false)
</code>
</script>
</expression>
Expand Down
1 change: 1 addition & 0 deletions infra/schema-pure-jaxb/src/compile/resources/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Used when building via xjc.
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-gui-3" uri="../../../target/midpoint-schema/xml/ns/public/common/common-gui-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-provisioning-3" uri="../../../target/midpoint-schema/xml/ns/public/common/common-provisioning-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-correlation-3" uri="../../../target/midpoint-schema/xml/ns/public/common/common-correlation-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-simulations-3" uri="../../../target/midpoint-schema/xml/ns/public/common/common-simulations-3.xsd" />

<!-- WSDLs -->
<public publicId="http://midpoint.evolveum.com/xml/ns/public/model/model-3" uri="../../../target/midpoint-schema/xml/ns/public/model/model-3.wsdl" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2019 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 @@ -9,7 +9,7 @@
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;

public class VirtualAssignmenetSpecification<R extends AbstractRoleType> {
public class VirtualAssignmentSpecification<R extends AbstractRoleType> {

private ObjectFilter filter;
private Class<R> type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.schema.VirtualAssignmenetSpecification;
import com.evolveum.midpoint.schema.VirtualAssignmentSpecification;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand Down Expand Up @@ -41,7 +41,7 @@ public static LifecycleStateType findStateDefinition(LifecycleStateModelType lif
return null;
}

public static <R extends AbstractRoleType> VirtualAssignmenetSpecification<R> getForcedAssignmentSpecification(LifecycleStateModelType lifecycleStateModel,
public static <R extends AbstractRoleType> VirtualAssignmentSpecification<R> getForcedAssignmentSpecification(LifecycleStateModelType lifecycleStateModel,
String targetLifecycleState, PrismContext prismContext) throws SchemaException {
LifecycleStateType stateDefinition = findStateDefinition(lifecycleStateModel, targetLifecycleState);
if (stateDefinition == null) {
Expand All @@ -64,14 +64,14 @@ public static <R extends AbstractRoleType> VirtualAssignmenetSpecification<R> ge
targetClass = (Class<R>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(targetType);
}

VirtualAssignmenetSpecification<R> virtualAssignmenetSpecification = new VirtualAssignmenetSpecification();
virtualAssignmenetSpecification.setType(targetClass);
VirtualAssignmentSpecification<R> virtualAssignmentSpecification = new VirtualAssignmentSpecification();
virtualAssignmentSpecification.setType(targetClass);


ObjectFilter objectFilter = prismContext.getQueryConverter().parseFilter(filter, targetClass);
virtualAssignmenetSpecification.setFilter(objectFilter);
virtualAssignmentSpecification.setFilter(objectFilter);

return virtualAssignmenetSpecification;
return virtualAssignmentSpecification;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Notes:
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-gui-3" uri="../xml/ns/public/common/common-gui-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-provisioning-3" uri="../xml/ns/public/common/common-provisioning-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-correlation-3" uri="../xml/ns/public/common/common-correlation-3.xsd" />
<system systemId="http://midpoint.evolveum.com/xml/ns/public/common/common-simulations-3" uri="../xml/ns/public/common/common-simulations-3.xsd" />


<!-- WSDLs -->
<public publicId="http://midpoint.evolveum.com/xml/ns/public/model/model-3" uri="../xml/ns/public/model/model-3.wsdl" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@
<xsd:include schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/common-gui-3"/>
<xsd:include schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/common-provisioning-3"/>
<xsd:include schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/common-correlation-3"/>

<xsd:include schemaLocation="http://midpoint.evolveum.com/xml/ns/public/common/common-simulations-3"/>
</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -10645,6 +10645,19 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="simulation" type="tns:SystemConfigurationSimulationType">
<xsd:annotation>
<xsd:documentation>
Global settings related to simulation
</xsd:documentation>
<xsd:appinfo>
<a:displayName>SystemConfigurationType.simulation</a:displayName>
<a:since>4.7</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Expand Down Expand Up @@ -16139,10 +16152,11 @@
<xsd:element name="simulation" type="tns:SimulationOptionsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
Container for options that control behaviour of different parts of clockwork during simulation.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.7</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand All @@ -16154,7 +16168,7 @@
<xsd:complexType name="SimulationOptionsType">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
Container for options that allow selectively switch behavior of different features during simulation or preview changes.
</xsd:documentation>
<xsd:appinfo>
<a:container>true</a:container>
Expand All @@ -16170,7 +16184,8 @@
<xsd:simpleType name="SimulationOptionType">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
Generic option to switch behaviour of feature into safe (transient behaviour) or non-safe mode (behaviour that can
leave persistent changes after processing).
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
Expand All @@ -16180,7 +16195,8 @@
<xsd:enumeration value="safe">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
Feature behaviour should result into zero changes (execution skipped if possible) or create changes that
will be transient (thrown away after processing).
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="SAFE"/>
Expand All @@ -16190,8 +16206,7 @@
<xsd:enumeration value="UNSAFE">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
...backward compatible probably :)
Feature behaviour option that can result into changes that are permanent and persistent.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="UNSAFE"/>
Expand Down

0 comments on commit 86cdafd

Please sign in to comment.