Skip to content

Commit eff4f59

Browse files
committed
custom release settings
1 parent 4a6d081 commit eff4f59

34 files changed

+224
-279
lines changed

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ releaseProcess := Seq[ReleaseStep](
9999
inquireVersions, // : ReleaseStep
100100
runClean, // : ReleaseStep
101101
runTest, // : ReleaseStep
102-
releaseStepTask(scalafmt), // : ReleaseStep
103102
setReleaseVersion, // : ReleaseStep
104103
commitReleaseVersion, // : ReleaseStep, performs the initial git checks
105104
tagRelease, // : ReleaseStep

src/main/scala/com/sfxcode/nosql/mongo/Aggregate.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ trait Aggregate extends Field with Filter with Sort {
1111
def compositeProjection(resultFieldName: String, keys: List[String]): Bson =
1212
computed(
1313
resultFieldName,
14-
Map[String, Any]("$concat" -> keys.map(key => Map[String, Any]("$substr" -> List("$" + key, 0, 99999))))
15-
)
14+
Map[String, Any]("$concat" -> keys.map(key => Map[String, Any]("$substr" -> List("$" + key, 0, 99999)))))
1615

1716
def divideProjection(resultFieldName: String, dividendFieldName: String, divisorFieldName: String): Bson =
1817
computed(resultFieldName, Map[String, Any]("$divide" -> List("$" + dividendFieldName, "$" + divisorFieldName)))

src/main/scala/com/sfxcode/nosql/mongo/Field.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ trait Field {
4141
val list = fieldnames.map { name =>
4242
if (name.startsWith("$")) {
4343
name
44-
}
45-
else {
44+
} else {
4645
"$" + name
4746
}
4847
}.toList

src/main/scala/com/sfxcode/nosql/mongo/Filter.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ trait Filter {
3030
def dateInRangeFilter(dateFieldKey: String, dateFrom: Date = null, dateUntil: Date = null): Bson =
3131
if (dateFrom != null && dateUntil != null) {
3232
and(gte(dateFieldKey, dateFrom), lte(dateFieldKey, dateUntil))
33-
}
34-
else if (dateUntil != null) {
33+
} else if (dateUntil != null) {
3534
lte(dateFieldKey, dateUntil)
36-
}
37-
else if (dateFrom != null) {
35+
} else if (dateFrom != null) {
3836
gte(dateFieldKey, dateFrom)
39-
}
40-
else {
37+
} else {
4138
Map()
4239
}
4340

src/main/scala/com/sfxcode/nosql/mongo/GridFSDAO.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
package com.sfxcode.nosql.mongo
22

3-
import com.sfxcode.nosql.mongo.database.{ChangeObserver, CollectionStats, DatabaseProvider}
3+
import com.sfxcode.nosql.mongo.database.{ ChangeObserver, CollectionStats, DatabaseProvider }
44
import com.sfxcode.nosql.mongo.gridfs.Metadata
55
import org.bson.types.ObjectId
66
import org.mongodb.scala.bson.conversions.Bson
7-
import org.mongodb.scala.gridfs.{GridFSBucket, GridFSFile}
7+
import org.mongodb.scala.gridfs.{ GridFSBucket, GridFSFile }
88
import org.mongodb.scala.model.CountOptions
9-
import org.mongodb.scala.{Document, Observable, ReadConcern, ReadPreference, SingleObservable, WriteConcern}
9+
import org.mongodb.scala.{ Document, Observable, ReadConcern, ReadPreference, SingleObservable, WriteConcern }
1010

1111
abstract class GridFSDAO(provider: DatabaseProvider, bucketName: String) extends Metadata(provider, bucketName) {
1212

1313
var bucket: GridFSBucket = {
1414
if (bucketName.contains(DatabaseProvider.CollectionSeparator)) {
1515
val newDatabaseName = bucketName.substring(0, bucketName.indexOf(DatabaseProvider.CollectionSeparator))
16-
val newBucketName = bucketName.substring(bucketName.indexOf(DatabaseProvider.CollectionSeparator) + 1)
16+
val newBucketName = bucketName.substring(bucketName.indexOf(DatabaseProvider.CollectionSeparator) + 1)
1717
GridFSBucket(provider.database(newDatabaseName), newBucketName)
18-
}
19-
else {
18+
} else {
2019
GridFSBucket(provider.database(), bucketName)
2120
}
2221
}

src/main/scala/com/sfxcode/nosql/mongo/MongoDAO.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@ import java.nio.charset.Charset
44

55
import better.files.File
66
import com.sfxcode.nosql.mongo.bson.DocumentHelper
7-
import com.sfxcode.nosql.mongo.database.{ChangeObserver, CollectionStats, DatabaseProvider}
7+
import com.sfxcode.nosql.mongo.database.{ ChangeObserver, CollectionStats, DatabaseProvider }
88
import com.sfxcode.nosql.mongo.operation.Crud
99
import org.bson.json.JsonParseException
10-
import org.mongodb.scala.{BulkWriteResult, Document, MongoCollection, Observable, SingleObservable}
10+
import org.mongodb.scala.{ BulkWriteResult, Document, MongoCollection, Observable, SingleObservable }
1111

1212
import scala.collection.mutable.ArrayBuffer
1313
import scala.reflect.ClassTag
1414

1515
/**
16-
* Created by tom on 20.01.17.
17-
*/
16+
* Created by tom on 20.01.17.
17+
*/
1818
abstract class MongoDAO[A](provider: DatabaseProvider, collectionName: String)(implicit ct: ClassTag[A])
19-
extends Crud[A] {
19+
extends Crud[A] {
2020

2121
val collection: MongoCollection[A] = {
2222
if (collectionName.contains(DatabaseProvider.CollectionSeparator)) {
23-
val newDatabaseName = collectionName.substring(0, collectionName.indexOf(DatabaseProvider.CollectionSeparator))
23+
val newDatabaseName = collectionName.substring(0, collectionName.indexOf(DatabaseProvider.CollectionSeparator))
2424
val newCollectionName = collectionName.substring(collectionName.indexOf(DatabaseProvider.CollectionSeparator) + 1)
2525
provider.database(newDatabaseName).getCollection[A](newCollectionName)
26-
}
27-
else {
26+
} else {
2827
provider.database().getCollection[A](collectionName)
2928
}
3029
}
@@ -49,8 +48,7 @@ abstract class MongoDAO[A](provider: DatabaseProvider, collectionName: String)(i
4948
val iterator = file.lineIterator(Charset.forName("UTF-8"))
5049
iterator.foreach(line => docs.+=(DocumentHelper.documentFromJsonString(line).get))
5150
}
52-
}
53-
catch {
51+
} catch {
5452
case e: JsonParseException =>
5553
logger.error(e.getMessage, e)
5654
}

src/main/scala/com/sfxcode/nosql/mongo/Sort.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sfxcode.nosql.mongo
22

33
import org.bson.conversions.Bson
4-
import org.mongodb.scala.model.Sorts.{ascending, descending, orderBy}
4+
import org.mongodb.scala.model.Sorts.{ ascending, descending, orderBy }
55

66
object Sort extends Sort
77

@@ -10,8 +10,7 @@ trait Sort {
1010
def sortByKey(key: String, sortAscending: Boolean = true): Bson =
1111
if (sortAscending) {
1212
orderBy(ascending(key))
13-
}
14-
else {
13+
} else {
1514
orderBy(descending(key))
1615
}
1716

src/main/scala/com/sfxcode/nosql/mongo/bson/BsonConverter.scala

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sfxcode.nosql.mongo.bson
22

33
import java.math.BigInteger
4-
import java.time.{LocalDate, LocalDateTime, ZoneId}
4+
import java.time.{ LocalDate, LocalDateTime, ZoneId }
55
import java.util.Date
66

77
import org.mongodb.scala.Document
@@ -22,32 +22,31 @@ object BsonConverter {
2222
case option: Option[Any] =>
2323
if (option.isDefined) {
2424
toBson(option.get)
25-
}
26-
else {
25+
} else {
2726
BsonNull()
2827
}
2928
case v: Any if converterPlugin.hasCustomClass(v) =>
3029
converterPlugin.toBson(v)
31-
case b: Boolean => BsonBoolean(b)
32-
case s: String => BsonString(s)
33-
case c: Char => BsonString(c.toString)
30+
case b: Boolean => BsonBoolean(b)
31+
case s: String => BsonString(s)
32+
case c: Char => BsonString(c.toString)
3433
case bytes: Array[Byte] => BsonBinary(bytes)
35-
case r: Regex => BsonRegularExpression(r)
36-
case d: Date => BsonDateTime(d)
34+
case r: Regex => BsonRegularExpression(r)
35+
case d: Date => BsonDateTime(d)
3736
case ld: LocalDate =>
3837
BsonDateTime(Date.from(ld.atStartOfDay(ZoneId.systemDefault()).toInstant))
3938
case ldt: LocalDateTime =>
4039
BsonDateTime(Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant))
41-
case oid: ObjectId => BsonObjectId(oid)
42-
case i: Int => BsonInt32(i)
43-
case l: Long => BsonInt64(l)
44-
case bi: BigInt => BsonInt64(bi.toLong)
45-
case bi: BigInteger => BsonInt64(bi.longValue())
46-
case d: Double => BsonDouble(d)
47-
case f: Float => BsonDouble(f)
48-
case bd: BigDecimal => BsonDecimal128.apply(bd)
40+
case oid: ObjectId => BsonObjectId(oid)
41+
case i: Int => BsonInt32(i)
42+
case l: Long => BsonInt64(l)
43+
case bi: BigInt => BsonInt64(bi.toLong)
44+
case bi: BigInteger => BsonInt64(bi.longValue())
45+
case d: Double => BsonDouble(d)
46+
case f: Float => BsonDouble(f)
47+
case bd: BigDecimal => BsonDecimal128.apply(bd)
4948
case bd: java.math.BigDecimal => BsonDecimal128.apply(bd)
50-
case doc: Document => BsonDocument(doc)
49+
case doc: Document => BsonDocument(doc)
5150
case map: scala.collection.Map[_, _] =>
5251
var doc = Document()
5352
map.keys.foreach { key =>
@@ -77,22 +76,22 @@ object BsonConverter {
7776
def fromBson(value: BsonValue): Any =
7877
value match {
7978

80-
case b: BsonBoolean => b.getValue
81-
case s: BsonString => s.getValue
82-
case bytes: BsonBinary => bytes.getData
79+
case b: BsonBoolean => b.getValue
80+
case s: BsonString => s.getValue
81+
case bytes: BsonBinary => bytes.getData
8382
case r: BsonRegularExpression => r.getPattern
84-
case d: BsonDateTime => new Date(d.getValue)
85-
case d: BsonTimestamp => new Date(d.getTime)
86-
case oid: BsonObjectId => oid.getValue
87-
case i: BsonInt32 => i.getValue
88-
case l: BsonInt64 => l.getValue
89-
case d: BsonDouble => d.doubleValue()
90-
case d: BsonDecimal128 => d.getValue.bigDecimalValue()
91-
case doc: BsonDocument => Document(doc)
83+
case d: BsonDateTime => new Date(d.getValue)
84+
case d: BsonTimestamp => new Date(d.getTime)
85+
case oid: BsonObjectId => oid.getValue
86+
case i: BsonInt32 => i.getValue
87+
case l: BsonInt64 => l.getValue
88+
case d: BsonDouble => d.doubleValue()
89+
case d: BsonDecimal128 => d.getValue.bigDecimalValue()
90+
case doc: BsonDocument => Document(doc)
9291
case array: BsonArray =>
9392
array.getValues.asScala.toList.map(v => fromBson(v))
9493
case n: BsonNull => null
95-
case _ => value
94+
case _ => value
9695
}
9796

9897
def asMap(document: Document): Map[String, Any] = {

src/main/scala/com/sfxcode/nosql/mongo/bson/ConverterPlugin.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ object ClassUtil {
5151
result.+=(name -> value)
5252
}
5353

54-
}
55-
else {
54+
} else {
5655
val fields = classRegistry(clazz)
5756
fields.keys.foreach { name =>
5857
val value = fields(name).get(v)

src/main/scala/com/sfxcode/nosql/mongo/bson/DocumentHelper.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sfxcode.nosql.mongo.bson
22

3-
import better.files.{Scanner, StringSplitter}
3+
import better.files.{ Scanner, StringSplitter }
44
import com.typesafe.scalalogging.LazyLogging
55
import org.mongodb.scala.Document
66

@@ -14,12 +14,11 @@ object DocumentHelper extends LazyLogging {
1414

1515
try {
1616
result = Some(Document(json))
17-
}
18-
catch {
17+
} catch {
1918
case e: Exception if e.getMessage.contains("parse string as a date") => {
2019
logger.debug("parse error - try to replace iso date")
21-
val scanner = Scanner(json, splitter = StringSplitter.on(SplitterDelimeter))
22-
var i = 0
20+
val scanner = Scanner(json, splitter = StringSplitter.on(SplitterDelimeter))
21+
var i = 0
2322
var datePosition = 0
2423
val resultBuffer = new StringBuffer()
2524

@@ -33,12 +32,10 @@ object DocumentHelper extends LazyLogging {
3332
resultBuffer.append(s.substring(0, 27))
3433
resultBuffer.append(":")
3534
resultBuffer.append(s.substring(27))
36-
}
37-
else {
35+
} else {
3836
resultBuffer.append(s)
3937
}
40-
}
41-
else {
38+
} else {
4239
resultBuffer.append(s)
4340
}
4441
resultBuffer.append(SplitterDelimeter)

0 commit comments

Comments
 (0)