@Test public void testBeforeUpdate() throws RepositoryException, InterruptedException { IndexInfo inclusion = createMockIndexInfo("include", true); when(indexesInfo.getIndexInfos()).thenReturn(Lists.newArrayList(inclusion)); RecordEvent recordEvent = new RecordEvent(); recordEvent.setType(Type.UPDATE); recordEvent.setTableName(Table.RECORD.name); indexFilterHook.beforeUpdate(newRecord, oldRecord, repository, fieldTypes, recordEvent); IndexRecordFilterData idxFilterData = recordEvent.getIndexRecordFilterData(); assertTrue(idxFilterData.getOldRecordExists()); assertTrue(idxFilterData.getNewRecordExists()); verify(indexFilterHook).calculateIndexInclusion(RepoAndTableUtil.DEFAULT_REPOSITORY, Table.RECORD.name, oldRecord, newRecord, idxFilterData); }
@Override public void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent) throws RepositoryException, InterruptedException { Collection<IndexInfo> indexInfos = indexesInfo.getIndexInfos(); if (indexInfos.size() > 0) { TypeManager typeMgr = repository.getTypeManager(); RecordEvent.IndexRecordFilterData idxSel = new RecordEvent.IndexRecordFilterData(); recordEvent.setIndexRecordFilterData(idxSel); idxSel.setOldRecordExists(true); idxSel.setNewRecordExists(true); if (indexesInfo.getRecordFilterDependsOnRecordType()) { SchemaId oldRecordTypeId = typeMgr.getRecordTypeByName(originalRecord.getRecordTypeName(), null).getId(); idxSel.setOldRecordType(oldRecordTypeId); idxSel.setNewRecordType(record.getRecordTypeName() != null ? typeMgr.getRecordTypeByName(record.getRecordTypeName(), null).getId() : oldRecordTypeId); } Set<QName> names = indexesInfo.getRecordFilterFieldDependencies(); for (QName name : names) { Object oldValue = null, newValue = null; if (record.hasField(name)) { newValue = record.getField(name); } if (originalRecord.hasField(name)) { oldValue = originalRecord.getField(name); } if (oldValue != null || newValue != null) { FieldType type = fieldTypes.getFieldType(name); addField(type, oldValue, newValue, idxSel); } } calculateIndexInclusion(repository.getRepositoryName(), recordEvent.getTableName(), originalRecord, record, idxSel); } }
IndexRecordFilterHook implements RecordUpdateHook { @Override public void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent) throws RepositoryException, InterruptedException { Collection<IndexInfo> indexInfos = indexesInfo.getIndexInfos(); if (indexInfos.size() > 0) { TypeManager typeMgr = repository.getTypeManager(); RecordEvent.IndexRecordFilterData idxSel = new RecordEvent.IndexRecordFilterData(); recordEvent.setIndexRecordFilterData(idxSel); idxSel.setOldRecordExists(true); idxSel.setNewRecordExists(true); if (indexesInfo.getRecordFilterDependsOnRecordType()) { SchemaId oldRecordTypeId = typeMgr.getRecordTypeByName(originalRecord.getRecordTypeName(), null).getId(); idxSel.setOldRecordType(oldRecordTypeId); idxSel.setNewRecordType(record.getRecordTypeName() != null ? typeMgr.getRecordTypeByName(record.getRecordTypeName(), null).getId() : oldRecordTypeId); } Set<QName> names = indexesInfo.getRecordFilterFieldDependencies(); for (QName name : names) { Object oldValue = null, newValue = null; if (record.hasField(name)) { newValue = record.getField(name); } if (originalRecord.hasField(name)) { oldValue = originalRecord.getField(name); } if (oldValue != null || newValue != null) { FieldType type = fieldTypes.getFieldType(name); addField(type, oldValue, newValue, idxSel); } } calculateIndexInclusion(repository.getRepositoryName(), recordEvent.getTableName(), originalRecord, record, idxSel); } } }
IndexRecordFilterHook implements RecordUpdateHook { @Override public void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent) throws RepositoryException, InterruptedException { Collection<IndexInfo> indexInfos = indexesInfo.getIndexInfos(); if (indexInfos.size() > 0) { TypeManager typeMgr = repository.getTypeManager(); RecordEvent.IndexRecordFilterData idxSel = new RecordEvent.IndexRecordFilterData(); recordEvent.setIndexRecordFilterData(idxSel); idxSel.setOldRecordExists(true); idxSel.setNewRecordExists(true); if (indexesInfo.getRecordFilterDependsOnRecordType()) { SchemaId oldRecordTypeId = typeMgr.getRecordTypeByName(originalRecord.getRecordTypeName(), null).getId(); idxSel.setOldRecordType(oldRecordTypeId); idxSel.setNewRecordType(record.getRecordTypeName() != null ? typeMgr.getRecordTypeByName(record.getRecordTypeName(), null).getId() : oldRecordTypeId); } Set<QName> names = indexesInfo.getRecordFilterFieldDependencies(); for (QName name : names) { Object oldValue = null, newValue = null; if (record.hasField(name)) { newValue = record.getField(name); } if (originalRecord.hasField(name)) { oldValue = originalRecord.getField(name); } if (oldValue != null || newValue != null) { FieldType type = fieldTypes.getFieldType(name); addField(type, oldValue, newValue, idxSel); } } calculateIndexInclusion(repository.getRepositoryName(), recordEvent.getTableName(), originalRecord, record, idxSel); } } IndexRecordFilterHook(IndexesInfo indexesInfo);  IndexRecordFilterHook(PluginRegistry pluginRegistry, IndexesInfo indexesInfo); }
IndexRecordFilterHook implements RecordUpdateHook { @Override public void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent) throws RepositoryException, InterruptedException { Collection<IndexInfo> indexInfos = indexesInfo.getIndexInfos(); if (indexInfos.size() > 0) { TypeManager typeMgr = repository.getTypeManager(); RecordEvent.IndexRecordFilterData idxSel = new RecordEvent.IndexRecordFilterData(); recordEvent.setIndexRecordFilterData(idxSel); idxSel.setOldRecordExists(true); idxSel.setNewRecordExists(true); if (indexesInfo.getRecordFilterDependsOnRecordType()) { SchemaId oldRecordTypeId = typeMgr.getRecordTypeByName(originalRecord.getRecordTypeName(), null).getId(); idxSel.setOldRecordType(oldRecordTypeId); idxSel.setNewRecordType(record.getRecordTypeName() != null ? typeMgr.getRecordTypeByName(record.getRecordTypeName(), null).getId() : oldRecordTypeId); } Set<QName> names = indexesInfo.getRecordFilterFieldDependencies(); for (QName name : names) { Object oldValue = null, newValue = null; if (record.hasField(name)) { newValue = record.getField(name); } if (originalRecord.hasField(name)) { oldValue = originalRecord.getField(name); } if (oldValue != null || newValue != null) { FieldType type = fieldTypes.getFieldType(name); addField(type, oldValue, newValue, idxSel); } } calculateIndexInclusion(repository.getRepositoryName(), recordEvent.getTableName(), originalRecord, record, idxSel); } } IndexRecordFilterHook(IndexesInfo indexesInfo);  IndexRecordFilterHook(PluginRegistry pluginRegistry, IndexesInfo indexesInfo); @PreDestroy void destroy(); @Override void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes,
            RecordEvent recordEvent); @Override void beforeCreate(Record newRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent); @Override void beforeDelete(Record originalRecord, Repository repository, FieldTypes fieldTypes,
            RecordEvent recordEvent); }
IndexRecordFilterHook implements RecordUpdateHook { @Override public void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent) throws RepositoryException, InterruptedException { Collection<IndexInfo> indexInfos = indexesInfo.getIndexInfos(); if (indexInfos.size() > 0) { TypeManager typeMgr = repository.getTypeManager(); RecordEvent.IndexRecordFilterData idxSel = new RecordEvent.IndexRecordFilterData(); recordEvent.setIndexRecordFilterData(idxSel); idxSel.setOldRecordExists(true); idxSel.setNewRecordExists(true); if (indexesInfo.getRecordFilterDependsOnRecordType()) { SchemaId oldRecordTypeId = typeMgr.getRecordTypeByName(originalRecord.getRecordTypeName(), null).getId(); idxSel.setOldRecordType(oldRecordTypeId); idxSel.setNewRecordType(record.getRecordTypeName() != null ? typeMgr.getRecordTypeByName(record.getRecordTypeName(), null).getId() : oldRecordTypeId); } Set<QName> names = indexesInfo.getRecordFilterFieldDependencies(); for (QName name : names) { Object oldValue = null, newValue = null; if (record.hasField(name)) { newValue = record.getField(name); } if (originalRecord.hasField(name)) { oldValue = originalRecord.getField(name); } if (oldValue != null || newValue != null) { FieldType type = fieldTypes.getFieldType(name); addField(type, oldValue, newValue, idxSel); } } calculateIndexInclusion(repository.getRepositoryName(), recordEvent.getTableName(), originalRecord, record, idxSel); } } IndexRecordFilterHook(IndexesInfo indexesInfo);  IndexRecordFilterHook(PluginRegistry pluginRegistry, IndexesInfo indexesInfo); @PreDestroy void destroy(); @Override void beforeUpdate(Record record, Record originalRecord, Repository repository, FieldTypes fieldTypes,
            RecordEvent recordEvent); @Override void beforeCreate(Record newRecord, Repository repository, FieldTypes fieldTypes, RecordEvent recordEvent); @Override void beforeDelete(Record originalRecord, Repository repository, FieldTypes fieldTypes,
            RecordEvent recordEvent);  }