List of usage examples for com.google.common.collect ListMultimap get
@Override List<V> get(@Nullable K key);
Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List , instead of the java.util.Collection specified in the Multimap interface.
From source file:de.bund.bfr.knime.nls.fitting.FittingNodeModel.java
private Map<String, OptimizationResult> doDiffFitting(Function f, BufferedDataTable dataTable, BufferedDataTable conditionTable, ExecutionContext exec) throws ParseException, CanceledExecutionException { if (f.getTimeVariable() == null) { return new LinkedHashMap<>(); }/*from w ww.ja v a2 s. c o m*/ Pair<ListMultimap<String, Double>, ListMultimap<String, Double>> data = readDataTable(dataTable, f); ListMultimap<String, Double> timeValues = data.getFirst(); ListMultimap<String, Double> targetValues = data.getSecond(); Map<String, ListMultimap<String, Double>> argumentValues = readConditionTable(conditionTable, f); Map<String, OptimizationResult> results = new LinkedHashMap<>(); List<String> ids = readIds(dataTable); numberOfFittings = ids.size(); currentFitting = 0; for (String id : ids) { Map<String, List<Double>> argumentLists = new LinkedHashMap<>(); for (String indep : f.getIndependentVariables()) { argumentLists.put(indep, argumentValues.get(indep).get(id)); } List<String> valueVariables = new ArrayList<>(f.getTerms().keySet()); List<String> terms = new ArrayList<>(); List<Double> initValues = new ArrayList<>(); List<String> initParameters = new ArrayList<>(); for (String var : valueVariables) { terms.add(f.getTerms().get(var)); initValues.add(f.getInitValues().get(var)); initParameters.add(f.getInitParameters().get(var)); } LeastSquaresOptimization optimizer = LeastSquaresOptimization.createVectorDiffOptimizer(terms, valueVariables, initValues, initParameters, f.getParameters(), timeValues.get(id), targetValues.get(id), f.getDependentVariable(), f.getTimeVariable(), argumentLists, new IntegratorFactory(IntegratorFactory.Type.RUNGE_KUTTA, set.getStepSize()), new InterpolationFactory(set.getInterpolator())); if (set.isEnforceLimits()) { optimizer.getMinValues().putAll(set.getMinStartValues()); optimizer.getMaxValues().putAll(set.getMaxStartValues()); } if (!set.getStartValues().isEmpty()) { results.put(id, optimizer.optimize(set.getnParameterSpace(), set.getnLevenberg(), set.isStopWhenSuccessful(), set.getStartValues(), new LinkedHashMap<>(), set.getMaxLevenbergIterations(), progressListener, exec)); } else { results.put(id, optimizer.optimize(set.getnParameterSpace(), set.getnLevenberg(), set.isStopWhenSuccessful(), set.getMinStartValues(), set.getMaxStartValues(), set.getMaxLevenbergIterations(), progressListener, exec)); } currentFitting++; } return results; }
From source file:org.kuali.rice.kew.impl.actionlist.ActionListCustomizationMediatorImpl.java
/** * <p>partitions ActionItems by application id, and calls the appropriate * {@link ActionListCustomizationHandlerService} for each parition, merging the results.</p> * * <dl><dt><b>inherited docs:</b></dt><dd>{@inheritDoc}</dd></dl> *//*from w w w .ja v a 2s .c o m*/ @Override public Map<String, ActionItemCustomization> getActionListCustomizations(String principalId, List<ActionItem> actionItems) throws RiceIllegalArgumentException { if (StringUtils.isBlank(principalId)) { throw new RiceIllegalArgumentException("invalid principalId: " + principalId); } if (actionItems == null) { actionItems = Collections.emptyList(); } // map from action item ID to ActionItemCustomization Map<String, ActionItemCustomization> results = new HashMap<String, ActionItemCustomization>(); // group each action item by application id that needs to be called for action list customizations (note that // the application id comes from the extension/rule attribute record, most action lists will have doc types // with no custom action list attribute, though the default still needs to be run in this case) ListMultimap<String, ActionItem> itemsByApplicationId = ArrayListMultimap.create(); for (ActionItem actionItem : actionItems) { //DocumentType docType = KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(actionItem.getDocName()); DocumentType docType = getDocumentTypeService().findByName(actionItem.getDocName()); if (docType == null) { LOG.error(String.format("Action item %s has an invalid document type name of %s", actionItem.getId(), actionItem.getDocName())); // OK to have a null key, this represents the default app id itemsByApplicationId.put(null, actionItem); } else { // OK to have a null key, this represents the default app id itemsByApplicationId.put(getActionListCustomizationApplicationId(docType), actionItem); } } // For each application id, pass all action items which might need to be customized (because they have a // document type, which declares an action list attribute, which has an application id declared) to the // appropriate ActionListCustomizationHandlerService endpoint for (String applicationId : itemsByApplicationId.keySet()) { ActionListCustomizationHandlerService actionListCustomizationHandler = getActionListCustomizationHandlerServiceChooser() .getByApplicationId(applicationId); if (actionListCustomizationHandler == null) { // get the local ActionListCustomizationHandlerService as a fallback actionListCustomizationHandler = getActionListCustomizationHandlerServiceChooser() .getByApplicationId(null); } List<ActionItemCustomization> customizations = actionListCustomizationHandler .customizeActionList(principalId, itemsByApplicationId.get(applicationId)); // Get back the customized results and reassemble with customized results from all different application // customizations (as well as default customizations) if (customizations != null) for (ActionItemCustomization customization : customizations) { results.put(customization.getActionItemId(), customization); } } return results; }
From source file:org.apache.tez.runtime.library.common.shuffle.orderedgrouped.ShuffleScheduler.java
public synchronized List<InputAttemptIdentifier> getMapsForHost(MapHost host) { List<InputAttemptIdentifier> origList = host.getAndClearKnownMaps(); ListMultimap<Integer, InputAttemptIdentifier> dedupedList = LinkedListMultimap.create(); Iterator<InputAttemptIdentifier> listItr = origList.iterator(); while (listItr.hasNext()) { // we may want to try all versions of the input but with current retry // behavior older ones are likely to be lost and should be ignored. // This may be removed after TEZ-914 InputAttemptIdentifier id = listItr.next(); if (inputShouldBeConsumed(id)) { Integer inputNumber = Integer.valueOf(id.getInputIdentifier()); List<InputAttemptIdentifier> oldIdList = dedupedList.get(inputNumber); if (oldIdList == null || oldIdList.isEmpty()) { dedupedList.put(inputNumber, id); continue; }/* ww w . j av a 2 s.c o m*/ //In case of pipelined shuffle, we can have multiple spills. In such cases, we can have // more than one item in the oldIdList. boolean addIdentifierToList = false; Iterator<InputAttemptIdentifier> oldIdIterator = oldIdList.iterator(); while (oldIdIterator.hasNext()) { InputAttemptIdentifier oldId = oldIdIterator.next(); //no need to add if spill ids are same if (id.canRetrieveInputInChunks()) { if (oldId.getSpillEventId() == id.getSpillEventId()) { //TODO: need to handle deterministic spills later. addIdentifierToList = false; continue; } else if (oldId.getAttemptNumber() == id.getAttemptNumber()) { //but with different spill id. addIdentifierToList = true; break; } } //if its from different attempt, take the latest attempt if (oldId.getAttemptNumber() < id.getAttemptNumber()) { //remove existing identifier oldIdIterator.remove(); LOG.warn("Old Src for InputIndex: " + inputNumber + " with attemptNumber: " + oldId.getAttemptNumber() + " was not determined to be invalid. Ignoring it for now in favour of " + id.getAttemptNumber()); addIdentifierToList = true; break; } } if (addIdentifierToList) { dedupedList.put(inputNumber, id); } } else { LOG.info("Ignoring finished or obsolete source: " + id); } } // Compute the final list, limited by NUM_FETCHERS_AT_ONCE List<InputAttemptIdentifier> result = new ArrayList<InputAttemptIdentifier>(); int includedMaps = 0; int totalSize = dedupedList.size(); for (Integer inputIndex : dedupedList.keySet()) { List<InputAttemptIdentifier> attemptIdentifiers = dedupedList.get(inputIndex); for (InputAttemptIdentifier inputAttemptIdentifier : attemptIdentifiers) { if (includedMaps++ >= maxTaskOutputAtOnce) { host.addKnownMap(inputAttemptIdentifier); } else { if (inputAttemptIdentifier.canRetrieveInputInChunks()) { ShuffleEventInfo shuffleEventInfo = pipelinedShuffleInfoEventsMap .get(inputAttemptIdentifier.getInputIdentifier()); if (shuffleEventInfo != null) { shuffleEventInfo.scheduledForDownload = true; } } result.add(inputAttemptIdentifier); } } } if (LOG.isDebugEnabled()) { LOG.debug("assigned " + includedMaps + " of " + totalSize + " to " + host + " to " + Thread.currentThread().getName()); } return result; }
From source file:org.eobjects.analyzer.job.JaxbJobReader.java
private void applyInputColumns(List<InputType> input, Map<String, InputColumn<?>> inputColumns, AbstractBeanWithInputColumnsBuilder<?, ?, ?> componentJobBuilder) { // build a map of inputs first so that we can set the // input in one go final ListMultimap<ConfiguredPropertyDescriptor, InputColumn<?>> inputMap = MultimapBuilder.hashKeys() .arrayListValues().build();/*from ww w .j a va 2s. c om*/ for (InputType inputType : input) { String name = inputType.getName(); String ref = inputType.getRef(); InputColumn<?> inputColumn; if (StringUtils.isNullOrEmpty(ref)) { inputColumn = createExpressionBasedInputColumn(inputType); } else { inputColumn = inputColumns.get(ref); } if (StringUtils.isNullOrEmpty(name)) { ConfiguredPropertyDescriptor propertyDescriptor = componentJobBuilder .getDefaultConfiguredPropertyForInput(); inputMap.put(propertyDescriptor, inputColumn); } else { ConfiguredPropertyDescriptor propertyDescriptor = componentJobBuilder.getDescriptor() .getConfiguredProperty(name); inputMap.put(propertyDescriptor, inputColumn); } } final Set<ConfiguredPropertyDescriptor> keys = inputMap.keySet(); for (ConfiguredPropertyDescriptor propertyDescriptor : keys) { List<InputColumn<?>> inputColumnsForProperty = inputMap.get(propertyDescriptor); componentJobBuilder.addInputColumns(inputColumnsForProperty, propertyDescriptor); } }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService.java
private <V> Map<InetAddress, List<V>> partitionByHost(Iterable<V> iterable, Function<V, byte[]> keyExtractor) { // Ensure that the same key goes to the same partition. This is important when writing multiple columns // to the same row, since this is a normally a single write in cassandra, whereas splitting the columns // into different requests results in multiple writes. ListMultimap<ByteBuffer, V> partitionedByKey = ArrayListMultimap.create(); for (V value : iterable) { partitionedByKey.put(ByteBuffer.wrap(keyExtractor.apply(value)), value); }//from w ww . j a v a 2s. c o m ListMultimap<InetAddress, V> valuesByHost = ArrayListMultimap.create(); for (ByteBuffer key : partitionedByKey.keySet()) { InetAddress host = tokenAwareMapper.getRandomHostForKey(key.array()); valuesByHost.putAll(host, partitionedByKey.get(key)); } return Multimaps.asMap(valuesByHost); }
From source file:org.datacleaner.job.JaxbJobReader.java
private void applyInputColumns(List<InputType> input, Map<String, InputColumn<?>> inputColumns, ComponentBuilder componentBuilder) { // build a map of inputs first so that we can set the // input in one go final ListMultimap<ConfiguredPropertyDescriptor, InputColumn<?>> inputMap = ArrayListMultimap.create(); for (InputType inputType : input) { String name = inputType.getName(); String ref = inputType.getRef(); InputColumn<?> inputColumn; if (StringUtils.isNullOrEmpty(ref)) { inputColumn = createExpressionBasedInputColumn(inputType); } else {/*from ww w. j a va2 s.c om*/ inputColumn = inputColumns.get(ref); } if (StringUtils.isNullOrEmpty(name)) { ConfiguredPropertyDescriptor propertyDescriptor = componentBuilder .getDefaultConfiguredPropertyForInput(); inputMap.put(propertyDescriptor, inputColumn); } else { ConfiguredPropertyDescriptor propertyDescriptor = componentBuilder.getDescriptor() .getConfiguredProperty(name); inputMap.put(propertyDescriptor, inputColumn); } } final Set<ConfiguredPropertyDescriptor> keys = inputMap.keySet(); for (ConfiguredPropertyDescriptor propertyDescriptor : keys) { List<InputColumn<?>> inputColumnsForProperty = inputMap.get(propertyDescriptor); componentBuilder.addInputColumns(inputColumnsForProperty, propertyDescriptor); } }
From source file:fr.obeo.releng.targetplatform.validation.TargetPlatformValidator.java
@Check public void checkIDUniqueOnAllLocations(final TargetPlatform targetPlatform) { final ListMultimap<String, Location> locationsByURI = this.indexBuilder.getLocationIndex(targetPlatform); final Resource resource = targetPlatform.eResource(); final LinkedHashMultimap<String, String> locationIDsByURI = LinkedHashMultimap.<String, String>create(); final Consumer<String> _function = new Consumer<String>() { @Override//from w ww. j av a2s . c o m public void accept(final String it) { final Function1<Location, String> _function = new Function1<Location, String>() { @Override public String apply(final Location it) { return it.getID(); } }; locationIDsByURI.putAll(it, IterableExtensions .<String>toSet(ListExtensions.<Location, String>map(locationsByURI.get(it), _function))); } }; locationsByURI.keySet().forEach(_function); final Function2<String, Collection<String>, Boolean> _function_1 = new Function2<String, Collection<String>, Boolean>() { @Override public Boolean apply(final String key, final Collection<String> value) { int _size = value.size(); return Boolean.valueOf((_size <= 1)); } }; final Set<String> locationsURIWithoutConflictingID = MapExtensions .<String, Collection<String>>filter(locationIDsByURI.asMap(), _function_1).keySet(); final Function1<String, List<Location>> _function_2 = new Function1<String, List<Location>>() { @Override public List<Location> apply(final String it) { return locationsByURI.get(it); } }; final Iterable<Location> locationsWithoutConflictingID = Iterables.<Location>concat( IterableExtensions.<String, List<Location>>map(locationsURIWithoutConflictingID, _function_2)); final Function1<Location, Boolean> _function_3 = new Function1<Location, Boolean>() { @Override public Boolean apply(final Location it) { String _iD = it.getID(); return Boolean.valueOf((!Objects.equal(_iD, null))); } }; final Function<Location, String> _function_4 = new Function<Location, String>() { @Override public String apply(final Location it) { return it.getID(); } }; final ImmutableListMultimap<String, Location> locationsWithoutConflictingIDByID = Multimaps .<String, Location>index( IterableExtensions.<Location>filter(locationsWithoutConflictingID, _function_3), _function_4); final Function2<String, Collection<Location>, Boolean> _function_5 = new Function2<String, Collection<Location>, Boolean>() { @Override public Boolean apply(final String key, final Collection<Location> value) { final Function1<Location, String> _function = new Function1<Location, String>() { @Override public String apply(final Location it) { return it.getUri(); } }; int _size = IterableExtensions .<String>toSet(IterableExtensions.<Location, String>map(value, _function)).size(); return Boolean.valueOf((_size > 1)); } }; final Iterable<Location> locationsWithDuplicateID = Iterables.<Location>concat(MapExtensions .<String, Collection<Location>>filter(locationsWithoutConflictingIDByID.asMap(), _function_5) .values()); final Consumer<Location> _function_6 = new Consumer<Location>() { @Override public void accept(final Location location) { Resource _eResource = location.eResource(); boolean _equals = Objects.equal(_eResource, resource); if (_equals) { TargetPlatformValidator.this.error("ID must be unique for each location", location, TargetPlatformPackage.Literals.LOCATION__ID, TargetPlatformValidator.CHECK__LOCATION_ID_UNIQNESS); } else { final Function1<IncludeDeclaration, Boolean> _function = new Function1<IncludeDeclaration, Boolean>() { @Override public Boolean apply(final IncludeDeclaration it) { boolean _xblockexpression = false; { final TargetPlatform direct = TargetPlatformValidator.this.indexBuilder .getImportedTargetPlatform(resource, it); _xblockexpression = (direct.getLocations().contains(location) || IterableExtensions.<Location>toSet(Iterables.<Location>concat( ListExtensions.<TargetPlatform, EList<Location>>map( TargetPlatformValidator.this.indexBuilder .getImportedTargetPlatforms(direct), new Function1<TargetPlatform, EList<Location>>() { @Override public EList<Location> apply(final TargetPlatform it) { return it.getLocations(); } }))) .contains(location)); } return Boolean.valueOf(_xblockexpression); } }; final Set<IncludeDeclaration> conflictualInclude = IterableExtensions.<IncludeDeclaration>toSet( IterableExtensions.<IncludeDeclaration>filter(targetPlatform.getIncludes(), _function)); final Consumer<IncludeDeclaration> _function_1 = new Consumer<IncludeDeclaration>() { @Override public void accept(final IncludeDeclaration it) { StringConcatenation _builder = new StringConcatenation(); _builder.append("ID \'"); String _iD = location.getID(); _builder.append(_iD); _builder.append("\' is duplicated in the included target platform"); TargetPlatformValidator.this.error(_builder.toString(), it, TargetPlatformPackage.Literals.INCLUDE_DECLARATION__IMPORT_URI, TargetPlatformValidator.CHECK__LOCATION_ID_UNIQNESS); } }; conflictualInclude.forEach(_function_1); } } }; locationsWithDuplicateID.forEach(_function_6); }
From source file:fr.obeo.releng.targetplatform.validation.TargetPlatformValidator.java
@Check public void checkSameIDForAllLocationWithSameURI(final TargetPlatform targetPlatform) { final ListMultimap<String, Location> locationsByURI = this.indexBuilder.getLocationIndex(targetPlatform); final Resource resource = targetPlatform.eResource(); Set<String> _keySet = locationsByURI.keySet(); for (final String locationURI : _keySet) { {// w w w .ja v a2 s .c o m final Function1<Location, Boolean> _function = new Function1<Location, Boolean>() { @Override public Boolean apply(final Location it) { Resource _eResource = it.eResource(); return Boolean.valueOf((!Objects.equal(_eResource, resource))); } }; final Iterable<Location> externalLocations = IterableExtensions .<Location>filter(locationsByURI.get(locationURI), _function); final Function1<Location, String> _function_1 = new Function1<Location, String>() { @Override public String apply(final Location it) { return Strings.nullToEmpty(it.getID()); } }; final Set<String> externalIDs = IterableExtensions .<String>toSet(IterableExtensions.<Location, String>map(externalLocations, _function_1)); final Function1<Location, Boolean> _function_2 = new Function1<Location, Boolean>() { @Override public Boolean apply(final Location it) { Resource _eResource = it.eResource(); return Boolean.valueOf(Objects.equal(_eResource, resource)); } }; final Iterable<Location> internalLocations = IterableExtensions .<Location>filter(locationsByURI.get(locationURI), _function_2); final Function1<Location, String> _function_3 = new Function1<Location, String>() { @Override public String apply(final Location it) { return Strings.nullToEmpty(it.getID()); } }; final Set<String> internalIDs = IterableExtensions .<String>toSet(IterableExtensions.<Location, String>map(internalLocations, _function_3)); int _size = externalIDs.size(); boolean _greaterThan = (_size > 1); if (_greaterThan) { final Function1<Location, Boolean> _function_4 = new Function1<Location, Boolean>() { @Override public Boolean apply(final Location it) { return Boolean.valueOf(externalIDs.contains(it.getID())); } }; final Iterable<Location> externalLocationsWithConflictualID = IterableExtensions .<Location>filter(externalLocations, _function_4); StringConcatenation _builder = new StringConcatenation(); _builder.append("The ID for location \'"); _builder.append(locationURI); _builder.append("\' must be unique. Found \'"); String _join = IterableExtensions.join(externalIDs, "\', \'"); _builder.append(_join); _builder.append("\' in \'"); final Function1<Location, String> _function_5 = new Function1<Location, String>() { @Override public String apply(final Location it) { return it.eResource().getURI().toString(); } }; String _join_1 = IterableExtensions.join( IterableExtensions.<String>toSet(IterableExtensions .<Location, String>map(externalLocationsWithConflictualID, _function_5)), "\', \'"); _builder.append(_join_1); _builder.append("\'."); final String msg = _builder.toString(); final Function1<Location, Iterable<IncludeDeclaration>> _function_6 = new Function1<Location, Iterable<IncludeDeclaration>>() { @Override public Iterable<IncludeDeclaration> apply(final Location location) { final Function1<IncludeDeclaration, Boolean> _function = new Function1<IncludeDeclaration, Boolean>() { @Override public Boolean apply(final IncludeDeclaration it) { boolean _xblockexpression = false; { final TargetPlatform direct = TargetPlatformValidator.this.indexBuilder .getImportedTargetPlatform(resource, it); _xblockexpression = (direct.getLocations().contains(location) || IterableExtensions.<Location>toSet(Iterables.<Location>concat( ListExtensions.<TargetPlatform, EList<Location>>map( TargetPlatformValidator.this.indexBuilder .getImportedTargetPlatforms(direct), new Function1<TargetPlatform, EList<Location>>() { @Override public EList<Location> apply( final TargetPlatform it) { return it.getLocations(); } }))) .contains(location)); } return Boolean.valueOf(_xblockexpression); } }; return IterableExtensions.<IncludeDeclaration>filter(targetPlatform.getIncludes(), _function); } }; final Set<IncludeDeclaration> conflictualInclude = IterableExtensions .<IncludeDeclaration>toSet(Iterables.<IncludeDeclaration>concat( IterableExtensions.<Location, Iterable<IncludeDeclaration>>map( externalLocationsWithConflictualID, _function_6))); final Consumer<IncludeDeclaration> _function_7 = new Consumer<IncludeDeclaration>() { @Override public void accept(final IncludeDeclaration it) { TargetPlatformValidator.this.error(msg, it, TargetPlatformPackage.Literals.INCLUDE_DECLARATION__IMPORT_URI, TargetPlatformValidator.CHECK__CONFLICTUAL_ID__BETWEEN_INCLUDED_LOCATION); } }; conflictualInclude.forEach(_function_7); } int _size_1 = externalIDs.size(); boolean _equals = (_size_1 == 1); if (_equals) { final Sets.SetView<String> diff = Sets.<String>symmetricDifference(externalIDs, internalIDs); boolean _isEmpty = diff.isEmpty(); boolean _not = (!_isEmpty); if (_not) { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("The ID for location \'"); _builder_1.append(locationURI); _builder_1.append( "\' must be unique across included target platforms and the current one. Found \'"); String _head = IterableExtensions.<String>head(externalIDs); _builder_1.append(_head); _builder_1.append("\' in \'"); final Function1<Location, String> _function_8 = new Function1<Location, String>() { @Override public String apply(final Location it) { return it.eResource().getURI().toString(); } }; String _join_2 = IterableExtensions.join( IterableExtensions.<String>toSet( IterableExtensions.<Location, String>map(externalLocations, _function_8)), "\', \'"); _builder_1.append(_join_2); _builder_1.append("\'."); _builder_1.newLineIfNotEmpty(); final String msg_1 = _builder_1.toString(); final Function1<Location, Boolean> _function_9 = new Function1<Location, Boolean>() { @Override public Boolean apply(final Location it) { boolean _contains = externalIDs.contains(Strings.nullToEmpty(it.getID())); return Boolean.valueOf((!_contains)); } }; final Consumer<Location> _function_10 = new Consumer<Location>() { @Override public void accept(final Location it) { TargetPlatformValidator.this.error(msg_1, it, TargetPlatformPackage.Literals.LOCATION__ID, TargetPlatformValidator.CHECK__INCLUDED_LOCATION_CONFLICTUAL_ID, IterableExtensions.<String>head(externalIDs), IterableExtensions.<Location>head(externalLocations).getUri()); } }; IterableExtensions.<Location>filter(internalLocations, _function_9).forEach(_function_10); } } if (((externalIDs.size() < 1) && (internalIDs.size() > 1))) { StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("The ID for location \'"); _builder_2.append(locationURI); _builder_2.append("\' must be unique. Found \'"); String _join_3 = IterableExtensions.join(internalIDs, "\', \'"); _builder_2.append(_join_3); _builder_2.append("\'."); final String msg_2 = _builder_2.toString(); final Consumer<Location> _function_11 = new Consumer<Location>() { @Override public void accept(final Location it) { TargetPlatformValidator.this.error(msg_2, it, TargetPlatformPackage.Literals.LOCATION__ID, TargetPlatformValidator.CHECK__LOCATION_CONFLICTUAL_ID); } }; internalLocations.forEach(_function_11); } } } }
From source file:org.wso2.carbon.uuf.internal.core.create.AppCreator.java
private Theme createTheme(ThemeReference themeReference) { Map<?, ?> rawConfig;/*from w ww . j av a 2 s .c om*/ try { rawConfig = new Yaml().loadAs(themeReference.getThemeConfig().getContent(), Map.class); } catch (Exception e) { // Yaml.loadAs() throws an Exception throw new MalformedConfigurationException( "Theme configuration '" + themeReference.getThemeConfig().getRelativePath() + "' is malformed.", e); } ListMultimap<String, String> config = ArrayListMultimap.create(); for (Map.Entry<?, ?> entry : rawConfig.entrySet()) { if (!(entry.getKey() instanceof String)) { throw new InvalidTypeException( "Theme configuration must be a Map<String, String[]>. Instead found a '" + entry.getKey().getClass().getName() + "' key."); } String key = (String) entry.getKey(); if (!(key.equals(Placeholder.css.name()) || key.equals(Placeholder.headJs.name()) || key.equals(Placeholder.js.name()))) { throw new IllegalArgumentException( "Theme configuration must be a Map<String, String[]> where key has to be either '" + Placeholder.css + "', '" + Placeholder.headJs + "', and '" + Placeholder.js + "'. Instead found '" + key + "' key."); } if (!(entry.getValue() instanceof List)) { throw new InvalidTypeException( "Theme configuration must be a Map<String, List<String>>. Instead found a '" + entry.getKey().getClass().getName() + "' value."); } else { List<?> rawList = (List) entry.getValue(); for (Object listValue : rawList) { if ((listValue instanceof String)) { config.put(key, (String) listValue); } else { throw new InvalidTypeException( "Theme configuration must be a Map<String, List<String>>. Instead found a '" + entry.getKey().getClass().getName() + "' value."); } } } } return new Theme(themeReference.getName(), config.get(Placeholder.css.name()), config.get(Placeholder.headJs.name()), config.get(Placeholder.js.name()), themeReference.getPath()); }
From source file:org.wso2.carbon.analytics.datasource.hbase.HBaseAnalyticsRecordStore.java
private void deleteDataRows(String tableName, ListMultimap<String, Long> recordsWithRef) throws AnalyticsException { Table dataTable = null;//from ww w .ja v a 2s . com List<Get> gets = new ArrayList<>(); List<Delete> deletes = new ArrayList<>(); String dataTableName = HBaseUtils.generateTableName(tableName, HBaseAnalyticsDSConstants.TableType.DATA); try { dataTable = this.conn.getTable(TableName.valueOf(dataTableName)); /* For all records set for termination, check if they really do have their timestamps within the given range through a GET operation (i.e. kick down doors and check if any of them are really Sarah Connor) */ gets.addAll(recordsWithRef.keySet().stream() .map(recordId -> new Get(Bytes.toBytes(recordId)).addColumn( HBaseAnalyticsDSConstants.ANALYTICS_DATA_COLUMN_FAMILY_NAME, HBaseAnalyticsDSConstants.ANALYTICS_TS_QUALIFIER_NAME)) .collect(Collectors.toList())); Result[] results = dataTable.get(gets); for (Result res : results) { if (res.containsColumn(HBaseAnalyticsDSConstants.ANALYTICS_DATA_COLUMN_FAMILY_NAME, HBaseAnalyticsDSConstants.ANALYTICS_TS_QUALIFIER_NAME)) { Cell dataCell = res.getColumnLatestCell( HBaseAnalyticsDSConstants.ANALYTICS_DATA_COLUMN_FAMILY_NAME, HBaseAnalyticsDSConstants.ANALYTICS_TS_QUALIFIER_NAME); byte[] originalTimestamp = CellUtil.cloneValue(dataCell); if (originalTimestamp.length > 0) { List<Long> candidateIndexEntries = recordsWithRef.get(Bytes.toString(res.getRow())); if (candidateIndexEntries.contains(Bytes.toLong(originalTimestamp))) { deletes.add(new Delete(res.getRow())); } } } } /* Cyberdyne Systems Model 101 Series 800 is GO */ dataTable.delete(deletes); } catch (IOException e) { throw new AnalyticsException("Error deleting records from [" + tableName + "] : " + e.getMessage(), e); } finally { AnalyticsCommonUtils.closeQuietly(dataTable); } }