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


Java OCommandExecutionException类代码示例

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


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

示例1: buildIndexDeclaration

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
/** Builds a DB index declaration. */
private void buildIndexDeclaration(String indexType, List<String> propertyKeys) {
    
    for(String key : propertyKeys) {
        try {
            // Make up a name
            String indexName = generateIndexName();        
            String declaration = String.format("CREATE INDEX %s ON V (%s) %s", indexName, key, indexType);
            ((OrientDBConnection)dbConnection).<Integer>executeSQL(declaration);
            ((OrientDBConnection)dbConnection).commit();
        } catch (OCommandExecutionException e) {
            // Intercept error so we can report it
            String stackTrace = getStackTrace(e);
            logger.error(String.format("Failed to create index for '%s'", key));
            logger.error(stackTrace); 
            
            // Re-throw up the stack
            throw e;
        }
    }
    
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:23,代码来源:IndexDefinitionsToOrientDB.java

示例2: getPropertyNamesFromDB

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
/**
 * identify the names of the properties that were made specific to the indexes
 * @return
 */
public Set<String> getPropertyNamesFromDB() {
    Set<String> dbPropertyNames = new HashSet<String>();

    String query = "SELECT field FROM (SELECT expand(indexDefinition) FROM (SELECT expand(indexes) FROM metadata:indexmanager))";
    try {
        OrientDynaElementIterable qiterable=((OrientDBConnection)dbConnection).<OrientDynaElementIterable>executeSQL(query);
        if (qiterable != null) { // Don't know if this can happen, but just in case
            Iterator<Object> iter = qiterable.iterator();
            while (iter.hasNext()) {
                OrientVertex v = (OrientVertex) iter.next();
                String fieldName = (String)v.getProperty("field");
                dbPropertyNames.add(fieldName);
            }
        }
    } catch (OCommandExecutionException e) {
        // Intercept error to print debug info
        e.printStackTrace();
        // Re-throw up the stack
        throw e;
    }
    return dbPropertyNames;
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:27,代码来源:IndexDefinitionsToOrientDB.java

示例3: createFunction

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
@Override
public OSQLFunction createFunction(String name) throws OCommandExecutionException {
  final Object obj = FUNCTIONS.get(name);

  if (obj == null)
    throw new OCommandExecutionException("Unknown function name :" + name);

  if (obj instanceof OSQLFunction)
    return (OSQLFunction) obj;
  else {
    // it's a class
    final Class<?> clazz = (Class<?>) obj;
    try {
      return (OSQLFunction) clazz.newInstance();
    } catch (Exception e) {
      throw OException.wrapException(new OCommandExecutionException("Error in creation of function " + name
          + "(). Probably there is not an empty constructor or the constructor generates errors"), e);
    }
  }

}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:22,代码来源:OSpatialFunctionsFactory.java

示例4: createFunction

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
@Override
public OSQLFunction createFunction(String name) throws OCommandExecutionException {
  final Object obj = FUNCTIONS.get(name);

  if (obj == null)
    throw new OCommandExecutionException("Unknown function name :" + name);

  if (obj instanceof OSQLFunction)
    return (OSQLFunction) obj;
  else {
    // it's a class
    final Class<?> clazz = (Class<?>) obj;
    try {
      return (OSQLFunction) clazz.newInstance();
    } catch (Exception e) {
      throw new OCommandExecutionException("Error in creation of function " + name
          + "(). Probably there is not an empty constructor or the constructor generates errors", e);
    }
  }

}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:22,代码来源:OLuceneFunctionsFactory.java

示例5: executeSQL

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
/**
 *  Runs SQL query to do things like create properties, indexes, etc...
 * @param query
 * @return
 */
<T> T executeSQL(String query) {
    try {
        OCommandSQL sql = new OCommandSQL(query);
        OCommandRequest ocr = graphDB.command(sql);
        T obj = ocr.<T>execute();
        return obj;
    } catch (OCommandExecutionException e)
    {
        throw new StuccoDBException(e);
    }
    
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:18,代码来源:OrientDBConnection.java

示例6: buildPropertyDeclarations

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
/**
 * Builds OrientDB declaration for the properties used in an index.
 * 
 * @param keys           The keys in JSON form
 * @param propertyNames  (OUT) The names of the keys, returned by side effect
 * 
 * @return OrientDB declaration of properties
 */
private String buildPropertyDeclarations(JSONArray keys, List<String> propertyNames) {
    StringBuilder declarations = new StringBuilder();
    
    // For each key
    int keyCount = keys.length();
    for (int i = 0; i < keyCount; i++) {
        JSONObject keySpec = keys.getJSONObject(i);
        
        // Get the property name
        String property = keySpec.getString(NAME);
        propertyNames.add(property);
        
        // Get the class type, defaulting to String
        String classType = keySpec.optString(CLASS);
        if (classType == null) {
            classType = STRING;
        }
        
        try {
            // Make the property declaration for the key
            String declaration = buildPropertyDeclaration(property, classType);
            ((OrientDBConnection)dbConnection).<OrientDynaElementIterable>executeSQL(declaration);
            ((OrientDBConnection)dbConnection).commit();
            declarations.append(declaration);
        } catch (OCommandExecutionException e) {
            // Intercept error to print debug info
            String stackTrace = getStackTrace(e);
            logger.error(String.format("Failed to generate property '%s'", property));
            logger.error(stackTrace);
            
            // Re-throw up the stack
            throw e;
        }
    }
    
    return declarations.toString();
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:46,代码来源:IndexDefinitionsToOrientDB.java

示例7: updateVertProperty

import com.orientechnologies.orient.core.exception.OCommandExecutionException; //导入依赖的package包/类
private void updateVertProperty(String id, String key, Object val) throws OCommandExecutionException{ 
    updateVertexProperty(id, key, val);
}
 
开发者ID:stucco,项目名称:graph-db-connection,代码行数:4,代码来源:OrientDBConnection.java


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