/** * Create an instance of {@link ResultTypeIndexSearchResponseDto } * */ public ResultTypeIndexSearchResponseDto createResultTypeIndexSearchResponseDto() { return new ResultTypeIndexSearchResponseDto(); }
public String toString() { final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
public static ResultTypeIndexSearchResponseDto.Builder<Void> copyOnly(final ResultTypeIndexSearchResponseDto _other, final PropertyTree _propertyTree) { return copyOf(_other, _propertyTree, PropertyTreeUse.INCLUDE); }
/** * Creates result type facet response dto * * @param searchResponse search response * * @return result type facet response dto list */ public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResponse searchResponse) { List<ResultTypeIndexSearchResponseDto> list = new ArrayList<>(); Terms aggregation = getAggregation(searchResponse, RESULT_TYPE_AGGS); for (Terms.Bucket resultTypeEntry : aggregation.getBuckets()) { ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto(); dto.setResultTypeCode(resultTypeEntry.getKeyAsString()); dto.setResultTypeDisplayName(resultTypeEntry.getKeyAsString()); dto.setCount(resultTypeEntry.getDocCount()); list.add(dto); } return list; }
public Object copyTo(ObjectLocator locator, Object target, CopyStrategy2 strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof ResultTypeIndexSearchResponseDto) { final ResultTypeIndexSearchResponseDto copy = ((ResultTypeIndexSearchResponseDto) draftCopy); if (resultTypeCodeShouldBeCopiedAndSet == Boolean.TRUE) { String sourceResultTypeCode; sourceResultTypeCode = this.getResultTypeCode(); String copyResultTypeCode = ((String) strategy.copy(LocatorUtils.property(locator, "resultTypeCode", sourceResultTypeCode), sourceResultTypeCode, (this.resultTypeCode!= null))); copy.setResultTypeCode(copyResultTypeCode); } else { if (resultTypeCodeShouldBeCopiedAndSet == Boolean.FALSE) { if (countShouldBeCopiedAndSet == Boolean.TRUE) { long sourceCount; sourceCount = this.getCount(); long copyCount = strategy.copy(LocatorUtils.property(locator, "count", sourceCount), sourceCount, true); copy.setCount(copyCount); } else { if (countShouldBeCopiedAndSet == Boolean.FALSE) { if (resultTypeDisplayNameShouldBeCopiedAndSet == Boolean.TRUE) { String sourceResultTypeDisplayName; sourceResultTypeDisplayName = this.getResultTypeDisplayName(); String copyResultTypeDisplayName = ((String) strategy.copy(LocatorUtils.property(locator, "resultTypeDisplayName", sourceResultTypeDisplayName), sourceResultTypeDisplayName, (this.resultTypeDisplayName!= null))); copy.setResultTypeDisplayName(copyResultTypeDisplayName); } else { if (resultTypeDisplayNameShouldBeCopiedAndSet == Boolean.FALSE) {
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theResultTypeCode; theResultTypeCode = this.getResultTypeCode(); strategy.appendField(locator, this, "resultTypeCode", buffer, theResultTypeCode, (this.resultTypeCode!= null)); } { long theCount; theCount = this.getCount(); strategy.appendField(locator, this, "count", buffer, theCount, true); } { String theResultTypeDisplayName; theResultTypeDisplayName = this.getResultTypeDisplayName(); strategy.appendField(locator, this, "resultTypeDisplayName", buffer, theResultTypeDisplayName, (this.resultTypeDisplayName!= null)); } return buffer; }
String facetId = getSearchIndexType(resultTypeIndexSearchResponseDto.getResultTypeDisplayName(), bdefActiveIndex, tagActiveIndex); Facet resultTypeFacet = new Facet(facetId, resultTypeIndexSearchResponseDto.getCount(), FacetTypeEnum.RESULT_TYPE.value(), facetId, null); resultTypeFacets.add(resultTypeFacet);
public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
/** * Creates result type facet response dto * * @param searchResponse search response * * @return result type facet response dto list */ public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResponse searchResponse) { List<ResultTypeIndexSearchResponseDto> list = new ArrayList<>(); Terms aggregation = getAggregation(searchResponse, RESULT_TYPE_AGGS); for (Terms.Bucket resultTypeEntry : aggregation.getBuckets()) { ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto(); dto.setResultTypeCode(resultTypeEntry.getKeyAsString()); dto.setResultTypeDisplayName(resultTypeEntry.getKeyAsString()); dto.setCount(resultTypeEntry.getDocCount()); list.add(dto); } return list; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theResultTypeCode; theResultTypeCode = this.getResultTypeCode(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "resultTypeCode", theResultTypeCode), currentHashCode, theResultTypeCode, (this.resultTypeCode!= null)); } { long theCount; theCount = this.getCount(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "count", theCount), currentHashCode, theCount, true); } { String theResultTypeDisplayName; theResultTypeDisplayName = this.getResultTypeDisplayName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "resultTypeDisplayName", theResultTypeDisplayName), currentHashCode, theResultTypeDisplayName, (this.resultTypeDisplayName!= null)); } return currentHashCode; }
String facetId = getSearchIndexType(resultTypeIndexSearchResponseDto.getResultTypeDisplayName(), bdefActiveIndex, tagActiveIndex); Facet resultTypeFacet = new Facet(facetId, resultTypeIndexSearchResponseDto.getCount(), FacetTypeEnum.RESULT_TYPE.value(), facetId, null); resultTypeFacets.add(resultTypeFacet);
/** * Creates result type facet response dto * * @param searchResult search result * * @return result type facet response dto list */ public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResult searchResult) { MetricAggregation metricAggregation = searchResult.getAggregations(); TermsAggregation resultTypeAggregation = metricAggregation.getTermsAggregation(RESULT_TYPE_AGGS); List<TermsAggregation.Entry> buckets = resultTypeAggregation.getBuckets(); List<ResultTypeIndexSearchResponseDto> resultTypeIndexSearchResponseDtos = new ArrayList<>(); for (TermsAggregation.Entry entry : buckets) { ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto(); dto.setResultTypeCode(entry.getKeyAsString()); dto.setResultTypeDisplayName(entry.getKeyAsString()); dto.setCount(entry.getCount()); resultTypeIndexSearchResponseDtos.add(dto); } return resultTypeIndexSearchResponseDtos; }
lhsResultTypeCode = this.getResultTypeCode(); String rhsResultTypeCode; rhsResultTypeCode = that.getResultTypeCode(); if (!strategy.equals(LocatorUtils.property(thisLocator, "resultTypeCode", lhsResultTypeCode), LocatorUtils.property(thatLocator, "resultTypeCode", rhsResultTypeCode), lhsResultTypeCode, rhsResultTypeCode, (this.resultTypeCode!= null), (that.resultTypeCode!= null))) { return false; lhsCount = this.getCount(); long rhsCount; rhsCount = that.getCount(); if (!strategy.equals(LocatorUtils.property(thisLocator, "count", lhsCount), LocatorUtils.property(thatLocator, "count", rhsCount), lhsCount, rhsCount, true, true)) { return false; lhsResultTypeDisplayName = this.getResultTypeDisplayName(); String rhsResultTypeDisplayName; rhsResultTypeDisplayName = that.getResultTypeDisplayName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "resultTypeDisplayName", lhsResultTypeDisplayName), LocatorUtils.property(thatLocator, "resultTypeDisplayName", rhsResultTypeDisplayName), lhsResultTypeDisplayName, rhsResultTypeDisplayName, (this.resultTypeDisplayName!= null), (that.resultTypeDisplayName!= null))) { return false;
public Object createNewInstance() { return new ResultTypeIndexSearchResponseDto(); }
public static ResultTypeIndexSearchResponseDto.Builder<Void> copyExcept(final ResultTypeIndexSearchResponseDto _other, final PropertyTree _propertyTree) { return copyOf(_other, _propertyTree, PropertyTreeUse.EXCLUDE); }
/** * Creates result type facet response dto * * @param searchResult search result * * @return result type facet response dto list */ public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResult searchResult) { MetricAggregation metricAggregation = searchResult.getAggregations(); TermsAggregation resultTypeAggregation = metricAggregation.getTermsAggregation(RESULT_TYPE_AGGS); List<TermsAggregation.Entry> buckets = resultTypeAggregation.getBuckets(); List<ResultTypeIndexSearchResponseDto> resultTypeIndexSearchResponseDtos = new ArrayList<>(); for (TermsAggregation.Entry entry : buckets) { ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto(); dto.setResultTypeCode(entry.getKeyAsString()); dto.setResultTypeDisplayName(entry.getKeyAsString()); dto.setCount(entry.getCount()); resultTypeIndexSearchResponseDtos.add(dto); } return resultTypeIndexSearchResponseDtos; }
@Override public ResultTypeIndexSearchResponseDto build() { if (_storedValue == null) { return this.init(new ResultTypeIndexSearchResponseDto()); } else { return ((ResultTypeIndexSearchResponseDto) _storedValue); } }
@Test public void testGetResultTypeIndexSearchResponseDto() { SearchResponse searchResponse = mock(SearchResponse.class); Terms terms = mock(Terms.class); Aggregations aggregations = mock(Aggregations.class); Terms.Bucket bucket = mock(Terms.Bucket.class); List<Terms.Bucket> buckets = Collections.singletonList(bucket); when(searchResponse.getAggregations()).thenReturn(aggregations); when(aggregations.get(RESULT_TYPE_AGGS)).thenReturn(terms); when(terms.getBuckets()).thenReturn(buckets); when(bucket.getKeyAsString()).thenReturn(TAG_CODE); when(bucket.getDocCount()).thenReturn(TAG_COUNT); List<ResultTypeIndexSearchResponseDto> expectedList = new ArrayList<>(); expectedList.add(new ResultTypeIndexSearchResponseDto(TAG_CODE, TAG_COUNT, TAG_CODE)); List<ResultTypeIndexSearchResponseDto> resultList = elasticsearchHelper.getResultTypeIndexSearchResponseDto(searchResponse); assertEquals(expectedList, resultList); }
@Test public void testGetFacetsResponse() { ElasticsearchResponseDto elasticsearchResponseDto = new ElasticsearchResponseDto(); List<TagTypeIndexSearchResponseDto> nestTagTypeIndexSearchResponseDtos = new ArrayList<>(); TagTypeIndexSearchResponseDto tagType1 = new TagTypeIndexSearchResponseDto(TAG_TYPE_CODE, null, TAG_TYPE_DISPLAY_NAME); TagTypeIndexSearchResponseDto tagType2 = new TagTypeIndexSearchResponseDto(TAG_TYPE_CODE_2, Collections.singletonList(new TagIndexSearchResponseDto(TAG_CODE, 1, TAG_CODE_DISPLAY_NAME)), TAG_TYPE_DISPLAY_NAME_2); nestTagTypeIndexSearchResponseDtos.add(tagType1); nestTagTypeIndexSearchResponseDtos.add(tagType2); elasticsearchResponseDto.setNestTagTypeIndexSearchResponseDtos(nestTagTypeIndexSearchResponseDtos); List<ResultTypeIndexSearchResponseDto> resultTypeIndexSearchResponseDtos = new ArrayList<>(); resultTypeIndexSearchResponseDtos.add(new ResultTypeIndexSearchResponseDto(TAG_CODE, TAG_COUNT, TAG_SEARCH_INDEX_NAME)); elasticsearchResponseDto.setResultTypeIndexSearchResponseDtos(resultTypeIndexSearchResponseDtos); List<Facet> facets = elasticsearchHelper.getFacetsResponse(elasticsearchResponseDto, BUSINESS_OBJECT_DEFINITION_SEARCH_INDEX_NAME, TAG_SEARCH_INDEX_NAME); List<Facet> expectedFacets = new ArrayList<>(); expectedFacets.add(new Facet(TAG_TYPE_DISPLAY_NAME, null, FacetTypeEnum.TAG_TYPE.value(), TAG_TYPE_CODE, new ArrayList<>())); List<Facet> tagFacet = new ArrayList<>(); tagFacet.add(new Facet(TAG_CODE_DISPLAY_NAME, 1L, FacetTypeEnum.TAG.value(), TAG_CODE, null)); expectedFacets.add(new Facet(TAG_TYPE_DISPLAY_NAME_2, null, FacetTypeEnum.TAG_TYPE.value(), TAG_TYPE_CODE_2, tagFacet)); expectedFacets.add(new Facet(SearchIndexTypeEntity.SearchIndexTypes.TAG.name(), 120L, FacetTypeEnum.RESULT_TYPE.value(), SearchIndexTypeEntity.SearchIndexTypes.TAG.name(), null)); assertEquals(expectedFacets, facets); }
.singletonList(new TagTypeIndexSearchResponseDto("code", Collections.singletonList(new TagIndexSearchResponseDto("tag1", 1, null)), null)); List<ResultTypeIndexSearchResponseDto> resultTypeIndexSearchResponseDto = Collections.singletonList(new ResultTypeIndexSearchResponseDto("type", 1, null));