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:com.edgytech.umongo.RouterPanel.java

License:Apache License

BasicDBObject getChunk(String ns, DBObject shardKey, BasicDBObject min, BasicDBObject max, BSONTimestamp ts) {
    BasicDBObject chunk = new BasicDBObject();
    BasicDBObject themin = (BasicDBObject) min.get("_id");
    BasicDBObject themax = (BasicDBObject) max.get("_id");
    String _id = ns;/*  w w  w . ja  va2s.  co  m*/
    for (String key : shardKey.keySet()) {
        _id += "-" + key + "_";
        Object val = themin.get(key);
        _id += (val != null ? val.toString() : "null");
    }
    chunk.put("_id", _id);
    chunk.put("lastmod", ts);
    chunk.put("ns", ns);
    chunk.put("min", themin);
    chunk.put("max", themax);
    chunk.put("shard", min.getString("_shard"));
    return chunk;
}

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

License:Apache License

void resetForEdit(DB config, BasicDBObject range) {
    xmlLoadCheckpoint();//from ww  w  . ja  va  2s . c  o m

    ((DocBuilderField) getBoundUnit(Item.min)).setDBObject((DBObject) range.get("min"));
    ((DocBuilderField) getBoundUnit(Item.min)).enabled = false;
    ((DocBuilderField) getBoundUnit(Item.max)).setDBObject((DBObject) range.get("max"));

    ((DynamicComboBox) getBoundUnit(Item.tag)).items = getExistingTags(config);
    setStringFieldValue(Item.tag, range.getString("tag"));

    updateComponent();
}

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

License:Apache License

void resetForEdit(BasicDBObject user) {
    xmlLoadCheckpoint();//from w  ww .  ja  v a 2  s.  c o  m

    setStringFieldValue(Item.user, user.getString(Item.user.name()));
    ((TextField) getBoundJComponentUnit(Item.user)).editable = false;

    ((PasswordField) getBoundJComponentUnit(Item.password)).nonEmpty = false;
    setStringFieldValue(Item.userSource, user.getString(Item.userSource.name()));

    BasicDBList roles = (BasicDBList) user.get("roles");
    if (roles != null) {
        for (Role role : Role.values()) {
            setBooleanFieldValue(role.item, roles.contains(role.name()));
        }
    } else {
        boolean ro = user.getBoolean("readOnly");
        if (ro)
            setBooleanFieldValue(Item.readWrite, true);
        else
            setBooleanFieldValue(Item.read, true);
    }

    updateComponent();
}

From source file:com.emuneee.camerasyncmanager.util.DatabaseUtil.java

License:Apache License

/**
 * Converts BasicDBObject to camera//from  w  w  w .  j  a va2 s.  c  om
 * @param dbObj
 * @return
 */
public Camera dbObjectToCamera(BasicDBObject dbObj) {
    Camera camera = new Camera();
    camera.setId(dbObj.getString("_id"));
    camera.setTitle(dbObj.getString("title"));
    camera.setLatitude(dbObj.getDouble("latitude"));
    camera.setLongitude(dbObj.getDouble("longitude"));
    camera.setCity(dbObj.getString("city"));
    camera.setArea(dbObj.getString("area"));
    camera.setState(dbObj.getString("state"));
    camera.setZipCode(dbObj.getString("zipcode"));
    camera.setCountry(dbObj.getString("country"));
    camera.setUrl(dbObj.getString("url"));
    camera.setCreated(dbObj.getDate("created"));
    camera.setUpdated(dbObj.getDate("updated"));
    return camera;
}

From source file:com.fpt.xml.hth.db.lib.converter.MovieConverter.java

public MovieDB convertBasicObjectToModel(BasicDBObject object) {
    String name = object.getString("name");
    String description = object.getString("description");
    String length = object.getString("length");
    String actor = object.getString("actor");
    String director = object.getString("director");
    String poster = object.getString("poster");
    String trailer = object.getString("trailer");
    String show_date = object.getString("show_date");
    String genre = object.getString("genre");
    String age_restriction = object.getString("age_restriction");
    String audio_type = object.getString("audio_type");
    String video_type = object.getString("video_type");
    // set values to object movie
    MovieDB movie = new MovieDB();
    movie.setName(name);// w  w w  . j a  va  2  s  .  c o m
    movie.setActor(actor);
    movie.setAge_restriction(age_restriction);
    movie.setAudio_type(audio_type);
    movie.setDescription(description);
    movie.setDirector(director);
    movie.setGenre(genre);
    movie.setLength(length);
    movie.setName(name);
    movie.setPoster(poster);
    movie.setShow_date(show_date);
    movie.setTrailer(trailer);
    movie.setVideo_type(video_type);
    return movie;
}

From source file:com.fpt.xml.hth.db.lib.converter.TheaterSessionConverter.java

/**
 * To convert from BasicDBObject object to TheaterDBSessionDTO object
 *
 * @param object/*  www  . j a va 2 s . c  o m*/
 * @return TheaterDBSessionDTO
 */
public TheaterSessionDTO convertBasicObjectToModel(BasicDBObject object) {
    String cinemaName = object.getString("cinemaName");
    String id = object.getString("id");
    BasicDBObject basicTheater = (BasicDBObject) object.get("theater");
    BasicDBList basicSessions = (BasicDBList) object.get("sessions");
    // convert basicTheater to theater
    TheaterDB theater = conveter.convertBasicObjectToModel(basicTheater);
    // convert basicSessions to session
    List<String> sessions = new ArrayList<String>();
    for (int i = 0; i < basicSessions.size(); i++) {
        String session = basicSessions.get(i).toString();
        sessions.add(session);
    }
    TheaterSessionDTO theaterSessionDTO = new TheaterSessionDTO();
    theaterSessionDTO.setId(id);
    theaterSessionDTO.setCinemaName(cinemaName);
    theaterSessionDTO.setLstSession(sessions);
    theaterSessionDTO.setTheater(theater);
    return theaterSessionDTO;
}

From source file:com.gederin.blog.dao.SessionDAO.java

License:Apache License

public String startSession(String username) {

    // get 32 byte random number. that's a lot of bits.
    SecureRandom generator = new SecureRandom();
    byte randomBytes[] = new byte[32];
    generator.nextBytes(randomBytes);/*from   www .jav  a 2 s  .  c o  m*/

    BASE64Encoder encoder = new BASE64Encoder();

    String sessionID = encoder.encode(randomBytes);

    // build the BSON object
    BasicDBObject session = new BasicDBObject("username", username);

    session.append("_id", sessionID);

    sessionsCollection.insert(session);

    return session.getString("_id");
}

From source file:com.ibm.bluemix.smartveggie.service.SubOutletVendorAllocationServiceImpl.java

private SubOutletVendorAllocationDTO setObjectToDTOMapping(BasicDBObject dbObj) {

    SubOutletVendorAllocationDTO subOutletVendorAllocationDTO = new SubOutletVendorAllocationDTO();
    subOutletVendorAllocationDTO.setSmartCityCode(dbObj.getString("smartCityCode"));
    subOutletVendorAllocationDTO.setSmartOutletCode(dbObj.getString("smartOutletCode"));
    subOutletVendorAllocationDTO.setSuboutletCode(dbObj.getString("suboutletCode"));
    subOutletVendorAllocationDTO.setVendorLicenseNo(dbObj.getString("vendorLicenseNo"));
    subOutletVendorAllocationDTO.setVendorUsername(dbObj.getString("vendorUsername"));
    subOutletVendorAllocationDTO.setSuboutletAllocatedFrom(dbObj.getString("suboutletAllocatedFrom"));
    subOutletVendorAllocationDTO.setSuboutletAllocatedTo(dbObj.getString("suboutletAllocatedTo"));
    return subOutletVendorAllocationDTO;
}

From source file:com.ibm.bluemix.smartveggie.service.UserServiceImpl.java

private UserDTO setObjectToDTOMapping(BasicDBObject dbObj) {
    UserDTO userDTO = new UserDTO();
    userDTO.setFirstName(dbObj.getString("firstName"));
    userDTO.setLastName(dbObj.getString("lastName"));
    userDTO.setAddressLine1(dbObj.getString("addressLine1"));
    userDTO.setAddressLine2(dbObj.getString("addressLine2"));
    userDTO.setSex(dbObj.getString("sex"));
    userDTO.setPinCode(dbObj.getString("pin"));
    userDTO.setAge(dbObj.getInt("age"));
    userDTO.setCity(dbObj.getString("city"));
    userDTO.setUserName(dbObj.getString("userName"));
    userDTO.setRegulatingCityCode(dbObj.getString("regulatingCityCode"));
    userDTO.setRegulatingCityName(dbObj.getString("regulatingCityName"));
    userDTO.setUserTypeCode(dbObj.getString("userType"));
    userDTO.setLicenseNo(dbObj.getString("licenseNo"));
    return userDTO;
}

From source file:com.ijuru.ijambo.dao.PlayerDAO.java

License:Open Source License

/**
 * Gets the specified player/* ww  w  . j  a  va 2s .co  m*/
 * @param identifier the player identifier
 * @return the player
 */
public Player getPlayer(String identifier) {
    DBCollection players = db.getCollection("players");

    BasicDBObject query = new BasicDBObject();
    query.put("identifier", identifier);

    BasicDBObject obj = (BasicDBObject) players.findOne(query);
    if (obj != null)
        return new Player(obj.getString("identifier"), obj.getString("prevAnswer"));
    else
        return null;
}