Skip to content

Commit

Permalink
MID-8053: added m_connector.available for the Native repo
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Aug 22, 2022
1 parent 9feaaa6 commit 1e31930
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions config/sql/native-new/postgres-new-upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ call apply_change(10, $aa$
ALTER TABLE m_resource ADD template BOOLEAN;
$aa$);

-- MID-8053: "Active" connectors detection
call apply_change(11, $aa$
ALTER TABLE m_connector ADD available BOOLEAN;
$aa$);

-- SCHEMA-COMMIT 4.6: commit TODO

-- WRITE CHANGES ABOVE ^^
Expand Down
5 changes: 3 additions & 2 deletions config/sql/native-new/postgres-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ CREATE TABLE m_connector (
connectorHostRefTargetOid UUID,
connectorHostRefTargetType ObjectType,
connectorHostRefRelationId INTEGER REFERENCES m_uri(id),
targetSystemTypes INTEGER[]
targetSystemTypes INTEGER[],
available BOOLEAN
)
INHERITS (m_assignment_holder);

Expand Down Expand Up @@ -1938,4 +1939,4 @@ END $$;

-- Initializing the last change number used in postgres-new-upgrade.sql.
-- This is important to avoid applying any change more than once.
call apply_change(9, $$ SELECT 1 $$, true);
call apply_change(11, $$ SELECT 1 $$, true);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -24,4 +24,5 @@ public class MConnector extends MObject {
public MObjectType connectorHostRefTargetType;
public Integer connectorHostRefRelationId;
public Integer[] targetSystemTypes;
public Boolean available;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -8,10 +8,7 @@

import java.sql.Types;

import com.querydsl.core.types.dsl.ArrayPath;
import com.querydsl.core.types.dsl.EnumPath;
import com.querydsl.core.types.dsl.NumberPath;
import com.querydsl.core.types.dsl.StringPath;
import com.querydsl.core.types.dsl.*;
import com.querydsl.sql.ColumnMetadata;

import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType;
Expand Down Expand Up @@ -44,6 +41,8 @@ public class QConnector extends QAssignmentHolder<MConnector> {
ColumnMetadata.named("connectorHostRefRelationId").ofType(Types.INTEGER);
public static final ColumnMetadata TARGET_SYSTEM_TYPES =
ColumnMetadata.named("targetSystemTypes").ofType(Types.ARRAY);
public static final ColumnMetadata AVAILABLE =
ColumnMetadata.named("available").ofType(Types.BOOLEAN);

public final StringPath connectorBundle = createString("connectorBundle", CONNECTOR_BUNDLE);
public final StringPath connectorType = createString("connectorType", CONNECTOR_TYPE);
Expand All @@ -58,6 +57,7 @@ public class QConnector extends QAssignmentHolder<MConnector> {
createInteger("connectorHostRefRelationId", CONNECTOR_HOST_REF_RELATION_ID);
public final ArrayPath<Integer[], Integer> targetSystemTypes =
createArray("targetSystemTypes", Integer[].class, TARGET_SYSTEM_TYPES);
public final BooleanPath available = createBoolean("available", AVAILABLE);

public QConnector(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -53,6 +53,7 @@ private QConnectorMapping(@NotNull SqaleRepoContext repositoryContext) {
QConnectorHostMapping::get);

addItemMapping(F_TARGET_SYSTEM_TYPE, multiUriMapper(q -> q.targetSystemTypes));
addItemMapping(F_AVAILABLE, booleanMapper(q -> q.available));
}

@Override
Expand Down Expand Up @@ -81,6 +82,7 @@ public MConnector newRowObject() {
r -> row.connectorHostRefRelationId = r);

row.targetSystemTypes = processCacheableUris(schemaObject.getTargetSystemType());
row.available = schemaObject.isAvailable();

return row;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,8 @@ public void test811Connector() throws Exception {
.connectorHostRef(connectorHostOid.toString(),
ConnectorHostType.COMPLEX_TYPE, connectorHostRelation)
.targetSystemType("type1")
.targetSystemType("type2");
.targetSystemType("type2")
.available(true);

when("adding it to the repository");
repositoryService.addObject(connector.asPrismObject(), null, result);
Expand All @@ -1368,6 +1369,7 @@ public void test811Connector() throws Exception {
assertCachedUri(row.connectorHostRefRelationId, connectorHostRelation);
assertThat(resolveCachedUriIds(row.targetSystemTypes))
.containsExactlyInAnyOrder("type1", "type2");
assertThat(row.available).isTrue();
}

@Test
Expand Down

0 comments on commit 1e31930

Please sign in to comment.