• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RichIterable类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.eclipse.collections.api.RichIterable的典型用法代码示例。如果您正苦于以下问题:Java RichIterable类的具体用法?Java RichIterable怎么用?Java RichIterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RichIterable类属于org.eclipse.collections.api包,在下文中一共展示了RichIterable类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getClassCompareInfos

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private MutableCollection<ClassCompareInfo> getClassCompareInfos(final Class clazz) {
    if (!this.classCompareInfoMap.containsKey(clazz)) {
        // We may have defined the comparison on a generalization (interface or superclass), so we check if there
        // are any compatible classes to check
        RichIterable<Class> realizedClasses = this.classCompareInfoMap.keysView().select(new Predicate<Class>() {
            @Override
            public boolean accept(Class each) {
                return each.isAssignableFrom(clazz);
            }
        });

        RichIterable<ClassCompareInfo> realizedClassCompareInfos = realizedClasses
                .flatCollect(new Function<Class, MutableCollection<ClassCompareInfo>>() {
                    @Override
                    public MutableCollection<ClassCompareInfo> valueOf(Class realizedClass) {
                        return DeepCompareUtil.this.classCompareInfoMap.get(realizedClass);
                    }
                });

        this.classCompareInfoMap.putAll(clazz, realizedClassCompareInfos.toList());
    }
    return this.classCompareInfoMap.get(clazz);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:24,
代码来源:DeepCompareUtil.java

示例2: determineChangeType

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private ChangeTypeInfo determineChangeType(final String wholeFileString) {
    RichIterable<ChangeTypeInfo> changeTypeInfos = this.patternMap.keyValuesView().collect(
            new Function<Pair<ChangeType, Pattern>, ChangeTypeInfo>() {
                @Override
                public ChangeTypeInfo valueOf(Pair<ChangeType, Pattern> object) {
                    Pair<Integer, String> contentInfo = getStartIndex(wholeFileString, object.getTwo());
                    return new ChangeTypeInfo(object.getOne()
                            , contentInfo.getOne()
                            , contentInfo.getTwo()
                    );
                }
            });
    ChangeTypeInfo chosenChangeTypeInfo = changeTypeInfos.minBy(ChangeTypeInfo.TO_START_INDEX);

    if (chosenChangeTypeInfo.getStartIndex() == Integer.MAX_VALUE) {
        return new ChangeTypeInfo(UnclassifiedChangeType.INSTANCE, Integer.MAX_VALUE, null);
    } else {
        return chosenChangeTypeInfo;
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:21,
代码来源:AquaRevengMain.java

示例3: getQualifiedObjectNames

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Functions need to be referred by their signatures for drops and grants in postgresql
 * For functions query info:
 * https://www.postgresql.org/docs/9.5/static/functions-info.html
 * https://www.postgresql.org/docs/9.5/static/catalog-pg-proc.html
 * https://www.postgresql.org/docs/9.5/static/catalog-pg-namespace.html
 */
@Override
public Pair<Boolean, RichIterable<String>> getQualifiedObjectNames(Connection conn, PhysicalSchema physicalSchema, String objectName) {
    String schemaName = getDbPlatform().convertDbObjectName().valueOf(physicalSchema.getPhysicalName());
    String functionNameWithCase = getDbPlatform().convertDbObjectName().valueOf(objectName);

    String sql = "select format('%s.%s(%s)',n.nspname, p.proname, pg_get_function_identity_arguments(p.oid)) " +
            "as functionname\n" +
            "FROM   pg_proc p\n" +
            "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" +
            "WHERE n.nspname = '" + schemaName + "' and p.proname = '" + functionNameWithCase + "'";

    List<Map<String, Object>> funcNameResults = getSqlExecutor().getJdbcTemplate().queryForList(conn, sql);

    MutableList<String> names = Lists.mutable.empty();
    for (Map<String, Object> funcNameResult : funcNameResults) {
        names.add((String) funcNameResult.get("functionname"));
    }

    return Tuples.<Boolean, RichIterable<String>>pair(false, names);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:28,
代码来源:PostgreSqlFunctionChangeTypeBehavior.java

示例4: recompileInvalidObjects

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private void recompileInvalidObjects(RichIterable<PhysicalSchema> physicalSchemas) {
    MutableList<String> warnings = Lists.mutable.empty();
    for (final PhysicalSchema physicalSchema : physicalSchemas) {
        try {
            this.stmtExecutor.executeWithinContext(physicalSchema, new Procedure<Connection>() {
                @Override
                public void value(Connection conn) {
                    stmtExecutor.getJdbcTemplate().update(conn, "CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS(NULL, '" + physicalSchema.getPhysicalName() + "', NULL)");
                }
            });
            LOG.info("Successfully recompiled objects in schema", physicalSchema);
        } catch (DataAccessException e) {
            warnings.add(physicalSchema.getPhysicalName() + ": " + e.getMessage());
            LOG.warn("Failed to recompile objects on schema {}; will not fail the overall deployment due to this", physicalSchema, e);
        }
    }

    if (warnings.notEmpty()) {
        deployMetricsCollector.addMetric(POST_DEPLOY_WARNINGS, "Failures on recompiling invalid objects: " + warnings.makeString("\n"));
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:22,
代码来源:Db2PostDeployAction.java

示例5: getSourceDirs

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public RichIterable<FileObject> getSourceDirs() {
    if (this.sourceDirs == null) {
        // only keep the distinct list of files here
        LinkedHashSet<FileObject> fileObjects = new LinkedHashSet<FileObject>();
        if (coreSourcePath != null) {
            fileObjects.add(coreSourcePath);
        }
        if (additionalSourceDirs != null) {
            fileObjects.addAll(additionalSourceDirs.flatCollect(new Function<String, Iterable<FileObject>>() {
                @Override
                public Iterable<FileObject> valueOf(String path) {
                    MutableList<FileObject> resolvedFileObjects = Lists.mutable.empty();
                    for (FileResolverStrategy fileResolverStrategy : fileResolverStrategies) {
                        resolvedFileObjects.addAllIterable(fileResolverStrategy.resolveFileObjects(path));
                    }
                    if (resolvedFileObjects.isEmpty()) {
                        throw new IllegalArgumentException("Unable to find the given path [" + path + "] via any of the fileResolverStrategies:" + fileResolverStrategies.makeString(", "));
                    }
                    return resolvedFileObjects;
                }
            }).toList());
        }
        this.sourceDirs = Lists.mutable.withAll(fileObjects);
    }
    return this.sourceDirs;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:27,
代码来源:Environment.java

示例6: convert

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public static Predicates<? super String> convert(ImmutableCollection<String> patterns) {
    if (patterns == null) {
        return Predicates.alwaysTrue();
    }
    PartitionIterable<String> wildcardPartition = patterns.partition(Predicates.or(StringPredicates.contains("*"), StringPredicates.contains("%")));
    RichIterable<String> wildcardPatterns = wildcardPartition.getSelected();
    RichIterable<WildcardPatternIndex> wildcardPatternIndexes = wildcardPatterns.collect(new Function<String, WildcardPatternIndex>() {
        @Override
        public WildcardPatternIndex valueOf(String pattern) {
            return new WildcardPatternIndex(pattern);
        }
    });

    RichIterable<String> lookupPatterns = wildcardPartition.getRejected();
    LookupIndex lookupIndex = lookupPatterns.notEmpty() ? new LookupIndex(lookupPatterns.toSet().toImmutable()) : null;

    MutableList<Index> indexes = Lists.mutable.empty();
    if (lookupIndex != null) {
        indexes.add(lookupIndex);
    }
    indexes.withAll(wildcardPatternIndexes);

    return Predicates.or(indexes);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:25,
代码来源:LookupPredicateBuilder.java

示例7: calculateDependencies

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public <T extends TextDependencyExtractable> void calculateDependencies(RichIterable<T> changes) {
    MutableSet<String> objectNames = changes.collect(Functions.chain(TextDependencyExtractable.TO_OBJECT_KEY, ObjectKey.TO_OBJECT_NAME)).collect(convertDbObjectName).toSet();

    for (T change : changes) {
        // note - only check for nulls here; we may set dependencies to blank explicitly in the overrides
        if (change.getCodeDependencies() == null && change.getObjectKey().getChangeType().isEnrichableForDependenciesInText()) {
            // we use getContentForDependencyCalculation() instead of just getContent() due to the staticData
            // objects needing to have its dependency calculated differently.

            // TODO go via objectNames and physicalSchema+objectName combo
            MutableSet<CodeDependency> codeDependencies = calculateDependencies(change.getObjectKey().toString(), change.getContentForDependencyCalculation(), objectNames)
                    .reject(Predicates.equal(convertDbObjectName.valueOf(change.getObjectKey().getObjectName())))
                    .reject(Predicates.in(change.getExcludeDependencies()))
                    .collectWith(CodeDependency.CREATE_WITH_TYPE, CodeDependencyType.DISCOVERED);

            codeDependencies.withAll(change.getIncludeDependencies().collectWith(CodeDependency.CREATE_WITH_TYPE, CodeDependencyType.EXPLICIT));

            change.setCodeDependencies(codeDependencies.toImmutable());
        }
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:23,
代码来源:TextDependencyExtractorImpl.java

示例8: getDroppedTableChangesThatAreAlreadyRemoved

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Use case: a table file has all of its changes to be deployed but the last one is a DROP_TABLE. This implies
 * that the object had previously been undeployed and is now safe for removal from the source codebase.
 */
private ImmutableSet<ObjectKey> getDroppedTableChangesThatAreAlreadyRemoved(RichIterable<ChangePair> changePairs) {
    MutableSet<ObjectKey> dropOnlyObjectKeys = Sets.mutable.empty();

    Multimap<ObjectKey, ChangePair> changePairsByObjectName = changePairs.groupBy(ChangePair.TO_OBJECT_KEY);
    for (Pair<ObjectKey, RichIterable<ChangePair>> stringRichIterablePair : changePairsByObjectName.keyMultiValuePairsView()) {
        ObjectKey objectKey = stringRichIterablePair.getOne();
        RichIterable<ChangePair> objectChangePairs = stringRichIterablePair.getTwo();
        if (objectChangePairs.allSatisfy(Predicates.attributeNotNull(ChangePair.TO_SOURCE_CHANGE).and(Predicates.attributeIsNull(ChangePair.TO_DEPLOYED_CHANGE)))) {
            RichIterable<Change> sourceChanges = objectChangePairs.collect(ChangePair.TO_SOURCE_CHANGE);
            Change lastChange = sourceChanges.maxBy(Change.TO_ORDER_WITHIN_OBJECT);
            if (((ChangeIncremental)lastChange).isDrop() && !((ChangeIncremental)lastChange).isForceDropForEnvCleaning()) {
                dropOnlyObjectKeys.add(objectKey);
            }
        }
    }

    return dropOnlyObjectKeys.toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:23,
代码来源:IncrementalChangeTypeCommandCalculator.java

示例9: sortChanges

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Sorts the graph to provide a consistent topological ordering.
 *
 * @param graph          The input graph
 * @param subsetVertices The subset vertices of the graph we want to sort
 * @param comparator     The comparator on which to order the vertices to guarantee a consistent topological ordering
 */
public <T> ImmutableList<T> sortChanges(DirectedGraph<T, DefaultEdge> graph, RichIterable<T> subsetVertices, Comparator<? super T> comparator) {
    if (subsetVertices.toSet().size() != subsetVertices.size()) {
        throw new IllegalStateException("Unexpected state - have some dupe elements here: " + subsetVertices);
    }

    DirectedGraph<T, DefaultEdge> subsetGraph = new DirectedSubgraph<T, DefaultEdge>(
            graph, subsetVertices.toSet(), null);

    // At one point, we _thought_ that the DirectedSubGraph was dropping vertices that don't have edges, so we
    // manually add them back to the graph to ensure that we can still order them.
    // However, that no longer seems to be the case. We add a check here just in case this comes up again.
    if (subsetVertices.size() != subsetGraph.vertexSet().size()) {
        throw new IllegalArgumentException("This case should never happen! [subsetVertices: " + subsetVertices + ", subsetGraphVertices: " + subsetGraph.vertexSet());
    }

    return sortChanges(subsetGraph, comparator);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:25,
代码来源:GraphSorter.java

示例10: getRequestedEnvironments

点赞 3

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public RichIterable<EnvType> getRequestedEnvironments(String sourcePath, String... envNames) {
    MutableCollection<EnvType> environments = getRequestedSystem(sourcePath);

    MutableList<EnvType> requestedEnvs = Lists.mutable.empty();

    if (envNames == null || envNames.length == 0) {
        requestedEnvs.add(readSingleEnvironment(environments, sourcePath));
    } else {
        for (EnvType sysEnv : environments) {
            for (String envPattern : envNames) {
                if (Pattern.compile(RegexUtil.convertWildcardPatternToRegex(envPattern))
                        .matcher(sysEnv.getName())
                        .matches()) {
                    requestedEnvs.add(sysEnv);
                }
            }
        }
    }

    if (requestedEnvs.isEmpty()) {
        throw new IllegalArgumentException("No environment with name/s "
                + Lists.mutable.with(envNames).makeString("(", ",", ")") + " found");
    }

    return requestedEnvs;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:27,
代码来源:AbstractMain.java

示例11: mergeRestrictions

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Merge file and change level restrictions by restriction class name
 */
private ImmutableList<ArtifactRestrictions> mergeRestrictions(ImmutableList<ArtifactRestrictions> fileLevelRestrictions, final ImmutableList<ArtifactRestrictions> changeLevelRestrictions) {
    return Lists.mutable.ofAll(fileLevelRestrictions)
            .withAll(changeLevelRestrictions)
            .groupBy(Functions.getToClass())
            .multiValuesView()
            .collect(new Function<RichIterable<ArtifactRestrictions>, ArtifactRestrictions>() {
                @Override
                public ArtifactRestrictions valueOf(RichIterable<ArtifactRestrictions> restictions) {
                    return restictions.getLast();
                }
            })
            .toList().toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:17,
代码来源:TableChangeParser.java

示例12: executeInserts

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Note - we still need the PhysicalSchema object, as the schema coming from sybase may still have "dbo" there.
 * Until we abstract this in the metadata API, we go w/ the signature as is
 *
 * Also - this can be overridable in case we want to support bulk-inserts for specific database types,
 * e.g. Sybase IQ
 *
 * We only use batching for "executeInserts" as that is the 90% case of the performance
 * (updates may vary the kinds of sqls that are needed, and deletes I'd assume are rare)
 */
protected void executeInserts(Connection conn, StaticDataChangeRows changeRows) {
    if (changeRows.getInsertRows().isEmpty()) {
        return;
    }

    StaticDataInsertRow changeFormat = changeRows.getInsertRows().getFirst();

    String[] paramValMarkers = new String[changeFormat.getInsertColumns().size()];
    Arrays.fill(paramValMarkers, "?");
    MutableList<String> insertValues = Lists.mutable.with(paramValMarkers);

    String sql = "INSERT INTO " + dbPlatform.getSchemaPrefix(changeRows.getSchema()) + changeRows.getTable().getName() +
            changeFormat.getInsertColumns().makeString("(", ", ", ")") +
            " VALUES " + insertValues.makeString("(", ", ", ")");
    LOG.info("Executing the insert " + sql);

    // TODO parameterize this chunk value - sybase sometimes cannot take a large chunk
    for (RichIterable<StaticDataInsertRow> chunkInsertRows : changeRows.getInsertRows().chunk(25)) {
        final Object[][] paramArrays = new Object[chunkInsertRows.size()][];
        chunkInsertRows.forEachWithIndex(new ObjectIntProcedure<StaticDataInsertRow>() {
            @Override
            public void value(StaticDataInsertRow insert, int i) {
                MutableList<Object> paramVals = insert.getParamVals();
                paramArrays[i] = paramVals.toArray(new Object[0]);
            }
        });

        if (LOG.isDebugEnabled()) {
            LOG.debug("for " + paramArrays.length + " rows with params: " + Arrays.deepToString(paramArrays));
        }
        try {
            this.jdbcTemplate.batchUpdate(conn, sql, paramArrays);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:49,
代码来源:CsvStaticDataDeployer.java

示例13: applyGrants

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public void applyGrants(Connection conn, PhysicalSchema schema, String objectName, RichIterable<Permission> permsToApply) {
    CommandExecutionContext cec = new CommandExecutionContext();
    applyGrants(conn, schema, objectName, permsToApply, cec);
    if (cec.getWarnings().notEmpty()) {
        LOG.warn("Failed to execute grants on schema {} and object {}", schema, objectName);
        for (String warning : cec.getWarnings()) {
            LOG.warn(warning);
        }
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:12,
代码来源:AbstractDbChangeTypeBehavior.java

示例14: generateGrantChanges

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
ImmutableList<String> generateGrantChanges(RichIterable<Permission> permsToApply, final DbChangeType changeType, final PhysicalSchema physicalSchema, final String mainObjectName, RichIterable<String> objectNames, final boolean specific) {
    final MutableList<String> changes = Lists.mutable.empty();

    for (Permission perm : permsToApply) {
        for (final Grant grant : perm.getGrants()) {
            grant.validate();

            for (final String objectName : objectNames) {
                grant.getGrantTargets().forEachKeyValue(new Procedure2<GrantTargetType, String>() {
                    @Override
                    public void value(GrantTargetType grantTargetType, String grantTarget) {
                        for (String privilege : grant.getPrivileges()) {
                            changes.add(createGrant(env, privilege, changeType, physicalSchema, objectName, grantTargetType, grantTarget, specific));
                        }
                    }
                });
            }
        }
    }

    if (LOG.isInfoEnabled()) {
        LOG.info(String.format("Applying grants on [%s] with [%d] permission entries on these qualified object names: [%s]",
                mainObjectName, permsToApply.size(), objectNames.makeString("; ")));
    }

    return changes.toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:28,
代码来源:GrantChangeParser.java

示例15: createIdealTables

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * http://infocenter.sybase.com/archive/index.jsp?topic=/com.sybase.help.ase_15.0.tables/html/tables/tables25.htm
 */
private RichIterable<DaTable> createIdealTables(RichIterable<TableSyncSide> syncSides) {
    Multimap<String, DaTable> tableMap = syncSides.flatCollect(TableSyncSide.TO_TABLES).groupBy(DaNamedObject.TO_NAME);

    return tableMap.keyMultiValuePairsView().collect(new Function<Pair<String, RichIterable<DaTable>>, DaTable>() {
        @Override
        public DaTable valueOf(Pair<String, RichIterable<DaTable>> pair) {
            RichIterable<DaTable> tables = pair.getTwo();

            final DaTable table = tables.getFirst();
            DaTableImpl idealTable = new DaTableImpl(table.getSchema(), table.getName());
            idealTable.setPrimaryKey(table.getPrimaryKey());

            idealTable.setColumns(createIdealColumns(tables).toList().toImmutable());

            MutableList<DaIndex> indices = Lists.mutable.empty();
            for (DaIndex idealColumn : TableSyncher.this.createIdealIndices(tables)) {
                if (idealColumn instanceof DaPrimaryKey) {
                    idealTable.setPrimaryKey((DaPrimaryKey) idealColumn);
                } else {
                    indices.add(idealColumn);
                }
            }

            idealTable.setIndices(indices.toImmutable());

            return idealTable;
        }
    });
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:33,
代码来源:TableSyncher.java

示例16: createIdealIndices

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private RichIterable<DaIndex> createIdealIndices(RichIterable<DaTable> tables) {
    Multimap<String, DaIndex> indexMap = tables.flatCollect(DaTable.TO_INDICES).groupBy(
            new Function<DaIndex, String>() {
                @Override
                public String valueOf(DaIndex index) {
                    return index.getName() + ":" + index.getParent().getName();
                }
            }
    );
    return indexMap.multiValuesView().collect(new Function<RichIterable<DaIndex>, DaIndex>() {
        @Override
        public DaIndex valueOf(RichIterable<DaIndex> indices) {
            if (indices.size() == 1) {
                return indices.getFirst();
            }
            DaIndex candidate = indices.detect(DaIndex.IS_UNIQUE);
            if (candidate != null) {
                return candidate;
            }

            candidate = indices.detect(Predicates.attributeEqual(DaIndex.TO_INDEX_TYPE, DaIndexType.CLUSTERED));
            if (candidate != null) {
                return candidate;
            }

            return indices.getFirst();
        }
    });
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:30,
代码来源:TableSyncher.java

示例17: getQualifiedObjectNames

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public Pair<Boolean, RichIterable<String>> getQualifiedObjectNames(Connection conn, PhysicalSchema physicalSchema, final String objectName) {
    ImmutableCollection<String> specificNames = getDbMetadataManager().getRoutineInfo(physicalSchema, objectName)
            .collect(DaRoutine.TO_SPECIFIC_NAME);

    return Tuples.<Boolean, RichIterable<String>>pair(true, specificNames);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:8,
代码来源:Db2RoutineChangeTypeBehavior.java

示例18: checkForInvalidObjects

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@VisibleForTesting
void checkForInvalidObjects(Connection conn, RichIterable<PhysicalSchema> physicalSchemas) {
    MutableList<ReorgQueryResult> invalidObjects = this.getInvalidObjects(conn, physicalSchemas);
    if (!invalidObjects.isEmpty()) {
        LOG.info("Found invalid objects, will attempt to recompile: {}", invalidObjects);
        recompileInvalidObjects(physicalSchemas);
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:9,
代码来源:Db2PostDeployAction.java

示例19: build

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * Builds the predicate on object type and name based on the input functions passed in.
 */
public <T> Predicates<? super T> build(final Function<? super T, String> objectTypeFunction, final Function<? super T, String> objectNameFunction) {
    if (objectNamesByType.isEmpty()) {
        if (filterType == null || filterType.isEmptyInputResult()) {
            return Predicates.alwaysTrue();
        } else {
            return Predicates.alwaysFalse();
        }
    }

    RichIterable<Predicate<? super T>> typePredicates = objectNamesByType.keyMultiValuePairsView().toList().collect(new Function<Pair<String, RichIterable<String>>, Predicate<? super T>>() {
        @Override
        public Predicate<? super T> valueOf(Pair<String, RichIterable<String>> pair) {
            String objectType = pair.getOne();
            RichIterable<String> objectPatterns = pair.getTwo();
            boolean negatePredicate = filterType == FilterType.EXCLUDE;
            if (objectType.startsWith("-")) {
                objectType = objectType.substring(1);
                negatePredicate = true;

            }

            Predicate<T> objectTypeAndNamePredicate = getObjectTypeAndNamePredicate(
                    objectTypeFunction, Lists.immutable.with(objectType),
                    negatePredicate, objectNameFunction, objectPatterns.toList().toImmutable()
            );

            return objectTypeAndNamePredicate;
        }
    });

    if (filterType == null || filterType == FilterType.EXCLUDE) {
        return Predicates.and(typePredicates);
    } else {
        return Predicates.or(typePredicates);
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:40,
代码来源:ObjectTypeAndNamePredicateBuilder.java

示例20: readPlatformProperties

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public Properties readPlatformProperties(RichIterable<String> configPackages) {
    Properties props = new Properties();

    for (String configPackage : configPackages) {
        String defaultConfigPath = configPackage + "/default.properties";
        List<URL> defaultConfigUrls = FileRetrievalMode.getResourcesFromClasspath(defaultConfigPath);

        if (defaultConfigUrls.isEmpty()) {
            throw new IllegalStateException("Could not find default configuration " + defaultConfigPath + " in the classpath");
        }
        if (defaultConfigUrls.size() > 1) {
            throw new IllegalStateException("Found multiple default config files " + defaultConfigPath + " in the classpath; this is not allowed: " + defaultConfigUrls);
        }

        String overrideConfigPath = configPackage + "/override.properties";
        List<URL> overrideConfigUrls = FileRetrievalMode.getResourcesFromClasspath(overrideConfigPath);
        if (overrideConfigUrls.size() > 1) {
            throw new IllegalStateException("Found multiple default config files " + overrideConfigPath + " in the classpath; this is not allowed: " + overrideConfigUrls);
        }

        loadPropertiesFromUrl(defaultConfigUrls, props);

        if (overrideConfigUrls.size() == 1) {
            loadPropertiesFromUrl(overrideConfigUrls, props);
        }
    }

    return props;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:30,
代码来源:PlatformConfigReader.java

示例21: returnOne

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public static <T> T returnOne(RichIterable<? extends T> coll, String message) {
    if (coll.size() > 1) {
        throw new IllegalArgumentException("Expectiong only 1 message in this coll (" + message
                + "), got this instead: " + coll);
    } else if (coll.size() == 1) {
        return coll.iterator().next();
    } else {
        return null;
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:11,
代码来源:CollectionUtil.java

示例22: returnOnlyOne

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public static <T> T returnOnlyOne(RichIterable<? extends T> coll, String message) {
    if (coll.size() > 1 || coll.size() == 0) {
        throw new IllegalArgumentException("Expectiong only 1 message in this coll (" + message
                + "), got this instead: " + coll);
    } else {
        return coll.iterator().next();
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:9,
代码来源:CollectionUtil.java

示例23: validateForDeployment

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public void validateForDeployment() {
    RichIterable<ChangeCommandWarning> fatalWarnings = this.changeWarnings.select(ChangeCommandWarning.IS_FATAL);

    if (!fatalWarnings.isEmpty()) {
        // check for serious exceptions
        throw new IllegalArgumentException("Found exceptions:\n"
                + fatalWarnings.collect(ChangeCommandWarning.TO_COMMAND_DESCRIPTION).makeString("\n"));
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:10,
代码来源:Changeset.java

示例24: sort

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public ImmutableList<ExecuteChangeCommand> sort(RichIterable<ExecuteChangeCommand> changeCommands, boolean rollback) {
    final RichIterable<DbCommandSortKey> commandDatas = changeCommands.collect(DbCommandSortKey.CREATE);

    PartitionIterable<DbCommandSortKey> dataCommandPartition = commandDatas.partition(
            Predicates.attributeIn(Functions.chain(DbCommandSortKey.TO_CHANGE_TYPE, ChangeType.TO_NAME), Sets.fixedSize.of(ChangeType.STATICDATA_STR)));

    PartitionIterable<DbCommandSortKey> dropPartition = dataCommandPartition.getRejected().partition(Predicates.attributeEqual(DbCommandSortKey.TO_DROP, true));

    ListIterable<DbCommandSortKey> orderedAdds = sortAddCommands(dropPartition.getRejected(), rollback);
    ListIterable<DbCommandSortKey> orderedDrops = sortDropCommands(dropPartition.getSelected());
    ListIterable<DbCommandSortKey> orderedDatas = sortDataCommands(dataCommandPartition.getSelected());

    return Lists.mutable.withAll(orderedDrops).withAll(orderedAdds).withAll(orderedDatas).collect(DbCommandSortKey.TO_CHANGE_COMMAND).toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:16,
代码来源:ChangeCommandSorterImpl.java

示例25: sortAddCommands

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private ListIterable<DbCommandSortKey> sortAddCommands(RichIterable<DbCommandSortKey> addCommands, boolean rollback) {
    DirectedGraph<DbCommandSortKey, DefaultEdge> addGraph = enricher.createDependencyGraph(addCommands, rollback);

    ListIterable<DbCommandSortKey> addChanges = graphSorter.sortChanges(addGraph, SortableDependencyGroup.GRAPH_SORTER_COMPARATOR);
    addChanges.forEachWithIndex(new ObjectIntProcedure<DbCommandSortKey>() {
        @Override
        public void value(DbCommandSortKey command, int order) {
            command.setOrder(order);
        }
    });

    return addCommands.toSortedListBy(DbCommandSortKey.TO_ORDER);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:14,
代码来源:ChangeCommandSorterImpl.java

示例26: sortDataCommands

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private ListIterable<DbCommandSortKey> sortDataCommands(RichIterable<DbCommandSortKey> dataCommands) {
    // The background behind this order check: while we want to rely on the FK-dependencies generally to
    // figure out the order of deployment (and once we group by connected components,
    // then the dependencies between components shouldn't matter), there are a couple use cases where we
    // still need to rely on the "order" attribute:
    // 1) for backwards-compatibility w/ teams using older versions of this tool that didn't have
    // this more-advanced ordering logic and that instead needed the "order" attribute
    // 2) the MetadataGroup use case (see "MetadataGroupTest")
    // Hence, we will still rely on the "changeOrder" attribute here as a fallback for the order
    MutableList<DbCommandSortKey> sortedDataCommands = dataCommands.toSortedListBy(new Function<DbCommandSortKey, Comparable>() {
        @Override
        public Comparable valueOf(DbCommandSortKey dbCommandSortKey) {
            ListIterable<Change> changes = dbCommandSortKey.getChangeCommand().getChanges();
            if (changes.isEmpty() || changes.size() > 1) {
                return Change.DEFAULT_CHANGE_ORDER;
            } else {
                return changes.getFirst().getOrder();
            }
        }
    });

    sortedDataCommands.forEachWithIndex(new ObjectIntProcedure<DbCommandSortKey>() {
        @Override
        public void value(DbCommandSortKey dataCommand, int order) {
            dataCommand.setOrder(order);
        }
    });

    return dataCommands.toSortedListBy(DbCommandSortKey.TO_ORDER);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:31,
代码来源:ChangeCommandSorterImpl.java

示例27: getObjectChangesRequiringRecompilation

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
/**
 * allow for use cases to redeploy changes that require recompiling
 * e.g. to add db objects to the change list to facilitate cases where it depends on another SP that is
 * changing, and so the dependent SP needs to get re-created also
 */
private MutableSet<Change> getObjectChangesRequiringRecompilation(ChangeType changeType, RichIterable<Change> fromSourceList, MutableCollection<Change> changedObjects) {
    if (fromSourceList.isEmpty()) {
        return Sets.mutable.empty();
    }
    // do not log errors as info or above here when creating the graph as we know that we don't have the full graph
    LOG.debug("START BLOCK: Ignore any 'Invalid change found?' errors in this block of code");
    DirectedGraph<Change, DefaultEdge> graph = enricher.createDependencyGraph(fromSourceList.select(Predicates.attributeEqual(Change.TO_CHANGE_TYPE, changeType)), false);
    LOG.debug("END BLOCK: Ignore any 'Invalid change found?' errors in this block of code");

    MutableCollection<Change> changesForType = changedObjects.select(
            Predicates.attributeEqual(Change.TO_CHANGE_TYPE, changeType));
    MutableMap<String, Change> changesForTypeMap = changesForType.toMap(
            Change.objectName(), Functions.<Change>getPassThru());

    MutableSet<Change> newChangesToAdd = HashingStrategySets.mutable.of(HashingStrategies.fromFunction(Change.objectName()));
    for (Change change : changesForType) {
        BreadthFirstIterator<Change, DefaultEdge> dependencyIterator = new BreadthFirstIterator<Change, DefaultEdge>(graph, change);

        MutableSet<Change> dependencies = ListAdapter.adapt(
                IteratorUtils.toList(dependencyIterator)).toSet();
        dependencies.remove(change);  // the iterator result includes the self; we can remove this

        for (Change changeToAddBack : dependencies) {
            if (!changesForTypeMap.containsKey(changeToAddBack.getObjectName())) {
                changeToAddBack.setReason("Re-deploying this object due to change in dependent object ["
                        + change.getObjectName() + "]");
                newChangesToAdd.add(changeToAddBack);
            }
        }
    }
    return newChangesToAdd;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:38,
代码来源:RerunnableChangeTypeCommandCalculator.java

示例28: printCommands

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public static void printCommands(RichIterable<? extends ChangeCommand> commands, String message) {
    if (commands.notEmpty()) {
        LOG.info("The following " + message + ":");
        for (ChangeCommand changeCommand : commands) {
            LOG.info("\t" + changeCommand.getCommandDescription());
        }
        LOG.info("");
    } else {
        LOG.info("Nothing applicable for: [" + message + "]");
        LOG.info("");
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:13,
代码来源:MainDeployer.java

示例29: start

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public void start(final DeployerArgs args) {
    RichIterable<EnvType> requestedEnvs = getRequestedEnvironments(args.getSourcePath(), args.getEnvNames());

    RichIterable<ContextType> deployContexts = requestedEnvs.collect(new Function<EnvType, ContextType>() {
        @Override
        public ContextType valueOf(EnvType environment) {
            return createRuntimeContext(environment, args);
        }
    });

    for (ContextType ctxt : deployContexts) {
        this.start(ctxt, args);
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:15,
代码来源:AbstractMain.java

示例30: compareTables

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public MutableCollection<CompareBreak> compareTables(RichIterable<DaTable> tableLefts, RichIterable<DaTable> tableRights) {
    return this.deepCompareUtil.compareCollections(DaTable.class, tableLefts.toList(), tableRights.toList());
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:4,
代码来源:DbMetadataComparisonUtil.java

示例31: backfillDbSchemaColumn

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
private void backfillDbSchemaColumn(Connection conn, PhysicalSchema physicalSchema) {
    // first, get a mapping of all the IDs to DB schemas from the artifactdeployment table. Note that technically
    // we may have lost information as rows can get updated in place, but we'll make do here
    final MutableSetMultimap<Long, String> execIdToSchemaMap = Multimaps.mutable.set.empty();
    for (Map<String, Object> tempExecIdToSchemaMap : jdbc.queryForList(conn, "SELECT DISTINCT INSERTDEPLOYID, UPDATEDEPLOYID, DBSCHEMA FROM " + platform.getSubschemaPrefix(physicalSchema) + "ARTIFACTDEPLOYMENT")) {
        Long insertDeployId = platform.getLongValue(tempExecIdToSchemaMap.get("INSERTDEPLOYID"));
        Long updateDeployId = platform.getLongValue(tempExecIdToSchemaMap.get("UPDATEDEPLOYID"));
        String dbSchema = (String) tempExecIdToSchemaMap.get("DBSCHEMA");
        if (insertDeployId != null) {
            execIdToSchemaMap.put(insertDeployId, dbSchema);
        }
        if (updateDeployId != null) {
            execIdToSchemaMap.put(updateDeployId, dbSchema);
        }
    }

    // find the list of distinct schemas from that list
    MutableSet<String> dbSchemas = execIdToSchemaMap.valuesView().toSet();

    if (dbSchemas.size() == 1) {
        // If we only found 1 schema in ARTIFACTDEPLOYMENT, then we can assume that all the IDs in ARTIFACTEXECUTION
        // also belonged to that schema. So we go w/ the simple update
        jdbc.execute(conn, "UPDATE " + platform.getSubschemaPrefix(physicalSchema) + deployExecutionTableName + " " +
                "SET " + dbSchemaColName + " = '" + dbSchemas.getFirst() + "' ");
    } else if (dbSchemas.size() > 1) {
        // If not, then we need to look a bit deeper to try to match the ID to a schema

        // First compare based on the version name (hoping that all the deployments of a version are traced back to only
        MutableListMultimap<String, Long> versionToIdsMap = Multimaps.mutable.list.empty();
        for (Map<String, Object> idToVersionMap : jdbc.queryForList(conn, "SELECT " + idColName + ", " + productVersionColName + " FROM " + platform.getSubschemaPrefix(physicalSchema) + deployExecutionTableName)) {
            versionToIdsMap.put((String) idToVersionMap.get(productVersionColName), platform.getLongValue(idToVersionMap.get(idColName)).longValue());
        }

        for (Pair<String, RichIterable<Long>> versionIdsPair : versionToIdsMap.keyMultiValuePairsView()) {
            RichIterable<Long> ids = versionIdsPair.getTwo();

            // Find all the schemas matched to the version
            MutableSet<String> versionSchemas = ids.flatCollect(new Function<Long, Iterable<String>>() {
                @Override
                public Iterable<String> valueOf(Long aLong) {
                    return execIdToSchemaMap.get(aLong);
                }
            }, Sets.mutable.<String>empty());

            for (Long id : ids) {
                // iterate for each ID of the version

                if (versionSchemas.size() == 1) {
                    // If we just had 1 schema for all the versions, then do the simple update
                    jdbc.execute(conn, "UPDATE " + platform.getSubschemaPrefix(physicalSchema) + deployExecutionTableName + " " +
                            "SET " + dbSchemaColName + " = '" + versionSchemas.getFirst() + "' " +
                            "WHERE " + idColName + " = " + id
                    );
                } else {
                    // Otherwise, fall back to the schema list per id
                    String schemaToSet;
                    MutableSet<String> idSchemas = execIdToSchemaMap.get(id);
                    if (idSchemas.size() == 1) {
                        schemaToSet = idSchemas.getFirst();
                    } else if (idSchemas.size() >= 1) {
                        LOG.warn("Not expecting multiple schemas on ID {} to be defined: {} ", id, idSchemas);
                        schemaToSet = "MULTISCHEMA";
                    } else {
                        LOG.warn("No schemas found for ID {}", id, idSchemas);
                        schemaToSet = "NOSCHEMA";
                    }

                    jdbc.execute(conn, "UPDATE " + platform.getSubschemaPrefix(physicalSchema) + deployExecutionTableName + " " +
                            "SET " + dbSchemaColName + " = '" + schemaToSet + "' " +
                            "WHERE " + idColName + " = " + id
                    );
                }
            }
        }
    }
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:77,
代码来源:SameSchemaDeployExecutionDao.java

示例32: searchExtraViewInfo

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public ImmutableCollection<ExtraRerunnableInfo> searchExtraViewInfo(DaSchema schema, String tableName, Connection conn) throws SQLException {
    String query = String.format("select obj.name name, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.type in ('V')\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "order by com.id, number, colid2, colid\n", schema.getName());
    QueryRunner qr = new QueryRunner();  // using queryRunner so that we can reuse the connection
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(qr.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> viewInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            return new ExtraRerunnableInfo(
                    (String) object.get("name"),
                    null,
                    (String) object.get("text"),
                    null,
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return viewInfos.groupBy(ExtraRerunnableInfo.TO_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new ExtraRerunnableInfo(
                    sortedInfos.get(0).getName(),
                    null,
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:47,
代码来源:SybaseAseMetadataDialect.java

示例33: searchExtraRoutines

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public ImmutableCollection<DaRoutine> searchExtraRoutines(final DaSchema schema, String procedureName, Connection conn) throws SQLException {
    String nameClause = procedureName != null ? "and obj.name = '" + procedureName + "'\n" : "";

    String query = String.format("select obj.name name, obj.type type, com.number number, colid2 colid2, colid colid, text text\n" +
            "from %1$s..syscomments com\n" +
            ", %1$s..sysobjects obj\n" +
            "    , " + schema.getName() + "..sysusers sch\n" +
            "where com.id = obj.id\n" +
            "and com.texttype = 0\n" +
            "and obj.uid = sch.uid and sch.name = '" + schema.getSubschemaName() + "'\n" +
            "and obj.type in ('SF', 'P')\n" +
            nameClause +
            "order by com.id, number, colid2, colid\n", schema.getName());
    QueryRunner qr = new QueryRunner();  // using queryRunner so that we can reuse the connection
    ImmutableList<Map<String, Object>> maps = ListAdapter.adapt(qr.query(conn, query, new MapListHandler())).toImmutable();

    ImmutableList<ExtraRerunnableInfo> routineInfos = maps.collect(new Function<Map<String, Object>, ExtraRerunnableInfo>() {
        @Override
        public ExtraRerunnableInfo valueOf(Map<String, Object> object) {
            String basename = (String) object.get("name");
            int number = ((Integer) object.get("number")).intValue();
            String specificName = number > 1 ? basename + ";" + number : basename;
            return new ExtraRerunnableInfo(
                    basename,
                    specificName,
                    (String) object.get("text"),
                    ((String) object.get("type")).trim(),
                    ((Integer) object.get("colid2")).intValue(),
                    ((Integer) object.get("colid")).intValue()
            );
        }
    });

    return routineInfos.groupBy(ExtraRerunnableInfo.TO_SPECIFIC_NAME).multiValuesView().collect(new Function<RichIterable<ExtraRerunnableInfo>, DaRoutine>() {
        @Override
        public DaRoutine valueOf(RichIterable<ExtraRerunnableInfo> objectInfos) {
            MutableList<ExtraRerunnableInfo> sortedInfos = objectInfos.toSortedList(Comparators.fromFunctions(ExtraRerunnableInfo.TO_ORDER2, ExtraRerunnableInfo.TO_ORDER1));
            StringBuilder definitionString = sortedInfos.injectInto(new StringBuilder(), new Function2<StringBuilder, ExtraRerunnableInfo, StringBuilder>() {
                @Override
                public StringBuilder value(StringBuilder sb, ExtraRerunnableInfo rerunnableInfo) {
                    return sb.append(rerunnableInfo.getDefinition());
                }
            });
            return new DaRoutinePojoImpl(
                    sortedInfos.get(0).getName(),
                    schema,
                    sortedInfos.get(0).getType().equals("P") ? DaRoutineType.procedure : DaRoutineType.function,
                    sortedInfos.get(0).getSpecificName(),
                    definitionString.toString()
            );
        }
    }).toList().toImmutable();
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:55,
代码来源:SybaseAseMetadataDialect.java

示例34: setSourceDirs

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public void setSourceDirs(RichIterable<FileObject> sourceDirs) {
    this.sourceDirs = sourceDirs;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:4,
代码来源:Environment.java

示例35: getWarnings

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public RichIterable<String> getWarnings() {
    return CollectionAdapter.adapt(warnings);
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:4,
代码来源:CommandExecutionContext.java

示例36: Changeset

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public Changeset(ImmutableList<ExecuteChangeCommand> inserts, ImmutableList<ExecuteChangeCommand> deferredChanges, RichIterable<AuditChangeCommand> auditChanges, RichIterable<ChangeCommandWarning> changeWarnings) {
    this.inserts = inserts;
    this.deferredChanges = deferredChanges;
    this.auditChanges = auditChanges;
    this.changeWarnings = changeWarnings;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:7,
代码来源:Changeset.java

示例37: getAuditChanges

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public RichIterable<AuditChangeCommand> getAuditChanges() {
    return this.auditChanges;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:4,
代码来源:Changeset.java

示例38: getChangeWarnings

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
public RichIterable<ChangeCommandWarning> getChangeWarnings() {
    return this.changeWarnings;
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:4,
代码来源:Changeset.java

示例39: determineChangeset

点赞 2

import org.eclipse.collections.api.RichIterable; //导入依赖的package包/类
@Override
public Changeset determineChangeset(RichIterable<Change> deploys, final RichIterable<Change> sources,
        final boolean rollback, final boolean initAllowedOnHashExceptions, Predicate<? super ExecuteChangeCommand> changesetPredicate) {
    final Multimap<ChangeType, Change> deployChangesByType = deploys.groupBy(Change.TO_CHANGE_TYPE);
    final Multimap<ChangeType, Change> sourceChangesByType = sources.groupBy(Change.TO_CHANGE_TYPE);

    SetIterable<ChangeType> changeTypes = Sets.mutable.withAll(deployChangesByType.keysView()).withAll(sourceChangesByType.keysView());

    RichIterable<ChangeCommand> commands = changeTypes.flatCollect(new Function<ChangeType, Iterable<ChangeCommand>>() {
        @Override
        public Iterable<ChangeCommand> valueOf(ChangeType changeType) {
            RichIterable<Change> changeTypeDeploys = deployChangesByType.get(changeType);
            RichIterable<Change> changeTypeSources = sourceChangesByType.get(changeType);

            final MutableMap<Change, ChangePair> changes = UnifiedMapWithHashingStrategy
                    .newMap(hashStrategy);
            Procedure2<Change, Boolean> addChangeToMap = new Procedure2<Change, Boolean>() {
                @Override
                public void value(Change change, Boolean fromSource) {
                    ChangePair changePair = changes.get(change);
                    if (changePair == null) {
                        changePair = new ChangePair();
                        changes.put(change, changePair);
                    }
                    if (fromSource) {
                        changePair.setSourceChange(change);
                    } else {
                        changePair.setDeployedChange(change);
                    }
                }
            };
            changeTypeSources.forEachWith(addChangeToMap, true);
            changeTypeDeploys.forEachWith(addChangeToMap, false);

            return changeTypeBehaviorRegistry.getChangeTypeBehavior(changeType.getName()).getChangeTypeCalculator().calculateCommands(changeType, changes.valuesView(), sources, rollback, initAllowedOnHashExceptions);
        }
    });

    PartitionIterable<ChangeCommand> executePartition = commands.partition(instanceOf(ExecuteChangeCommand.class));
    PartitionIterable<ChangeCommand> auditPartition = executePartition.getRejected().partition(instanceOf(AuditChangeCommand.class));
    PartitionIterable<ChangeCommand> warningPartition = auditPartition.getRejected().partition(instanceOf(ChangeCommandWarning.class));

    if (warningPartition.getRejected().notEmpty()) {
        throw new IllegalStateException("These changes are not of an expected class type: " + executePartition.getRejected());
    }

    ImmutableList<ExecuteChangeCommand> changeCommands = changeCommandSorter.sort(cast(executePartition.getSelected(), ExecuteChangeCommand.class), rollback);

    if (changesetPredicate == null) {
        changesetPredicate = DEFAULT_DEFERRED_PREDICATE;
    }
    PartitionImmutableList<ExecuteChangeCommand> changesetPartition = changeCommands.partition(
            changesetPredicate
    );

    return new Changeset(changesetPartition.getSelected(),
            changesetPartition.getRejected(),
            cast(auditPartition.getSelected(), AuditChangeCommand.class),
            cast(warningPartition.getSelected(), ChangeCommandWarning.class)
    );
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:62,
代码来源:ChangesetCreatorImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)