Examples of DatabaseType


Examples of com.compomics.util.protein.Header.DatabaseType

            try {
                if (!sequenceFactory.isDecoyAccession(proteins.get(i)) && sequenceFactory.getHeader(proteinAccession) != null) {

                    // try to find the database from the SequenceDatabase
                    DatabaseType database = sequenceFactory.getHeader(proteinAccession).getDatabaseType();

                    // create the database link
                    if (database != null) {

                        // @TODO: support more databases
View Full Code Here

Examples of com.gmail.nossr50.datatypes.database.DatabaseType

public class ConvertDatabaseCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        switch (args.length) {
            case 2:
                DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
                DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();

                if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
                    sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
                    return true;
                }

                DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);

                if (previousType == DatabaseType.CUSTOM) {
                    Class<?> clazz;

                    try {
                        clazz = Class.forName(args[1]);

                        if (!DatabaseManager.class.isAssignableFrom(clazz)) {
                            sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
                            return true;
                        }

                        oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
                    }
                    catch (Throwable e) {
                        e.printStackTrace();
                        sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
                        return true;
                    }
                }

                sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));

                UserManager.saveAll();
                UserManager.clearAll();

                for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
                    PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());

                    if (profile.isLoaded()) {
                        mcMMO.getDatabaseManager().saveUser(profile);
                    }

                    new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
                }

                new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
                return true;

            default:
                return false;
        }
View Full Code Here

Examples of com.hp.hpl.jena.sdb.store.DatabaseType

            desc.connDesc.setType(desc.getDbType().getName()) ;
       
        if ( sdb == null && desc.connDesc != null)
            sdb = SDBConnectionFactory.create(desc.connDesc) ;
       
        DatabaseType dbType = desc.getDbType() ;
        LayoutType layoutType = desc.getLayout() ;
       
        return _create(desc, sdb, dbType, layoutType) ;
    }
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

   * You should use {@link FieldType#createFieldType} to instantiate one of these field if you have a {@link Field}.
   */
  public FieldType(ConnectionSource connectionSource, String tableName, Field field, DatabaseFieldConfig fieldConfig,
      Class<?> parentClass) throws SQLException {
    this.connectionSource = connectionSource;
    DatabaseType databaseType = connectionSource.getDatabaseType();
    this.field = field;
    Class<?> clazz = field.getType();
    DataPersister dataPersister;
    if (fieldConfig.getDataPersister() == null) {
      Class<? extends DataPersister> persisterClass = fieldConfig.getPersisterClass();
      if (persisterClass == null || persisterClass == VoidType.class) {
        dataPersister = DataPersisterManager.lookupForField(field);
      } else {
        Method method;
        try {
          method = persisterClass.getDeclaredMethod("getSingleton");
        } catch (Exception e) {
          throw SqlExceptionUtil.create("Could not find getSingleton static method on class "
              + persisterClass, e);
        }
        Object result;
        try {
          result = (DataPersister) method.invoke(null);
        } catch (InvocationTargetException e) {
          throw SqlExceptionUtil.create("Could not run getSingleton method on class " + persisterClass,
              e.getTargetException());
        } catch (Exception e) {
          throw SqlExceptionUtil.create("Could not run getSingleton method on class " + persisterClass, e);
        }
        if (result == null) {
          throw new SQLException("Static getSingleton method should not return null on class "
              + persisterClass);
        }
        try {
          dataPersister = (DataPersister) result;
        } catch (Exception e) {
          throw new SQLException(
              "Could not cast result of static getSingleton method to DataPersister from class "
                  + persisterClass);
        }
      }
    } else {
      dataPersister = fieldConfig.getDataPersister();
      if (!dataPersister.isValidForField(field)) {
        throw new IllegalArgumentException("Field class " + clazz + " for field " + this
            + " is not valid for data persister " + dataPersister);
      }
    }
    String defaultFieldName = field.getName();
    if (fieldConfig.isForeign() || fieldConfig.isForeignAutoRefresh()) {
      if (dataPersister != null && dataPersister.isPrimitive()) {
        throw new IllegalArgumentException("Field " + this + " is a primitive class " + clazz
            + " but marked as foreign");
      }
      defaultFieldName = defaultFieldName + FOREIGN_ID_FIELD_SUFFIX;
    } else if (fieldConfig.isForeignCollection()) {
      if (clazz != Collection.class && !ForeignCollection.class.isAssignableFrom(clazz)) {
        throw new SQLException("Field class for '" + field.getName() + "' must be of class "
            + ForeignCollection.class.getSimpleName() + " or Collection.");
      }
      Type type = field.getGenericType();
      if (!(type instanceof ParameterizedType)) {
        throw new SQLException("Field class for '" + field.getName() + "' must be a parameterized Collection.");
      }
      Type[] genericArguments = ((ParameterizedType) type).getActualTypeArguments();
      if (genericArguments.length == 0) {
        // i doubt this will ever be reached
        throw new SQLException("Field class for '" + field.getName()
            + "' must be a parameterized Collection with at least 1 type.");
      }
    } else if (dataPersister == null && (!fieldConfig.isForeignCollection())) {
      if (byte[].class.isAssignableFrom(clazz)) {
        throw new SQLException("ORMLite can't store unknown class " + clazz + " for field '" + field.getName()
            + "'. byte[] fields must specify dataType=DataType.BYTE_ARRAY or SERIALIZABLE");
      } else if (Serializable.class.isAssignableFrom(clazz)) {
        throw new SQLException("ORMLite can't store unknown class " + clazz + " for field '" + field.getName()
            + "'. Serializable fields must specify dataType=DataType.SERIALIZABLE");
      } else {
        throw new IllegalArgumentException("ORMLite does not know how to store field class " + clazz
            + " for field " + this);
      }
    }
    if (fieldConfig.getColumnName() == null) {
      this.dbColumnName = defaultFieldName;
    } else {
      this.dbColumnName = fieldConfig.getColumnName();
    }
    this.fieldConfig = fieldConfig;
    if (fieldConfig.isId()) {
      if (fieldConfig.isGeneratedId() || fieldConfig.getGeneratedIdSequence() != null) {
        throw new IllegalArgumentException("Must specify one of id, generatedId, and generatedIdSequence with "
            + field.getName());
      }
      this.isId = true;
      this.isGeneratedId = false;
      this.generatedIdSequence = null;
    } else if (fieldConfig.isGeneratedId()) {
      if (fieldConfig.getGeneratedIdSequence() != null) {
        throw new IllegalArgumentException("Must specify one of id, generatedId, and generatedIdSequence with "
            + field.getName());
      }
      this.isId = true;
      this.isGeneratedId = true;
      if (databaseType.isIdSequenceNeeded()) {
        this.generatedIdSequence = databaseType.generateIdSequenceName(tableName, this);
      } else {
        this.generatedIdSequence = null;
      }
    } else if (fieldConfig.getGeneratedIdSequence() != null) {
      this.isId = true;
      this.isGeneratedId = true;
      String seqName = fieldConfig.getGeneratedIdSequence();
      if (databaseType.isEntityNamesMustBeUpCase()) {
        seqName = seqName.toUpperCase();
      }
      this.generatedIdSequence = seqName;
    } else {
      this.isId = false;
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

   *
   * @see BaseDaoImpl#initialize()
   */
  public void configDaoInformation(ConnectionSource connectionSource, Class<?> parentClass) throws SQLException {
    Class<?> clazz = field.getType();
    DatabaseType databaseType = connectionSource.getDatabaseType();
    TableInfo<?, ?> foreignTableInfo;
    final FieldType foreignIdField;
    final Constructor<?> foreignConstructor;
    final FieldType foreignFieldType;
    final Dao<?, ?> foreignDao;
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

  /**
   * Return An instantiated {@link FieldType} or null if the field does not have a {@link DatabaseField} annotation.
   */
  public static FieldType createFieldType(ConnectionSource connectionSource, String tableName, Field field,
      Class<?> parentClass) throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    DatabaseFieldConfig fieldConfig = DatabaseFieldConfig.fromField(databaseType, tableName, field);
    if (fieldConfig == null) {
      return null;
    } else {
      return new FieldType(connectionSource, tableName, field, fieldConfig, parentClass);
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

   *            If set to true then try each statement regardless of {@link SQLException} thrown previously.
   * @return The number of statements executed to do so.
   */
  public static <T, ID> int dropTable(ConnectionSource connectionSource, Class<T> dataClass, boolean ignoreErrors)
      throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    Dao<T, ID> dao = DaoManager.createDao(connectionSource, dataClass);
    if (!(dao instanceof BaseDaoImpl<?, ?>)) {
      TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(connectionSource, null, dataClass);
      return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
    } else {
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

   *            If set to true then try each statement regardless of {@link SQLException} thrown previously.
   * @return The number of statements executed to do so.
   */
  public static <T, ID> int dropTable(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig,
      boolean ignoreErrors) throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    Dao<T, ID> dao = DaoManager.createDao(connectionSource, tableConfig);
    if (!(dao instanceof BaseDaoImpl<?, ?>)) {
      tableConfig.extractFieldTypes(connectionSource);
      TableInfo<T, ID> tableInfo = new TableInfo<T, ID>(databaseType, null, tableConfig);
      return doDropTable(databaseType, connectionSource, tableInfo, ignoreErrors);
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

      return doCreateTable(connectionSource, ((BaseDaoImpl<?, ?>) dao).getTableInfo(), ifNotExists);
    }
  }

  private static <T> int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    StringBuilder sb = new StringBuilder(48);
    if (databaseType.isTruncateSupported()) {
      sb.append("TRUNCATE TABLE ");
    } else {
      sb.append("DELETE FROM ");
    }
    databaseType.appendEscapedEntityName(sb, tableName);
    String statement = sb.toString();
    logger.info("clearing table '{}' with '{}", tableName, statement);
    CompiledStatement compiledStmt = null;
    try {
      compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes);
View Full Code Here

Examples of com.j256.ormlite.db.DatabaseType

    statements.addAll(statementsAfter);
  }

  private static <T, ID> int doCreateTable(ConnectionSource connectionSource, TableInfo<T, ID> tableInfo,
      boolean ifNotExists) throws SQLException {
    DatabaseType databaseType = connectionSource.getDatabaseType();
    logger.info("creating table '{}'", tableInfo.getTableName());
    List<String> statements = new ArrayList<String>();
    List<String> queriesAfter = new ArrayList<String>();
    addCreateTableStatements(databaseType, tableInfo, statements, queriesAfter, ifNotExists);
    DatabaseConnection connection = connectionSource.getReadWriteConnection();
    try {
      int stmtC = doStatements(connection, "create", statements, false, databaseType.isCreateTableReturnsZero());
      stmtC += doCreateTestQueries(connection, databaseType, queriesAfter);
      return stmtC;
    } finally {
      connectionSource.releaseConnection(connection);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.