Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
259 additions
and
21 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
31 changes: 31 additions & 0 deletions
31
...e/src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/cases/workitem/MCaseWorkItem.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,31 @@ | ||
/* | ||
* Copyright (C) 2010-2021 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.cases.workitem; | ||
|
||
import com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType; | ||
|
||
import java.time.Instant; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Querydsl "row bean" type related to {@link QCaseWorkItem}. | ||
*/ | ||
public class MCaseWorkItem extends MContainer { | ||
|
||
public Instant closeTimestamp; | ||
public Instant createTimestamp; | ||
public Instant deadline; | ||
public UUID originalAssigneeRefTargetOid; | ||
public MObjectType originalAssigneeRefTargetType; | ||
public Integer originalAssigneeRefRelationId; | ||
public String outcome; | ||
public UUID performerRefTargetOid; | ||
public MObjectType performerRefTargetType; | ||
public Integer performerRefRelationId; | ||
public Integer stageNumber; | ||
} |
103 changes: 103 additions & 0 deletions
103
...e/src/main/java/com/evolveum/midpoint/repo/sqale/qmodel/cases/workitem/QCaseWorkItem.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,103 @@ | ||
/* | ||
* Copyright (C) 2010-2021 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.cases.workitem; | ||
|
||
import com.evolveum.midpoint.repo.sqale.qmodel.assignment.MAssignment; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObject; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.JsonbPath; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.UuidPath; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType; | ||
|
||
import com.querydsl.core.types.dsl.*; | ||
import com.querydsl.sql.ColumnMetadata; | ||
|
||
import java.sql.Types; | ||
import java.time.Instant; | ||
|
||
import static com.evolveum.midpoint.repo.sqlbase.querydsl.JsonbPath.JSONB_TYPE; | ||
|
||
/** | ||
* Querydsl query type for {@value #TABLE_NAME} table. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class QCaseWorkItem<OR extends MCase> extends QContainer<MCaseWorkItem, OR> { | ||
|
||
private static final long serialVersionUID = 341727922218837393L; | ||
|
||
/** | ||
* If `QCaseWorkItem.class` is not enough because of generics, try `QCaseWorkItem.CLASS`. | ||
*/ | ||
@SuppressWarnings({ "unchecked", "rawtypes" }) | ||
public static final Class<QCaseWorkItem<MCase>> CLASS = (Class) QContainer.class; | ||
|
||
public static final String TABLE_NAME = "m_case_wi"; | ||
|
||
public static final ColumnMetadata CLOSE_TIMESTAMP = | ||
ColumnMetadata.named("closeTimestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE); | ||
public static final ColumnMetadata CREATE_TIMESTAMP = | ||
ColumnMetadata.named("createTimestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE); | ||
public static final ColumnMetadata DEADLINE = | ||
ColumnMetadata.named("deadline").ofType(Types.TIMESTAMP_WITH_TIMEZONE); | ||
public static final ColumnMetadata ORIGINAL_ASSIGNEE_REF_TARGET_OID = | ||
ColumnMetadata.named("originalAssigneeRefTargetOid").ofType(UuidPath.UUID_TYPE); | ||
public static final ColumnMetadata ORIGINAL_ASSIGNEE_REF_TARGET_TYPE = | ||
ColumnMetadata.named("originalAssigneeRefTargetType").ofType(Types.OTHER); | ||
public static final ColumnMetadata ORIGINAL_ASSIGNEE_REF_RELATION_ID = | ||
ColumnMetadata.named("originalAssigneeRefRelationId").ofType(Types.INTEGER); | ||
public static final ColumnMetadata OUTCOME = | ||
ColumnMetadata.named("outcome").ofType(Types.VARCHAR); | ||
public static final ColumnMetadata PERFORMER_REF_TARGET_OID = | ||
ColumnMetadata.named("performerRefTargetOid").ofType(UuidPath.UUID_TYPE); | ||
public static final ColumnMetadata PERFORMER_REF_TARGET_TYPE = | ||
ColumnMetadata.named("performerRefTargetType").ofType(Types.OTHER); | ||
public static final ColumnMetadata PERFORMER_REF_RELATION_ID = | ||
ColumnMetadata.named("performerRefRelationId").ofType(Types.INTEGER); | ||
public static final ColumnMetadata STAGE_NUMBER = | ||
ColumnMetadata.named("stageNumber").ofType(Types.INTEGER); | ||
|
||
// attributes | ||
|
||
public final DateTimePath<Instant> closeTimestamp = | ||
createInstant("closeTimestamp", CLOSE_TIMESTAMP); | ||
public final DateTimePath<Instant> createTimestamp = | ||
createInstant("createTimestamp", CREATE_TIMESTAMP); | ||
public final DateTimePath<Instant> deadline = | ||
createInstant("deadline", DEADLINE); | ||
public final UuidPath originalAssigneeRefTargetOid = | ||
createUuid("originalAssigneeRefTargetOid", ORIGINAL_ASSIGNEE_REF_TARGET_OID); | ||
public final EnumPath<MObjectType> originalAssigneeRefTargetType = | ||
createEnum("originalAssigneeRefTargetType", MObjectType.class, ORIGINAL_ASSIGNEE_REF_TARGET_TYPE); | ||
public final NumberPath<Integer> originalAssigneeRefRelationId = | ||
createInteger("originalAssigneeRefRelationId", ORIGINAL_ASSIGNEE_REF_RELATION_ID); | ||
public final StringPath outcome = createString("outcome", OUTCOME); | ||
public final UuidPath performerRefTargetOid = | ||
createUuid("performerRefTargetOid", PERFORMER_REF_TARGET_OID); | ||
public final EnumPath<MObjectType> performerRefTargetType = | ||
createEnum("performerRefTargetType", MObjectType.class, PERFORMER_REF_TARGET_TYPE); | ||
public final NumberPath<Integer> performerRefRelationId = | ||
createInteger("performerRefRelationId", PERFORMER_REF_RELATION_ID); | ||
public final NumberPath<Integer> stageNumber = | ||
createInteger("stageNumber", STAGE_NUMBER); | ||
|
||
|
||
public QCaseWorkItem(String variable) { | ||
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME); | ||
} | ||
|
||
public QCaseWorkItem(String variable, String schema, String table) { | ||
super(MCaseWorkItem.class, variable, schema, table); | ||
} | ||
|
||
@Override | ||
public BooleanExpression isOwnedBy(OR ownerRow) { | ||
return ownerOid.eq(ownerRow.oid); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...ain/java/com/evolveum/midpoint/repo/sqale/qmodel/cases/workitem/QCaseWorkItemMapping.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,108 @@ | ||
/* | ||
* Copyright (C) 2010-2021 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.cases.workitem; | ||
|
||
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType; | ||
import com.evolveum.midpoint.repo.sqale.qmodel.common.QContainerMapping; | ||
import com.evolveum.midpoint.repo.sqlbase.JdbcSession; | ||
import com.evolveum.midpoint.util.MiscUtil; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType.*; | ||
|
||
/** | ||
* Mapping between {@link QCaseWorkItem} and {@link CaseWorkItemType}. | ||
* | ||
* @param <OR> type of the owner row | ||
*/ | ||
public class QCaseWorkItemMapping<OR extends MCase> | ||
extends QContainerMapping<CaseWorkItemType, QCaseWorkItem<OR>, MCaseWorkItem, OR> { | ||
|
||
public static final String DEFAULT_ALIAS_NAME = "cswi"; | ||
|
||
private final MContainerType containerType; | ||
|
||
// We can't declare Class<QCaseWorkItem<OR>>.class, so we cheat a bit. | ||
@SuppressWarnings({ "unchecked", "rawtypes" }) | ||
private QCaseWorkItemMapping( | ||
@NotNull MContainerType containerType, | ||
@NotNull SqaleRepoContext repositoryContext) { | ||
super(QCaseWorkItem.TABLE_NAME, DEFAULT_ALIAS_NAME, | ||
CaseWorkItemType.class, (Class) QCaseWorkItem.class, repositoryContext); | ||
this.containerType = containerType; | ||
|
||
addItemMapping(F_CLOSE_TIMESTAMP, timestampMapper(q -> q.closeTimestamp)); | ||
addItemMapping(F_CREATE_TIMESTAMP, timestampMapper(q -> q.createTimestamp)); | ||
addItemMapping(F_DEADLINE, timestampMapper(q -> q.deadline)); | ||
|
||
addItemMapping(F_ORIGINAL_ASSIGNEE_REF, refMapper( | ||
q -> q.originalAssigneeRefTargetOid, | ||
q -> q.originalAssigneeRefTargetType, | ||
q -> q.originalAssigneeRefRelationId)); | ||
|
||
// TODO: OUTCOME | ||
// addItemMapping(F_OUTCOME, stringMapper(q -> q.outcome)); | ||
|
||
addItemMapping(F_PERFORMER_REF, refMapper( | ||
q -> q.performerRefTargetOid, | ||
q -> q.performerRefTargetType, | ||
q -> q.performerRefRelationId)); | ||
|
||
addItemMapping(F_STAGE_NUMBER, integerMapper(q -> q.stageNumber)); | ||
|
||
} | ||
|
||
@Override | ||
protected QCaseWorkItem<OR> newAliasInstance(String alias) { | ||
return new QCaseWorkItem<>(alias); | ||
} | ||
|
||
@Override | ||
public MCaseWorkItem newRowObject() { | ||
MCaseWorkItem row = new MCaseWorkItem(); | ||
row.containerType = this.containerType; | ||
return row; | ||
} | ||
|
||
@Override | ||
public MCaseWorkItem newRowObject(OR ownerRow) { | ||
MCaseWorkItem row = newRowObject(); | ||
row.ownerOid = ownerRow.oid; | ||
return row; | ||
} | ||
|
||
// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject | ||
@SuppressWarnings("DuplicatedCode") | ||
@Override | ||
public MCaseWorkItem insert(CaseWorkItemType workItem, OR ownerRow, JdbcSession jdbcSession) { | ||
MCaseWorkItem row = initRowObject(workItem, ownerRow); | ||
|
||
row.closeTimestamp = MiscUtil.asInstant(workItem.getCloseTimestamp()); | ||
row.createTimestamp = MiscUtil.asInstant(workItem.getCreateTimestamp()); | ||
row.deadline = MiscUtil.asInstant(workItem.getDeadline()); | ||
setReference(workItem.getOriginalAssigneeRef(), | ||
o -> row.originalAssigneeRefTargetOid = o, | ||
t -> row.originalAssigneeRefTargetType = t, | ||
r -> row.originalAssigneeRefRelationId = r); | ||
|
||
// TODO: Outcome | ||
|
||
setReference(workItem.getPerformerRef(), | ||
o -> row.performerRefTargetOid = o, | ||
t -> row.performerRefTargetType = t, | ||
r -> row.performerRefRelationId = r); | ||
row.stageNumber = workItem.getStageNumber(); | ||
|
||
insert(row, jdbcSession); | ||
|
||
return row; | ||
} | ||
} |