Skip to content

Commit 765b4b0

Browse files
benedekiZejnilovic
andauthored
First poc (#1)
First draft of the project * Core functions establishment * Naming conventions * Slick as the first db library to use Co-authored-by: Saša Zejnilović <[email protected]>
1 parent 42a0c3b commit 765b4b0

34 files changed

+1565
-1
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright 2021 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# top-most EditorConfig file
16+
root = true
17+
18+
[*]
19+
charset = utf-8
20+
end_of_line = lf
21+
trim_trailing_whitespace = true
22+
23+
[*.xml]
24+
indent_size = 4
25+
indent_style = space
26+
insert_final_newline = true
27+
28+
[*.{java,scala,js,json,css}]
29+
indent_size = 2
30+
indent_style = space
31+
insert_final_newline = true
32+
max_line_length = 120
33+
34+
[*.md]
35+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Copyright 2021 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
###############################
16+
# Git Line Endings #
17+
###############################
18+
19+
# Set default behaviour to automatically normalize line endings.
20+
* text=auto
21+
22+
# Force the following filetypes to have unix eols, Windows can usually handle it well
23+
*.* text eol=lf
24+
25+
# Force batch scripts to always use CRLF line endings as they in some cases might not work correctly.
26+
# Also if a repo is accessed in Windows via a file share from Linux, the scripts will work too
27+
*.cmd text eol=crlf
28+
*.bat text eol=crlf

.gitignore

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1+
#
2+
# Copyright 2021 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# use glob syntax.
16+
syntax: glob
17+
*.ser
118
*.class
2-
*.log
19+
*~
20+
*.bak
21+
#*.off
22+
*.old
23+
# eclipse conf file
24+
.settings
25+
.classpath
26+
.project
27+
.manager
28+
.scala_dependencies
29+
.scalastyle
30+
31+
# idea
32+
.idea
33+
*.iml
34+
35+
# vs code
36+
.vscode
37+
38+
# building
39+
target
40+
build
41+
null
42+
tmp*
43+
temp*
44+
dist
45+
test-output
46+
build.log
47+
.bsp

build.sbt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2021 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
ThisBuild / name := "fa-db"
17+
ThisBuild / organization := "za.co.absa"
18+
19+
lazy val scala211 = "2.11.12"
20+
lazy val scala212 = "2.12.12"
21+
22+
ThisBuild / scalaVersion := scala211
23+
ThisBuild / crossScalaVersions := Seq(scala211, scala212)
24+
ThisBuild / publish := {}
25+
26+
libraryDependencies ++= List(
27+
28+
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
29+
//"org.tpolecat" %% "skunk-core" % "0.2.0",
30+
// "org.scalikejdbc" %% "scalikejdbc" % "3.4.+",
31+
// "com.h2database" % "h2" % "1.4.+",
32+
// "ch.qos.logback" % "logback-classic" % "1.2.+",
33+
34+
"com.typesafe.slick" %% "slick" % "3.3.3",
35+
"org.slf4j" % "slf4j-nop" % "1.6.4",
36+
"com.typesafe.slick" %% "slick-hikaricp" % "3.3.3",
37+
"org.postgresql" % "postgresql" % "9.4-1206-jdbc42",
38+
//
39+
// "io.github.finagle" %% "finagle-postgres" % "0.13.0",
40+
41+
"org.scalatest" %% "scalatest" % "3.2.9" % Test,
42+
"org.scalamock" %% "scalamock" % "5.1.0" % Test
43+
)
44+
45+
releasePublishArtifactsAction := PgpKeys.publishSigned.value

project/build.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright 2019 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
sbt.version=1.5.5

project/plugins.sbt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
/*
3+
* Copyright 2019 ABSA Group Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
18+
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
19+
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

publish.sbt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2021 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
ThisBuild / organizationName := "ABSA Group Limited"
18+
ThisBuild / organizationHomepage := Some(url("https://www.absa.africa"))
19+
ThisBuild / scmInfo := Some(
20+
ScmInfo(
21+
browseUrl = url("https://github.com/AbsaOSS/fa-db/tree/master"),
22+
connection = "scm:git:git://github.com/AbsaOSS/fa-db.git",
23+
devConnection = "scm:git:ssh://github.com/AbsaOSS/fa-db.git"
24+
)
25+
)
26+
27+
ThisBuild / developers := List(
28+
Developer(
29+
id = "benedeki",
30+
name = "David Benedeki",
31+
email = "[email protected]",
32+
url = url("https://github.com/benedeki")
33+
)
34+
)
35+
36+
ThisBuild / homepage := Some(url("https://github.com/AbsaOSS/fa-DB"))
37+
ThisBuild / description := "DB data access via procedures"
38+
ThisBuild / startYear := Some(2022)
39+
ThisBuild / licenses += "Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")
40+
41+
ThisBuild / pomIncludeRepository := { _ => false }
42+
ThisBuild / publishTo := {
43+
val nexus = "https://oss.sonatype.org/"
44+
if (isSnapshot.value) {
45+
Some("snapshots" at s"${nexus}content/repositories/snapshots")
46+
} else {
47+
Some("releases" at s"${nexus}service/local/staging/deploy/maven2")
48+
}
49+
}
50+
ThisBuild / publishMavenStyle := true
51+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
menasdb = {
2+
connectionPool = "HikariCP" //use HikariCP for our connection pool
3+
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource" //Simple datasource with no connection pooling. The connection pool has already been specified with HikariCP.
4+
properties = {
5+
serverName = "localhost"
6+
portNumber = "5432"
7+
databaseName = "menas_db"
8+
user = "menas"
9+
password = "menas"
10+
}
11+
numThreads = 10
12+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2021 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package za.co.absa.faDB
17+
18+
import scala.concurrent.Future
19+
20+
abstract class DBFunction(schema: DBSchema, functionNameOverride: Option[String] = Some("a")) {
21+
val functionName: String = {
22+
val fn = functionNameOverride.getOrElse(schema.objectNameFromClassName(getClass))
23+
if (schema.schemaName.isEmpty) {
24+
fn
25+
} else {
26+
s"${schema.schemaName}.$fn"
27+
}
28+
}
29+
}
30+
31+
object DBFunction {
32+
abstract class DBSeqFunction[T, R](schema: DBSchema, functionNameOverride: Option[String] = None)
33+
extends DBFunction(schema, functionNameOverride) {
34+
def apply(values: T): Future[Seq[R]]
35+
}
36+
37+
abstract class DBValueFunction[T, R](schema: DBSchema, functionNameOverride: Option[String] = None)
38+
extends DBFunction(schema, functionNameOverride) {
39+
def apply(values: T): Future[R]
40+
}
41+
42+
abstract class DBOptionFunction[T, R](schema: DBSchema, functionNameOverride: Option[String] = None)
43+
extends DBFunction (schema, functionNameOverride) {
44+
def apply(values: T): Future[Option[R]]
45+
}
46+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2021 ABSA Group Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package za.co.absa.faDB
17+
18+
import za.co.absa.faDB.namingConventions.NamingConvention
19+
20+
abstract class DBSchema(val session: DBSession, schemaNameOverride: Option[String] = None)
21+
(implicit namingConvention: NamingConvention) {
22+
23+
def objectNameFromClassName(c: Class[_]): String = {
24+
namingConvention.fromClassNamePerConvention(c)
25+
}
26+
27+
val schemaName: String = schemaNameOverride.getOrElse(objectNameFromClassName(getClass))
28+
29+
}

0 commit comments

Comments
 (0)