public class Translator extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ERR_INVALID_COMPARISON |
static String |
ERR_INVALID_FIELD |
static String |
ERR_INVALID_OBJECTTYPE |
static String |
ERR_NO_OBJECT_TYPE |
static com.redhat.lightblue.util.Path |
ID_PATH |
static com.redhat.lightblue.util.Path |
OBJECT_TYPE |
static String |
OBJECT_TYPE_STR |
| Constructor and Description |
|---|
Translator(com.redhat.lightblue.crud.MetadataResolver mdResolver,
com.fasterxml.jackson.databind.node.JsonNodeFactory factory)
Constructs a translator using the given metadata resolver and factory
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInvisibleFields(com.mongodb.DBObject oldDBObject,
com.mongodb.DBObject newObject,
com.redhat.lightblue.metadata.EntityMetadata md)
Add any fields in the old object that are not in the metadata of the new
object
|
static Object |
createIdFrom(Object source)
Creates appropriate identifier object given source data.
|
static Object |
getDBObject(com.mongodb.DBObject start,
com.redhat.lightblue.util.Path p) |
static Set<com.redhat.lightblue.util.Path> |
getRequiredFields(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.Projection p,
com.redhat.lightblue.query.QueryExpression q,
com.redhat.lightblue.query.Sort s)
Returns all the fields required to evaluate the given projection, query, and sort
|
com.mongodb.DBObject |
toBson(com.redhat.lightblue.util.JsonDoc doc)
Translates a JSON document to DBObject.
|
com.mongodb.DBObject[] |
toBson(List<? extends com.redhat.lightblue.util.JsonDoc> docs)
Translates a list of JSON documents to DBObjects.
|
com.redhat.lightblue.util.JsonDoc |
toJson(com.mongodb.DBObject object)
Traslates a DBObject document to Json document
|
List<com.redhat.lightblue.util.JsonDoc> |
toJson(List<com.mongodb.DBObject> objects)
Translates DBObjects into Json documents
|
com.mongodb.DBObject |
translate(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.QueryExpression query)
Translates a query to Mongo query
|
com.mongodb.DBObject |
translate(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.UpdateExpression expr)
Tranlates an update expression to Mongo query
|
com.mongodb.DBObject |
translate(com.redhat.lightblue.query.Sort sort)
Translates a sort expression to Mongo sort expression
|
static String |
translateJsPath(com.redhat.lightblue.util.Path p)
Translate a path to a javascript path
Path cannot have *.
|
static String |
translatePath(com.redhat.lightblue.util.Path p)
Translate a path to a mongo path
Any * in the path is removed.
|
com.mongodb.DBObject |
translateProjection(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.Projection p,
com.redhat.lightblue.query.QueryExpression q,
com.redhat.lightblue.query.Sort s)
Writes a MongoDB projection containing fields to evaluate the projection, sort, and query
|
public static final String OBJECT_TYPE_STR
public static final com.redhat.lightblue.util.Path OBJECT_TYPE
public static final com.redhat.lightblue.util.Path ID_PATH
public static final String ERR_NO_OBJECT_TYPE
public static final String ERR_INVALID_OBJECTTYPE
public static final String ERR_INVALID_FIELD
public static final String ERR_INVALID_COMPARISON
public Translator(com.redhat.lightblue.crud.MetadataResolver mdResolver,
com.fasterxml.jackson.databind.node.JsonNodeFactory factory)
public static String translatePath(com.redhat.lightblue.util.Path p)
public static String translateJsPath(com.redhat.lightblue.util.Path p)
public com.mongodb.DBObject[] toBson(List<? extends com.redhat.lightblue.util.JsonDoc> docs)
public com.mongodb.DBObject toBson(com.redhat.lightblue.util.JsonDoc doc)
public com.redhat.lightblue.util.JsonDoc toJson(com.mongodb.DBObject object)
public List<com.redhat.lightblue.util.JsonDoc> toJson(List<com.mongodb.DBObject> objects)
public void addInvisibleFields(com.mongodb.DBObject oldDBObject,
com.mongodb.DBObject newObject,
com.redhat.lightblue.metadata.EntityMetadata md)
public static Object getDBObject(com.mongodb.DBObject start, com.redhat.lightblue.util.Path p)
public com.mongodb.DBObject translate(com.redhat.lightblue.query.Sort sort)
public com.mongodb.DBObject translate(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.QueryExpression query)
md - Entity metadataquery - The query expressionpublic com.mongodb.DBObject translate(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.UpdateExpression expr)
throws CannotTranslateException
md - Entity metedataexpr - Update expression
If the update expresssion is something that can be translated into a
mongo update expression, translation is performed. Otherwise,
CannotTranslateException is thrown, and the update operation must be
performed using the Updaters.CannotTranslateExceptionpublic static Set<com.redhat.lightblue.util.Path> getRequiredFields(com.redhat.lightblue.metadata.EntityMetadata md, com.redhat.lightblue.query.Projection p, com.redhat.lightblue.query.QueryExpression q, com.redhat.lightblue.query.Sort s)
md - Entity metadatap - Projectionq - Querys - Sort
All arguments are optional. The returned set contains the
fields required to evaluate all the non-null expressionspublic com.mongodb.DBObject translateProjection(com.redhat.lightblue.metadata.EntityMetadata md,
com.redhat.lightblue.query.Projection p,
com.redhat.lightblue.query.QueryExpression q,
com.redhat.lightblue.query.Sort s)
Copyright © 2014. All rights reserved.