-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MID-8928: Updated repository schema for tasks / affects indexes
- Loading branch information
1 parent
b92818a
commit e086872
Showing
6 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/task/MAffectedResourceObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.task; | ||
|
||
import com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; | ||
|
||
import java.util.UUID; | ||
|
||
public class MAffectedResourceObjects extends MContainer { | ||
|
||
public Integer objectClassId; | ||
public UUID resourceRefTargetOid; | ||
public MObjectType resourceRefTargetType; | ||
public Integer resourceRefRelationId; | ||
public String intent; | ||
public String tag; | ||
public ShadowKindType kind; | ||
} |
58 changes: 58 additions & 0 deletions
58
.../src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/task/QAffectedResourceObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2023 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.task; | ||
|
||
import com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.UuidPath; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; | ||
|
||
import com.querydsl.core.types.dsl.EnumPath; | ||
import com.querydsl.core.types.dsl.NumberPath; | ||
import com.querydsl.core.types.dsl.StringPath; | ||
import com.querydsl.sql.ColumnMetadata; | ||
|
||
import java.sql.Types; | ||
|
||
public class QAffectedResourceObjects extends QContainer<MAffectedResourceObjects, MTask> { | ||
|
||
public static final String TABLE_NAME = " m_task_affects_resource_objects"; | ||
|
||
public static final ColumnMetadata OBJECT_CLASS_ID = | ||
ColumnMetadata.named("objectClassId").ofType(Types.INTEGER); | ||
public static final ColumnMetadata RESOURCE_REF_TARGET_OID = | ||
ColumnMetadata.named("resourceRefTargetOid").ofType(UuidPath.UUID_TYPE); | ||
public static final ColumnMetadata RESOURCE_REF_TARGET_TYPE = | ||
ColumnMetadata.named("resourceRefTargetType").ofType(Types.OTHER); | ||
public static final ColumnMetadata RESOURCE_REF_RELATION_ID = | ||
ColumnMetadata.named("resourceRefRelationId").ofType(Types.INTEGER); | ||
public static final ColumnMetadata INTENT = | ||
ColumnMetadata.named("intent").ofType(Types.VARCHAR); | ||
public static final ColumnMetadata KIND = | ||
ColumnMetadata.named("kind").ofType(Types.OTHER); | ||
|
||
public final NumberPath<Integer> objectClassId = | ||
createInteger("objectClassId", OBJECT_CLASS_ID); | ||
public final UuidPath resourceRefTargetOid = | ||
createUuid("resourceRefTargetOid", RESOURCE_REF_TARGET_OID); | ||
public final EnumPath<MObjectType> resourceRefTargetType = | ||
createEnum("resourceRefTargetType", MObjectType.class, RESOURCE_REF_TARGET_TYPE); | ||
public final NumberPath<Integer> resourceRefRelationId = | ||
createInteger("resourceRefRelationId", RESOURCE_REF_RELATION_ID); | ||
public final StringPath intent = createString("intent", INTENT); | ||
public final EnumPath<ShadowKindType> kind = createEnum("kind", ShadowKindType.class, KIND); | ||
|
||
public QAffectedResourceObjects(String variable) { | ||
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME); | ||
} | ||
|
||
public QAffectedResourceObjects(String variable, String schema, String table) { | ||
super(MAffectedResourceObjects.class, variable, schema, table); | ||
} | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...in/java/com/evolveum/midpoint/repo/sqale/qmodel/task/QAffectedResourceObjectsMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.evolveum.midpoint.repo.sqale.qmodel.task; | ||
|
||
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.common.QContainerMapping; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.resource.QResourceMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.JdbcSession; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.BasicResourceObjectSetType; | ||
|
||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.BasicResourceObjectSetType.*; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class QAffectedResourceObjectsMapping extends QContainerMapping<BasicResourceObjectSetType,QAffectedResourceObjects,MAffectedResourceObjects,MTask> { | ||
|
||
public static final String DEFAULT_ALIAS_NAME = "aro"; | ||
|
||
private static QAffectedResourceObjectsMapping instance; | ||
|
||
|
||
// Explanation in class Javadoc for SqaleTableMapping | ||
public static QAffectedResourceObjectsMapping init(@NotNull SqaleRepoContext repositoryContext) { | ||
if (needsInitialization(instance, repositoryContext)) { | ||
instance = new QAffectedResourceObjectsMapping(repositoryContext); | ||
} | ||
return instance; | ||
} | ||
|
||
protected QAffectedResourceObjectsMapping(@NotNull SqaleRepoContext repositoryContext) { | ||
super(QAffectedResourceObjects.TABLE_NAME, DEFAULT_ALIAS_NAME, BasicResourceObjectSetType.class, QAffectedResourceObjects.class, repositoryContext); | ||
|
||
addItemMapping(ShadowType.F_OBJECT_CLASS, uriMapper(q -> q.objectClassId)); | ||
addRefMapping(F_RESOURCE_REF, | ||
q -> q.resourceRefTargetOid, | ||
q -> q.resourceRefTargetType, | ||
q -> q.resourceRefRelationId, | ||
QResourceMapping::get); | ||
addItemMapping(F_INTENT, stringMapper(q -> q.intent)); | ||
addItemMapping(F_KIND, enumMapper(q -> q.kind)); | ||
} | ||
|
||
public static QAffectedResourceObjectsMapping get() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public MAffectedResourceObjects newRowObject() { | ||
return new MAffectedResourceObjects(); | ||
} | ||
|
||
@Override | ||
public MAffectedResourceObjects newRowObject(MTask ownerRow) { | ||
var row = super.newRowObject(); | ||
row.ownerOid = ownerRow.oid; | ||
return row; | ||
} | ||
|
||
@Override | ||
protected QAffectedResourceObjects newAliasInstance(String alias) { | ||
return new QAffectedResourceObjects(alias); | ||
} | ||
|
||
@Override | ||
public MAffectedResourceObjects insert(BasicResourceObjectSetType object, MTask ownerRow, JdbcSession jdbcSession) throws SchemaException { | ||
MAffectedResourceObjects row = initRowObject(object, ownerRow); | ||
setReference(object.getResourceRef(), | ||
o -> row.resourceRefTargetOid = o , | ||
t -> row.resourceRefTargetType = t, | ||
r -> row.resourceRefRelationId = r | ||
); | ||
row.kind = object.getKind(); | ||
row.intent = object.getIntent(); | ||
row.objectClassId = processCacheableUri(object.getObjectclass()); | ||
insert(row, jdbcSession); | ||
return row; | ||
} | ||
} |