Skip to content

Commit

Permalink
Updated mongo deprecations to 3.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
eltimn committed Nov 28, 2020
1 parent 074f352 commit d88be68
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 85 deletions.
Expand Up @@ -45,16 +45,16 @@ trait BsonRecord[MyType <: BsonRecord[MyType]] extends Record[MyType] {
/**
* Encode a record instance into a DBObject
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def asDBObject: DBObject = meta.asDBObject(this)

@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def asDocument: Document = meta.asDocument(this)

/**
* Set the fields of this record from the given DBObject
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def setFieldsFromDBObject(dbo: DBObject): Unit = meta.setFieldsFromDBObject(this, dbo)

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ trait BsonMetaRecord[BaseRecord <: BsonRecord[BaseRecord]] extends MetaRecord[Ba
* - MongoFieldFlavor types (List) are converted to DBObjects
* using asDBObject
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def asDBObject(inst: BaseRecord): DBObject = {
val dbo = BasicDBObjectBuilder.start // use this so regex patterns can be stored.

Expand All @@ -135,7 +135,7 @@ trait BsonMetaRecord[BaseRecord <: BsonRecord[BaseRecord]] extends MetaRecord[Ba
dbo.get
}

@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def asDocument(inst: BaseRecord): Document = {
val dbo = new Document()

Expand All @@ -150,7 +150,7 @@ trait BsonMetaRecord[BaseRecord <: BsonRecord[BaseRecord]] extends MetaRecord[Ba
/**
* Return the value of a field suitable to be put in a DBObject
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def fieldDbValue(f: Field[_, BaseRecord]): Box[Any] = {
import Meta.Reflection._
import field.MongoFieldFlavor
Expand Down Expand Up @@ -185,7 +185,7 @@ trait BsonMetaRecord[BaseRecord <: BsonRecord[BaseRecord]] extends MetaRecord[Ba
* @param dbo - the DBObject
* @return Box[BaseRecord]
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def fromDBObject(dbo: DBObject): BaseRecord = {
val inst: BaseRecord = createRecord
setFieldsFromDBObject(inst, dbo)
Expand All @@ -200,7 +200,7 @@ trait BsonMetaRecord[BaseRecord <: BsonRecord[BaseRecord]] extends MetaRecord[Ba
* @param dbo - The DBObject
* @return Unit
*/
@deprecated("RecordCodec is now used instead.", "3.4.2")
@deprecated("RecordCodec is now used instead.", "3.4.3")
def setFieldsFromDBObject(inst: BaseRecord, dbo: DBObject): Unit = {
for (k <- dbo.keySet.asScala; field <- inst.fieldByName(k.toString)) {
field.setFromAny(dbo.get(k.toString))
Expand Down
Expand Up @@ -68,7 +68,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
case x => x
}

@deprecated("Use useCollection instead", "3.4.2")
@deprecated("Use useCollection instead", "3.4.3")
def useColl[T](f: DBCollection => T): T =
MongoDB.useCollection(connectionIdentifier, collectionName)(f)

Expand Down Expand Up @@ -98,10 +98,10 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
}
}

@deprecated("Use useDatabase instead", "3.4.2")
@deprecated("Use useDatabase instead", "3.4.3")
def useDb[T](f: DB => T): T = MongoDB.use(connectionIdentifier)(f)

@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.2")
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.3")
def useCollAsync[T](f: com.mongodb.async.client.MongoCollection[Document] => T): T = {
MongoAsync.useCollection[T](connectionIdentifier, collectionName)(f)
}
Expand Down Expand Up @@ -286,7 +286,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]

def findAll(ids: List[ObjectId]): List[BaseRecord] = findAllByList[ObjectId](ids)

@deprecated("Use saveOperation instead", "3.4.2")
@deprecated("Use saveOperation instead", "3.4.3")
protected def saveOp[T](inst: BaseRecord)(f: => T): Boolean = {
foreachCallback(inst, _.beforeSave)
f
Expand Down Expand Up @@ -334,7 +334,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
insts.foreach(inst => foreachCallback(inst, _.afterSave))
}

@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.2")
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.3")
def insertAsync(inst: BaseRecord): Future[Boolean] = {
useCollAsync { coll =>
val cb = new SingleBooleanVoidCallback( () => {
Expand Down Expand Up @@ -365,7 +365,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
* in similar way as save() from sync api.
*
*/
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.2")
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.3")
def replaceOneAsync(inst: BaseRecord, upsert: Boolean = true, concern: WriteConcern = MongoRules.defaultWriteConcern.vend): Future[BaseRecord] = {
useCollAsync { coll =>
val p = Promise[BaseRecord]
Expand Down Expand Up @@ -395,7 +395,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Save the instance in the appropriate backing store
*/
@deprecated("Set WriteConcern in MongoClientOptions or on this MongoMetaRecord", "3.4.2")
@deprecated("Set WriteConcern in MongoClientOptions or on this MongoMetaRecord", "3.4.3")
def save(inst: BaseRecord, concern: WriteConcern): Boolean = saveOp(inst) {
useColl { coll =>
coll.save(inst.asDBObject, concern)
Expand All @@ -405,23 +405,23 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Save a document to the db using the given Mongo instance
*/
@deprecated("Set WriteConcern in MongoClientOptions or on this MongoMetaRecord", "3.4.2")
@deprecated("Set WriteConcern in MongoClientOptions or on this MongoMetaRecord", "3.4.3")
def save(inst: BaseRecord, db: DB, concern: WriteConcern): Boolean = saveOp(inst) {
db.getCollection(collectionName).save(inst.asDBObject, concern)
}

/**
* Update records with a JObject query using the given Mongo instance
*/
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.3")
def update(qry: JObject, newbr: BaseRecord, db: DB, opts: UpdateOption*): Unit = {
update(JObjectParser.parse(qry), newbr.asDBObject, db, opts :_*)
}

/**
* Update records with a JObject query
*/
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.3")
def update(qry: JObject, newbr: BaseRecord, opts: UpdateOption*): Unit = {
useDb ( db =>
update(qry, newbr, db, opts :_*)
Expand All @@ -431,7 +431,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Upsert records with a DBObject query
*/
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.3")
def upsert(query: DBObject, update: DBObject): Unit = {
useColl( coll =>
coll.update(query, update, true, false)
Expand All @@ -441,7 +441,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Update one record with a DBObject query
*/
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, updateMany, or replaceOne instead", "3.4.3")
def update(query: DBObject, update: DBObject): Unit = {
useColl( coll =>
coll.update(query, update)
Expand All @@ -451,7 +451,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Update multiple records with a DBObject query
*/
@deprecated("Use updateMany instead", "3.4.2")
@deprecated("Use updateMany instead", "3.4.3")
def updateMulti(query: DBObject, update: DBObject): Unit = {
useColl( coll =>
coll.updateMulti(query, update)
Expand All @@ -461,7 +461,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
/**
* Update a record with a DBObject query
*/
@deprecated("Use updateOne, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, or replaceOne instead", "3.4.3")
def update(obj: BaseRecord, update: DBObject): Unit = {
val query = (BasicDBObjectBuilder.start
.add("_id", idValue(obj))
Expand All @@ -481,7 +481,7 @@ trait MongoMetaRecord[BaseRecord <: MongoRecord[BaseRecord]]
*
* Note: PatternField will always set the dirty flag when set.
*/
@deprecated("Use updateOne, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, or replaceOne instead", "3.4.3")
def update(inst: BaseRecord): Unit = updateOp(inst) {
val dirtyFields = fields(inst).filter(_.dirty_?)
if (dirtyFields.length > 0) {
Expand Down
Expand Up @@ -47,7 +47,7 @@ trait MongoRecord[MyType <: MongoRecord[MyType]] extends BsonRecord[MyType] {
/**
* Save the instance and return the instance
*/
@deprecated("Set WriteConcern in MongoClientOptions or on the MongoMetaRecord", "3.4.2")
@deprecated("Set WriteConcern in MongoClientOptions or on the MongoMetaRecord", "3.4.3")
def save(concern: WriteConcern): MyType = {
runSafe {
meta.save(this, concern)
Expand All @@ -58,7 +58,7 @@ trait MongoRecord[MyType <: MongoRecord[MyType]] extends BsonRecord[MyType] {
/**
* Inserts record and returns Future that completes when mongo driver finishes operation
*/
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.2")
@deprecated("No longer supported. This will be removed in Lift 4.", "3.4.3")
def insertAsync():Future[Boolean] = {
runSafe {
meta.insertAsync(this)
Expand All @@ -74,7 +74,7 @@ trait MongoRecord[MyType <: MongoRecord[MyType]] extends BsonRecord[MyType] {
* Save the instance and return the instance
* @param safe - if true will use WriteConcern ACKNOWLEDGED else UNACKNOWLEDGED
*/
@deprecated("Set WriteConcern in MongoClientOptions or on the MongoMetaRecord", "3.4.2")
@deprecated("Set WriteConcern in MongoClientOptions or on the MongoMetaRecord", "3.4.3")
def save(safe: Boolean = true): MyType = {
save(if (safe) WriteConcern.ACKNOWLEDGED else WriteConcern.UNACKNOWLEDGED)
}
Expand All @@ -99,7 +99,7 @@ trait MongoRecord[MyType <: MongoRecord[MyType]] extends BsonRecord[MyType] {
/**
* Update only the dirty fields
*/
@deprecated("Use updateOne, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, or replaceOne instead", "3.4.3")
def update: MyType = {
runSafe {
meta.update(this)
Expand All @@ -110,7 +110,7 @@ trait MongoRecord[MyType <: MongoRecord[MyType]] extends BsonRecord[MyType] {
/**
* Try to update only the dirty fields
*/
@deprecated("Use updateOne, or replaceOne instead", "3.4.2")
@deprecated("Use updateOne, or replaceOne instead", "3.4.3")
def updateBox: Box[MyType] = tryo {
runSafe {
meta.update(this)
Expand Down
Expand Up @@ -132,14 +132,14 @@ class BsonRecordListField[OwnerType <: BsonRecord[OwnerType], SubRecordType <: B

override def validations = ((elems: ValueType) => elems.flatMap(_.validate)) :: super.validations

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def asDBObject: DBObject = {
val dbl = new BasicDBList
value.foreach { v => dbl.add(v.asDBObject) }
dbl
}

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def setFromDBObject(dbo: DBObject): Box[List[SubRecordType]] = {
setBox(Full(dbo.keySet.asScala.toList.map { k =>
valueMeta.fromDBObject(dbo.get(k).asInstanceOf[DBObject])
Expand All @@ -156,7 +156,7 @@ class BsonRecordListField[OwnerType <: BsonRecord[OwnerType], SubRecordType <: B
case other => setBox(FieldHelpers.expectedA("JArray", other))
}

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def setFromDocumentList(list: java.util.List[Document]): Box[List[SubRecordType]] = {
setBox(Full(
list.asScala.toList.map { valueMeta.fromDocument }
Expand Down
Expand Up @@ -32,7 +32,7 @@ import org.bson.types.ObjectId
/*
* Field for storing a DBRef
*/
@deprecated("DBref is being removed. See 'MongoRef' for an alternative", "3.4.2")
@deprecated("DBref is being removed. See 'MongoRef' for an alternative", "3.4.3")
class DBRefField[OwnerType <: BsonRecord[OwnerType], RefType <: MongoRecord[RefType]](rec: OwnerType, ref: RefType)
extends Field[DBRef, OwnerType] with MandatoryTypedField[DBRef] {

Expand Down
Expand Up @@ -67,12 +67,12 @@ trait JObjectTypedField[OwnerType <: BsonRecord[OwnerType]] extends TypedField[J

def toForm: Box[NodeSeq] = Empty

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def asDBObject: DBObject = valueBox
.map { v => JObjectParser.parse(v)(owner.meta.formats) }
.openOr(new BasicDBObject)

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def setFromDBObject(obj: DBObject): Box[JObject] =
Full(JObjectParser.serialize(obj)(owner.meta.formats).asInstanceOf[JObject])

Expand Down
Expand Up @@ -90,11 +90,11 @@ abstract class JsonObjectTypedField[OwnerType <: BsonRecord[OwnerType], JObjectT
/*
* Convert this field's value into a DBObject so it can be stored in Mongo.
*/
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def asDBObject: DBObject = JObjectParser.parse(asJValue.asInstanceOf[JObject])

// set this field's value using a DBObject returned from Mongo.
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def setFromDBObject(dbo: DBObject): Box[JObjectType] =
setFromJValue(JObjectParser.serialize(dbo).asInstanceOf[JObject])
}
Expand Down Expand Up @@ -127,14 +127,14 @@ class JsonObjectListField[OwnerType <: BsonRecord[OwnerType], JObjectType <: Jso
extends MongoListField[OwnerType, JObjectType](owner: OwnerType)
{

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def asDBObject: DBObject = {
val dbl = new BasicDBList
value.foreach { v => dbl.add(JObjectParser.parse(v.asJObject()(owner.meta.formats))(owner.meta.formats)) }
dbl
}

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def setFromDBObject(dbo: DBObject): Box[List[JObjectType]] =
setBox(Full(dbo.keySet.asScala.toList.map { k =>
val v = dbo.get(k)
Expand All @@ -159,7 +159,7 @@ class JsonObjectListField[OwnerType <: BsonRecord[OwnerType], JObjectType <: Jso
case other => setBox(FieldHelpers.expectedA("JArray", other))
}

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
override def setFromDocumentList(list: java.util.List[Document]): Box[MyType] = {
val objs = list.asScala.map { JObjectParser.serialize }
setFromJValue(JArray(objs.toList))
Expand Down
Expand Up @@ -27,17 +27,17 @@ import com.mongodb.DBObject
/**
* Describes common aspects related to Mongo fields
*/
@deprecated("Please use 'BsonableField' instead.", "3.4.2")
@deprecated("Please use 'BsonableField' instead.", "3.4.3")
trait MongoFieldFlavor[MyType] {

/*
* convert this field's value into a DBObject so it can be stored in Mongo.
*/
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def asDBObject: DBObject

// set this field's value using a DBObject returned from Mongo.
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def setFromDBObject(obj: DBObject): Box[MyType]

/**
Expand Down
Expand Up @@ -153,7 +153,7 @@ class MongoListField[OwnerType <: BsonRecord[OwnerType], ListType: Manifest](rec
/*
* Convert this field's value into a DBObject so it can be stored in Mongo.
*/
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def asDBObject: DBObject = {
val dbl = new BasicDBList

Expand All @@ -169,11 +169,11 @@ class MongoListField[OwnerType <: BsonRecord[OwnerType], ListType: Manifest](rec
}

// set this field's value using a DBObject returned from Mongo.
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def setFromDBObject(dbo: DBObject): Box[MyType] =
setBox(Full(dbo.asInstanceOf[BasicDBList].asScala.toList.asInstanceOf[MyType]))

@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.2")
@deprecated("This was replaced with the functions from 'BsonableField'.", "3.4.3")
def setFromDocumentList(list: JavaList[Document]): Box[MyType] = {
throw new RuntimeException("Warning, setting Document as field with no conversion, probably not something you want to do")
}
Expand Down

0 comments on commit d88be68

Please sign in to comment.