Пример #1
0
  public static DataType parse(String typeString) {
    typeString = StringUtil.trimToEmpty(typeString);

    DataType dataType = new DataType();
    Matcher nameMatcher = Pattern.compile("^(\\w+)").matcher(typeString);
    if (nameMatcher.find()) {
      dataType.name = nameMatcher.group(1);
    } else {
      return dataType;
    }

    Matcher matcher = Pattern.compile("(.*)\\((.*)\\)(.*)").matcher(typeString);
    if (matcher.find()) {
      String beforeParens = matcher.group(1);
      String inParens = matcher.group(2);
      String afterParens = matcher.group(3);
      List<String> params = StringUtil.splitAndTrim(inParens, "\\s*,\\s*");
      dataType.parameters = params;
      dataType.clausesBeforeParameters =
          new StringClauses(" ")
              .append(StringUtil.trimToNull(beforeParens.substring(dataType.name.length())));
      dataType.clausesAfterParameters = new StringClauses(" ").append(afterParens);
    } else {
      dataType.clausesBeforeParameters =
          new StringClauses(" ")
              .append(StringUtil.trimToNull(typeString.substring(dataType.name.length())));
    }

    dataType.standardType = standardType(dataType.name);
    if (dataType.standardType != null) {
      dataType.valueType = dataType.standardType.valueType;
    }
    return dataType;
  }
  @Override
  public void removeFromHistory(String id, String author, String logicalPath, Scope scope)
      throws LiquibaseException {
    if (id == null || author == null || logicalPath == null) {
      throw new IllegalArgumentException("removeFromHistory requires id, author, and logicalPath");
    }

    DeleteDataAction action = new DeleteDataAction();
    action.relation = this.changeLogTable;

    DataType stringType = DataType.forType(String.class);
    DataTypeLogic stringDataTypeLogic =
        scope.getSingleton(DataTypeLogicFactory.class).getDataTypeLogic(stringType, scope);

    action.where.append(correctCase("id") + "=" + stringDataTypeLogic.toSql(id, stringType, scope));
    action.where.append(
        correctCase("author") + "=" + stringDataTypeLogic.toSql(author, stringType, scope));
    action.where.append(
        correctCase("filename") + "=" + stringDataTypeLogic.toSql(logicalPath, stringType, scope));

    scope.getSingleton(ActionExecutor.class).execute(action, scope);
  }