org.eclipse.collections.api.RichIterable Java Examples
The following examples show how to use
org.eclipse.collections.api.RichIterable.
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: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 6 votes |
@Test void shouldCollectSingleResultForSingleAxis() { IssuesRecorder recorder = mock(IssuesRecorder.class); IssuesAggregator aggregator = createIssueAggregator(recorder); Issue warning = createIssue(PMD); aggregator.endRun(createBuild(AXIS_WINDOWS, createAction(warning))); assertThat(aggregator.getNames()).containsExactly(AXIS_WINDOWS); Map<String, RichIterable<AnnotatedReport>> results = aggregator.getResultsPerTool(); assertThat(results).containsOnlyKeys(PMD); assertThat(results.get(PMD)).hasSize(1) .satisfies(reports -> assertThat(reports.iterator().next().getReport()).hasSize(1).contains(warning)); aggregator.endBuild(); verify(recorder).publishResult(any(), any(), anyString(), any(), anyString(), any()); }
Example #2
Source File: Environment.java From obevo with Apache License 2.0 | 6 votes |
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; }
Example #3
Source File: Db2PostDeployAction.java From obevo with Apache License 2.0 | 6 votes |
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")); } }
Example #4
Source File: LookupPredicateBuilder.java From obevo with Apache License 2.0 | 6 votes |
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 patternString) { return new WildcardPatternIndex(patternString); } }); 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); }
Example #5
Source File: PostgreSqlFunctionChangeTypeBehavior.java From obevo with Apache License 2.0 | 6 votes |
/** * 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 protected 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); }
Example #6
Source File: AquaRevengMain.java From obevo with Apache License 2.0 | 6 votes |
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; } }
Example #7
Source File: TableSyncher.java From obevo with Apache License 2.0 | 6 votes |
public void execute(DbFileMergerArgs args) { Configuration config; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ).getConfiguration(); } catch (ConfigurationException e) { throw new RuntimeException(e); } RichIterable<DbMergeInfo> dbMergeInfos = DbMergeInfo.parseFromProperties(config); RichIterable<TableSyncSide> tableSyncSides = dbMergeInfos.collect(new Function<DbMergeInfo, TableSyncSide>() { @Override public TableSyncSide valueOf(DbMergeInfo dbMergeInfo) { DataSource ds = ds(dbMergeInfo.getDriverClassName(), dbMergeInfo.getUrl(), dbMergeInfo.getUsername(), dbMergeInfo.getPassword()); return new TableSyncSide(ds, PhysicalSchema.parseFromString(dbMergeInfo.getPhysicalSchema())); } }); this.syncSchemaTables(DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")), tableSyncSides, args.getOutputDir()); }
Example #8
Source File: DbFileMerger.java From obevo with Apache License 2.0 | 6 votes |
public void execute(DbFileMergerArgs args) { PropertiesConfiguration config; RichIterable<DbMergeInfo> dbNameLocationPairs; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ) .getConfiguration(); dbNameLocationPairs = DbMergeInfo.parseFromProperties(config); } catch (Exception e) { throw new DeployerRuntimeException("Exception reading configs from file " + args.getDbMergeConfigFile(), e); } Platform dialect = PlatformConfiguration.getInstance().valueOf(config.getString("dbType")); this.generateDiffs(dialect, dbNameLocationPairs, args.getOutputDir()); }
Example #9
Source File: AbstractMain.java From obevo with Apache License 2.0 | 6 votes |
private 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; }
Example #10
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 6 votes |
private List<String> detectNotFullTopLevelObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType) { final List<String> notFullClassNames = FastList.newList(); MutableListMultimap<String,TopLevelLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getTopLevelLoaders()).groupBy(new Function<TopLevelLoaderType, String>() { @Override public String valueOf(final TopLevelLoaderType topLevelLoaderType) { MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(topLevelLoaderType.getClassToLoad()); if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull()) { notFullClassNames.add(topLevelLoaderType.getClassToLoad()); } return topLevelLoaderType.getClassToLoad() + topLevelLoaderType.getSourceAttributes() + topLevelLoaderType.getFactoryClass(); } }); RichIterable<RichIterable<TopLevelLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1)); this.assertEmpty("Found duplicates in TopLevel Loader:" + this.printListOfTopLevelLoaderType(listOfDupes), listOfDupes.toList()); return notFullClassNames; }
Example #11
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 6 votes |
private List<String> detectNotFullDependentObjects(final Map<String, MithraObjectConfigurationType> allDefinedClasses, CacheLoaderType cacheLoaderType) { final List<String> notFullClassNames = FastList.newList(); MutableListMultimap<String,DependentLoaderType> classesByName = ListAdapter.adapt(cacheLoaderType.getDependentLoaders()).groupBy(new Function<DependentLoaderType, String>() { @Override public String valueOf(final DependentLoaderType dependentLoaderType) { final String className = dependentLoaderType.getRelationship().substring(0, dependentLoaderType.getRelationship().lastIndexOf(".")); MithraObjectConfigurationType objectConfigurationType = allDefinedClasses.get(className); if (objectConfigurationType == null || !objectConfigurationType.getCacheType().isFull()) { notFullClassNames.add(dependentLoaderType.getRelationship()); } return dependentLoaderType.getRelationship() + dependentLoaderType.getHelperFactoryClass(); } }); RichIterable<RichIterable<DependentLoaderType>> listOfDupes = classesByName.multiValuesView().select(Predicates.attributeGreaterThan(Functions.getSizeOf(), 1)); this.assertEmpty("Found duplicates in Dependent Relationship:" + this.printListOfDependentLoaderType(listOfDupes), listOfDupes.toList()); return notFullClassNames; }
Example #12
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 6 votes |
@Test @org.jvnet.hudson.test.Issue("JENKINS-59178") void shouldCollectDifferentResultsForTwoAxes() { IssuesRecorder recorder = mock(IssuesRecorder.class); IssuesAggregator aggregator = createIssueAggregator(recorder); Issue warning = createIssue(PMD); aggregator.endRun(createBuild(AXIS_WINDOWS, createAction(warning))); Issue bug = createIssue(SPOTBUGS); aggregator.endRun(createBuild(AXIS_UNIX, createAction(bug))); assertThat(aggregator.getNames()).containsExactly(AXIS_WINDOWS, AXIS_UNIX); Map<String, RichIterable<AnnotatedReport>> results = aggregator.getResultsPerTool(); assertThat(results).containsOnlyKeys(PMD, SPOTBUGS); assertThat(results.get(PMD)).hasSize(1) .satisfies(reports -> assertThat(reports.iterator().next().getReport()).hasSize(1).contains(warning)); assertThat(results.get(SPOTBUGS)).hasSize(1) .satisfies(reports -> assertThat(reports.iterator().next().getReport()).hasSize(1).contains(bug)); aggregator.endBuild(); verify(recorder, times(2)).publishResult(any(), any(), anyString(), any(), anyString(), any()); }
Example #13
Source File: DeepCompareUtil.java From obevo with Apache License 2.0 | 6 votes |
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); }
Example #14
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 6 votes |
@Test void shouldCollectMultipleToolsOneAxis() { IssuesRecorder recorder = mock(IssuesRecorder.class); IssuesAggregator aggregator = createIssueAggregator(recorder); Issue warning = createIssue(PMD); Issue bug = createIssue(SPOTBUGS); aggregator.endRun(createBuild(AXIS_UNIX, createAction(warning), createAction(bug))); assertThat(aggregator.getNames()).containsExactly(AXIS_UNIX); Map<String, RichIterable<AnnotatedReport>> results = aggregator.getResultsPerTool(); assertThat(results).containsOnlyKeys(PMD, SPOTBUGS); assertThat(results.get(PMD)).hasSize(1) .satisfies(reports -> assertThat(reports.iterator().next().getReport()).hasSize(1).contains(warning)); assertThat(results.get(SPOTBUGS)).hasSize(1) .satisfies(reports -> assertThat(reports.iterator().next().getReport()).hasSize(1).contains(bug)); aggregator.endBuild(); verify(recorder, times(2)).publishResult(any(), any(), anyString(), any(), anyString(), any()); }
Example #15
Source File: FileSourceParams.java From obevo with Apache License 2.0 | 5 votes |
private FileSourceParams(RichIterable<FileObject> files, ImmutableSet<String> schemaNames, boolean baseline, ImmutableList<ChangeType> changeTypes, ImmutableSet<String> acceptedExtensions, String defaultSourceEncoding, boolean legacyDirectoryStructureEnabled) { this.files = files; this.schemaNames = schemaNames; this.baseline = baseline; this.changeTypes = changeTypes; this.acceptedExtensions = acceptedExtensions; this.defaultSourceEncoding = defaultSourceEncoding; this.legacyDirectoryStructureEnabled = legacyDirectoryStructureEnabled; }
Example #16
Source File: AbstractMain.java From obevo with Apache License 2.0 | 5 votes |
public void start(final DeployerArgs args) { RichIterable<EnvType> requestedEnvs = getRequestedEnvironments(args.getSourcePath(), args.getEnvNames()); RichIterable<DeployerAppContext> deployContexts = requestedEnvs.collect(new Function<EnvType, DeployerAppContext>() { @Override public DeployerAppContext valueOf(EnvType environment) { return AbstractMain.this.createRuntimeContext(environment, args); } }); for (DeployerAppContext ctxt : deployContexts) { this.start(ctxt, args); } }
Example #17
Source File: RawDeserializationTest.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Test public void objectList() throws IOException { testCollection(Lists.mutable.of("a", Collections.emptyMap(), 1), "[\"a\", {}, 1]", new TypeReference<MutableList>() {}, new TypeReference<ImmutableList>() {}, new TypeReference<MutableCollection>() {}, new TypeReference<ImmutableCollection>() {}, new TypeReference<RichIterable>() {}); testCollection(Lists.mutable.of("a", Collections.emptyMap(), 1), "[\"a\", {}, 1]", MutableList.class, ImmutableList.class, MutableCollection.class, ImmutableCollection.class, RichIterable.class); }
Example #18
Source File: PlatformConfigReader.java From obevo with Apache License 2.0 | 5 votes |
public ImmutableHierarchicalConfiguration readPlatformProperties(RichIterable<String> configPackages) { MutableList<PropertyInput> prioritizedProperties = readConfigPackages(configPackages); validate(prioritizedProperties); // order properties by priority: higher-numbered files will replace properties of lower-numbered files prioritizedProperties.sortThisBy(new Function<PropertyInput, Integer>() { @Override public Integer valueOf(PropertyInput propertyInput1) { return propertyInput1.getPriority(); } }).reverseThis(); // needs to be reversed as CombinedConfiguration takes the higher-priority files first // merge properties CombinedConfiguration combinedConfiguration = new CombinedConfiguration(new OverrideCombiner()); for (HierarchicalConfiguration<ImmutableNode> properties : prioritizedProperties.collect(new Function<PropertyInput, HierarchicalConfiguration<ImmutableNode>>() { @Override public HierarchicalConfiguration<ImmutableNode> valueOf(PropertyInput propertyInput) { return propertyInput.getProps(); } })) { combinedConfiguration.addConfiguration(properties); } // remove the configPriority property combinedConfiguration.clearTree(PROP_CONFIG_PRIORITY); return combinedConfiguration; }
Example #19
Source File: PlatformConfigReader.java From obevo with Apache License 2.0 | 5 votes |
private MutableList<PropertyInput> readConfigPackages(RichIterable<String> configPackages) { MutableSet<PropertyInput> prioritizedProperties = HashingStrategySets.mutable.of(HashingStrategies.fromFunction(new Function<PropertyInput, URL>() { @Override public URL valueOf(PropertyInput propertyInput) { return propertyInput.getPropertyFilePath(); } })); for (String configPackage : configPackages) { ListIterable<FileObject> fileObjects = FileRetrievalMode.CLASSPATH.resolveFileObjects(configPackage) .flatCollect(new Function<FileObject, Iterable<FileObject>>() { @Override public Iterable<FileObject> valueOf(FileObject object) { return ArrayAdapter.adapt(object.getChildren()); } }); ListIterable<FileObject> propertyFiles = fileObjects .select(new Predicate<FileObject>() { @Override public boolean accept(FileObject it) { return it.getName().getExtension().equals("yaml"); } }); for (FileObject propertyFile : propertyFiles) { HierarchicalConfiguration<ImmutableNode> fileProps = loadPropertiesFromUrl(propertyFile); String configPriorityProp = fileProps.getString(PROP_CONFIG_PRIORITY); if (configPriorityProp != null) { int priority = Integer.parseInt(configPriorityProp); prioritizedProperties.add(new PropertyInput(propertyFile.getName().getBaseName(), propertyFile.getURLDa(), priority, fileProps)); } else { LOG.warn("Property file {} was ignored as it did not contain {} property", propertyFile, PROP_CONFIG_PRIORITY); } } } return prioritizedProperties.toList(); }
Example #20
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 5 votes |
private String printListOfTopLevelLoaderType(RichIterable<RichIterable<TopLevelLoaderType>> items) { final StringBuilder builder = new StringBuilder("[["); for (int i =0; i < items.toList().size(); i++) { RichIterable listOfBreaks = items.toList().get(i); TopLevelLoaderType topLevelLoaderType = (TopLevelLoaderType)listOfBreaks.getFirst(); builder.append(topLevelLoaderType.getClassToLoad() + "/" + topLevelLoaderType.getSourceAttributes() + "/" + topLevelLoaderType.getFactoryClass() + ","); } builder.append("]]"); return builder.toString(); }
Example #21
Source File: CollectionUtil.java From obevo with Apache License 2.0 | 5 votes |
public static <T> T returnOne(RichIterable<? extends T> coll, String message) { if (coll.size() > 1) { throw new IllegalArgumentException("Expectiong only 1 message in this collection (" + message + "), got this instead: " + coll); } else if (coll.size() == 1) { return coll.iterator().next(); } else { return null; } }
Example #22
Source File: CollectionUtil.java From obevo with Apache License 2.0 | 5 votes |
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 collection (" + message + "), got this instead: " + coll); } else { return coll.iterator().next(); } }
Example #23
Source File: RerunnableChangeTypeCommandCalculator.java From obevo with Apache License 2.0 | 5 votes |
@Override public ImmutableList<ChangeCommand> calculateCommands(ChangeType changeType, RichIterable<ChangePair> changePairs, RichIterable<Change> allSourceChanges, boolean initAllowedOnHashExceptions) { RerunnableObjectInfo rerunnableObjectInfo = changePairs.injectInto(new RerunnableObjectInfo(), new Function2<RerunnableObjectInfo, ChangePair, RerunnableObjectInfo>() { @Override public RerunnableObjectInfo value(RerunnableObjectInfo rerunnableObjectInfo1, ChangePair changePair) { // TODO make this a bit more OO, e.g. avoid the instanceof all over the place Change source = changePair.getSourceChange(); Change deployed = changePair.getDeployedChange(); if (source == null && deployed == null) { // this branch and exception throwing here is to avoid null deference warnings in findbugs for the next else branch throw new IllegalStateException("This code branch should never happen; either of source or deployed should exist"); } if (source == null && deployed != null) { // In this case - the change exists in the target DB but was removed from the source rerunnableObjectInfo1.addDroppedObject(deployed); } else if (source != null && deployed == null) { rerunnableObjectInfo1.addChangedObject(source); } else if (ObjectUtils.equals(source.getContentHash(), deployed.getContentHash()) || source.getAcceptableHashes().contains(deployed.getContentHash())) { // In this case - the change exists in both the source and target db. // We need to check if anything has changed, using the hash LOG.trace("Nothing to do here; source [{}] and target [{}] match in hash", source, deployed); } else { rerunnableObjectInfo1.addChangedObject(source); } return rerunnableObjectInfo1; } }); return this.processRerunnableChanges(changeType, rerunnableObjectInfo, allSourceChanges); }
Example #24
Source File: RerunnableChangeTypeCommandCalculator.java From obevo with Apache License 2.0 | 5 votes |
/** * 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 #25
Source File: MithraCacheLoaderRuntimeConfigTestUtil.java From reladomo with Apache License 2.0 | 5 votes |
private String printListOfDependentLoaderType(RichIterable<RichIterable<DependentLoaderType>> items) { final StringBuilder builder = new StringBuilder("[["); for (int i =0; i < items.toList().size(); i++) { RichIterable listOfBreaks = items.toList().get(i); DependentLoaderType dependentLoaderType = (DependentLoaderType)listOfBreaks.getFirst(); builder.append(dependentLoaderType.getRelationship() + "/" + dependentLoaderType.getHelperFactoryClass() + ","); } builder.append("]]"); return builder.toString(); }
Example #26
Source File: DbMergeInfo.java From obevo with Apache License 2.0 | 5 votes |
public static RichIterable<DbMergeInfo> parseFromProperties(Configuration config) { MutableSet<String> dbs = CollectionAdapter.wrapSet(config.getList(String.class, "instances", Lists.mutable.<String>empty())); MutableList<String> exceptions = Lists.mutable.empty(); MutableList<DbMergeInfo> dbMergeInfos = Lists.mutable.empty(); for (String db : dbs) { Configuration subset = config.subset(db); if (subset.containsKey("inputDir")) { File inputDir = new File(subset.getString("inputDir")); if (!inputDir.canRead()) { if (inputDir.getPath().contains("\r")) { exceptions.add("Could not find " + db + "." + "inputDir file (use forward-slash instead of back-slash in path): " + inputDir.getPath().replaceAll("\r", "")); } else { exceptions.add("Could not find " + db + "." + "inputDir file: " + inputDir); } } DbMergeInfo mergeInfo = new DbMergeInfo(db, inputDir); if (subset.containsKey("driverClassName")) { mergeInfo.setDriverClassName(subset.getString("driverClassName")); mergeInfo.setUrl(subset.getString("url")); mergeInfo.setUsername(subset.getString("username")); mergeInfo.setPassword(subset.getString("password")); mergeInfo.setPhysicalSchema(subset.getString("physicalSchema")); } dbMergeInfos.add(mergeInfo); } } if (exceptions.notEmpty()) { throw new IllegalArgumentException("Invalid properties found in configuration:\n" + exceptions.collect(new Function<String, String>() { @Override public String valueOf(String it) { return "* " + it; } }).makeString("\n")); } return dbMergeInfos; }
Example #27
Source File: ObjectTypeAndNamePredicateBuilder.java From obevo with Apache License 2.0 | 5 votes |
/** * 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); } }
Example #28
Source File: IssuesAggregatorTest.java From warnings-ng-plugin with MIT License | 5 votes |
@Test void shouldCollectOneToolMultipleAxes() { IssuesRecorder recorder = mock(IssuesRecorder.class); IssuesAggregator aggregator = createIssueAggregator(recorder); Issue unixWarning = createIssue(PMD); aggregator.endRun(createBuild(AXIS_UNIX, createAction(unixWarning))); Issue windowsWarning = createIssue(PMD); aggregator.endRun(createBuild(AXIS_WINDOWS, createAction(windowsWarning))); assertThat(aggregator.getNames()).containsExactly(AXIS_UNIX, AXIS_WINDOWS); Map<String, RichIterable<AnnotatedReport>> results = aggregator.getResultsPerTool(); assertThat(results).containsOnlyKeys(PMD); assertThat(results.get(PMD)).hasSize(2) .satisfies(reports -> { Iterator<? extends AnnotatedReport> iterator = reports.iterator(); assertThat(iterator.next().getReport()).hasSize(1).contains(unixWarning); assertThat(iterator.next().getReport()).hasSize(1).contains(windowsWarning); }); aggregator.endBuild(); verify(recorder).publishResult(any(), any(), anyString(), any(), anyString(), any()); }
Example #29
Source File: AbstractDbChangeTypeBehavior.java From obevo with Apache License 2.0 | 5 votes |
@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); } } }
Example #30
Source File: Db2PostDeployAction.java From obevo with Apache License 2.0 | 5 votes |
@VisibleForTesting MutableSet<SchemaObjectRow> getInvalidObjects(Connection conn, RichIterable<PhysicalSchema> physicalSchemas) { LOG.info("Checking for invalid objects"); String schemaInClause = physicalSchemas.collect(new Function<PhysicalSchema, String>() { @Override public String valueOf(PhysicalSchema physicalSchema) { return physicalSchema.getPhysicalName(); } }).makeString("('", "','", "')"); MutableSet<SchemaObjectRow> oldInvalidObjects = queryOldInvalidObjects(conn, schemaInClause); try { MutableSet<SchemaObjectRow> newInvalidObjects = queryNewInvalidObjects(conn, schemaInClause); if (oldInvalidObjects.isEmpty() && newInvalidObjects.notEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInNew", true); } else if (oldInvalidObjects.notEmpty() && newInvalidObjects.isEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInOld", true); } return oldInvalidObjects.withAll(newInvalidObjects); } catch (DataAccessException e) { deployMetricsCollector.addMetric("oldInvalidObjectQueryRequired", true); LOG.debug("Failed to execute new invalid objects SQL; falling back to old query"); return oldInvalidObjects; } }