Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 22, 2021
2 parents a755912 + 9e6c431 commit a6c24a5
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 74 deletions.
107 changes: 57 additions & 50 deletions repo/repo-sqale/sql/pgnew-repo.sql
Expand Up @@ -83,13 +83,16 @@ CREATE TYPE ActivationStatusType AS ENUM ('ENABLED', 'DISABLED', 'ARCHIVED');

CREATE TYPE AvailabilityStatusType AS ENUM ('DOWN', 'UP', 'BROKEN');

CREATE TYPE TimeIntervalStatusType AS ENUM ('BEFORE', 'IN', 'AFTER');

CREATE TYPE OperationResultStatusType AS ENUM ('SUCCESS', 'WARNING', 'PARTIAL_ERROR',
'FATAL_ERROR', 'HANDLED_ERROR', 'NOT_APPLICABLE', 'IN_PROGRESS', 'UNKNOWN');

CREATE TYPE ResourceAdministrativeStateType AS ENUM ('ENABLED', 'DISABLED');

CREATE TYPE ShadowKindType AS ENUM ('ACCOUNT', 'ENTITLEMENT', 'GENERIC', 'UNKNOWN');

CREATE TYPE SynchronizationSituationType AS ENUM (
'DELETED', 'DISPUTED', 'LINKED', 'UNLINKED', 'UNMATCHED');

CREATE TYPE TaskBindingType AS ENUM ('LOOSE', 'TIGHT');

CREATE TYPE TaskExecutionStatusType AS ENUM ('RUNNABLE', 'WAITING', 'SUSPENDED', 'CLOSED');
Expand All @@ -99,6 +102,8 @@ CREATE TYPE TaskRecurrenceType AS ENUM ('SINGLE', 'RECURRING');
CREATE TYPE TaskWaitingReasonType AS ENUM ('OTHER_TASKS', 'OTHER');

CREATE TYPE ThreadStopActionType AS ENUM ('RESTART', 'RESCHEDULE', 'SUSPEND', 'CLOSE');

CREATE TYPE TimeIntervalStatusType AS ENUM ('BEFORE', 'IN', 'AFTER');
-- endregion

-- region OID-pool table
Expand Down Expand Up @@ -206,7 +211,7 @@ CREATE TABLE m_object (
fullObject BYTEA,
tenantRef_targetOid UUID,
tenantRef_targetType ObjectType,
tenantRef_relation_id INTEGER, -- soft-references m_uri,
tenantRef_relation_id INTEGER REFERENCES m_uri(id),
lifecycleState TEXT/*VARCHAR(255)*/, -- TODO what is this? how many distinct values?
cid_seq BIGINT NOT NULL DEFAULT 1, -- sequence for container id, next free cid
version INTEGER NOT NULL DEFAULT 1,
Expand All @@ -219,13 +224,13 @@ CREATE TABLE m_object (
-- metadata
creatorRef_targetOid UUID,
creatorRef_targetType ObjectType,
creatorRef_relation_id INTEGER, -- soft-references m_uri,
createChannel_id INTEGER, -- soft-references m_uri
creatorRef_relation_id INTEGER REFERENCES m_uri(id),
createChannel_id INTEGER REFERENCES m_uri(id),
createTimestamp TIMESTAMPTZ,
modifierRef_targetOid UUID,
modifierRef_targetType ObjectType,
modifierRef_relation_id INTEGER, -- soft-references m_uri
modifyChannel_id INTEGER, -- soft-references m_uri,
modifierRef_relation_id INTEGER REFERENCES m_uri(id),
modifyChannel_id INTEGER REFERENCES m_uri(id),
modifyTimestamp TIMESTAMPTZ,

-- these are purely DB-managed metadata, not mapped to in midPoint
Expand Down Expand Up @@ -263,7 +268,7 @@ CREATE TABLE m_reference (
referenceType ReferenceType NOT NULL,
targetOid UUID NOT NULL, -- soft-references m_object
targetType ObjectType NOT NULL,
relation_id INTEGER NOT NULL, -- soft-references m_uri
relation_id INTEGER NOT NULL REFERENCES m_uri(id),

-- prevents inserts to this table, but not to inherited ones; this makes it "abstract" table
CHECK (FALSE) NO INHERIT
Expand Down Expand Up @@ -408,7 +413,7 @@ CREATE INDEX m_ref_projection_targetOid_relation_id_idx
CREATE TABLE m_generic_object (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('GENERIC_OBJECT') STORED,
genericObjectType_id INTEGER NOT NULL -- GenericObjectType#objectType, soft-references m_uri
genericObjectType_id INTEGER NOT NULL REFERENCES m_uri(id) -- GenericObjectType#objectType
)
INHERITS (m_focus);

Expand Down Expand Up @@ -555,12 +560,12 @@ ALTER TABLE m_archetype ADD CONSTRAINT m_archetype_name_norm_key UNIQUE (name_no
CREATE TABLE m_access_cert_definition (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('ACCESS_CERTIFICATION_DEFINITION') STORED,
handlerUri_id INTEGER, -- soft-references m_uri
handlerUri_id INTEGER REFERENCES m_uri(id),
lastCampaignStartedTimestamp TIMESTAMPTZ,
lastCampaignClosedTimestamp TIMESTAMPTZ,
ownerRef_targetOid UUID,
ownerRef_targetType ObjectType,
ownerRef_relation_id INTEGER -- soft-references m_uri
ownerRef_relation_id INTEGER REFERENCES m_uri(id)
)
INHERITS (m_object);

Expand All @@ -582,13 +587,13 @@ CREATE TABLE m_access_cert_campaign (
objectType ObjectType GENERATED ALWAYS AS ('ACCESS_CERTIFICATION_CAMPAIGN') STORED,
definitionRef_targetOid UUID,
definitionRef_targetType ObjectType,
definitionRef_relation_id INTEGER, -- soft-references m_uri
definitionRef_relation_id INTEGER REFERENCES m_uri(id),
endTimestamp TIMESTAMPTZ,
handlerUri_id INTEGER, -- soft-references m_uri
handlerUri_id INTEGER REFERENCES m_uri(id),
iteration INTEGER NOT NULL,
ownerRef_targetOid UUID,
ownerRef_targetType ObjectType,
ownerRef_relation_id INTEGER, -- soft-references m_uri
ownerRef_relation_id INTEGER REFERENCES m_uri(id),
stageNumber INTEGER,
startTimestamp TIMESTAMPTZ,
state INTEGER
Expand Down Expand Up @@ -625,21 +630,21 @@ CREATE TABLE m_access_cert_case (
iteration INTEGER NOT NULL,
objectRef_targetOid UUID,
objectRef_targetType ObjectType,
objectRef_relation_id INTEGER, -- soft-references m_uri
objectRef_relation_id INTEGER REFERENCES m_uri(id),
orgRef_targetOid UUID,
orgRef_targetType ObjectType,
orgRef_relation_id INTEGER, -- soft-references m_uri
orgRef_relation_id INTEGER REFERENCES m_uri(id),
outcome TEXT/*VARCHAR(255)*/,
remediedTimestamp TIMESTAMPTZ,
reviewDeadline TIMESTAMPTZ,
reviewRequestedTimestamp TIMESTAMPTZ,
stageNumber INTEGER,
targetRef_targetOid UUID,
targetRef_targetType ObjectType,
targetRef_relation_id INTEGER, -- soft-references m_uri
targetRef_relation_id INTEGER REFERENCES m_uri(id),
tenantRef_targetOid UUID,
tenantRef_targetType ObjectType,
tenantRef_relation_id INTEGER, -- soft-references m_uri
tenantRef_relation_id INTEGER REFERENCES m_uri(id),

PRIMARY KEY (owner_oid, cid)
)
Expand All @@ -655,7 +660,7 @@ CREATE TABLE m_access_cert_wi (
outputChangeTimestamp TIMESTAMPTZ,
performerRef_targetOid UUID,
performerRef_targetType ObjectType,
performerRef_relation_id INTEGER, -- soft-references m_uri
performerRef_relation_id INTEGER REFERENCES m_uri(id),
stageNumber INTEGER,

PRIMARY KEY (owner_oid, acc_cert_case_cid, cid)
Expand All @@ -673,7 +678,7 @@ CREATE TABLE m_access_cert_wi_reference (
acc_cert_wi_cid INTEGER NOT NULL, -- PK+FK
targetOid UUID NOT NULL, -- more PK columns...
targetType ObjectType,
relation_id INTEGER NOT NULL, -- soft-references m_uri
relation_id INTEGER NOT NULL REFERENCES m_uri(id),

-- TODO is the order of last two components optimal for index/query?
PRIMARY KEY (owner_oid, acc_cert_case_cid, acc_cert_wi_cid, relation_id, targetOid)
Expand Down Expand Up @@ -706,7 +711,7 @@ CREATE TABLE m_resource (
operationalState_lastAvailabilityStatus AvailabilityStatusType,
connectorRef_targetOid UUID,
connectorRef_targetType ObjectType,
connectorRef_relation_id INTEGER -- soft-references m_uri
connectorRef_relation_id INTEGER REFERENCES m_uri(id)
)
INHERITS (m_object);

Expand All @@ -733,29 +738,31 @@ CREATE TABLE m_ref_resource_business_configuration_approver (
CREATE INDEX m_ref_resource_biz_config_approver_targetOid_relation_id_idx
ON m_ref_resource_business_configuration_approver (targetOid, relation_id);

-- TODO not mapped yet
-- Represents ShadowType, see https://wiki.evolveum.com/display/midPoint/Shadow+Objects
-- and also https://docs.evolveum.com/midpoint/reference/schema/focus-and-projections/
CREATE TABLE m_shadow (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('SHADOW') STORED,
objectClass TEXT/*VARCHAR(157)*/ NOT NULL,
objectClass_id INTEGER REFERENCES m_uri(id),
resourceRef_targetOid UUID,
resourceRef_targetType ObjectType,
resourceRef_relation_id INTEGER, -- soft-references m_uri
resourceRef_relation_id INTEGER REFERENCES m_uri(id),
intent TEXT/*VARCHAR(255)*/,
kind INTEGER,
kind ShadowKindType,
attemptNumber INTEGER,
dead BOOLEAN,
exist BOOLEAN,
failedOperationType INTEGER,
fullSynchronizationTimestamp TIMESTAMPTZ,
pendingOperationCount INTEGER,
primaryIdentifierValue TEXT/*VARCHAR(255)*/,
status INTEGER,
synchronizationSituation INTEGER,
-- status INTEGER, TODO how is this mapped?
synchronizationSituation SynchronizationSituationType,
synchronizationTimestamp TIMESTAMPTZ
)
INHERITS (m_object);

-- TODO not partitioned yet, discriminator columns probably can't be NULL

CREATE TRIGGER m_shadow_oid_insert_tr BEFORE INSERT ON m_shadow
FOR EACH ROW EXECUTE PROCEDURE insert_object_oid();
CREATE TRIGGER m_shadow_update_tr BEFORE UPDATE ON m_shadow
Expand All @@ -778,9 +785,9 @@ CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);
CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);
CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);
CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);
ALTER TABLE m_shadow
ADD CONSTRAINT iPrimaryIdentifierValueWithOC UNIQUE (primaryIdentifierValue, objectClass, resourceRef_targetOid);
*/
ALTER TABLE m_shadow ADD CONSTRAINT iPrimaryIdentifierValueWithOC
UNIQUE (primaryIdentifierValue, objectClass, resourceRef_targetOid);
*/

-- Represents NodeType, see https://wiki.evolveum.com/display/midPoint/Managing+cluster+nodes
CREATE TABLE m_node (
Expand Down Expand Up @@ -912,7 +919,7 @@ CREATE TABLE m_report_data (
objectType ObjectType GENERATED ALWAYS AS ('REPORT_DATA') STORED,
reportRef_targetOid UUID,
reportRef_targetType ObjectType,
reportRef_relation_id INTEGER -- soft-references m_uri
reportRef_relation_id INTEGER REFERENCES m_uri(id)
)
INHERITS (m_object);

Expand Down Expand Up @@ -959,10 +966,10 @@ CREATE TABLE m_connector (
connectorBundle TEXT/*VARCHAR(255)*/, -- typically a package name
connectorType TEXT/*VARCHAR(255)*/, -- typically a class name
connectorVersion TEXT/*VARCHAR(255)*/,
framework_id INTEGER, -- soft-references m_uri
framework_id INTEGER REFERENCES m_uri(id),
connectorHostRef_targetOid UUID,
connectorHostRef_targetType ObjectType,
connectorHostRef_relation_id INTEGER, -- soft-references m_uri
connectorHostRef_relation_id INTEGER REFERENCES m_uri(id),
targetSystemTypes TEXT[] -- TODO any strings? cached URIs?
)
INHERITS (m_object);
Expand Down Expand Up @@ -1014,16 +1021,16 @@ CREATE TABLE m_task (
completionTimestamp TIMESTAMPTZ,
executionStatus TaskExecutionStatusType,
fullResult BYTEA,
handlerUri_id INTEGER, -- soft-references m_uri
handlerUri_id INTEGER REFERENCES m_uri(id),
lastRunStartTimestamp TIMESTAMPTZ,
lastRunFinishTimestamp TIMESTAMPTZ,
node TEXT/*VARCHAR(255)*/, -- node_id only for information purposes
objectRef_targetOid UUID,
objectRef_targetType ObjectType,
objectRef_relation_id INTEGER, -- soft-references m_uri
objectRef_relation_id INTEGER REFERENCES m_uri(id),
ownerRef_targetOid UUID,
ownerRef_targetType ObjectType,
ownerRef_relation_id INTEGER, -- soft-references m_uri
ownerRef_relation_id INTEGER REFERENCES m_uri(id),
parent TEXT/*VARCHAR(255)*/, -- value of taskIdentifier
recurrence TaskRecurrenceType,
resultStatus OperationResultStatusType,
Expand Down Expand Up @@ -1055,16 +1062,16 @@ CREATE TABLE m_case (
closeTimestamp TIMESTAMPTZ,
objectRef_targetOid UUID,
objectRef_targetType ObjectType,
objectRef_relation_id INTEGER, -- soft-references m_uri
objectRef_relation_id INTEGER REFERENCES m_uri(id),
parentRef_targetOid UUID,
parentRef_targetType ObjectType,
parentRef_relation_id INTEGER, -- soft-references m_uri
parentRef_relation_id INTEGER REFERENCES m_uri(id),
requestorRef_targetOid UUID,
requestorRef_targetType ObjectType,
requestorRef_relation_id INTEGER, -- soft-references m_uri
requestorRef_relation_id INTEGER REFERENCES m_uri(id),
targetRef_targetOid UUID,
targetRef_targetType ObjectType,
targetRef_relation_id INTEGER -- soft-references m_uri
targetRef_relation_id INTEGER REFERENCES m_uri(id)
)
INHERITS (m_object);

Expand Down Expand Up @@ -1193,13 +1200,13 @@ CREATE TABLE m_assignment_type (
orderValue INTEGER,
orgRef_targetOid UUID,
orgRef_targetType ObjectType,
orgRef_relation_id INTEGER, -- soft-references m_uri
orgRef_relation_id INTEGER REFERENCES m_uri(id),
targetRef_targetOid UUID,
targetRef_targetType ObjectType,
targetRef_relation_id INTEGER, -- soft-references m_uri
targetRef_relation_id INTEGER REFERENCES m_uri(id),
tenantRef_targetOid UUID,
tenantRef_targetType ObjectType,
tenantRef_relation_id INTEGER, -- soft-references m_uri
tenantRef_relation_id INTEGER REFERENCES m_uri(id),
-- TODO what is this? see RAssignment.getExtension (both extId/Oid)
extId INTEGER,
extOid TEXT/*VARCHAR(36)*/, -- is this UUID too?
Expand All @@ -1208,7 +1215,7 @@ CREATE TABLE m_assignment_type (
-- construction
resourceRef_targetOid UUID,
resourceRef_targetType ObjectType,
resourceRef_relation_id INTEGER, -- soft-references m_uri
resourceRef_relation_id INTEGER REFERENCES m_uri(id),
-- activation
administrativeStatus ActivationStatusType,
effectiveStatus ActivationStatusType,
Expand All @@ -1223,12 +1230,12 @@ CREATE TABLE m_assignment_type (
-- metadata
creatorRef_targetOid UUID,
creatorRef_targetType ObjectType,
creatorRef_relation_id INTEGER, -- soft-references m_uri
creatorRef_relation_id INTEGER REFERENCES m_uri(id),
createChannel_id INTEGER,
createTimestamp TIMESTAMPTZ,
modifierRef_targetOid UUID,
modifierRef_targetType ObjectType,
modifierRef_relation_id INTEGER, -- soft-references m_uri
modifierRef_relation_id INTEGER REFERENCES m_uri(id),
modifyChannel_id INTEGER,
modifyTimestamp TIMESTAMPTZ,

Expand Down Expand Up @@ -1316,7 +1323,7 @@ CREATE INDEX m_inducement_resourceRef_targetOid_idx ON m_inducement (resourceRef
CREATE TABLE m_trigger (
owner_oid UUID NOT NULL REFERENCES m_object_oid(oid) ON DELETE CASCADE,
containerType ContainerType GENERATED ALWAYS AS ('TRIGGER') STORED,
handlerUri_id INTEGER, -- soft-references m_uri
handlerUri_id INTEGER REFERENCES m_uri(id),
timestampValue TIMESTAMPTZ,

PRIMARY KEY (owner_oid, cid)
Expand All @@ -1332,10 +1339,10 @@ CREATE TABLE m_operation_execution (
status OperationResultStatusType,
initiatorRef_targetOid UUID,
initiatorRef_targetType ObjectType,
initiatorRef_relation_id INTEGER, -- soft-references m_uri
initiatorRef_relation_id INTEGER REFERENCES m_uri(id),
taskRef_targetOid UUID,
taskRef_targetType ObjectType,
taskRef_relation_id INTEGER, -- soft-references m_uri
taskRef_relation_id INTEGER REFERENCES m_uri(id),
timestampValue TIMESTAMPTZ,

PRIMARY KEY (owner_oid, cid)
Expand Down
Expand Up @@ -44,6 +44,8 @@ public SqaleRepoContext(
querydslConfig.register(new EnumAsObjectType<>(MReferenceType.class));
querydslConfig.register(new EnumAsObjectType<>(OperationResultStatusType.class));
querydslConfig.register(new EnumAsObjectType<>(ResourceAdministrativeStateType.class));
querydslConfig.register(new EnumAsObjectType<>(ShadowKindType.class));
querydslConfig.register(new EnumAsObjectType<>(SynchronizationSituationType.class));
querydslConfig.register(new EnumAsObjectType<>(TaskBindingType.class));
querydslConfig.register(new EnumAsObjectType<>(TaskExecutionStateType.class));
querydslConfig.register(new EnumAsObjectType<>(TaskRecurrenceType.class));
Expand Down
Expand Up @@ -45,6 +45,7 @@
import com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetypeMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.role.QRoleMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.role.QServiceMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadowMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.system.QSecurityPolicyMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfigurationMapping;
import com.evolveum.midpoint.repo.sqale.qmodel.system.QValuePolicyMapping;
Expand Down Expand Up @@ -140,6 +141,7 @@ public SqaleRepoContext sqlRepoContext(
.register(SecurityPolicyType.COMPLEX_TYPE, QSecurityPolicyMapping.INSTANCE)
.register(SequenceType.COMPLEX_TYPE, QSequenceMapping.INSTANCE)
.register(ServiceType.COMPLEX_TYPE, QServiceMapping.INSTANCE)
.register(ShadowType.COMPLEX_TYPE, QShadowMapping.INSTANCE)
.register(SystemConfigurationType.COMPLEX_TYPE,
QSystemConfigurationMapping.INSTANCE)
.register(TaskType.COMPLEX_TYPE, QTaskMapping.INSTANCE)
Expand Down
Expand Up @@ -150,7 +150,16 @@ protected Integer processCacheableRelation(QName qName, JdbcSession jdbcSession)

/** Returns ID for URI creating new cache row in DB as needed. */
protected Integer processCacheableUri(String uri, JdbcSession jdbcSession) {
return transformerSupport.processCachedUri(uri, jdbcSession);
return uri != null
? transformerSupport.processCachedUri(uri, jdbcSession)
: null;
}

/** Returns ID for URI creating new cache row in DB as needed. */
protected Integer processCacheableUri(QName qName, JdbcSession jdbcSession) {
return qName != null
? transformerSupport.processCachedUri(QNameUtil.qNameToUri(qName), jdbcSession)
: null;
}

/**
Expand Down
Expand Up @@ -17,4 +17,6 @@ public LookupTableRowSqlTransformer(
SqlTransformerSupport transformerSupport, QLookupTableRowMapping mapping) {
super(transformerSupport, mapping);
}

// TODO ROWS
}

0 comments on commit a6c24a5

Please sign in to comment.