-
Notifications
You must be signed in to change notification settings - Fork 188
/
FocusSqlTransformer.java
86 lines (74 loc) · 3.79 KB
/
FocusSqlTransformer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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.focus;
import org.jetbrains.annotations.NotNull;
import com.evolveum.midpoint.repo.sqale.qmodel.object.ObjectSqlTransformer;
import com.evolveum.midpoint.repo.sqlbase.JdbcSession;
import com.evolveum.midpoint.repo.sqlbase.SqlTransformerSupport;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
public class FocusSqlTransformer<S extends FocusType, Q extends QFocus<R>, R extends MFocus>
extends ObjectSqlTransformer<S, Q, R> {
private final QFocusMapping<S, Q, R> mapping;
public FocusSqlTransformer(
SqlTransformerSupport transformerSupport, QFocusMapping<S, Q, R> mapping) {
super(transformerSupport, mapping);
this.mapping = mapping;
}
@SuppressWarnings("DuplicatedCode") // activation code duplicated with assignment
@Override
public @NotNull R toRowObjectWithoutFullObject(S focus, JdbcSession jdbcSession) {
R row = super.toRowObjectWithoutFullObject(focus, jdbcSession);
row.costCenter = focus.getCostCenter();
row.emailAddress = focus.getEmailAddress();
row.photo = focus.getJpegPhoto();
row.locale = focus.getLocale();
setPolyString(focus.getLocality(), o -> row.localityOrig = o, n -> row.localityNorm = n);
row.preferredLanguage = focus.getPreferredLanguage();
row.telephoneNumber = focus.getTelephoneNumber();
row.timezone = focus.getTimezone();
// credential/password/metadata (sorry for nesting, but the gets may not be so cheap)
CredentialsType credentials = focus.getCredentials();
if (credentials != null) {
PasswordType password = credentials.getPassword();
if (password != null) {
MetadataType passwordMetadata = password.getMetadata();
if (passwordMetadata != null) {
row.passwordCreateTimestamp =
MiscUtil.asInstant(passwordMetadata.getCreateTimestamp());
row.passwordModifyTimestamp =
MiscUtil.asInstant(passwordMetadata.getModifyTimestamp());
}
}
}
// activation
ActivationType activation = focus.getActivation();
if (activation != null) {
row.administrativeStatus = activation.getAdministrativeStatus();
row.effectiveStatus = activation.getEffectiveStatus();
row.enableTimestamp = MiscUtil.asInstant(activation.getEnableTimestamp());
row.disableTimestamp = MiscUtil.asInstant(activation.getDisableTimestamp());
row.disableReason = activation.getDisableReason();
row.validityStatus = activation.getValidityStatus();
row.validFrom = MiscUtil.asInstant(activation.getValidFrom());
row.validTo = MiscUtil.asInstant(activation.getValidTo());
row.validityChangeTimestamp = MiscUtil.asInstant(activation.getValidityChangeTimestamp());
row.archiveTimestamp = MiscUtil.asInstant(activation.getArchiveTimestamp());
row.lockoutStatus = activation.getLockoutStatus();
}
return row;
}
@Override
public void storeRelatedEntities(
@NotNull R row, @NotNull S schemaObject, @NotNull JdbcSession jdbcSession) {
super.storeRelatedEntities(row, schemaObject, jdbcSession);
storeRefs(row, schemaObject.getLinkRef(),
mapping.projectionReferenceMapping(), jdbcSession);
storeRefs(row, schemaObject.getPersonaRef(),
mapping.personaReferenceMapping(), jdbcSession);
}
}