use of org.finra.herd.model.jpa.SearchIndexEntity in project herd by FINRAOS.
the class SearchIndexDaoHelperTest method testGetSearchIndexEntity.
@Test
public void testGetSearchIndexEntity() {
// Create and persist database entities required for testing.
SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS);
// Retrieve the search index entity.
assertEquals(searchIndexEntity, searchIndexDaoHelper.getSearchIndexEntity(new SearchIndexKey(SEARCH_INDEX_NAME)));
// Try to retrieve a non-existing search index.
try {
searchIndexDaoHelper.getSearchIndexEntity(new SearchIndexKey(I_DO_NOT_EXIST));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Search index with name \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage());
}
}
use of org.finra.herd.model.jpa.SearchIndexEntity in project herd by FINRAOS.
the class SearchIndexDaoHelperTest method testActivateSearchIndexEntity.
@Test
public void testActivateSearchIndexEntity() {
// Create and persist multiple search index entities of the same type.
SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS);
SearchIndexEntity searchIndexEntity1 = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME_2, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS);
// Activate the first search index
searchIndexDaoHelper.activateSearchIndex(searchIndexEntity);
// Validate the results
assertEquals(Boolean.TRUE, searchIndexEntity.getActive());
assertEquals(Boolean.FALSE, searchIndexEntity1.getActive());
}
use of org.finra.herd.model.jpa.SearchIndexEntity in project herd by FINRAOS.
the class SearchIndexDaoHelperTest method testActivateSearchIndexEntitySingleEntity.
@Test
public void testActivateSearchIndexEntitySingleEntity() {
// Create and persist a search index entity.
SearchIndexEntity searchIndexEntity = searchIndexDaoTestHelper.createSearchIndexEntity(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS);
searchIndexDaoHelper.activateSearchIndex(searchIndexEntity);
assertEquals(Boolean.TRUE, searchIndexEntity.getActive());
}
use of org.finra.herd.model.jpa.SearchIndexEntity in project herd by FINRAOS.
the class SearchIndexActivationServiceImpl method createSearchIndexActivation.
@Override
public SearchIndexActivation createSearchIndexActivation(SearchIndexActivationCreateRequest request) {
// Validate the request
validateSearchIndexActivationRequest(request);
// Ensure that search index for the specified search index key exists.
SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(request.getSearchIndexKey());
// Activate the specified search index entity.
searchIndexDaoHelper.activateSearchIndex(searchIndexEntity);
SearchIndex searchIndex = createSearchIndexFromEntity(searchIndexEntity);
return new SearchIndexActivation(searchIndex.getSearchIndexKey(), searchIndex.getSearchIndexType(), searchIndex.getSearchIndexStatus(), searchIndex.isActive(), searchIndex.getCreatedByUserId(), searchIndex.getCreatedOn(), searchIndex.getLastUpdatedOn());
}
use of org.finra.herd.model.jpa.SearchIndexEntity in project herd by FINRAOS.
the class SearchIndexServiceImpl method createSearchIndex.
@Override
public SearchIndex createSearchIndex(SearchIndexCreateRequest request) {
// Perform validation and trim.
validateSearchIndexCreateRequest(request);
// Get the search index type and ensure it exists.
SearchIndexTypeEntity searchIndexTypeEntity = searchIndexTypeDaoHelper.getSearchIndexTypeEntity(request.getSearchIndexType());
// Get the BUILDING search index status entity and ensure it exists.
SearchIndexStatusEntity searchIndexStatusEntity = searchIndexStatusDaoHelper.getSearchIndexStatusEntity(SearchIndexStatusEntity.SearchIndexStatuses.BUILDING.name());
// Creates the relative search index entity from the request information.
SearchIndexEntity searchIndexEntity = createSearchIndexEntity(request, searchIndexTypeEntity, searchIndexStatusEntity);
// Persist the new entity.
searchIndexEntity = searchIndexDao.saveAndRefresh(searchIndexEntity);
// Create search index key with the auto-generated search index name
SearchIndexKey searchIndexKey = new SearchIndexKey();
searchIndexKey.setSearchIndexName(searchIndexEntity.getName());
// Create the search index.
createSearchIndexHelper(searchIndexKey, searchIndexTypeEntity.getCode());
// Create and return the search index object from the persisted entity.
return createSearchIndexFromEntity(searchIndexEntity);
}
Aggregations