Skip to content

Commit

Permalink
"exists" filter also on standard properties (currently shadow.pending…
Browse files Browse the repository at this point in the history
…Operation)

new indices for m_shadow: kind, intent, objectClass, failedOperationType, synchronizationSituation, pendingOperationCount
  • Loading branch information
mederly committed Apr 19, 2017
1 parent 49dfdcd commit 3daa033
Show file tree
Hide file tree
Showing 25 changed files with 314 additions and 85 deletions.
13 changes: 13 additions & 0 deletions config/sql/midpoint/3.6/h2/h2-3.6.sql
Expand Up @@ -654,6 +654,7 @@ CREATE TABLE m_shadow (
name_norm VARCHAR(255),
name_orig VARCHAR(255),
objectClass VARCHAR(157),
pendingOperationCount INTEGER,
resourceRef_relation VARCHAR(157),
resourceRef_targetOid VARCHAR(36),
resourceRef_type INTEGER,
Expand Down Expand Up @@ -933,6 +934,18 @@ CREATE INDEX iShadowResourceRef ON m_shadow (resourceRef_targetOid);

CREATE INDEX iShadowDead ON m_shadow (dead);

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);

ALTER TABLE m_system_configuration
ADD CONSTRAINT uc_system_configuration_name UNIQUE (name_norm);

Expand Down
14 changes: 14 additions & 0 deletions config/sql/midpoint/3.6/h2/h2-upgrade-3.5-3.6.sql
Expand Up @@ -128,3 +128,17 @@ ALTER TABLE m_acc_cert_wi_reference
ADD CONSTRAINT fk_acc_cert_wi_ref_owner
FOREIGN KEY (owner_id, owner_owner_id, owner_owner_owner_oid)
REFERENCES m_acc_cert_wi;

ALTER TABLE m_shadow ADD pendingOperationCount INTEGER;

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);
13 changes: 13 additions & 0 deletions config/sql/midpoint/3.6/mysql/mysql-3.6.sql
Expand Up @@ -832,6 +832,7 @@ CREATE TABLE m_shadow (
name_norm VARCHAR(255),
name_orig VARCHAR(255),
objectClass VARCHAR(157),
pendingOperationCount INTEGER,
resourceRef_relation VARCHAR(157),
resourceRef_targetOid VARCHAR(36),
resourceRef_type INTEGER,
Expand Down Expand Up @@ -1143,6 +1144,18 @@ CREATE INDEX iShadowResourceRef ON m_shadow (resourceRef_targetOid);

CREATE INDEX iShadowDead ON m_shadow (dead);

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);

ALTER TABLE m_system_configuration
ADD CONSTRAINT uc_system_configuration_name UNIQUE (name_norm);

Expand Down
14 changes: 14 additions & 0 deletions config/sql/midpoint/3.6/mysql/mysql-upgrade-3.5-3.6.sql
Expand Up @@ -150,3 +150,17 @@ ALTER TABLE m_acc_cert_wi_reference
ADD CONSTRAINT fk_acc_cert_wi_ref_owner
FOREIGN KEY (owner_id, owner_owner_id, owner_owner_owner_oid)
REFERENCES m_acc_cert_wi (id, owner_id, owner_owner_oid);

ALTER TABLE m_shadow ADD COLUMN pendingOperationCount INTEGER;

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);
13 changes: 13 additions & 0 deletions config/sql/midpoint/3.6/oracle/oracle-3.6.sql
Expand Up @@ -664,6 +664,7 @@ CREATE TABLE m_shadow (
name_norm VARCHAR2(255 CHAR),
name_orig VARCHAR2(255 CHAR),
objectClass VARCHAR2(157 CHAR),
pendingOperationCount NUMBER(10, 0),
resourceRef_relation VARCHAR2(157 CHAR),
resourceRef_targetOid VARCHAR2(36 CHAR),
resourceRef_type NUMBER(10, 0),
Expand Down Expand Up @@ -943,6 +944,18 @@ CREATE INDEX iShadowResourceRef ON m_shadow (resourceRef_targetOid) INITRANS 30;

CREATE INDEX iShadowDead ON m_shadow (dead) INITRANS 30;

CREATE INDEX iShadowKind ON m_shadow (kind) INITRANS 30;

CREATE INDEX iShadowIntent ON m_shadow (intent) INITRANS 30;

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass) INITRANS 30;

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType) INITRANS 30;

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation) INITRANS 30;

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount) INITRANS 30;

ALTER TABLE m_system_configuration
ADD CONSTRAINT uc_system_configuration_name UNIQUE (name_norm) INITRANS 30;

Expand Down
14 changes: 14 additions & 0 deletions config/sql/midpoint/3.6/oracle/oracle-upgrade-3.5-3.6.sql
Expand Up @@ -130,3 +130,17 @@ ALTER TABLE m_acc_cert_wi_reference
ADD CONSTRAINT fk_acc_cert_wi_ref_owner
FOREIGN KEY (owner_id, owner_owner_id, owner_owner_owner_oid)
REFERENCES m_acc_cert_wi;

ALTER TABLE m_shadow ADD (pendingOperationCount NUMBER(10, 0));

CREATE INDEX iShadowKind ON m_shadow (kind) INITRANS 30;

CREATE INDEX iShadowIntent ON m_shadow (intent) INITRANS 30;

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass) INITRANS 30;

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType) INITRANS 30;

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation) INITRANS 30;

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount) INITRANS 30;
13 changes: 13 additions & 0 deletions config/sql/midpoint/3.6/postgresql/postgresql-3.6.sql
Expand Up @@ -654,6 +654,7 @@ CREATE TABLE m_shadow (
name_norm VARCHAR(255),
name_orig VARCHAR(255),
objectClass VARCHAR(157),
pendingOperationCount INT4,
resourceRef_relation VARCHAR(157),
resourceRef_targetOid VARCHAR(36),
resourceRef_type INT4,
Expand Down Expand Up @@ -933,6 +934,18 @@ CREATE INDEX iShadowResourceRef ON m_shadow (resourceRef_targetOid);

CREATE INDEX iShadowDead ON m_shadow (dead);

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);

ALTER TABLE m_system_configuration
ADD CONSTRAINT uc_system_configuration_name UNIQUE (name_norm);

Expand Down
14 changes: 14 additions & 0 deletions config/sql/midpoint/3.6/postgresql/postgresql-upgrade-3.5-3.6.sql
Expand Up @@ -129,3 +129,17 @@ ALTER TABLE m_acc_cert_wi_reference
ADD CONSTRAINT fk_acc_cert_wi_ref_owner
FOREIGN KEY (owner_id, owner_owner_id, owner_owner_owner_oid)
REFERENCES m_acc_cert_wi;

ALTER TABLE m_shadow ADD COLUMN pendingOperationCount INT4;

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);
13 changes: 13 additions & 0 deletions config/sql/midpoint/3.6/sqlserver/sqlserver-3.6.sql
Expand Up @@ -654,6 +654,7 @@ CREATE TABLE m_shadow (
name_norm NVARCHAR(255) COLLATE database_default,
name_orig NVARCHAR(255) COLLATE database_default,
objectClass NVARCHAR(157) COLLATE database_default,
pendingOperationCount INT,
resourceRef_relation NVARCHAR(157) COLLATE database_default,
resourceRef_targetOid NVARCHAR(36) COLLATE database_default,
resourceRef_type INT,
Expand Down Expand Up @@ -933,6 +934,18 @@ CREATE INDEX iShadowResourceRef ON m_shadow (resourceRef_targetOid);

CREATE INDEX iShadowDead ON m_shadow (dead);

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);

ALTER TABLE m_system_configuration
ADD CONSTRAINT uc_system_configuration_name UNIQUE (name_norm);

Expand Down
14 changes: 14 additions & 0 deletions config/sql/midpoint/3.6/sqlserver/sqlserver-upgrade-3.5-3.6.sql
Expand Up @@ -129,3 +129,17 @@ ALTER TABLE m_acc_cert_wi_reference
ADD CONSTRAINT fk_acc_cert_wi_ref_owner
FOREIGN KEY (owner_id, owner_owner_id, owner_owner_owner_oid)
REFERENCES m_acc_cert_wi;

ALTER TABLE m_shadow ADD pendingOperationCount INT;

CREATE INDEX iShadowKind ON m_shadow (kind);

CREATE INDEX iShadowIntent ON m_shadow (intent);

CREATE INDEX iShadowObjectClass ON m_shadow (objectClass);

CREATE INDEX iShadowFailedOperationType ON m_shadow (failedOperationType);

CREATE INDEX iShadowSyncSituation ON m_shadow (synchronizationSituation);

CREATE INDEX iShadowPendingOperationCount ON m_shadow (pendingOperationCount);
Expand Up @@ -282,7 +282,7 @@ public S_FilterEntryOrEmpty type(Class<? extends Containerable> type) {
}

@Override
public S_FilterEntry exists(QName... names) {
public S_FilterEntryOrEmpty exists(QName... names) {
if (existsRestriction != null) {
throw new IllegalStateException("Exists within exists");
}
Expand Down
Expand Up @@ -52,5 +52,5 @@ public interface S_AtomicFilterEntry {
S_AtomicFilterExit fullText(String... words);
S_FilterEntryOrEmpty block();
S_FilterEntryOrEmpty type(Class<? extends Containerable> type) ;
S_FilterEntry exists(QName... names) ;
S_FilterEntryOrEmpty exists(QName... names) ;
}
Expand Up @@ -238,8 +238,7 @@ private void checkContainerValuesSize(QName parentName, PrismContainerValue newV

private void checkContainersSize(PrismContainer newContainer, PrismContainer oldContainer) {
LOGGER.info("checkContainersSize {} new {} old {}",

new Object[]{newContainer.getElementName(), newContainer.size(), oldContainer.size()});
newContainer.getElementName(), newContainer.size(), oldContainer.size());
AssertJUnit.assertEquals(newContainer.size(), oldContainer.size());

List<Long> checked = new ArrayList<Long>();
Expand Down
Expand Up @@ -3780,7 +3780,35 @@ public void testAdHoc106AbstractRoleParameters() throws Exception {
}
}

// @Test
@Test
public void testAdHoc107ExistsShadowPendingOperation() throws Exception {
Session session = open();
try {
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext)
.exists(ShadowType.F_PENDING_OPERATION)
.build();
String real = getInterpretedQuery2(session, ShadowType.class, query);
String expected = "select\n"
+ " s.oid,\n"
+ " s.fullObject,\n"
+ " s.stringsCount,\n"
+ " s.longsCount,\n"
+ " s.datesCount,\n"
+ " s.referencesCount,\n"
+ " s.polysCount,\n"
+ " s.booleansCount\n"
+ "from\n"
+ " RShadow s\n"
+ "where\n"
+ " s.pendingOperationCount > :pendingOperationCount";
assertEqualsIgnoreWhitespace(expected, real);
} finally {
close(session);
}
}


// @Test
// public void test930OrganizationEqualsCostCenter() throws Exception {
// Session session = open();
//
Expand Down
Expand Up @@ -707,6 +707,18 @@ public void fullTextSearch() throws Exception {
distinct, 1);
}

@Test
public void testShadowPendingOperation() throws SchemaException {
ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext)
.exists(ShadowType.F_PENDING_OPERATION)
.build();
OperationResult result = new OperationResult("search");
List<PrismObject<ShadowType>> shadows = repositoryService.searchObjects(ShadowType.class, query, null, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals("Should find one object", 1, shadows.size());
}

@SuppressWarnings("SameParameterValue")
private List<PrismObject<UserType>> assertUsersFound(ObjectQuery query, boolean distinct, int expectedCount) throws Exception {
Collection<SelectorOptions<GetOperationOptions>> options = distinct ?
Expand Down
6 changes: 6 additions & 0 deletions repo/repo-sql-impl-test/src/test/resources/basic/objects.xml
Expand Up @@ -794,6 +794,12 @@
<administrativeStatus>archived</administrativeStatus>
<effectiveStatus>disabled</effectiveStatus>
</activation>
<pendingOperation id="1">
<asynchronousOperationReference>123456</asynchronousOperationReference>
</pendingOperation>
<pendingOperation id="2">
<asynchronousOperationReference>789012</asynchronousOperationReference>
</pendingOperation>
</object>

<object xsi:type="ConnectorType" oid="1234" xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand Down

0 comments on commit 3daa033

Please sign in to comment.