Example usage for com.mongodb DBObject put

List of usage examples for com.mongodb DBObject put

Introduction

In this page you can find the example usage for com.mongodb DBObject put.

Prototype

Object put(String key, Object v);

Source Link

Document

Sets a name/value pair in this object.

Usage

From source file:com.eywa.impl.app.mongo.entities.items.jobs.ItemJobMessage.java

License:Open Source License

public static void addRecipient(final DBObject item, final String userId, final String templateName) {
    final DBObject recipients = getRecipients(item);
    recipients.put(userId, templateName);
    setRecipients(item, recipients);/*w  w w  .ja v  a  2  s .co  m*/
}

From source file:com.eywa.impl.app.mongo.entities.items.jobs.ItemJobMessage.java

License:Open Source License

public static void addTemplate(final DBObject item, final String name, final String title,
        final String content) {
    final DBObject template = new BasicDBObject();
    template.put(TITLE, title);
    template.put(CONTENT, content);/* www  . ja  va2 s. c o  m*/
    addTemplate(item, name, template);
}

From source file:com.eywa.impl.app.mongo.entities.items.jobs.ItemJobMessage.java

License:Open Source License

public static void addTemplate(final DBObject item, final String name, final DBObject template) {
    final DBObject map = getTemplates(item);
    map.put(name, template);
    setTemplates(item, map);//from   w  w  w . java  2s.c  o  m
}

From source file:com.eywa.impl.app.mongo.entities.items.session.cart.ItemSessionDataCart.java

License:Open Source License

public static void setItems(final DBObject item, final List<DBObject> value) {
    MongoUtils.put(item, ITEMS, value);// w w  w .j a v  a  2 s . c o  m
    setItemsCount(item, getItems(item).size());
    double total_qty = 0;
    double total_price = 0;
    final List<String> seller_id = new LinkedList<>();
    final DBObject seller_price = new BasicDBObject();
    String currency = DEF_CURRENCY;
    for (final DBObject cart_item : value) {
        final double price = ItemSessionDataCartItem.getPrice(cart_item);
        final double qty = ItemSessionDataCartItem.getQty(cart_item);
        final String seller = ItemSessionDataCartItem.getSellerId(cart_item);
        currency = ItemSessionDataCartItem.getCurrencyCode(cart_item);
        total_qty += qty;
        total_price += price * qty;
        if (!seller_id.contains(seller)) {
            seller_id.add(seller);
        }
        if (!seller_price.containsField(seller)) {
            seller_price.put(seller, 0.0);
        }
        seller_price.put(seller, MongoUtils.getDouble(seller_price, seller) + price * qty);
    }
    setItemsPrice(item, total_price);
    setItemsQty(item, total_qty);
    setSellerId(item, seller_id);
    setSellerPrice(item, seller_price);
    setCurrencyCode(item, currency);
}

From source file:com.eywa.impl.app.mongo.entities.items.session.cart.ItemSessionDataCartItem.java

License:Open Source License

public void setAttribute(final String key, final Object value) {
    final DBObject attributes = getAttributes(this);
    attributes.put(key, value);
    setAttributes(this, attributes);
}

From source file:com.eywa.impl.app.mongo.entities.items.session.configurator.ItemSessionDataConfiguratorItem.java

License:Open Source License

public static void setAttribute(final DBObject item, final String key, final Object value) {
    final DBObject attr = getAttributes(item);
    if (null != attr) {
        attr.put(key, value);
    }/*from   w w w.  j  av a 2  s  .c  om*/
}

From source file:com.eywa.impl.app.mongo.entities.ProductTransaction.java

License:Open Source License

public static void init(final DBObject item) {
    if (!StringUtils.hasText(getId(item))) {
        item.put(ID, createUUID());
        item.put(CREATIONDATE, FormatUtils.getNow());
        item.put(CREATION_DATE, DateUtils.now().getTime());
    }//from   ww w .  j  a va2 s  .  co m
}

From source file:com.eywa.impl.app.mongo.services.ContactService.java

License:Open Source License

public DBObject getByEmail(final String email) {
    final DBObject query = new BasicDBObject();
    query.put(Contact.EMAILS, email);
    return super.findOne(query);
}

From source file:com.eywa.impl.app.mongo.services.ContactService.java

License:Open Source License

public List<DBObject> getByHubAndKeywords(final String hubId, final Collection<String> keywords,
        final String[] fieldNames) {
    final DBObject query = new BasicDBObject();
    query.put(Contact.HUB_ID, hubId);
    MongoUtils.queryIn(query, Contact.PARALLEL_ARRAY_KEY, keywords.toArray(new String[keywords.size()]));

    final String[] sortAsc = new String[] { Contact.NAME };
    final String[] sortDes = new String[] {};

    return super.find(query, fieldNames, sortAsc, sortDes);
}

From source file:com.eywa.impl.app.mongo.services.ContactService.java

License:Open Source License

public MongoPage lookup(final String hubId, final int skip, final int limit,
        final Collection<String> keywords) {
    final DBObject query = new BasicDBObject();
    query.put(Contact.HUB_ID, hubId);
    MongoUtils.queryIn(query, Contact.PARALLEL_ARRAY_KEY, keywords.toArray(new String[keywords.size()]));

    final String[] fieldNames = null;
    final String[] sortAsc = new String[] { Contact.NAME };
    final String[] sortDes = new String[] {};

    return super.paged(query, fieldNames, skip, limit, sortAsc, sortDes);
}