Example usage for com.mongodb MongoClient getDB

List of usage examples for com.mongodb MongoClient getDB

Introduction

In this page you can find the example usage for com.mongodb MongoClient getDB.

Prototype

@Deprecated 
public DB getDB(final String dbName) 

Source Link

Document

Gets a database object.

Usage

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Packagedocumentinsert(String id, String FQN, String name, String container) {

    try {//from   ww w  . j a  v a 2s  . c o  m
        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("package");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        collection.insert(document);

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Deepmodeldocumentinsert(int id, int p_id, String FQN, String name, String container) {
    mdlocalhost = Login.tmtexthostx();// w w  w  .  j  ava 2 s.c  om
    mdport = Integer.valueOf(Login.tmtextportx());
    tmtextdb = Login.tmtextdbx();
    tmtextuser = Login.tmtextuserx();
    tmtextpassword = Login.tmtextpasswordx();
    try {

        clearmongodb();
        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("deepmodel");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("p_id", p_id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Leveldocumentinsert(int id, String FQN, String name, String container, int number) {
    try {//from w w w.j a  va  2s.  c o  m

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("level");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        document.put("number", number);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Entitydocumentinsert(int id, String FQN, String name, String container, int potincy,
        String directtype)/*www . j a  v a2s.  c o m*/

{
    try {

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());

        DBCollection collection = db.getCollection("entity");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("name", name);
        document.put("FQN", FQN);
        document.put("container", container);
        document.put("potincy", potincy);
        collection.insert(document);

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void entityupdate(String entitychildFQN, String entityfatherFQN) {
    try {/*from www  . j  a  v  a2s  .  c o  m*/
        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("entity");

        DBCursor curs = collection.find();
        while (curs.hasNext()) {
            DBObject dbObject = curs.next();
            String FQN = ((BasicBSONObject) dbObject).getString("FQN");
            String exdirecttype = ((BasicBSONObject) dbObject).getString("directtype");
            if (FQN.equals(entityfatherFQN)) {

                dbObject.put("directtype", entitychildFQN);
                collection.save(dbObject);
            }

        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Attributedocumentinsert(int id, String FQN, String name, String container, String duribility,
        String type, String value, String mutability) {
    try {//from   w ww  .  java2s  .c  o  m

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("attribute");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        document.put("duribility", duribility);
        document.put("type", type);
        document.put("duribility", duribility);
        document.put("value", value);
        document.put("duribility", duribility);
        document.put("mutability", mutability);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Methoddocumentinsert(int id, String FQN, String name, String container, String duribility,
        String signature, String body) {
    try {/*ww w. j a  v  a2 s .  c  o m*/

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("method");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        document.put("duribility", duribility);
        document.put("signature", signature);
        if (body == null) {
            body = "null";

        }
        document.put("body", body);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Binarydocumentinsert(int id, String FQN, String name, String container, int potency,
        String directtype, String label, String participant1, String participant2, String roleName1,
        String roleName2, String lower1, String lower2, String upper1, String upper2, String navigalbeTo1,
        String navigableTo2) {//from   w w w  .j a va  2  s . com
    try {

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("binaryconnection");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("potincy", potency);
        document.put("container", container);
        //               document.put("directtype", directtype);
        document.put("label", label);
        document.put("participant1", participant1);
        document.put("participant2", participant2);
        document.put("roleName1", roleName1);
        document.put("roleName2", roleName2);
        document.put("lower1", lower1);
        document.put("lower2", lower2);
        document.put("upper1", upper1);
        document.put("upper2", upper2);
        document.put("navigalbeTo1", navigalbeTo1);
        document.put("navigableTo2", navigableTo2);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Binaryconnectionupdate(String coninstanceFQN, String conFQN) {

    try {/*from  www.j  av a2 s. co  m*/
        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("binaryconnection");

        DBCursor curs = collection.find();
        while (curs.hasNext()) {
            DBObject dbObject = curs.next();
            String FQN = ((BasicBSONObject) dbObject).getString("FQN");
            String exdirecttype = ((BasicBSONObject) dbObject).getString("directtype");
            if (FQN.equals(coninstanceFQN)) {

                dbObject.put("directtype", conFQN);
                collection.save(dbObject);
            }

        }
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}

From source file:de.unimannheim.infor.swt.uim.actions.MogoDBCreate.java

License:Open Source License

public static void Inrdocumentinsert(int id, String FQN, String name, String container, String disjoint,
        String complete) {/*  www  . jav a2  s.  co  m*/
    try {

        MongoClient mongoClient = new MongoClient(mdlocalhost, mdport);
        DB db = mongoClient.getDB(tmtextdb);
        boolean auth = db.authenticate(tmtextuser, tmtextpassword.toCharArray());
        DBCollection collection = db.getCollection("inheritancerelationship");
        DBCursor cursor = collection.find();
        BasicDBObject document = new BasicDBObject();
        document.put("MySQLid", id);
        document.put("FQN", FQN);
        document.put("name", name);
        document.put("container", container);
        document.put("disjoint", disjoint);
        document.put("complete", complete);
        collection.insert(document);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (MongoException e) {
        e.printStackTrace();
    }
}