Search in sources :

Example 1 with SearchIndexEntity

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

the class SearchIndexServiceImplTest method testCreateSearchIndexEntity.

@Test
public void testCreateSearchIndexEntity() {
    // Create a search index key.
    SearchIndexKey searchIndexKey = new SearchIndexKey(SEARCH_INDEX_NAME);
    // Create a search index create request.
    SearchIndexCreateRequest searchIndexCreateRequest = new SearchIndexCreateRequest(SEARCH_INDEX_TYPE);
    // 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 search index entity from the search index create request.
    SearchIndexEntity searchIndexEntity = searchIndexServiceImpl.createSearchIndexEntity(searchIndexCreateRequest, searchIndexTypeEntity, searchIndexStatusEntity);
    // Verify the external calls.
    verifyNoMoreInteractions(alternateKeyHelper, businessObjectDefinitionDao, businessObjectDefinitionHelper, configurationDaoHelper, searchIndexDao, searchIndexDaoHelper, searchIndexHelperService, searchIndexStatusDaoHelper, searchIndexTypeDaoHelper);
    // Validate the returned object.
    assertNotNull(searchIndexEntity);
    assertNotNull(searchIndexEntity.getType());
    assertEquals(SEARCH_INDEX_TYPE, searchIndexEntity.getType().getCode());
    assertNotNull(searchIndexEntity.getStatus());
    assertEquals(SEARCH_INDEX_STATUS, searchIndexEntity.getStatus().getCode());
    assertNull(searchIndexEntity.getCreatedBy());
    assertNull(searchIndexEntity.getCreatedOn());
    assertNull(searchIndexEntity.getUpdatedBy());
    assertNull(searchIndexEntity.getUpdatedOn());
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) SearchIndexKey(org.finra.herd.model.api.xml.SearchIndexKey) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) SearchIndexCreateRequest(org.finra.herd.model.api.xml.SearchIndexCreateRequest) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 2 with SearchIndexEntity

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

the class SearchIndexServiceImpl method deleteSearchIndex.

@Override
public SearchIndex deleteSearchIndex(SearchIndexKey searchIndexKey) {
    // Perform validation and trim.
    validateSearchIndexKey(searchIndexKey);
    // Retrieve and ensure that a search index already exists with the specified key.
    SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(searchIndexKey);
    // If the index exists delete it.
    deleteSearchIndexHelper(searchIndexEntity.getName());
    // Delete the search index.
    searchIndexDao.delete(searchIndexEntity);
    // Create and return the search index object from the deleted entity.
    return createSearchIndexFromEntity(searchIndexEntity);
}
Also used : SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Example 3 with SearchIndexEntity

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

the class SearchIndexServiceImpl method createSearchIndexEntity.

/**
 * Creates a new search index entity from the request information.
 *
 * @param request the information needed to create a search index
 * @param searchIndexTypeEntity the search index type entity
 * @param searchIndexStatusEntity the search index status entity
 *
 * @return the newly created search index entity
 */
protected SearchIndexEntity createSearchIndexEntity(SearchIndexCreateRequest request, SearchIndexTypeEntity searchIndexTypeEntity, SearchIndexStatusEntity searchIndexStatusEntity) {
    SearchIndexEntity searchIndexEntity = new SearchIndexEntity();
    searchIndexEntity.setName(setSearchIndexName(request.getSearchIndexType()));
    searchIndexEntity.setType(searchIndexTypeEntity);
    searchIndexEntity.setStatus(searchIndexStatusEntity);
    return searchIndexEntity;
}
Also used : SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity)

Example 4 with SearchIndexEntity

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

the class SearchIndexValidationServiceImpl method createSearchIndexValidation.

@Override
public SearchIndexValidation createSearchIndexValidation(SearchIndexValidationCreateRequest request) {
    // validate the request
    validateSearchIndexValidationRequest(request);
    // Ensure that search index for the specified search index key exists. Fetch the type
    SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(request.getSearchIndexKey());
    String searchIndexType = searchIndexEntity.getType().getCode();
    String indexName = request.getSearchIndexKey().getSearchIndexName();
    boolean sizeCheck = false;
    boolean spotCheckPercentage = false;
    boolean spotCheckMostRecent = false;
    // Currently, only search index for business object definitions and tag are supported.
    if (SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name().equalsIgnoreCase(searchIndexType)) {
        // only perform full validation if specified in the request
        if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) {
            businessObjectDefinitionService.indexValidateAllBusinessObjectDefinitions(indexName);
        }
        sizeCheck = businessObjectDefinitionService.indexSizeCheckValidationBusinessObjectDefinitions(indexName);
        spotCheckPercentage = businessObjectDefinitionService.indexSpotCheckPercentageValidationBusinessObjectDefinitions(indexName);
        spotCheckMostRecent = businessObjectDefinitionService.indexSpotCheckMostRecentValidationBusinessObjectDefinitions(indexName);
    } else if (SearchIndexTypeEntity.SearchIndexTypes.TAG.name().equalsIgnoreCase(searchIndexType)) {
        // only perform full validation if specified in the request
        if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) {
            tagService.indexValidateAllTags(indexName);
        }
        sizeCheck = tagService.indexSizeCheckValidationTags(indexName);
        spotCheckPercentage = tagService.indexSpotCheckPercentageValidationTags(indexName);
        spotCheckMostRecent = tagService.indexSpotCheckMostRecentValidationTags(indexName);
    }
    return new SearchIndexValidation(request.getSearchIndexKey(), getXMLGregorianCalendarValue(new Date()), sizeCheck, spotCheckPercentage, spotCheckMostRecent);
}
Also used : SearchIndexValidation(org.finra.herd.model.api.xml.SearchIndexValidation) SearchIndexEntity(org.finra.herd.model.jpa.SearchIndexEntity) Date(java.util.Date)

Example 5 with SearchIndexEntity

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

the class SearchIndexDaoHelper method updateSearchIndexStatus.

/**
 * Gets a search index entity by its key and ensure it exists.
 *
 * @param searchIndexKey the search index key (case sensitive)
 * @param searchIndexStatus the status of the search index (case insensitive)
 *
 * @throws org.finra.herd.model.ObjectNotFoundException if the search index entity or search index status entity doesn't exist
 */
public void updateSearchIndexStatus(SearchIndexKey searchIndexKey, String searchIndexStatus) throws ObjectNotFoundException {
    // Get the search index entity and ensure that it exists.
    SearchIndexEntity searchIndexEntity = getSearchIndexEntity(searchIndexKey);
    // Get the search index status entity and ensure that it exists.
    SearchIndexStatusEntity searchIndexStatusEntity = searchIndexStatusDaoHelper.getSearchIndexStatusEntity(searchIndexStatus);
    // Update the search index status.
    searchIndexEntity.setStatus(searchIndexStatusEntity);
    // Persist the entity.
    searchIndexDao.saveAndRefresh(searchIndexEntity);
}
Also used : SearchIndexStatusEntity(org.finra.herd.model.jpa.SearchIndexStatusEntity) 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