generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relational Mapper Packageable Element (#2817)
- Loading branch information
1 parent
6a0065a
commit 936400d
Showing
28 changed files
with
1,330 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,6 @@ public enum PackageableElementType | |
DATASPACE, | ||
DIAGRAM, | ||
FILE_GENERATION, | ||
DATA | ||
DATA, | ||
QUERYPOSTPROCESSOR | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../finos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/DatabaseMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class DatabaseMapper | ||
{ | ||
public String databaseName; | ||
public List<SchemaPtr> schemas = Collections.emptyList(); | ||
} |
36 changes: 36 additions & 0 deletions
36
...inos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/RelationalMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; | ||
import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class RelationalMapper extends PackageableElement | ||
{ | ||
public List<DatabaseMapper> databaseMappers = Collections.emptyList(); | ||
public List<SchemaMapper> schemaMappers = Collections.emptyList(); | ||
public List<TableMapper> tableMappers = Collections.emptyList(); | ||
|
||
@Override | ||
public <T> T accept(PackageableElementVisitor<T> visitor) | ||
{ | ||
return visitor.visit(this); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...rg/finos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/SchemaMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
public class SchemaMapper | ||
{ | ||
public SchemaPtr from; | ||
public String to; | ||
} |
38 changes: 38 additions & 0 deletions
38
...a/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/SchemaPtr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import org.bson.codecs.pojo.annotations.BsonIgnore; | ||
import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; | ||
|
||
public class SchemaPtr | ||
{ | ||
public String _type; | ||
public String schema; | ||
public String database; | ||
public SourceInformation sourceInformation; | ||
|
||
public SchemaPtr() | ||
{ | ||
} | ||
|
||
@JsonIgnore | ||
@BsonIgnore | ||
public String getDb() | ||
{ | ||
return this.database; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...org/finos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/TableMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
public class TableMapper | ||
{ | ||
public TablePtr from; | ||
public String to; | ||
} |
39 changes: 39 additions & 0 deletions
39
...va/org/finos/legend/engine/protocol/pure/v1/model/packageableElement/mapper/TablePtr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapper; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import org.bson.codecs.pojo.annotations.BsonIgnore; | ||
import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; | ||
|
||
public class TablePtr | ||
{ | ||
public String _type; | ||
public String table; | ||
public String schema; | ||
public String database; | ||
public SourceInformation sourceInformation; | ||
|
||
public TablePtr() | ||
{ | ||
} | ||
|
||
@JsonIgnore | ||
@BsonIgnore | ||
public String getDb() | ||
{ | ||
return this.database; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...os/legend/engine/language/pure/grammar/from/antlr4/mapper/RelationalMapperLexerGrammar.g4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
lexer grammar RelationalMapperLexerGrammar; | ||
|
||
import CoreLexerGrammar; | ||
|
||
// -------------------------------------- KEYWORD -------------------------------------- | ||
IMPORT : 'import'; | ||
RELATIONALMAPPER : 'RelationalMapper'; | ||
DATABASEMAPPER : 'DatabaseMappers'; | ||
SCHEMAMAPPER : 'SchemaMappers'; | ||
TABLEMAPPER : 'TableMappers'; | ||
INCLUDE : 'include'; | ||
RELATIONAL_MAPPER : 'relationalMapper'; |
83 changes: 83 additions & 0 deletions
83
...s/legend/engine/language/pure/grammar/from/antlr4/mapper/RelationalMapperParserGrammar.g4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
parser grammar RelationalMapperParserGrammar; | ||
|
||
import CoreParserGrammar; | ||
|
||
options | ||
{ | ||
tokenVocab = RelationalMapperLexerGrammar; | ||
} | ||
|
||
// -------------------------------------- IDENTIFIER -------------------------------------- | ||
|
||
unquotedIdentifier: VALID_STRING | IMPORT | INCLUDE | RELATIONAL_MAPPER | ||
; | ||
identifier: unquotedIdentifier | STRING | ||
; | ||
|
||
|
||
// -------------------------------------- DEFINITION -------------------------------------- | ||
|
||
imports: (importStatement)* | ||
; | ||
importStatement: IMPORT packagePath PATH_SEPARATOR STAR SEMI_COLON | ||
; | ||
definition: imports | ||
(relationalMapper)* | ||
EOF | ||
; | ||
relationalMapper: RELATIONALMAPPER qualifiedName | ||
PAREN_OPEN | ||
(databaseMapperSection)? | ||
(schemaMapperSection)? | ||
(tableMapperSection)? | ||
PAREN_CLOSE | ||
; | ||
databaseMapperSection: DATABASEMAPPER COLON | ||
BRACKET_OPEN | ||
(databaseMapper(COMMA databaseMapper)*)? | ||
BRACKET_CLOSE | ||
SEMI_COLON | ||
; | ||
schemaMapperSection: SCHEMAMAPPER COLON | ||
BRACKET_OPEN | ||
(schemaMapper(COMMA schemaMapper)*)? | ||
BRACKET_CLOSE | ||
SEMI_COLON | ||
; | ||
tableMapperSection: TABLEMAPPER COLON | ||
BRACKET_OPEN | ||
(tableMapper(COMMA tableMapper)*)? | ||
BRACKET_CLOSE | ||
SEMI_COLON | ||
; | ||
include: INCLUDE qualifiedName | ||
; | ||
|
||
|
||
// -------------------------------------- DATABASE MAPPERS -------------------------------------- | ||
|
||
databaseMapper: BRACKET_OPEN | ||
(schemaReference (COMMA schemaReference)*)? | ||
BRACKET_CLOSE ARROW STRING | ||
|
||
; | ||
schemaReference: database DOT schema | ||
; | ||
database: qualifiedName | ||
; | ||
schema: identifier | ||
; | ||
|
||
// -------------------------------------- SCHEMA MAPPERS -------------------------------------- | ||
|
||
schemaMapper: schemaReference ARROW STRING | ||
; | ||
|
||
// -------------------------------------- TABLE MAPPERS -------------------------------------- | ||
|
||
tableReference: database DOT schema DOT table | ||
; | ||
tableMapper: tableReference ARROW STRING | ||
; | ||
table: identifier | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.