public String getSourceType() {
   String typeName = source.getTypeName();
   if (source.getDataKind() == DBPDataKind.STRING) {
     typeName += "(" + source.getMaxLength() + ")";
   }
   return typeName;
 }
 void updateMappingType(DBRProgressMonitor monitor) throws DBException {
   switch (parent.getMappingType()) {
     case existing:
       {
         mappingType = DatabaseMappingType.unspecified;
         if (parent.getTarget() instanceof DBSEntity) {
           if (CommonUtils.isEmpty(targetName)) {
             targetName = source.getName();
           }
           target =
               DBUtils.findObject(
                   ((DBSEntity) parent.getTarget()).getAttributes(monitor), targetName);
           if (target != null) {
             mappingType = DatabaseMappingType.existing;
           } else {
             mappingType = DatabaseMappingType.create;
           }
         }
         break;
       }
     case create:
       mappingType = DatabaseMappingType.create;
       if (CommonUtils.isEmpty(targetName)) {
         targetName = source.getName();
       }
       break;
     case skip:
       mappingType = DatabaseMappingType.skip;
       break;
     default:
       mappingType = DatabaseMappingType.unspecified;
       break;
   }
 }
  public String getTargetType(DBPDataSource targetDataSource) {
    if (!CommonUtils.isEmpty(targetType)) {
      return targetType;
    }
    // TODO: make some smart data type matcher
    // Current solution looks like hack
    String typeName = source.getTypeName();
    DBPDataKind dataKind = source.getDataKind();
    if (targetDataSource instanceof DBPDataTypeProvider) {
      DBPDataTypeProvider dataTypeProvider = (DBPDataTypeProvider) targetDataSource;
      DBSDataType dataType = dataTypeProvider.getLocalDataType(typeName);
      if (dataType == null && typeName.equals("DOUBLE")) {
        dataType = dataTypeProvider.getLocalDataType("DOUBLE PRECISION");
        if (dataType != null) {
          typeName = dataType.getTypeName();
        }
      }
      if (dataType != null && dataType.getDataKind() != dataKind) {
        // Type mismatch
        dataType = null;
      }
      if (dataType == null) {
        // Type not supported by target database
        // Let's try to find something similar
        List<DBSDataType> possibleTypes = new ArrayList<>();
        for (DBSDataType type : dataTypeProvider.getLocalDataTypes()) {
          if (type.getDataKind() == dataKind) {
            possibleTypes.add(type);
          }
        }
        typeName = DBUtils.getDefaultDataTypeName(targetDataSource, dataKind);
        if (!possibleTypes.isEmpty()) {
          DBSDataType targetType = null;
          for (DBSDataType type : possibleTypes) {
            if (type.getName().equalsIgnoreCase(typeName)) {
              targetType = type;
              break;
            }
          }
          if (targetType == null) {
            targetType = possibleTypes.get(0);
          }
          typeName = targetType.getTypeName();
        }
      }
      if (dataType != null) {
        dataKind = dataType.getDataKind();
      }
    }

    String modifiers = SQLUtils.getColumnTypeModifiers(source, typeName, dataKind);
    if (modifiers != null) {
      typeName += modifiers;
    }
    return typeName;
  }