Esempio n. 1
0
 // -------
 // Helpers
 // -------
 private DBEPersistAction buildCommentAction(DB2Table db2Table) {
   if (CommonUtils.isNotEmpty(db2Table.getDescription())) {
     String commentSQL =
         String.format(SQL_COMMENT, db2Table.getFullQualifiedName(), db2Table.getDescription());
     return new SQLDatabasePersistAction(CMD_COMMENT, commentSQL);
   } else {
     return null;
   }
 }
Esempio n. 2
0
  @Override
  @SuppressWarnings("rawtypes")
  public void appendTableModifiers(
      DB2Table db2Table, NestedObjectCommand tableProps, StringBuilder ddl) {

    try {
      // Add Tablespaces infos
      if (db2Table.getTablespace(VoidProgressMonitor.INSTANCE) != null) {
        ddl.append(LINE_SEPARATOR);
        ddl.append(CLAUSE_IN_TS);
        ddl.append(getTablespaceName(db2Table.getTablespace(VoidProgressMonitor.INSTANCE)));
      }
      if (db2Table.getIndexTablespace(VoidProgressMonitor.INSTANCE) != null) {
        ddl.append(LINE_SEPARATOR);
        ddl.append(CLAUSE_IN_TS_IX);
        ddl.append(getTablespaceName(db2Table.getIndexTablespace(VoidProgressMonitor.INSTANCE)));
      }
      if (db2Table.getLongTablespace(VoidProgressMonitor.INSTANCE) != null) {
        ddl.append(LINE_SEPARATOR);
        ddl.append(CLAUSE_IN_TS_LONG);
        ddl.append(getTablespaceName(db2Table.getLongTablespace(VoidProgressMonitor.INSTANCE)));
      }
    } catch (DBException e) {
      // Never be here
      log.warn(e);
    }
  }
Esempio n. 3
0
  @Override
  public DBEPersistAction[] makeObjectModifyActions(ObjectChangeCommand command) {
    DB2Table db2Table = command.getObject();

    List<DBEPersistAction> actions = new ArrayList<>(2);

    if (command.getProperties().size() > 1) {
      StringBuilder sb = new StringBuilder(128);
      sb.append(SQL_ALTER);
      sb.append(db2Table.getFullQualifiedName());
      sb.append(" ");

      appendTableModifiers(command.getObject(), command, sb);

      actions.add(new SQLDatabasePersistAction(CMD_ALTER, sb.toString()));
    }

    DBEPersistAction commentAction = buildCommentAction(db2Table);
    if (commentAction != null) {
      actions.add(commentAction);
    }

    return actions.toArray(new DBEPersistAction[actions.size()]);
  }
Esempio n. 4
0
 @Nullable
 @Override
 public DBSObjectCache<DB2Schema, DB2Table> getObjectsCache(DB2Table object) {
   return object.getSchema().getTableCache();
 }