Search in sources :

Example 11 with SearchIndexTypeEntity

use of org.finra.herd.model.jpa.SearchIndexTypeEntity 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)

Example 12 with SearchIndexTypeEntity

use of org.finra.herd.model.jpa.SearchIndexTypeEntity in project herd by FINRAOS.

the class SearchIndexServiceTest method createTestSearchIndexEntity.

/**
 * Creates a test search index entity along with the relative database entities.
 *
 * @return the search index entity
 */
private SearchIndexEntity createTestSearchIndexEntity() {
    // Creates a test search index type entity.
    SearchIndexTypeEntity searchIndexTypeEntity = new SearchIndexTypeEntity();
    searchIndexTypeEntity.setCode(SEARCH_INDEX_TYPE_BDEF);
    // Creates a test search index status entity.
    SearchIndexStatusEntity searchIndexStatusEntity = new SearchIndexStatusEntity();
    searchIndexStatusEntity.setCode(SEARCH_INDEX_STATUS);
    // Create a test search index entity.
    SearchIndexEntity searchIndexEntity = new SearchIndexEntity();
    searchIndexEntity.setName(SEARCH_INDEX_NAME);
    searchIndexEntity.setType(searchIndexTypeEntity);
    searchIndexEntity.setStatus(searchIndexStatusEntity);
    searchIndexEntity.setCreatedBy(USER_ID);
    searchIndexEntity.setCreatedOn(new Timestamp(CREATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setUpdatedOn(new Timestamp(UPDATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setActive(Boolean.FALSE);
    return searchIndexEntity;
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) Timestamp(java.sql.Timestamp) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Example 13 with SearchIndexTypeEntity

use of org.finra.herd.model.jpa.SearchIndexTypeEntity in project herd by FINRAOS.

the class SearchIndexServiceImplTest method testCreateSearchIndexFromEntity.

@Test
public void testCreateSearchIndexFromEntity() {
    // Create a search index key.
    SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
    // Creates a test search index type entity.
    SearchIndexTypeEntity searchIndexTypeEntity = new SearchIndexTypeEntity();
    searchIndexTypeEntity.setCode(SEARCH_INDEX_TYPE);
    // Creates a test search index status entity.
    SearchIndexStatusEntity searchIndexStatusEntity = new SearchIndexStatusEntity();
    searchIndexStatusEntity.setCode(SEARCH_INDEX_STATUS);
    // Create a test search index entity.
    SearchIndexEntity searchIndexEntity = new SearchIndexEntity();
    searchIndexEntity.setName(SEARCH_INDEX_NAME);
    searchIndexEntity.setType(searchIndexTypeEntity);
    searchIndexEntity.setStatus(searchIndexStatusEntity);
    searchIndexEntity.setCreatedBy(USER_ID);
    searchIndexEntity.setCreatedOn(new Timestamp(CREATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setUpdatedOn(new Timestamp(UPDATED_ON.toGregorianCalendar().getTimeInMillis()));
    searchIndexEntity.setActive(Boolean.FALSE);
    // Create a search index object from the search index entity.
    SearchIndex searchIndex = searchIndexServiceImpl.createSearchIndexFromEntity(searchIndexEntity);
    // Verify the external calls.
    verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, configurationHelper, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
    // Validate the returned object.
    assertEquals(new SearchIndex(searchIndexKey, SEARCH_INDEX_TYPE, SEARCH_INDEX_STATUS, SEARCH_INDEX_DEFAULT_ACTIVE_FLAG, NO_SEARCH_INDEX_STATISTICS, USER_ID, CREATED_ON, UPDATED_ON), searchIndex);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndex(org.finra.herd.model.api.xml.SearchIndex) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) Timestamp(java.sql.Timestamp) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 14 with SearchIndexTypeEntity

use of org.finra.herd.model.jpa.SearchIndexTypeEntity in project herd by FINRAOS.

the class SearchIndexTypeDaoHelperTest method testGetSearchIndexTypeEntity.

@Test
public void testGetSearchIndexTypeEntity() {
    // Create and persist database entities required for testing.
    SearchIndexTypeEntity searchIndexTypeEntity = searchIndexTypeDaoTestHelper.createSearchIndexTypeEntity(SEARCH_INDEX_TYPE);
    // Retrieve the search index type entity.
    assertEquals(searchIndexTypeEntity, searchIndexTypeDaoHelper.getSearchIndexTypeEntity(SEARCH_INDEX_TYPE));
    // Test case insensitivity of the search index type code.
    assertEquals(searchIndexTypeEntity, searchIndexTypeDaoHelper.getSearchIndexTypeEntity(SEARCH_INDEX_TYPE.toUpperCase()));
    assertEquals(searchIndexTypeEntity, searchIndexTypeDaoHelper.getSearchIndexTypeEntity(SEARCH_INDEX_TYPE.toLowerCase()));
    // Try to retrieve a non existing search index type.
    try {
        searchIndexTypeDaoHelper.getSearchIndexTypeEntity(I_DO_NOT_EXIST);
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Search index type with code \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

SearchIndexTypeEntity (org.finra.herd.model.jpa.SearchIndexTypeEntity)14 SearchIndexKey (org.finra.herd.model.api.xml.SearchIndexKey)8 SearchIndexEntity (org.finra.herd.model.jpa.SearchIndexEntity)8 Test (org.junit.Test)8 SearchIndexStatusEntity (org.finra.herd.model.jpa.SearchIndexStatusEntity)6 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)3 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)3 IndexSearchRequest (org.finra.herd.model.api.xml.IndexSearchRequest)3 IndexSearchResponse (org.finra.herd.model.api.xml.IndexSearchResponse)3 IndexSearchResult (org.finra.herd.model.api.xml.IndexSearchResult)3 IndexSearchResultKey (org.finra.herd.model.api.xml.IndexSearchResultKey)3 SearchIndex (org.finra.herd.model.api.xml.SearchIndex)3 TagKey (org.finra.herd.model.api.xml.TagKey)3 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 IndexSearchFilter (org.finra.herd.model.api.xml.IndexSearchFilter)2 IndexSearchKey (org.finra.herd.model.api.xml.IndexSearchKey)2 IndexSearchResultTypeKey (org.finra.herd.model.api.xml.IndexSearchResultTypeKey)2 SearchIndexCreateRequest (org.finra.herd.model.api.xml.SearchIndexCreateRequest)2