Example usage for com.mongodb WriteConcern getWObject

List of usage examples for com.mongodb WriteConcern getWObject

Introduction

In this page you can find the example usage for com.mongodb WriteConcern getWObject.

Prototype

public Object getWObject() 

Source Link

Document

Gets the w value.

Usage

From source file:com.edgytech.umongo.OptionDialog.java

License:Apache License

void update(int options, WriteConcern wc, ReadPreference rp) {
    // reset//from w w  w  .  ja  v  a  2  s. c o m
    xmlLoadCheckpoint();

    setBooleanFieldValue(Item.tailable, (options & Bytes.QUERYOPTION_TAILABLE) != 0);
    setBooleanFieldValue(Item.slaveOk, (options & Bytes.QUERYOPTION_SLAVEOK) != 0);
    setBooleanFieldValue(Item.opLogReplay, (options & Bytes.QUERYOPTION_OPLOGREPLAY) != 0);
    setBooleanFieldValue(Item.noTimeout, (options & Bytes.QUERYOPTION_NOTIMEOUT) != 0);
    setBooleanFieldValue(Item.awaitData, (options & Bytes.QUERYOPTION_AWAITDATA) != 0);
    setBooleanFieldValue(Item.exhaust, (options & Bytes.QUERYOPTION_EXHAUST) != 0);
    setBooleanFieldValue(Item.partial, (options & Bytes.QUERYOPTION_PARTIAL) != 0);

    Object w = wc.getWObject();
    int wInt = (Integer) (w instanceof Integer ? w : 0);
    String wStr = (String) (w instanceof String ? w : "");
    setIntFieldValue(Item.writeFactor, wInt);
    setStringFieldValue(Item.writePolicy, wStr);
    setIntFieldValue(Item.writeTimeout, wc.getWtimeout());
    //        setBooleanFieldValue(Item.fsync, wc.fsync());

    DBObject rpObj = rp.toDBObject();
    ComboBox readBox = (ComboBox) getBoundUnit(Item.rpPreference);
    ReadPref rpEnm = ReadPref.primary;
    if (rp != null)
        rpEnm = ReadPref.valueOf(rp.getName());
    readBox.value = rpEnm.ordinal();
    if (rpObj.containsField("tags")) {
        List tags = (List) rpObj.get("tags");
        if (tags.size() > 0) {
            ((DocBuilderField) getBoundComponentUnit(Item.rpTag)).setDBObject((DBObject) tags.get(0));
        }
    }
}

From source file:org.springframework.data.mongodb.core.MongoTemplate.java

License:Apache License

private WriteConcern potentiallyForceAcknowledgedWrite(WriteConcern wc) {

    if (ObjectUtils.nullSafeEquals(WriteResultChecking.EXCEPTION, writeResultChecking)
            && MongoClientVersion.isMongo3Driver()) {
        if (wc == null || wc.getWObject() == null
                || (wc.getWObject() instanceof Number && ((Number) wc.getWObject()).intValue() < 1)) {
            return WriteConcern.ACKNOWLEDGED;
        }//from   w w w .  ja va2s. c o  m
    }
    return wc;
}