Package org.sqlproc.engine.impl
Class SqlProcessor
java.lang.Object
org.sqlproc.engine.impl.SqlProcessor
Pre-compiled META SQL statements, output mappings and optional features (also known as the SQL Processor artifacts).
Instance of this class is created by the ANTLR parser. The grammar is defined in SqlProcessor.g.
- Author:
- Vladimir Hudec
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The mapping rule type.(package private) static enum
This status is the result of the filters processing, based on the next rules:
in the case there are no filters
- there are activeFilters, the artifact is dead - NOK
- otherwise the artifact is ok - OK
in the case there are filters
- there are no activeFilters, the artifact is ok, but lower priority - OK_LOWER
- there are activeFilters, and the intersection is not empty, the artifact is ok - OK
- there are activeFilters, and the intersection is empty, the artifact is dead - NOKstatic enum
The mapping rule type.static enum
The META SQL statement type. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe collection of all artifacts to enable duplicity control.The collection of the SQL Processor default optional features.The list of all errors.The collection of the SQL Processor optional features.private static final String
private static final String
private static final int
private static final int
protected static org.slf4j.Logger
The internal slf4j logger.private static final int
private Pattern
Pattern for MOPT(package private) Map
<String, Map<String, SqlMappingRule>> The collection of the output value mappings.(package private) Map
<String, Map<String, SqlMetaStatement>> The collection of the META SQL statements.Only statements and rules with the names in this set are picked up from the statements' repository.private static final String
The collection of the SQL Processor optional features in the statement context.The collection of the SQL Processor optional features to be cleared in the statement context.The list of all warnings. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addFeature
(String type, String name, String feature, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new optional feature.boolean
addMappingRule
(String type, String name, String raw, SqlMappingRule mapping, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new output value mapping.(package private) boolean
addMetaStatement
(String type, String name, String raw, SqlMetaStatement statement, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new META SQL statement.protected void
addWarnings
(List<ErrorMsg> errors) Adds all parsing errors as warnings.protected boolean
duplicityControl
(String type, String name, List<String> activeFilters) Controls if the name of the artifact isn't already used.filterActiveFilters
(List<String> activeFilters) Filter the active filters removing all values, which contain the character '='protected SqlProcessor.FilterStatus
filtersControl
(String[] filters, List<String> activeFilters) Runs the business logic for the filters related to the artifact usability.Returns the list of error, which can happen in the process of this instance creation and ALTLR parsingprotected Object
getFeature
(String type, String feature) Builds the correct class instance for the optional featureReturns the collection of the SQL Processor optional features.static SqlProcessor
getInstance
(StringBuilder sbStatements, SqlTypeFactory typeFactory, Map<String, Object> defaultFeatures, Set<String> onlyStatements, String... filters) Simple factory method (design pattern).static SqlProcessor
getLazyInstance
(StringBuilder sbStatements, SqlTypeFactory typeFactory, Map<String, Object> defaultFeatures, Set<String> onlyStatements, String... filters) Simple factory method (design pattern).getMappingRules
(String type) Returns the collection of the output value mappings.Returns the collection of the output value mappings.getMetaStatements
(String type) Returns the collection of the META SQL statements.Returns the collection of the META SQL statements.Returns the collection of the SQL Processor optional features in the statement context.Returns the collection of the SQL Processor optional features to be cleared in the statement context.Returns the list of warnings, which can happen in the process of this instance creation and ALTLR parsingprivate void
loadStatementFeatures
(String name, List<String> activeFilters) Some filters can be the optional features in the statement context.protected boolean
nameControl
(Set<String> onlyStatements, String name) Controls, if the artifact name is listed in the provided containerprotected String
uniqueArtifactName
(String type, String name, List<String> activeFilters) Builds the unique artifact name.
-
Field Details
-
logger
protected static org.slf4j.Logger loggerThe internal slf4j logger. -
mapPattern
Pattern for MOPT -
metaStatements
Map<String,Map<String, metaStatementsSqlMetaStatement>> The collection of the META SQL statements. -
mappingRules
Map<String,Map<String, mappingRulesSqlMappingRule>> The collection of the output value mappings. -
features
The collection of the SQL Processor optional features. -
statementsFeatures
The collection of the SQL Processor optional features in the statement context. -
statementsFeaturesUnset
The collection of the SQL Processor optional features to be cleared in the statement context. -
defaultFeatures
The collection of the SQL Processor default optional features. -
onlyStatements
Only statements and rules with the names in this set are picked up from the statements' repository. -
allArtifactsNames
The collection of all artifacts to enable duplicity control. -
warnings
The list of all warnings. -
errors
The list of all errors. -
IDGEN
-
lIDGEN
private static final int lIDGEN -
SEQ
-
lSEQ
private static final int lSEQ -
IDSEL
-
lIDSEL
private static final int lIDSEL
-
-
Constructor Details
-
SqlProcessor
Creates a new instance.
-
-
Method Details
-
getInstance
public static SqlProcessor getInstance(StringBuilder sbStatements, SqlTypeFactory typeFactory, Map<String, Object> defaultFeatures, Set<String> onlyStatements, String... filters) throws SqlEngineExceptionSimple factory method (design pattern). The new instance is created from the String input by the ANTLR parser.- Parameters:
sbStatements
- String representation of the META SQL queries/statements/output mappingstypeFactory
- the factory for the META types constructiondefaultFeatures
- the default features based onSqlFeature
onlyStatements
- only the statements and rules with the names in this set are picked up from the statements' repositoryfilters
- only the artifacts without active filters and the artifacts with the active filter from this collections are picked up from the statements' repository- Returns:
- new container of pre-compiled META SQL queries/statements/output mappings
- Throws:
SqlEngineException
- in the case of ANTLR parsing exception
-
getLazyInstance
public static SqlProcessor getLazyInstance(StringBuilder sbStatements, SqlTypeFactory typeFactory, Map<String, Object> defaultFeatures, Set<String> onlyStatements, String... filters) throws SqlEngineExceptionSimple factory method (design pattern). The new instance is created from the String input by the ANTLR parser.- Parameters:
sbStatements
- String representation of the META SQL queries/statements/output mappingstypeFactory
- the factory for the META types constructiondefaultFeatures
- the default features based onSqlFeature
onlyStatements
- only the statements and rules with the names in this set are picked up from the statements' repositoryfilters
- only the artifacts without active filters and the artifacts with the active filter from this collections are picked up from the statements' repository- Returns:
- new container of raw (not pre-compiled) META SQL queries/statements/output mappings
- Throws:
SqlEngineException
- in the case of ANTLR parsing exception
-
getMetaStatements
Returns the collection of the META SQL statements.- Parameters:
type
- the META SQL statement type- Returns:
- the collection of the META SQL statements
-
getMetaStatements
Returns the collection of the META SQL statements.- Parameters:
type
- the String representation of the META SQL statement type- Returns:
- the collection of the META SQL statements
-
addMetaStatement
boolean addMetaStatement(String type, String name, String raw, SqlMetaStatement statement, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new META SQL statement. It's used internally by the ANTLR parser.- Parameters:
type
- the String representation of the META SQL statement typename
- the name of the META SQL statementraw
- the raw (not pre-compiled) representation of the META SQL statementstatement
- the META SQL statementerrors
- the list of potential errors created during the ANTLR based parsingactiveFilters
- the active filters from the META SQL statement definitionfilters
- only the artifacts without active filters and the artifacts with the active filter from this collections are taken into this instance of the SQL Processor- Returns:
- the indicator this statement was taken into this instance of the SQL Processor
-
getMappingRules
Returns the collection of the output value mappings.- Parameters:
type
- the input/output mapping rule type- Returns:
- the collection of the output value mappings
-
getMappingRules
Returns the collection of the output value mappings.- Parameters:
type
- the String representation of the input/output mapping rule type- Returns:
- the collection of the output value mappings
-
addMappingRule
public boolean addMappingRule(String type, String name, String raw, SqlMappingRule mapping, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new output value mapping. It's used internally by the ANTLR parser.- Parameters:
type
- the String representation of the output value mapping typename
- the name of the output value mappingraw
- the raw (not pre-compiled) representation of the output value mappingmapping
- the output value mappingerrors
- the list of potential errors created during the ANTLR based parsingactiveFilters
- the active filters from the output value mapping definitionfilters
- only the artifacts without active filters and the artifacts with the active filter from this collections are taken into this instance of the SQL Processor- Returns:
- the indicator this output value mapping was taken into this instance of the SQL Processor
-
getFeatures
Returns the collection of the SQL Processor optional features.- Returns:
- the collection of the SQL Processor optional features
-
getStatementsFeatures
Returns the collection of the SQL Processor optional features in the statement context.- Returns:
- the collection of the SQL Processor optional features in the statement context
-
getStatementsFeaturesUnset
Returns the collection of the SQL Processor optional features to be cleared in the statement context.- Returns:
- the collection of the SQL Processor optional features to be cleared in the statement context
-
getFeature
Builds the correct class instance for the optional feature- Parameters:
type
- the type of the optional feature based on enumarationSqlProcessor.FeatureType
feature
- the String representation of the optional feature- Returns:
- the correct class instance for the optional feature
-
addFeature
public boolean addFeature(String type, String name, String feature, List<ErrorMsg> errors, List<String> activeFilters, String... filters) Adds a new optional feature. It's used internally by the ANTLR parser.- Parameters:
type
- the String representation of the optional feature typename
- the name of the optional featurefeature
- the optional featureerrors
- the list of potential errors created during the ANTLR based parsingactiveFilters
- the active filters from the optional feature definitionfilters
- only the artifacts without active filters and the artifacts with the active filter from this collections are taken into this instance of the SQL Processor- Returns:
- the indicator this optional feature was taken into this instance of the SQL Processor
-
duplicityControl
Controls if the name of the artifact isn't already used.- Parameters:
type
- the String representation of the artifact typename
- the name of the artifactactiveFilters
- the active filters from the artifact definition- Returns:
- the indicator of the potential duplicity
-
uniqueArtifactName
Builds the unique artifact name.- Parameters:
type
- the String representation of the artifact typename
- the name of the artifactactiveFilters
- the active filters from the artifact definition- Returns:
- the unique artifact name
-
addWarnings
Adds all parsing errors as warnings.- Parameters:
errors
- the list of potential errors created during the ANTLR based parsing
-
getWarnings
Returns the list of warnings, which can happen in the process of this instance creation and ALTLR parsing- Returns:
- the list of warnings
-
getErrors
Returns the list of error, which can happen in the process of this instance creation and ALTLR parsing- Returns:
- the list of errors
-
filtersControl
Runs the business logic for the filters related to the artifact usability.- Parameters:
filters
- only the artifacts without active filters and the artifacts with the active filter from this collections are taken into this instance of the SQL ProcessoractiveFilters
- the active filters from the artifact definition- Returns:
- the status, which control the artifact usability
-
nameControl
Controls, if the artifact name is listed in the provided container- Parameters:
onlyStatements
- only the statements and rules with the names in this set are picked up from the statements' repositoryname
- the artifact name- Returns:
- the indicator if the artifact name is listed in the provided container
-
filterActiveFilters
Filter the active filters removing all values, which contain the character '='- Parameters:
activeFilters
- the active filters from the artifact definition- Returns:
- filtered active filters
-
loadStatementFeatures
Some filters can be the optional features in the statement context.- Parameters:
name
- the name of the META SQL statementactiveFilters
- the active filters from the META SQL statement definition
-