use of com.tvd12.dahlia.core.setting.DatabaseSetting in project dahlia by youngmonkeys.
the class LocalDahlia method createDatabase.
@Override
public IDatabase createDatabase(Object setting) {
DatabaseSetting s = (DatabaseSetting) setting;
CommandCreateDatabase command = new CommandCreateDatabase(s);
Database databaseStore = commandExecutor.execute(command);
LocalDatabase database = new LocalDatabase(databaseStore, commandExecutor);
databases.put(databaseStore.getName(), database);
return database;
}
use of com.tvd12.dahlia.core.setting.DatabaseSetting in project dahlia by youngmonkeys.
the class DatabaseStorage method readSetting.
public DatabaseSetting readSetting() {
DatabaseSetting setting = settingStorage.read();
setting.setDatabaseName(databaseName);
return setting;
}
use of com.tvd12.dahlia.core.setting.DatabaseSetting in project dahlia by youngmonkeys.
the class SecondTest method main.
public static void main(String[] args) {
deleteDataDir();
LocalDahlia dahlia = new LocalDahlia("data");
DatabaseSetting databaseSetting = new DatabaseSetting();
databaseSetting.setDatabaseName("hello");
IDatabase database = null;
try {
database = dahlia.createDatabase(databaseSetting);
} catch (DatabaseExistedException e) {
database = dahlia.getDatabase("hello");
}
ICollection collection = null;
try {
collection = database.createCollection("classpath:hello_test_setting2.json");
} catch (CollectionExistedException e) {
collection = database.getCollection("test");
}
EzyObject insertOneData = newObjectBuilder().append("value", 323L).append("name", "dungtv").build();
try {
EzyObject insertOneResult = collection.insert(insertOneData);
System.out.println("insert one result: " + insertOneResult);
} catch (DuplicatedIdException e) {
} catch (Exception e) {
e.printStackTrace();
}
long v1 = 1;
double v2 = 1.1;
System.out.println(v2 == v1);
// EzyObject query1 = newObjectBuilder()
// .append("_id", newObjectBuilder().append(Keywords.LESS_THAN_EQUAL, 3L))
// .build();
// CommandFindOne findOne = new CommandFindOne(collection.getId(), query1);
// EzyObject findOneResult = commandExecutor.execute(findOne);
// System.out.println("findOneResult: " + findOneResult);
// EzyObject query2 = newObjectBuilder()
// .append(Keywords.OR, newArrayBuilder()
// .append(newObjectBuilder().append("_id", newObjectBuilder().append(Keywords.LESS_THAN_EQUAL, 3L)))
// .append(newObjectBuilder().append("value", 223))
// )
// .build();
EzyObject query3 = newObjectBuilder().append(Keywords.OR, newArrayBuilder().append(newObjectBuilder().append("value", 323L))).build();
FindOptions options = new FindOptions().setSkip(0).setLimit(10);
EzyArray findResult = collection.find(query3, options);
System.out.println("findResult = " + findResult);
Long size = collection.count();
System.out.println("size: " + size);
}
use of com.tvd12.dahlia.core.setting.DatabaseSetting in project dahlia by youngmonkeys.
the class DahliaCoreLoader method readDatabaseSettings.
protected Map<String, DatabaseSetting> readDatabaseSettings(Map<String, DatabaseStorage> storages) {
Map<String, DatabaseSetting> settings = new HashMap<>();
for (String databaseName : storages.keySet()) {
DatabaseStorage storage = storages.get(databaseName);
DatabaseSetting setting = storage.readSetting();
settings.put(databaseName, setting);
}
return settings;
}
use of com.tvd12.dahlia.core.setting.DatabaseSetting in project dahlia by youngmonkeys.
the class SettingDatabaseDeserializer method deserialize.
@Override
public DatabaseSetting deserialize(byte[] bytes) {
EzyObject object = objectDeserializer.deserialize(bytes);
DatabaseSetting setting = new DatabaseSetting();
setting.setDatabaseId(object.get(SettingFields.ID, int.class));
return setting;
}
Aggregations