Class SchemaHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.solr.schema.SchemaHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
Component providing helper methods to work with search schema and fields.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DOMParser
A DOM parser.protected SourceResolver
The source resolver.protected XPathProcessor
A XPath processor.static final String
The component role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilterListNode
(List<Map<String, Object>> fieldList) Filters the list of field declarations and only keep valid ones.protected org.apache.solr.client.solrj.request.schema.AnalyzerDefinition
getAnalyzer
(Node analyzerNode) Get an analyzer definition from the corresponding DOM node.getAttributes
(Node node) Extract a DOM node attributes as a Map.protected org.apache.solr.client.solrj.request.schema.FieldTypeDefinition
getFieldType
(Node fieldTypeNode) Get a field type definition from the corresponding DOM node.protected List<org.apache.solr.client.solrj.request.schema.FieldTypeDefinition>
getFieldTypes
(NodeList fieldTypeNodes) Get the field type definitions from the corresponding DOM nodes.Extract the list of DOM node attributes.org.apache.solr.client.solrj.response.schema.SchemaRepresentation
Get the schema at the corresponding location (source URI).static String
getSchemaType
(MetadataType metaType) Get the solr schema type from the metadata type.static boolean
isNameValid
(String fieldName) Chekcs that the passed Solr field name is validorg.apache.solr.client.solrj.response.schema.SchemaRepresentation
Read the static schema.void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
_sourceResolver
The source resolver. -
_domParser
A DOM parser. -
_xPathProcessor
A XPath processor.
-
-
Constructor Details
-
SchemaHelper
public SchemaHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getSchemaType
Get the solr schema type from the metadata type.- Parameters:
metaType
- The metadata type.- Returns:
- The solr schema type.
-
isNameValid
Chekcs that the passed Solr field name is valid- Parameters:
fieldName
- the Solr field name- Returns:
- true if name is valid, false otherwise
-
getSchema
Get the schema at the corresponding location (source URI).- Parameters:
location
- The location, as a source URI.- Returns:
- The schema representation.
-
readSchema
public org.apache.solr.client.solrj.response.schema.SchemaRepresentation readSchema(InputStream is) throws IOException, SAXException Read the static schema.- Parameters:
is
- An input stream on the schema XML.- Returns:
- The representation of the schema.
- Throws:
IOException
- If an error occurs reading the stream.SAXException
- If an error occurs parsing the XML.
-
getFieldTypes
protected List<org.apache.solr.client.solrj.request.schema.FieldTypeDefinition> getFieldTypes(NodeList fieldTypeNodes) Get the field type definitions from the corresponding DOM nodes.- Parameters:
fieldTypeNodes
- The field type nodes.- Returns:
- The list of field type definitions.
-
getFieldType
protected org.apache.solr.client.solrj.request.schema.FieldTypeDefinition getFieldType(Node fieldTypeNode) Get a field type definition from the corresponding DOM node.- Parameters:
fieldTypeNode
- The field type DOM node.- Returns:
- The field type definition.
-
getAnalyzer
protected org.apache.solr.client.solrj.request.schema.AnalyzerDefinition getAnalyzer(Node analyzerNode) Get an analyzer definition from the corresponding DOM node.- Parameters:
analyzerNode
- The analyzer node.- Returns:
- The analyzer definition.
-
getAttributes
Extract a DOM node attributes as a Map.- Parameters:
node
- The node.- Returns:
- The attributes as a Map.
-
getList
Extract the list of DOM node attributes.- Parameters:
nodeList
- The node list.- Returns:
- A List of the attribute values as Maps.
-
filterListNode
Filters the list of field declarations and only keep valid ones.- Parameters:
fieldList
- The list of fields to filter- Returns:
- The filtered list
-