本文整理汇总了Java中com.arangodb.ArangoDB类的典型用法代码示例。如果您正苦于以下问题:Java ArangoDB类的具体用法?Java ArangoDB怎么用?Java ArangoDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArangoDB类属于com.arangodb包,在下文中一共展示了ArangoDB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FormRepositoryArangoImpl
import com.arangodb.ArangoDB; //导入依赖的package包/类
public FormRepositoryArangoImpl() {
arangoDB = new ArangoDB.Builder()
.host(config.getHost(), config.getPort())
.user(config.getUser())
.password(config.getPassword())
.registerModule(new VPackJdk8Module())
.build();
// if first time connect to the arango, create menu database.
if(!arangoDB.getDatabases().contains(config.getFormDBName())) {
arangoDB.createDatabase(config.getFormDBName());
db = arangoDB.db(config.getFormDBName());
// add form collection with unique indexes
CollectionEntity formCollection = db.createCollection(FORM);
final Collection<String> fields = new ArrayList<String>();
fields.add(ID);
HashIndexOptions options = new HashIndexOptions();
options.unique(true);
db.collection(FORM).createHashIndex(fields, options);
}
if(db == null) db = arangoDB.db(config.getFormDBName());
}
示例2: open
import com.arangodb.ArangoDB; //导入依赖的package包/类
@Override
public void open() {
try {
final ArangoDB.Builder builder = new ArangoDB.Builder()
.host(getProperty(ARANGODB_HOST), Integer.parseInt(getProperty(ARANGODB_PORT)));
if (!StringUtils.isEmpty(getProperty(ARANGODB_USER))) {
builder.user(getProperty(ARANGODB_USER)).password(getProperty(ARANGODB_PWD));
}
arango = builder.build();
}
catch (final Exception e) {
LOGGER.error("Open connection with ArangoDB", e);
}
}
示例3: init
import com.arangodb.ArangoDB; //导入依赖的package包/类
protected static void init(String dbName) {
AbstractArangoDbInterpreterTest.dbName = dbName;
arango = new ArangoDB.Builder()
.host(HOST, PORT)
.user(USERNAME).password(PASSWORD)
.build();
try {
arango.db(dbName).drop();
}
catch (final ArangoDBException e) {}
arango.createDatabase(dbName);
final Properties props = new Properties();
props.put(ArangoDbInterpreter.ARANGODB_HOST, HOST);
props.put(ArangoDbInterpreter.ARANGODB_PORT, "" + PORT);
props.put(ArangoDbInterpreter.ARANGODB_DATABASE, dbName);
props.put(ArangoDbInterpreter.ARANGODB_USER, USERNAME);
props.put(ArangoDbInterpreter.ARANGODB_PWD, PASSWORD);
interpreter = new ArangoDbInterpreter(props);
interpreter.open();
}
示例4: connect
import com.arangodb.ArangoDB; //导入依赖的package包/类
@Test
@Ignore
public void connect() throws Exception {
final KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(this.getClass().getResourceAsStream(SSL_TRUSTSTORE), SSL_TRUSTSTORE_PASSWORD.toCharArray());
final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, SSL_TRUSTSTORE_PASSWORD.toCharArray());
final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
final SSLContext sc = SSLContext.getInstance("TLS");
sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
final ArangoDB arangoDB = new ArangoDB.Builder()
.loadProperties(SslExample.class.getResourceAsStream("/arangodb-ssl.properties")).useSsl(true)
.sslContext(sc).build();
final ArangoDBVersion version = arangoDB.getVersion();
assertThat(version, is(notNullValue()));
}
示例5: init
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void init() {
if (arangoDB == null) {
arangoDB = new ArangoDB.Builder().build();
}
try {
arangoDB.db(TEST_DB).drop();
} catch (final ArangoDBException e) {
}
arangoDB.createDatabase(TEST_DB);
BaseGraphTest.db = arangoDB.db(TEST_DB);
final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<EdgeDefinition>();
final EdgeDefinition edgeDefinition = new EdgeDefinition().collection(EDGE_COLLECTION_NAME)
.from(VERTEXT_COLLECTION_NAME).to(VERTEXT_COLLECTION_NAME);
edgeDefinitions.add(edgeDefinition);
try {
db.createGraph(GRAPH_NAME, edgeDefinitions, null);
addExampleElements();
} catch (final ArangoDBException ex) {
}
}
示例6: createClient
import com.arangodb.ArangoDB; //导入依赖的package包/类
protected ArangoDB createClient() {
ArangoDB.Builder builder;
try {
builder = createClientBuilder();
} catch (Exception ex) {
throw new RuntimeException("Failed create ArangoDB: " + ex.getMessage(), ex);
}
builder.registerModule(new VPackFebitModule());
ArangoDB db = builder.build();
return db;
}
示例7: createArango
import com.arangodb.ArangoDB; //导入依赖的package包/类
@OnScheduled
public final void createArango(ProcessContext context) throws IOException {
if (arangoDB != null) {
closeArango();
}
final String host = context.getProperty(HOST).getValue();
final int port = context.getProperty(PORT).asInteger();
final String user = context.getProperty(USERNAME).getValue();
final String password = context.getProperty(PASSWORD).getValue();
arangoDB = new ArangoDB.Builder().host(host).port(port).user(user).password(password).build();
getLogger().info("Creating ArangoDB Connection");
}
示例8: setUp
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
arangoDB = new ArangoDB.Builder().build();
try {
arangoDB.db(DB_NAME).drop();
} catch (final ArangoDBException e) {
}
arangoDB.createDatabase(DB_NAME);
db = arangoDB.db(DB_NAME);
db.createCollection(COLLECTION_NAME);
collection = db.collection(COLLECTION_NAME);
}
示例9: setUp
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
arangoDB = new ArangoDB.Builder().build();
try {
arangoDB.db(TEST_DB).drop();
} catch (final ArangoDBException e) {
}
arangoDB.createDatabase(TEST_DB);
db = arangoDB.db(TEST_DB);
createData();
}
示例10: setup
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void setup() {
final InternalArangoDB<ArangoExecutorSync, Response, ConnectionSync> arangoDB = new ArangoDB.Builder().build();
util = arangoDB.util();
}
示例11: client
import com.arangodb.ArangoDB; //导入依赖的package包/类
public ArangoDB client() {
return LAZY_CLIENT.get();
}
示例12: MenuRepositoryArangoImpl
import com.arangodb.ArangoDB; //导入依赖的package包/类
public MenuRepositoryArangoImpl() {
arangoDB = new ArangoDB.Builder()
.host(config.getHost(), config.getPort())
.user(config.getUser())
.password(config.getPassword())
.registerModule(new VPackJdk8Module())
.build();
// if first time connect to the arango, create menu database.
if(!arangoDB.getDatabases().contains(config.getMenuDBName())) {
arangoDB.createDatabase(config.getMenuDBName());
db = arangoDB.db(config.getMenuDBName());
// add two collections with unique indexes
CollectionEntity menuCollection = db.createCollection(MENU);
final Collection<String> fields = new ArrayList<String>();
fields.add(ENTITYID);
HashIndexOptions options = new HashIndexOptions();
options.unique(true);
db.collection(MENU).createHashIndex(fields, options);
CollectionEntity menuItemCollection = db.createCollection(MENUITEM);
db.collection(MENUITEM).createHashIndex(fields, options);
// add graph
Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>();
EdgeDefinition edgeDefinition = new EdgeDefinition();
edgeDefinition.collection(CONTAINS);
edgeDefinition.from(MENU, MENUITEM);
edgeDefinition.to(MENUITEM);
edgeDefinitions.add(edgeDefinition);
db.createGraph(CONTAINSGRAPH, edgeDefinitions);
// create a function
db.createAqlFunction("LIGHTAPI::COMMON::AGGREGATE_PATH",
"function (flat) {\n" +
" var result = flat[0][0];\n" +
" if (flat) {\n" +
" flat.forEach(function (path) {\n" +
" for(var i = path.length -1; i > 0; i--) {\n" +
" path[i-1].contains = new Array();\n" +
" path[i-1].contains.push(path[i]);\n" +
" }\n" +
" });\n" +
" }\n" +
" function includes(a, o) {\n" +
" var found;\n" +
" a.forEach(function (e) {\n" +
" if(e._key === o._key) {\n" +
" found = e;\n" +
" }\n" +
" });\n" +
" return found;\n" +
" }\n" +
" function mergeObjects(target, source) {\n" +
" if(target && target.contains) {\n" +
" if(source.contains) {\n" +
" source.contains.forEach(function(v) {\n" +
" var e = includes(target.contains, v);\n" +
" if(!e) {\n" +
" target.contains.push(v);\n" +
" } else {\n" +
" mergeObjects(e, v);\n" +
" }\n" +
" });\n" +
" }\n" +
" } else {\n" +
" if(target && source.contains) {\n" +
" target.contains = source.contains;\n" +
" }\n" +
" }\n" +
" }\n" +
" for(var j= flat.length -1; j >= 0; j--) {\n" +
" mergeObjects(result, flat[j][0]);\n" +
" }\n" +
" return result;\n" +
" }\n", null);
}
if(db == null) db = arangoDB.db(config.getMenuDBName());
}
示例13: setDataSource
import com.arangodb.ArangoDB; //导入依赖的package包/类
@Override
public void setDataSource(Object object) {
this.arangoDB = (ArangoDB)object;
}
示例14: setUp
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
arangoDB = (ArangoDB)menuQueryRepository.getDataSource();
// add testing data
}
示例15: setUp
import com.arangodb.ArangoDB; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
arangoDB = (ArangoDB)formQueryRepository.getDataSource();
// add testing data
}