Example usage for com.mongodb DBCollection getName

List of usage examples for com.mongodb DBCollection getName

Introduction

In this page you can find the example usage for com.mongodb DBCollection getName.

Prototype

public String getName() 

Source Link

Document

Get the name of a collection.

Usage

From source file:br.bireme.scl.BrokenLinks.java

License:Open Source License

private static List<Integer> getIsisCcFields(final String mstName, final DBCollection coll) throws IOException {
    assert mstName != null;
    assert coll != null;

    final List<Integer> lst = new ArrayList<Integer>();
    final BasicDBObject query = new BasicDBObject(MST_FIELD, mstName);
    final DBCursor cursor = coll.find(query);

    if (cursor.hasNext()) {
        final BasicDBObject obj = (BasicDBObject) cursor.next();
        final BasicDBList flds = (BasicDBList) obj.get(CC_TAGS_FIELD);
        if (flds.isEmpty()) {
            throw new IOException("Missing CCs field");
        }//from  w  w w  .j  ava 2s.c om
        for (Object tag : flds) {
            lst.add((Integer) tag);
        }
    } else {
        throw new IOException("Missing collection: " + coll.getName());
    }
    cursor.close();

    return lst;
}

From source file:br.bireme.scl.BrokenLinks.java

License:Open Source License

private static int getIsisIdField(final String mstName, final DBCollection coll) throws IOException {
    assert mstName != null;
    assert coll != null;

    final BasicDBObject query = new BasicDBObject(MST_FIELD, mstName);
    final BasicDBObject doc = (BasicDBObject) coll.findOne(query);

    if (doc == null) {
        throw new IOException(
                "Missing fields: collection[" + coll.getName() + "] or master name[" + mstName + "]");
    }//from   www.ja  v  a2 s. c o  m

    return doc.getInt(ID_TAG_FIELD);
}

From source file:br.bireme.scl.BrokenLinks.java

License:Open Source License

private static int getIsisUrlFields(final String mstName, final DBCollection coll) throws IOException {
    assert mstName != null;
    assert coll != null;

    final BasicDBObject query = new BasicDBObject(MST_FIELD, mstName);
    final BasicDBObject doc = (BasicDBObject) coll.findOne(query);

    if (doc == null) {
        throw new IOException(
                "Missing fields: collection[" + coll.getName() + "] or master name[" + mstName + "]");
    }/*from www.  j a va  2  s  .  c  om*/

    return doc.getInt(URL_TAG_FIELD);
}

From source file:com.bosscs.spark.mongodb.extractor.MongoNativeExtractor.java

License:Apache License

/**
 * Calculate splits./*w  ww  .j a v  a  2s.co  m*/
 *
 * @param collection the collection
 * @return the deep partition [ ]
 */
private HadoopPartition[] calculateSplits(DBCollection collection) {

    BasicDBList splitData = getSplitData(collection);
    List<ServerAddress> serverAddressList = collection.getDB().getMongo().getServerAddressList();

    if (splitData == null) {
        Pair<BasicDBList, List<ServerAddress>> pair = getSplitDataCollectionShardEnviroment(
                getShards(collection), collection.getDB().getName(), collection.getName());
        splitData = pair.left;
        serverAddressList = pair.right;
    }

    Object lastKey = null; // Lower boundary of the first min split

    List<String> stringHosts = new ArrayList<>();

    for (ServerAddress serverAddress : serverAddressList) {
        stringHosts.add(serverAddress.toString());
    }
    int i = 0;

    MongoPartition[] partitions = new MongoPartition[splitData.size() + 1];

    for (Object aSplitData : splitData) {

        BasicDBObject currentKey = (BasicDBObject) aSplitData;

        Object currentO = currentKey.get(MONGO_DEFAULT_ID);

        partitions[i] = new MongoPartition(mongoDeepJobConfig.getRddId(), i,
                new TokenRange(lastKey, currentO, stringHosts), MONGO_DEFAULT_ID);

        lastKey = currentO;
        i++;
    }
    QueryBuilder queryBuilder = QueryBuilder.start(MONGO_DEFAULT_ID);
    queryBuilder.greaterThanEquals(lastKey);
    partitions[i] = new MongoPartition(0, i, new TokenRange(lastKey, null, stringHosts), MONGO_DEFAULT_ID);
    return partitions;
}

From source file:com.dilmus.dilshad.scabi.deprecated.DTableOld.java

License:Open Source License

public DTableOld(DDBOld ddb, DBCollection table) {
    m_ddb = ddb;/*from w  ww  .j  a  va  2s.c  o  m*/
    m_table = table;
    m_tableName = table.getName();
    m_firstTime = true;
    m_fieldNames = null;

    m_dcursor = new DResultSetOld();

}

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

License:Apache License

void updateFromCmd(DBCollection col) {
    updateFromCmd(col.getDB(), new BasicDBObject(cmd, col.getName()));
}

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

License:Apache License

@Override
protected void updateComponentCustom(JPanel old) {
    try {/*from   w  ww  . j  a v  a2  s .c  o  m*/
        DBCollection collection = getCollectionNode().getCollection();
        setStringFieldValue(Item.name, collection.getName());
        setStringFieldValue(Item.fullName, collection.getFullName());
        setStringFieldValue(Item.queryOptions, MongoUtils.queryOptionsToString(collection.getOptions()));
        ((DocField) getBoundUnit(Item.writeConcern)).setDoc(collection.getWriteConcern().getCommand());
        ((DocField) getBoundUnit(Item.readPreference)).setDoc(collection.getReadPreference().toDBObject());
        ((CmdField) getBoundUnit(Item.stats)).updateFromCmd(collection);
    } catch (Exception e) {
        UMongo.instance.showError(this.getClass().getSimpleName() + " update", e);
    }
}

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

License:Apache License

public void distinct(final ButtonBase button) {
    final DBCollection col = getCollectionNode().getCollection();
    final BasicDBObject cmd = new BasicDBObject("distinct", col.getName());
    cmd.put("key", getStringFieldValue(Item.distinctKey));
    DBObject query = ((DocBuilderField) getBoundUnit(Item.distinctQuery)).getDBObject();
    if (query != null)
        cmd.put("query", query);
    new DbJobCmd(col.getDB(), cmd, null, button).addJob();
}

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

License:Apache License

public void dropCollection(ButtonBase button) {
    final CollectionNode colNode = getCollectionNode();
    final DBCollection col = getCollectionNode().getCollection();
    BasicDBObject cmd = new BasicDBObject("drop", col.getName());
    new DbJobCmd(col.getDB(), cmd, null, colNode.getDbNode(), null).addJob();
}

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

License:Apache License

public void count(final ButtonBase button) {
    final DBCollection col = getCollectionNode().getCollection();
    final DBObject query = ((DocBuilderField) getBoundUnit(Item.countQuery)).getDBObject();
    final int skip = getIntFieldValue(Item.countSkip);
    final int limit = getIntFieldValue(Item.countLimit);

    BasicDBObject cmd = new BasicDBObject();
    cmd.put("count", col.getName());
    cmd.put("query", query);

    if (limit > 0) {
        cmd.put("limit", limit);
    }/*from w w w.jav a2s.co  m*/
    if (skip > 0) {
        cmd.put("skip", skip);
    }
    new DbJobCmd(col.getDB(), cmd, null, button).addJob();
}