当前位置: 首页>>代码示例>>Java>>正文


Java Jongo类代码示例

本文整理汇总了Java中org.jongo.Jongo的典型用法代码示例。如果您正苦于以下问题:Java Jongo类的具体用法?Java Jongo怎么用?Java Jongo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Jongo类属于org.jongo包,在下文中一共展示了Jongo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUser

import org.jongo.Jongo; //导入依赖的package包/类
public UserEntity createUser(String accountId, String username) {
	JongoDBService manager = AppContext.getManager(JongoDBService.class);
	Jongo jongo = manager.getJongo();

	MongoCollection collection = jongo.getCollection("USER");

	UserEntity userEntity = new UserEntity();
	userEntity.setUserId(accountId);
	userEntity.setAccountId(accountId);
	userEntity.setLevel(1);
	userEntity.setUserName(username);

	try {
		collection.insert(userEntity);
		return userEntity;
	} catch (com.mongodb.DuplicateKeyException e) {
	}
	return null;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:20,代码来源:UserManager.java

示例2: DBManager

import org.jongo.Jongo; //导入依赖的package包/类
public DBManager(String host, int port, String dbname, String username, String password) {
	// Construct mongo url
	if (dbname == null || dbname.isEmpty()) dbname = "Grimoire";
	if (host == null || host.isEmpty()) host = "127.0.0.1";
	if (port <= 0 || port >= 65535) port = 27017;
	String mongoURL = host + ":" + port + "/" + dbname;
	if (username != null && !username.isEmpty()) {
		String auth = username;
		if (password != null && !password.isEmpty()) auth += ":" + password;
		mongoURL = auth + "@" + mongoURL;
	}
	mongoURL = "mongodb://" + mongoURL;

	// Construct client
	MongoClient client = new MongoClient(new MongoClientURI(mongoURL));

	// Wrap with jongo
	jongo = new Jongo(client.getDB(dbname));
}
 
开发者ID:BeMacized,项目名称:Grimoire,代码行数:20,代码来源:DBManager.java

示例3: _countByCriteria

import org.jongo.Jongo; //导入依赖的package包/类
@Override
public int _countByCriteria(Table table) {
	int count = 0;
	Map<String, Object> coditon = new HashMap<String, Object>();
	try {
		QueryCriteria queryCriteria = table.getQueryCriteria();
		DB db = database.getDB();
		Jongo jongo = new Jongo(db);
		for(Criteria criteria:queryCriteria.getOredCriteria()){
			for(Criterion criterion:criteria.getAllCriteria()){
				coditon = buildCriteria(criterion, coditon);
			}
		}
		long size = jongo.getCollection(queryCriteria.getTable()).count(JsonUtils.objToJson(coditon));
		count = (int) size;
	} catch (MongoException e) {
		LOG.error("mongo find error", e);
	}
	return count;
}
 
开发者ID:uncodecn,项目名称:uncode-dal-all,代码行数:21,代码来源:MongoDAL.java

示例4: _selectByPrimaryKey

import org.jongo.Jongo; //导入依赖的package包/类
@Override
public Map<String, Object> _selectByPrimaryKey(Table table) {
	Map<String, Object> result = null;
	try {
		DB db = database.getDB();
		Jongo jongo = new Jongo(db);
		FindOne find = null;
		if(table.getConditions().containsKey("_id")){
			find = jongo.getCollection(table.getTableName()).findOne(new ObjectId(String.valueOf(table.getConditions().get("_id"))));
		}else{
			find = jongo.getCollection(table.getTableName()).findOne(JsonUtils.objToJson(table.getConditions()));
		}
        result = find.as(Map.class);
        result.put("id", result.get("_id").toString());
	} catch (MongoException e) {
		LOG.error("mongo findOne error", e);
	}
	return result;
}
 
开发者ID:uncodecn,项目名称:uncode-dal-all,代码行数:20,代码来源:MongoDAL.java

示例5: _deleteByPrimaryKey

import org.jongo.Jongo; //导入依赖的package包/类
@Override
public int _deleteByPrimaryKey(Table table) {
	try {
		DB db = database.getDB();
		Jongo jongo = new Jongo(db);
		
		if(table.getConditions().containsKey("_id")){
			jongo.getCollection(table.getTableName()).remove(new ObjectId(String.valueOf(table.getConditions().get("_id"))));
		}else{
			jongo.getCollection(table.getTableName()).remove(JsonUtils.objToJson(table.getConditions()));
		}
	} catch (MongoException e) {
		LOG.error("mongo findOne error", e);
	}
	return 1;
}
 
开发者ID:uncodecn,项目名称:uncode-dal-all,代码行数:17,代码来源:MongoDAL.java

示例6: MongoWorkspaceDB

import org.jongo.Jongo; //导入依赖的package包/类
public MongoWorkspaceDB(final DB workspaceDB, final BlobStore blobStore,
		final TempFilesManager tfm)
		throws WorkspaceCommunicationException,
		WorkspaceDBInitializationException, CorruptWorkspaceDBException {
	if (workspaceDB == null || blobStore == null || tfm == null) {
		throw new NullPointerException("No arguments can be null");
	}
	rescfg = new ResourceUsageConfigurationBuilder().build();
	this.tfm = tfm;
	wsmongo = workspaceDB;
	wsjongo = new Jongo(wsmongo);
	query = new QueryMethods(wsmongo, (AllUsers) ALL_USERS, COL_WORKSPACES,
			COL_WORKSPACE_OBJS, COL_WORKSPACE_VERS, COL_WS_ACLS);
	objutils = new ObjectInfoUtils(query);
	blob = blobStore;
	updateWScounter = buildCounterQuery(wsjongo);
	//TODO DBCONSIST check a few random types and make sure they exist
	ensureIndexes();
	checkConfig();
}
 
开发者ID:kbase,项目名称:workspace_deluxe,代码行数:21,代码来源:MongoWorkspaceDB.java

示例7: start

import org.jongo.Jongo; //导入依赖的package包/类
@Activate
public void start(Map<String, Object> properties) {
    LOGGER.info("Starting MongoDb service...");
    MongoClient mongoClient;
    try {
        String host = PropertiesUtil.toString(properties.get(MONGO_HOST), "127.0.0.1");
        int port = PropertiesUtil.toInteger(properties.get(MONGO_PORT), 27017);
        String dbName = PropertiesUtil.toString(properties.get(MONGO_DB_NAME), "cisen");

        mongoClient = new MongoClient(host, port);
        DB mDb = mongoClient.getDB(dbName);

        this.m_mongo = mDb.getMongo();
        this.jongo = new Jongo(mDb);
        setUpDB();
        LOGGER.info("MongoDb service was started successfully.");
    } catch (UnknownHostException e) {
        LOGGER.error("Fail to connect: ", e);
    }
}
 
开发者ID:eliogrin,项目名称:CISEN,代码行数:21,代码来源:MongoDBServiceImpl.java

示例8: getProfilingCollection

import org.jongo.Jongo; //导入依赖的package包/类
private MongoCollection getProfilingCollection() {
        CollectorServerDto serverDto = ConfigReader.getCollectorServer();
;
        try{
            MongoDbAccessor mongo = new MongoDbAccessor(60000, true, serverDto.getAdminUser(), serverDto.getAdminPw(), serverDto.getHosts());
            DB db = mongo.getMongoDB(serverDto.getDb());
            Jongo jongo = new Jongo(db);
            MongoCollection result =  jongo.getCollection(serverDto.getCollection());

            if(result == null) {
                throw new IllegalArgumentException("Can't continue without profile collection for " + serverDto.getHosts());
            }

            return result;
        } catch (MongoException e) {
            LOG.error("Exception while connecting to: {}", serverDto.getHosts(), e);
        }
        return null;
    }
 
开发者ID:idealo,项目名称:mongodb-slow-operations-profiler,代码行数:20,代码来源:Grapher.java

示例9: jongo

import org.jongo.Jongo; //导入依赖的package包/类
@Bean
public Jongo jongo() {
    MongoCredential credential =
        MongoCredential.createCredential(mongoUser, mongoDatabase,
            mongoPassword.toCharArray());
    ServerAddress serverAddress = new ServerAddress(mongoHost, mongoPort);
    MongoClient mongoClient = new MongoClient(serverAddress,
        new ArrayList<MongoCredential>() {{
            add(credential);
        }});

    DB db = mongoClient.getDB(mongoDatabase);
    return new Jongo(db);
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:15,代码来源:NitriteDataGate.java

示例10: getClient

import org.jongo.Jongo; //导入依赖的package包/类
public Jongo getClient() {
    if(jongo == null) {
        createConnection();
    }

    return jongo;
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:8,代码来源:MongoDBClient.java

示例11: setup

import org.jongo.Jongo; //导入依赖的package包/类
@Before
public void setup() {
    Jongo jongo = mock(Jongo.class);
    collection = mock(MongoCollection.class);
    when(client.getClient()).thenReturn(jongo);
    when(jongo.getCollection("tokens")).thenReturn(collection);
}
 
开发者ID:2DV603NordVisaProject,项目名称:nordvisa_calendar,代码行数:8,代码来源:TokenDAOMongoTest.java

示例12: getUser

import org.jongo.Jongo; //导入依赖的package包/类
public UserEntity getUser(String userId) {
	JongoDBService manager = AppContext.getManager(JongoDBService.class);
	Jongo jongo = manager.getJongo();

	MongoCollection collection = jongo.getCollection("USER");
	try {
		UserEntity as = collection.findOne("{_id:#}", userId).as(UserEntity.class);
		return as;
	} catch (com.mongodb.DuplicateKeyException e) {
	}
	return null;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:13,代码来源:UserManager.java

示例13: selectAccount

import org.jongo.Jongo; //导入依赖的package包/类
public AccountEntity selectAccount(String account,String password){
	JongoDBService manager = AppContext.getManager(JongoDBService.class);
	Jongo jongo = manager.getJongo();
	
	MongoCollection collection = jongo.getCollection("Account");
	try {
		AccountEntity as = collection.findOne("{_id:#,accountPassWord:#}",account,password).as(AccountEntity.class);
		return  as;
	} catch (com.mongodb.DuplicateKeyException e) {
	}
	return null;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:13,代码来源:AccountManager.java

示例14: regeditAccount

import org.jongo.Jongo; //导入依赖的package包/类
public AccountEntity regeditAccount(String account,String password){
	JongoDBService manager = AppContext.getManager(JongoDBService.class);
	Jongo jongo = manager.getJongo();
	
	AccountEntity accountEntity=new AccountEntity();
	accountEntity.setAccountName(account);
	accountEntity.setAccountPassWord(password);
	MongoCollection collection = jongo.getCollection("Account");
	try {
		collection.insert(accountEntity);
		return accountEntity;
	} catch (com.mongodb.DuplicateKeyException e) {
	}
	return null;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:16,代码来源:AccountManager.java

示例15: checkRegedit

import org.jongo.Jongo; //导入依赖的package包/类
public boolean checkRegedit(String account){
	JongoDBService manager = AppContext.getManager(JongoDBService.class);
	Jongo jongo = manager.getJongo();
	MongoCollection collection = jongo.getCollection("Account");
	AccountEntity findOne = collection.findOne("{_id:#}",account).as(AccountEntity.class);
	return findOne!=null;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:8,代码来源:AccountManager.java


注:本文中的org.jongo.Jongo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。