-
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.
Sqale: AccessCertificationWorkItem WIP
- Loading branch information
Showing
9 changed files
with
424 additions
and
4 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
30 changes: 30 additions & 0 deletions
30
...java/com/evolveum/midpoint/repo/sqale/qmodel/accesscert/MAccessCertificationWorkItem.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,30 @@ | ||
/* | ||
* 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.accesscert; | ||
|
||
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 QAccessCertificationWorkItem}. | ||
*/ | ||
public class MAccessCertificationWorkItem extends MContainer { | ||
|
||
public Long accCertCaseCid; | ||
|
||
public Instant closeTimestamp; | ||
public Integer campaignIteration; | ||
public String outcome; | ||
public Instant outputChangeTimestamp; | ||
public UUID performerRefTargetOid; | ||
public MObjectType performerRefTargetType; | ||
public Integer performerRefRelationId; | ||
public Integer stageNumber; | ||
} |
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
82 changes: 82 additions & 0 deletions
82
...java/com/evolveum/midpoint/repo/sqale/qmodel/accesscert/QAccessCertificationWorkItem.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,82 @@ | ||
/* | ||
* 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.accesscert; | ||
|
||
import java.sql.Types; | ||
import java.time.Instant; | ||
|
||
import com.querydsl.core.types.dsl.*; | ||
import com.querydsl.sql.ColumnMetadata; | ||
|
||
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; | ||
|
||
/** | ||
* Querydsl query type for {@value #TABLE_NAME} table. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class QAccessCertificationWorkItem extends QContainer<MAccessCertificationWorkItem, MAccessCertificationCampaign> { | ||
|
||
private static final long serialVersionUID = -672265595179912120L; | ||
|
||
public static final String TABLE_NAME = "m_access_cert_wi"; | ||
|
||
public static final ColumnMetadata ACC_CERT_CASE_CID = | ||
ColumnMetadata.named("accCertCaseCid").ofType(Types.BIGINT).notNull(); | ||
|
||
public static final ColumnMetadata CLOSE_TIMESTAMP = | ||
ColumnMetadata.named("closeTimestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE); | ||
public static final ColumnMetadata CAMPAIGN_ITERATION = | ||
ColumnMetadata.named("campaignIteration").ofType(Types.INTEGER); | ||
public static final ColumnMetadata OUTCOME = | ||
ColumnMetadata.named("outcome").ofType(Types.VARCHAR); | ||
public static final ColumnMetadata OUTPUT_CHANGE_TIMESTAMP = | ||
ColumnMetadata.named("outputChangeTimestamp").ofType(Types.TIMESTAMP_WITH_TIMEZONE); | ||
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 NumberPath<Long> accCertCaseCid = | ||
createLong("accCertCaseCid", ACC_CERT_CASE_CID); | ||
|
||
public final DateTimePath<Instant> closeTimestamp = | ||
createInstant("closeTimestamp", CLOSE_TIMESTAMP); | ||
public final NumberPath<Integer> campaignIteration = | ||
createInteger("campaignIteration", CAMPAIGN_ITERATION); | ||
public final StringPath outcome = createString("outcome", OUTCOME); | ||
public final DateTimePath<Instant> outputChangeTimestamp = | ||
createInstant("outputChangeTimestamp", OUTPUT_CHANGE_TIMESTAMP); | ||
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 QAccessCertificationWorkItem(String variable) { | ||
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME); | ||
} | ||
|
||
public QAccessCertificationWorkItem(String variable, String schema, String table) { | ||
super(MAccessCertificationWorkItem.class, variable, schema, table); | ||
} | ||
|
||
@Override | ||
public BooleanExpression isOwnedBy(MAccessCertificationCampaign ownerRow) { | ||
return ownerOid.eq(ownerRow.oid); | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
...m/evolveum/midpoint/repo/sqale/qmodel/accesscert/QAccessCertificationWorkItemMapping.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,121 @@ | ||
/* | ||
* 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.accesscert; | ||
|
||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType.*; | ||
|
||
import java.util.Objects; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext; | ||
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.AbstractWorkItemOutputType; | ||
|
||
/** | ||
* Mapping between {@link QAccessCertificationWorkItem} and {@link AccessCertificationWorkItemType}. | ||
*/ | ||
public class QAccessCertificationWorkItemMapping | ||
extends QContainerMapping<AccessCertificationWorkItemType, QAccessCertificationWorkItem, MAccessCertificationWorkItem, MAccessCertificationCampaign> { | ||
|
||
public static final String DEFAULT_ALIAS_NAME = "acwi"; | ||
|
||
private static QAccessCertificationWorkItemMapping instance; | ||
|
||
public static QAccessCertificationWorkItemMapping init( | ||
@NotNull SqaleRepoContext repositoryContext) { | ||
if (instance == null) { | ||
instance = new QAccessCertificationWorkItemMapping(repositoryContext); | ||
} | ||
return get(); | ||
} | ||
|
||
public static QAccessCertificationWorkItemMapping get() { | ||
return Objects.requireNonNull(instance); | ||
} | ||
|
||
private QAccessCertificationWorkItemMapping(@NotNull SqaleRepoContext repositoryContext) { | ||
super(QAccessCertificationWorkItem.TABLE_NAME, DEFAULT_ALIAS_NAME, | ||
AccessCertificationWorkItemType.class, QAccessCertificationWorkItem.class, repositoryContext); | ||
|
||
addItemMapping(F_CLOSE_TIMESTAMP, timestampMapper(q -> q.closeTimestamp)); | ||
// TODO: iteration -> campaignIteration | ||
addItemMapping(F_ITERATION, integerMapper(q -> q.campaignIteration)); | ||
addNestedMapping(F_OUTPUT, AbstractWorkItemOutputType.class) | ||
.addItemMapping(AbstractWorkItemOutputType.F_OUTCOME, stringMapper(q -> q.outcome)); | ||
addItemMapping(F_OUTPUT_CHANGE_TIMESTAMP, timestampMapper(q -> q.outputChangeTimestamp)); | ||
addItemMapping(F_PERFORMER_REF, refMapper( | ||
q -> q.performerRefTargetOid, | ||
q -> q.performerRefTargetType, | ||
q -> q.performerRefRelationId)); | ||
|
||
// TODO | ||
// addRefMapping(F_ASSIGNEE_REF, | ||
// QCaseWorkItemReferenceMapping.initForCaseWorkItemAssignee(repositoryContext)); | ||
// addRefMapping(F_CANDIDATE_REF, | ||
// QCaseWorkItemReferenceMapping.initForCaseWorkItemCandidate(repositoryContext)); | ||
|
||
addItemMapping(F_STAGE_NUMBER, integerMapper(q -> q.stageNumber)); | ||
|
||
} | ||
|
||
@Override | ||
protected QAccessCertificationWorkItem newAliasInstance(String alias) { | ||
return new QAccessCertificationWorkItem(alias); | ||
} | ||
|
||
@Override | ||
public MAccessCertificationWorkItem newRowObject() { | ||
return new MAccessCertificationWorkItem(); | ||
} | ||
|
||
@Override | ||
public MAccessCertificationWorkItem newRowObject(MAccessCertificationCampaign ownerRow) { | ||
MAccessCertificationWorkItem row = newRowObject(); | ||
row.ownerOid = ownerRow.oid; | ||
return row; | ||
} | ||
|
||
// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject | ||
@SuppressWarnings("DuplicatedCode") | ||
public MAccessCertificationWorkItem insert(AccessCertificationWorkItemType workItem, MAccessCertificationCampaign campaignRow, MAccessCertificationCase caseRow, JdbcSession jdbcSession) { | ||
MAccessCertificationWorkItem row = initRowObject(workItem, campaignRow); | ||
row.accCertCaseCid = caseRow.cid; | ||
|
||
row.closeTimestamp = MiscUtil.asInstant(workItem.getCloseTimestamp()); | ||
// TODO: iteration -> campaignIteration | ||
row.campaignIteration = workItem.getIteration(); | ||
|
||
AbstractWorkItemOutputType output = workItem.getOutput(); | ||
if (output != null) { | ||
row.outcome = output.getOutcome(); | ||
} | ||
|
||
row.outputChangeTimestamp = MiscUtil.asInstant(workItem.getOutputChangeTimestamp()); | ||
|
||
setReference(workItem.getPerformerRef(), | ||
o -> row.performerRefTargetOid = o, | ||
t -> row.performerRefTargetType = t, | ||
r -> row.performerRefRelationId = r); | ||
|
||
row.stageNumber = workItem.getStageNumber(); | ||
|
||
insert(row, jdbcSession); | ||
|
||
// TODO | ||
// storeRefs(row, workItem.getAssigneeRef(), | ||
// QCaseWorkItemReferenceMapping.getForCaseWorkItemAssignee(), jdbcSession); | ||
// storeRefs(row, workItem.getCandidateRef(), | ||
// QCaseWorkItemReferenceMapping.getForCaseWorkItemCandidate(), jdbcSession); | ||
|
||
return row; | ||
} | ||
} |
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
Oops, something went wrong.