Skip to content

Commit

Permalink
repo-sqale fixes after schema cleanup of various *Type attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Sep 14, 2021
1 parent 029bb6c commit abd98b1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 56 deletions.
6 changes: 2 additions & 4 deletions repo/repo-sqale/sql/pgnew-repo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ CREATE INDEX m_ref_projectionTargetOidRelationId_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
CHECK (objectType = 'GENERIC_OBJECT'),
genericObjectTypeId INTEGER NOT NULL REFERENCES m_uri(id) -- GenericObjectType#objectType
CHECK (objectType = 'GENERIC_OBJECT')
)
INHERITS (m_focus);

Expand Down Expand Up @@ -580,8 +579,7 @@ CREATE INDEX iAutoassignEnabled ON m_abstract_role(autoassign_enabled);
CREATE TABLE m_role (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('ROLE') STORED
CHECK (objectType = 'ROLE'),
roleType TEXT
CHECK (objectType = 'ROLE')
)
INHERITS (m_abstract_role);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public class QFocus<R extends MFocus> extends QAssignmentHolder<R> {

public static final String TABLE_NAME = "m_focus";

public static final ColumnMetadata ROLE_TYPE =
ColumnMetadata.named("roleType").ofType(Types.VARCHAR);

public static final ColumnMetadata COST_CENTER =
ColumnMetadata.named("costCenter").ofType(Types.VARCHAR);
public static final ColumnMetadata EMAIL_ADDRESS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,21 @@
*/
package com.evolveum.midpoint.repo.sqale.qmodel.focus;

import java.sql.Types;

import com.querydsl.core.types.dsl.NumberPath;
import com.querydsl.sql.ColumnMetadata;

/**
* Querydsl query type for {@value #TABLE_NAME} table.
*/
@SuppressWarnings("unused")
public class QGenericObject extends QFocus<MGenericObject> {
public class QGenericObject extends QFocus<MFocus> {

private static final long serialVersionUID = -8447131528511969285L;

public static final String TABLE_NAME = "m_generic_object";

public static final ColumnMetadata GENERIC_OBJECT_TYPE_ID =
ColumnMetadata.named("genericObjectTypeId").ofType(Types.INTEGER);

public final NumberPath<Integer> genericObjectTypeId =
createInteger("genericObjectTypeId", GENERIC_OBJECT_TYPE_ID);

public QGenericObject(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
}

public QGenericObject(String variable, String schema, String table) {
super(MGenericObject.class, variable, schema, table);
super(MFocus.class, variable, schema, table);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Mapping between {@link QGenericObject} and {@link GenericObjectType}.
*/
public class QGenericObjectMapping
extends QFocusMapping<GenericObjectType, QGenericObject, MGenericObject> {
extends QFocusMapping<GenericObjectType, QGenericObject, MFocus> {

public static final String DEFAULT_ALIAS_NAME = "go";

Expand All @@ -35,14 +35,14 @@ protected QGenericObject newAliasInstance(String alias) {
}

@Override
public MGenericObject newRowObject() {
return new MGenericObject();
public MFocus newRowObject() {
return new MFocus();
}

@Override
public @NotNull MGenericObject toRowObjectWithoutFullObject(
public @NotNull MFocus toRowObjectWithoutFullObject(
GenericObjectType genericObject, JdbcSession jdbcSession) {
MGenericObject row = super.toRowObjectWithoutFullObject(genericObject, jdbcSession);
MFocus row = super.toRowObjectWithoutFullObject(genericObject, jdbcSession);

return row;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
* Querydsl "row bean" type related to {@link QRole}.
*/
public class MRole extends MAbstractRole {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package com.evolveum.midpoint.repo.sqale.qmodel.role;

/**
* Querydsl "row bean" type related to {@link QRole}.
* Querydsl "row bean" type related to {@link QService}.
*/
public class MService extends MAbstractRole {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
*/
package com.evolveum.midpoint.repo.sqale.qmodel.role;

import java.sql.Types;

import com.querydsl.core.types.dsl.StringPath;
import com.querydsl.sql.ColumnMetadata;

/**
* Querydsl query type for {@value #TABLE_NAME} table.
*/
Expand All @@ -21,13 +16,8 @@ public class QRole extends QAbstractRole<MRole> {

public static final String TABLE_NAME = "m_role";

public static final ColumnMetadata ROLE_TYPE =
ColumnMetadata.named("roleType").ofType(Types.VARCHAR);

// columns and relations

public final StringPath roleType = createString("roleType", ROLE_TYPE);

public QRole(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost;
import com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector;
import com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost;
import com.evolveum.midpoint.repo.sqale.qmodel.focus.MGenericObject;
import com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus;
import com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser;
import com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject;
import com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser;
Expand Down Expand Up @@ -1493,7 +1493,7 @@ public void test820GenericObject() throws Exception {
then("it is stored and relevant attributes are in columns");
assertThatOperationResult(result).isSuccess();

MGenericObject row = selectObjectByOid(
MFocus row = selectObjectByOid(
QGenericObject.class, UUID.fromString(genericObject.getOid()));
assertThat(row.costCenter).isEqualTo("cost-center");
assertThat(row.emailAddress).isEqualTo("email-address");
Expand All @@ -1520,9 +1520,7 @@ public void test820GenericObject() throws Exception {
assertThat(row.archiveTimestamp).isEqualTo(Instant.ofEpochMilli(8));
assertThat(row.lockoutStatus).isEqualTo(LockoutStatusType.NORMAL);

// TODO: fix after objectType -> subtype change
// field specific to GenericObjectType
// assertCachedUri(row.genericObjectTypeId, "some-custom-object-type-uri");
assertThat(row.subtypes).containsExactlyInAnyOrder("some-custom-object-type-uri");
}

// This covers mapping of attributes in AbstractRole + Archetype + inducement mapping.
Expand Down

0 comments on commit abd98b1

Please sign in to comment.