Search in sources :

Example 16 with SearchIndexEntity

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());
    }
}
Also used : SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 17 with SearchIndexEntity

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());
}
Also used : SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 18 with SearchIndexEntity

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());
}
Also used : SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 19 with SearchIndexEntity

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());
}
Also used : SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexActivation(org.finra.herd.model.api.xml.SearchIndexActivation) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Example 20 with SearchIndexEntity

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);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Aggregations

SearchIndexEntity (org.finra.herd.model.jpa.SearchIndexEntity)26 Test (org.junit.Test)12 SearchIndexKey (org.finra.herd.model.api.xml.SearchIndexKey)11 SearchIndexTypeEntity (org.finra.herd.model.jpa.SearchIndexTypeEntity)8 SearchIndex (org.finra.herd.model.api.xml.SearchIndex)7 SearchIndexStatusEntity (org.finra.herd.model.jpa.SearchIndexStatusEntity)7 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)6 Timestamp (java.sql.Timestamp)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 Predicate (javax.persistence.criteria.Predicate)2 Settings (org.elasticsearch.common.settings.Settings)2 DocsStats (org.elasticsearch.index.shard.DocsStats)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 SearchIndexActivation (org.finra.herd.model.api.xml.SearchIndexActivation)2 SearchIndexCreateRequest (org.finra.herd.model.api.xml.SearchIndexCreateRequest)2 SearchIndexValidation (org.finra.herd.model.api.xml.SearchIndexValidation)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 SearchIndexActivationCreateRequest (org.finra.herd.model.api.xml.SearchIndexActivationCreateRequest)1