mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-4953 Add builder to TAS highlight POJO. (#2214)
* ACS-4953 Add builder to TAS highlight POJO. Also rename ResponseHighLightModel to ResponseHighlightModel.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
@@ -52,11 +53,11 @@ import org.alfresco.utility.model.TestModel;
|
||||
* @author Michael Suzuki
|
||||
*
|
||||
*/
|
||||
public class ResponseHighLightModel extends TestModel implements IRestModel<ResponseHighLightModel>
|
||||
public class ResponseHighlightModel extends TestModel implements IRestModel<ResponseHighlightModel>
|
||||
{
|
||||
private ResponseHighLightModel model;
|
||||
private ResponseHighlightModel model;
|
||||
private String field;
|
||||
private List<Object> snippets;
|
||||
private List<String> snippets;
|
||||
|
||||
public String getField()
|
||||
{
|
||||
@@ -66,19 +67,44 @@ public class ResponseHighLightModel extends TestModel implements IRestModel<Resp
|
||||
{
|
||||
this.field = field;
|
||||
}
|
||||
public List<Object> getSnippets()
|
||||
public List<String> getSnippets()
|
||||
{
|
||||
return snippets;
|
||||
}
|
||||
public void setSnippets(List<Object> snippets)
|
||||
public void setSnippets(List<String> snippets)
|
||||
{
|
||||
this.snippets = snippets;
|
||||
}
|
||||
@Override
|
||||
public ResponseHighLightModel onModel()
|
||||
public ResponseHighlightModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ResponseHighlightModel that = (ResponseHighlightModel) o;
|
||||
return Objects.equals(model, that.model) && Objects.equals(field, that.field) && Objects.equals(snippets, that.snippets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(model, field, snippets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "ResponseHighlightModel{model=%s, field=%s, snippets=%s}".formatted(model, field, snippets);
|
||||
}
|
||||
}
|
@@ -2,23 +2,23 @@
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
@@ -33,62 +33,38 @@ import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Generated by 'msuzuki' on '2017-02-23 13:41' from 'Alfresco Search REST API' swagger file
|
||||
* Generated by 'msuzuki' on '2017-02-23 13:41' from 'Alfresco Search REST API' swagger file
|
||||
* Generated from 'Alfresco Search REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1}
|
||||
*/
|
||||
public class RestRequestHighlightModel extends TestModel implements IRestModel<RestRequestHighlightModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
@JsonProperty("entry")
|
||||
RestRequestHighlightModel model;
|
||||
|
||||
/** The string used to mark the start of a highlight in a fragment. */
|
||||
private String prefix;
|
||||
/** The string used to mark the end of a highlight in a fragment. */
|
||||
private String postfix;
|
||||
/** The maximum number of distinct highlight snippets to return for each highlight field. */
|
||||
private int snippetCount;
|
||||
/** The character length of each snippet. */
|
||||
private int fragmentSize;
|
||||
/** The number of characters to be considered for highlighting. Matches after this count will not be shown. */
|
||||
private int maxAnalyzedChars;
|
||||
/** If fragments overlap they can be merged into one larger fragment */
|
||||
private boolean mergeContiguous;
|
||||
/** Should phrases be identified. */
|
||||
private boolean usePhraseHighlighter;
|
||||
/** The fields to highlight and field specific configuration properties for each field */
|
||||
private List<RestRequestFieldsModel> fields;
|
||||
|
||||
@Override
|
||||
public RestRequestHighlightModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
The string used to mark the start of a highlight in a fragment.
|
||||
*/
|
||||
|
||||
private String prefix;
|
||||
/**
|
||||
The string used to mark the end of a highlight in a fragment.
|
||||
*/
|
||||
|
||||
private String postfix;
|
||||
/**
|
||||
The maximum number of distinct highlight snippets to return for each highlight field.
|
||||
*/
|
||||
|
||||
private int snippetCount;
|
||||
/**
|
||||
The character length of each snippet.
|
||||
*/
|
||||
|
||||
private int fragmentSize;
|
||||
/**
|
||||
The number of characters to be considered for highlighting. Matches after this count will not be shown.
|
||||
*/
|
||||
|
||||
private int maxAnalyzedChars;
|
||||
/**
|
||||
If fragments over lap they can be merged into one larger fragment
|
||||
*/
|
||||
|
||||
private boolean mergeContiguous;
|
||||
/**
|
||||
Should phrases be identified.
|
||||
*/
|
||||
|
||||
private boolean usePhraseHighlighter;
|
||||
/**
|
||||
The fields to highlight and field specific configuration properties for each field
|
||||
*/
|
||||
|
||||
private List<RestRequestFieldsModel> fields;
|
||||
|
||||
public String getPrefix()
|
||||
{
|
||||
return this.prefix;
|
||||
@@ -97,7 +73,7 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setPrefix(String prefix)
|
||||
{
|
||||
this.prefix = prefix;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPostfix()
|
||||
{
|
||||
@@ -107,7 +83,7 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setPostfix(String postfix)
|
||||
{
|
||||
this.postfix = postfix;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSnippetCount()
|
||||
{
|
||||
@@ -117,7 +93,7 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setSnippetCount(int snippetCount)
|
||||
{
|
||||
this.snippetCount = snippetCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFragmentSize()
|
||||
{
|
||||
@@ -127,7 +103,7 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setFragmentSize(int fragmentSize)
|
||||
{
|
||||
this.fragmentSize = fragmentSize;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxAnalyzedChars()
|
||||
{
|
||||
@@ -137,9 +113,9 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setMaxAnalyzedChars(int maxAnalyzedChars)
|
||||
{
|
||||
this.maxAnalyzedChars = maxAnalyzedChars;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getMergeContiguous()
|
||||
public boolean isMergeContiguous()
|
||||
{
|
||||
return this.mergeContiguous;
|
||||
}
|
||||
@@ -147,9 +123,9 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setMergeContiguous(boolean mergeContiguous)
|
||||
{
|
||||
this.mergeContiguous = mergeContiguous;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getUsePhraseHighlighter()
|
||||
public boolean isUsePhraseHighlighter()
|
||||
{
|
||||
return this.usePhraseHighlighter;
|
||||
}
|
||||
@@ -157,7 +133,7 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setUsePhraseHighlighter(boolean usePhraseHighlighter)
|
||||
{
|
||||
this.usePhraseHighlighter = usePhraseHighlighter;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RestRequestFieldsModel> getFields()
|
||||
{
|
||||
@@ -167,6 +143,85 @@ public class RestRequestHighlightModel extends TestModel implements IRestModel<R
|
||||
public void setFields(List<RestRequestFieldsModel> fields)
|
||||
{
|
||||
this.fields = fields;
|
||||
}
|
||||
}
|
||||
|
||||
public static RestRequestHighlightModelBuilder builder()
|
||||
{
|
||||
return new RestRequestHighlightModelBuilder();
|
||||
}
|
||||
|
||||
public static class RestRequestHighlightModelBuilder
|
||||
{
|
||||
private String prefix;
|
||||
private String postfix;
|
||||
private int snippetCount;
|
||||
private int fragmentSize;
|
||||
private int maxAnalyzedChars;
|
||||
private boolean mergeContiguous;
|
||||
private boolean usePhraseHighlighter;
|
||||
private List<RestRequestFieldsModel> fields;
|
||||
|
||||
public RestRequestHighlightModelBuilder prefix(String prefix)
|
||||
{
|
||||
this.prefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder postfix(String postfix)
|
||||
{
|
||||
this.postfix = postfix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder snippetCount(int snippetCount)
|
||||
{
|
||||
this.snippetCount = snippetCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder fragmentSize(int fragmentSize)
|
||||
{
|
||||
this.fragmentSize = fragmentSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder maxAnalyzedChars(int maxAnalyzedChars)
|
||||
{
|
||||
this.maxAnalyzedChars = maxAnalyzedChars;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder mergeContinuous(boolean mergeContiguous)
|
||||
{
|
||||
this.mergeContiguous = mergeContiguous;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder usePhraseHighlighter(boolean usePhraseHighlighter)
|
||||
{
|
||||
this.usePhraseHighlighter = usePhraseHighlighter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModelBuilder fields(List<String> fields)
|
||||
{
|
||||
this.fields = fields.stream().map(field -> new RestRequestFieldsModel(field)).toList();
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestRequestHighlightModel build()
|
||||
{
|
||||
RestRequestHighlightModel highlightModel = new RestRequestHighlightModel();
|
||||
highlightModel.setPrefix(prefix);
|
||||
highlightModel.setPostfix(postfix);
|
||||
highlightModel.setSnippetCount(snippetCount);
|
||||
highlightModel.setFragmentSize(fragmentSize);
|
||||
highlightModel.setMaxAnalyzedChars(maxAnalyzedChars);
|
||||
highlightModel.setMergeContiguous(mergeContiguous);
|
||||
highlightModel.setUsePhraseHighlighter(usePhraseHighlighter);
|
||||
highlightModel.setFields(fields);
|
||||
return highlightModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public class SearchScoreModel extends TestModel implements IRestModel<SearchScor
|
||||
@JsonProperty(required = true)
|
||||
private float score;
|
||||
|
||||
private List<ResponseHighLightModel> highlight;
|
||||
private List<ResponseHighlightModel> highlight;
|
||||
|
||||
public float getScore()
|
||||
{
|
||||
@@ -78,12 +78,12 @@ public class SearchScoreModel extends TestModel implements IRestModel<SearchScor
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ResponseHighLightModel> getHighlight()
|
||||
public List<ResponseHighlightModel> getHighlight()
|
||||
{
|
||||
return highlight;
|
||||
}
|
||||
|
||||
public void setHighlight(List<ResponseHighLightModel> highlight)
|
||||
public void setHighlight(List<ResponseHighlightModel> highlight)
|
||||
{
|
||||
this.highlight = highlight;
|
||||
}
|
||||
|
Reference in New Issue
Block a user