Java Code Examples for org.eclipse.collections.api.list.MutableList#addAll()

The following examples show how to use org.eclipse.collections.api.list.MutableList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaselineTableChangeParser.java    From obevo with Apache License 2.0 6 votes vote down vote up
private MutableList<String> sortSqls(MutableList<String> sqls) {
    MutableList<String> orderedSqls = Lists.mutable.empty();
    MutableList<String> fkSqls = Lists.mutable.empty();
    MutableList<String> triggerSqls = Lists.mutable.empty();

    for (String sql : sqls) {
        Matcher matcher = RegexpPatterns.fkPattern.matcher(sql);
        Matcher triggerMatcher = RegexpPatterns.triggerPattern.matcher(sql);
        if (matcher.find()) {
            fkSqls.add(sql);
        } else if (triggerMatcher.find()) {
            triggerSqls.add(sql);
        } else {
            orderedSqls.add(sql);
        }
    }

    orderedSqls.addAll(fkSqls);
    orderedSqls.addAll(triggerSqls);
    return orderedSqls;
}
 
Example 2
Source File: RerunnableChangeTypeCommandCalculator.java    From obevo with Apache License 2.0 5 votes vote down vote up
/**
 * TODO for rerunnable to support a better change group:
 * -add dependent changes where applicable (e.g. views, sps, functions, but not static data)
 * -group the related changes as needed
 * -create the change for each group
 */
private ImmutableList<ChangeCommand> processRerunnableChanges(ChangeType changeType,
        RerunnableObjectInfo rerunnableObjectInfo,
        RichIterable<Change> fromSourceList) {
    final MutableList<ChangeCommand> commands = Lists.mutable.empty();

    commands.addAll(rerunnableObjectInfo.getDroppedObjects().collect(new Function<Change, ExecuteChangeCommand>() {
        @Override
        public ExecuteChangeCommand valueOf(Change droppedObject) {
            return changeCommandFactory.createRemove(droppedObject).withDrop(true);
        }
    }));

    if (changeType.isDependentObjectRecalculationRequired()) {
        commands.addAll(getObjectChangesRequiringRecompilation(changeType, fromSourceList, rerunnableObjectInfo.getChangedObjects()
                .reject(new Predicate<Change>() {
                    @Override
                    public boolean accept(Change change1) {
                        return change1.isCreateOrReplace();
                    }
                }))
                .collect(new Function<Change, ExecuteChangeCommand>() {
                    @Override
                    public ExecuteChangeCommand valueOf(Change change) {
                        return changeCommandFactory.createDeployCommand(change, "Re-deploying this object due to change in dependent object [" + change.getObjectName() + "]");
                    }
                }));
    }

    commands.addAll(rerunnableObjectInfo.getChangedObjects().collect(new Function<Change, ExecuteChangeCommand>() {
        @Override
        public ExecuteChangeCommand valueOf(Change source) {
            return changeCommandFactory.createDeployCommand(source);
        }
    }));

    return commands.toImmutable();
}
 
Example 3
Source File: MultiLineStringSplitter.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public MutableList<String> valueOf(String inputString) {
    inputString += "\n";  // add sentinel to facilitate line split

    MutableList<SqlToken> sqlTokens = this.tokenParser.parseTokens(inputString);
    sqlTokens = this.collapseWhiteSpaceAndTokens(sqlTokens);

    MutableList<String> finalSplitStrings = Lists.mutable.empty();
    String currentSql = "";

    for (SqlToken sqlToken : sqlTokens) {
        if (sqlToken.getTokenType() == SqlTokenType.COMMENT || sqlToken.getTokenType() == SqlTokenType.STRING) {
            currentSql += sqlToken.getText();
        } else {
            String pattern = splitOnWholeLine ? "(?i)^" + this.splitToken + "$" : this.splitToken;
            MutableList<String> splitStrings =
                    Lists.mutable.with(Pattern.compile(pattern, Pattern.MULTILINE).split(sqlToken.getText()));
            if (splitStrings.isEmpty()) {
                // means that we exactly match
                finalSplitStrings.add(currentSql);
                currentSql = "";
            } else if (splitStrings.size() == 1) {
                currentSql += sqlToken.getText();
            } else {
                splitStrings.set(0, currentSql + splitStrings.get(0));

                if (splitOnWholeLine) {
                    if (splitStrings.size() > 1) {
                        splitStrings.set(0, StringUtils.chomp(splitStrings.get(0)));
                        for (int i = 1; i < splitStrings.size(); i++) {
                            String newSql = splitStrings.get(i);
                            if (newSql.startsWith("\n")) {
                                newSql = newSql.replaceFirst("^\n", "");
                            } else if (newSql.startsWith("\r\n")) {
                                newSql = newSql.replaceFirst("^\r\n", "");
                            }

                            // Chomping the end of each sql due to the split of the GO statement
                            if (i < splitStrings.size() - 1) {
                                newSql = StringUtils.chomp(newSql);
                            }
                            splitStrings.set(i, newSql);
                        }
                    }
                }

                finalSplitStrings.addAll(splitStrings.subList(0, splitStrings.size() - 1));
                currentSql = splitStrings.getLast();
            }
        }
    }

    if (!currentSql.isEmpty()) {
        finalSplitStrings.add(currentSql);
    }

    // accounting for the sentinel
    if (finalSplitStrings.getLast().isEmpty()) {
        finalSplitStrings.remove(finalSplitStrings.size() - 1);
    } else {
        finalSplitStrings.set(finalSplitStrings.size() - 1, StringUtils.chomp(finalSplitStrings.getLast()));
    }

    return finalSplitStrings;
}