本文整理汇总了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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
示例10: getClient
import org.jongo.Jongo; //导入依赖的package包/类
public Jongo getClient() {
if(jongo == null) {
createConnection();
}
return jongo;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}