示例#1
0
  @Override
  public void load(ParsedNode node, ResourceAccessor resourceAccessor) throws ParsedNodeException {
    this.id = node.getChildValue(null, "id", String.class);
    this.author = node.getChildValue(null, "author", String.class);
    this.alwaysRun =
        node.getChildValue(null, "runAlways", node.getChildValue(null, "alwaysRun", false));
    this.runOnChange = node.getChildValue(null, "runOnChange", false);
    this.contexts = new ContextExpression(node.getChildValue(null, "context", String.class));
    this.labels =
        new Labels(StringUtils.trimToNull(node.getChildValue(null, "labels", String.class)));
    setDbms(node.getChildValue(null, "dbms", String.class));
    this.runInTransaction = node.getChildValue(null, "runInTransaction", true);
    this.created = node.getChildValue(null, "created", String.class);
    this.runOrder = node.getChildValue(null, "runOrder", String.class);
    this.comments =
        StringUtils.join(
            node.getChildren(null, "comment"),
            "\n",
            new StringUtils.StringUtilsFormatter() {
              @Override
              public String toString(Object obj) {
                if (((ParsedNode) obj).getValue() == null) {
                  return "";
                } else {
                  return ((ParsedNode) obj).getValue().toString();
                }
              }
            });
    this.comments = StringUtils.trimToNull(this.comments);

    String objectQuotingStrategyString =
        StringUtils.trimToNull(node.getChildValue(null, "objectQuotingStrategy", String.class));
    if (changeLog != null) {
      this.objectQuotingStrategy = changeLog.getObjectQuotingStrategy();
    }
    if (objectQuotingStrategyString != null) {
      this.objectQuotingStrategy = ObjectQuotingStrategy.valueOf(objectQuotingStrategyString);
    }

    if (this.objectQuotingStrategy == null) {
      this.objectQuotingStrategy = ObjectQuotingStrategy.LEGACY;
    }

    this.filePath =
        StringUtils.trimToNull(node.getChildValue(null, "logicalFilePath", String.class));
    if (filePath == null) {
      filePath = changeLog.getFilePath();
    }

    this.setFailOnError(node.getChildValue(null, "failOnError", Boolean.class));
    String onValidationFailString = node.getChildValue(null, "onValidationFail", "HALT");
    this.setOnValidationFail(ValidationFailOption.valueOf(onValidationFailString));

    for (ParsedNode child : node.getChildren()) {
      handleChildNode(child, resourceAccessor);
    }
  }
示例#2
0
 public Collection<ContextExpression> getInheritableContexts() {
   Collection<ContextExpression> expressions = new ArrayList<ContextExpression>();
   DatabaseChangeLog changeLog = getChangeLog();
   while (changeLog != null) {
     ContextExpression expression = changeLog.getContexts();
     if (expression != null && !expression.isEmpty()) {
       expressions.add(expression);
     }
     ContextExpression includeExpression = changeLog.getIncludeContexts();
     if (includeExpression != null && !includeExpression.isEmpty()) {
       expressions.add(includeExpression);
     }
     changeLog = changeLog.getParentChangeLog();
   }
   return Collections.unmodifiableCollection(expressions);
 }