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());
}
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);
}
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;
}
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);
}
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);
}
Aggregations