List of usage examples for com.mongodb BasicDBObjectBuilder start
public static BasicDBObjectBuilder start()
From source file:org.apache.rya.mongodb.document.operators.aggregation.SetOperators.java
License:Apache License
/** * Checks if any elements from the expression are {@code true}. * @param expression the expression to see if any elements are {@code true}. * @return the $anyElementTrue expression {@link BasicDBObject}. *//* ww w . ja va 2 s. c om*/ public static BasicDBObject anyElementTrue(final DBObject expression) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) anyElementTrue(builder, expression).get(); }
From source file:org.apache.rya.mongodb.document.operators.aggregation.VariableOperators.java
License:Apache License
/** * Applies an expression to each item in an array and returns an array with * the applied results./*from ww w .j a v a 2 s . c o m*/ * @param input an expression that resolves to an array. * @param as the variable name for the items in the {@code input} array. * The {@code in} expression accesses each item in the {@code input} array * by this variable. * @param in the expression to apply to each item in the {@code input} * array. The expression accesses the item by its variable name. * @return the $map expression {@link BasicDBObject}. */ public static BasicDBObject map(final String input, final String as, final DBObject in) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) map(builder, input, as, in).get(); }
From source file:org.apache.rya.mongodb.document.operators.query.ArrayOperators.java
License:Apache License
/** * Creates an $size MongoDB expression.// w ww . ja v a 2s .com * @param expression the expression to get the size of. * @return the $size expression {@link BasicDBObject}. */ public static BasicDBObject size(final Object expression) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) size(builder, expression).get(); }
From source file:org.apache.rya.mongodb.document.operators.query.ComparisonOperators.java
License:Apache License
/** * Creates a $gt MongoDB expression./*from ww w. j av a 2 s.co m*/ * @param expression the expression. * @param value the value to test if the expression is greater than * @return the $gt expression {@link BasicDBObject}. */ public static BasicDBObject gt(final BasicDBObject expression, final Number value) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) gt(builder, expression, value).get(); }
From source file:org.apache.rya.mongodb.document.operators.query.ComparisonOperators.java
License:Apache License
/** * Creates an $eq MongoDB expression.//from w w w. j a va 2s. c o m * @param expression1 the first expression. * @param expression2 the second expression. * @return the $eq expression {@link BasicDBObject}. */ public static BasicDBObject eq(final BasicDBObject expression1, final Object expression2) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) eq(builder, expression1, expression2).get(); }
From source file:org.apache.rya.mongodb.document.operators.query.LogicalOperators.java
License:Apache License
/** * Creates an $and MongoDB expression./*from w w w.ja v a 2s . c o m*/ * @param lhs the left-hand side operand. * @param rhs the right-hand side operand. * @param extras any additional operands. * @return the $and expression {@link BasicDBObject}. */ public static BasicDBObject and(final BasicDBObject lhs, final BasicDBObject rhs, final BasicDBObject... extras) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) and(builder, lhs, rhs, extras).get(); }
From source file:org.apache.rya.mongodb.document.operators.query.LogicalOperators.java
License:Apache License
/** * Creates an $or MongoDB expression./*from w ww . j a va2s.co m*/ * @param lhs the left-hand side operand. * @param rhs the right-hand side operand. * @param extras any additional operands. * @return the $or expression {@link BasicDBObject}. */ public static BasicDBObject or(final BasicDBObject lhs, final BasicDBObject rhs, final BasicDBObject... extras) { final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); return (BasicDBObject) or(builder, lhs, rhs, extras).get(); }
From source file:org.apache.rya.mongodb.document.visibility.DocumentVisibilityAdapter.java
License:Apache License
/** * Serializes a {@link DocumentVisibility} to a MongoDB {@link DBObject}. * @param documentVisibility the {@link DocumentVisibility} to be * serialized.//w w w . ja v a 2 s . com * @return The MongoDB {@link DBObject}. */ public static BasicDBObject toDBObject(final DocumentVisibility documentVisibility) { DocumentVisibility dv; if (documentVisibility == null) { dv = MongoDbRdfConstants.EMPTY_DV; } else { dv = documentVisibility; } Object[] dvArray = null; try { dvArray = DocumentVisibilityUtil.toMultidimensionalArray(dv); } catch (final DocumentVisibilityConversionException e) { log.error("Unable to convert document visibility"); } final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); builder.add(DOCUMENT_VISIBILITY_KEY, dvArray); return (BasicDBObject) builder.get(); }
From source file:org.apache.rya.mongodb.instance.MongoDetailsAdapter.java
License:Apache License
/** * Serializes {@link RyaDetails} to mongo {@link DBObject}. * @param details - The details to be serialized. * @return The mongo {@link DBObject}.//from w w w .j a v a 2s .c om */ public static BasicDBObject toDBObject(final RyaDetails details) { Preconditions.checkNotNull(details); final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start() .add(INSTANCE_KEY, details.getRyaInstanceName()).add(VERSION_KEY, details.getRyaVersion()) .add(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()) //RYA-215 .add(GEO_DETAILS_KEY, details.getGeoIndexDetails().isEnabled()) .add(PCJ_DETAILS_KEY, toDBObject(details.getPCJIndexDetails())) .add(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()) .add(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled()); if (details.getProspectorDetails().getLastUpdated().isPresent()) { builder.add(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get()); } if (details.getJoinSelectivityDetails().getLastUpdated().isPresent()) { builder.add(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get()); } return (BasicDBObject) builder.get(); }
From source file:org.apache.rya.mongodb.instance.MongoDetailsAdapter.java
License:Apache License
private static DBObject toDBObject(final PCJIndexDetails pcjIndexDetails) { requireNonNull(pcjIndexDetails);//from w w w .j av a 2s . c o m final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(); // Is Enabled builder.add(PCJ_ENABLED_KEY, pcjIndexDetails.isEnabled()); // Fluo Details if present. if (pcjIndexDetails.getFluoDetails().isPresent()) { builder.add(PCJ_FLUO_KEY, pcjIndexDetails.getFluoDetails().get().getUpdateAppName()); } // Add the PCJDetail objects. final List<DBObject> pcjDetailsList = new ArrayList<>(); for (final PCJDetails pcjDetails : pcjIndexDetails.getPCJDetails().values()) { pcjDetailsList.add(toDBObject(pcjDetails)); } builder.add(PCJ_PCJS_KEY, pcjDetailsList.toArray()); return builder.get(); }