Example usage for com.mongodb BasicDBObject getString

List of usage examples for com.mongodb BasicDBObject getString

Introduction

In this page you can find the example usage for com.mongodb BasicDBObject getString.

Prototype

public String getString(final String key) 

Source Link

Document

Returns the value of a field as a string

Usage

From source file:bd.DArticulo.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CArticulo x = new CArticulo();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {// w w  w. ja  v  a 2 s.c  om
        while (cursor.hasNext()) {
            x = new CArticulo();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DCategoria.java

@Override
public String insertar(Object o) {
    CCategoria x = (CCategoria) o;//  w w w. j  av  a  2 s  .  c  om

    String ver = verificar(x);
    if (ver.compareTo(MSG_ACEPTADO) != 0)
        return ver;

    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject(x.get_datos());
    con.get_colletion().insert(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DCategoria.java

@Override
public String eliminar(Object o) {
    CCategoria x = (CCategoria) o;/*from   w  ww  .j a  v  a  2 s .  c o  m*/
    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject("_id", x.getId());
    con.get_colletion().remove(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DCategoria.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CCategoria x = new CCategoria();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {//from   ww  w. j a  v a2s  .  com
        while (cursor.hasNext()) {
            x = new CCategoria();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DPersona.java

@Override
public String insertar(Object o) {
    CPersona x = (CPersona) o;// www .  j  a  v  a2s  .com

    String ver = verificar(x);
    if (ver.compareTo(MSG_ACEPTADO) != 0)
        return ver;

    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject(x.get_datos());
    con.get_colletion().insert(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DPersona.java

@Override
public String eliminar(Object o) {
    CPersona x = (CPersona) o;//from  w  ww .j av a  2  s  .  co m
    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject("_id", x.getId());
    con.get_colletion().remove(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DPersona.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CPersona x = new CPersona();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {/* w  w w  .j  a  v a 2  s.  c o m*/
        while (cursor.hasNext()) {
            x = new CPersona();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DSession.java

@Override
public String insertar(Object o) {
    CSession x = (CSession) o;//from  w  ww. java2 s. co m

    String ver = verificar(x);
    if (ver.compareTo(MSG_ACEPTADO) != 0)
        return ver;

    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject(x.get_datos());
    con.get_colletion().insert(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DSession.java

@Override
public String eliminar(Object o) {
    CSession x = (CSession) o;//from w ww  .  j  ava2 s. c  o m
    conecion con = new conecion(table);
    BasicDBObject datos = new BasicDBObject("_id", x.getId());
    con.get_colletion().remove(datos);
    con.end();
    return datos.getString("_id");
}

From source file:bd.DSession.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CSession x = new CSession();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {//from   w ww  .  j  av a  2  s  .  c  o  m
        while (cursor.hasNext()) {
            x = new CSession();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}