List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:com.siemens.sw360.commonIO.TypeMappings.java
@NotNull public static Map<Integer, Todo> getTodoMap(LicenseService.Iface licenseClient, Map<Integer, Obligation> obligationMap, Map<Integer, Set<Integer>> obligationTodoMapping, InputStream in) throws TException { List<CSVRecord> todoRecords = ImportCSV.readAsCSVRecords(in); final List<Todo> todos = CommonUtils.nullToEmptyList(licenseClient.getTodos()); Map<Integer, Todo> todoMap = Maps.newHashMap(Maps.uniqueIndex(todos, getTodoIdentifier())); final List<Todo> todosToAdd = ConvertRecord.convertTodos(todoRecords); final ImmutableList<Todo> filteredTodos = getElementsWithIdentifiersNotInMap(getTodoIdentifier(), todoMap, todosToAdd);// w w w . ja v a2s .c o m final ImmutableMap<Integer, Todo> filteredMap = Maps.uniqueIndex(filteredTodos, getTodoIdentifier()); putToTodos(obligationMap, filteredMap, obligationTodoMapping); if (filteredTodos.size() > 0) { final List<Todo> addedTodos = licenseClient.addTodos(filteredTodos); if (addedTodos != null) { final ImmutableMap<Integer, Todo> addedTodoMap = Maps.uniqueIndex(addedTodos, getTodoIdentifier()); todoMap.putAll(addedTodoMap); } } return todoMap; }
From source file:com.alibaba.jstorm.ui.UIUtils.java
public static Map readUiConfig() { Map ret = Utils.readStormConfig(); String curDir = System.getProperty("user.home"); String confPath = curDir + File.separator + ".jstorm" + File.separator + "storm.yaml"; File file = new File(confPath); if (file.exists()) { FileInputStream fileStream; try {/*w w w . j a v a 2s . c om*/ fileStream = new FileInputStream(file); Yaml yaml = new Yaml(); Map clientConf = (Map) yaml.load(fileStream); if (clientConf != null) { ret.putAll(clientConf); } if (ONE_TABLE_PAGE_SIZE == null) { ONE_TABLE_PAGE_SIZE = ConfigExtension.getUiOneTablePageSize(clientConf); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block } } if (ret.containsKey(Config.NIMBUS_HOST) == false) { ret.put(Config.NIMBUS_HOST, "localhost"); } return ret; }
From source file:com.sworddance.util.CUtilities.java
public static <K, V extends Collection<W>, W> Map<K, V> merge(Map<K, V> first, Map<K, V> second) { Map<K, V> result = new HashMap<K, V>(); if (isNotEmpty(first) || isNotEmpty(second)) { if (isEmpty(first)) { result.putAll(second); } else if (isEmpty(second)) { result.putAll(first);/*ww w. j av a 2 s . com*/ } else { result.putAll(first); Set<Map.Entry<K, V>> secondMapEntrySet = second.entrySet(); for (Map.Entry<K, V> entry : secondMapEntrySet) { K key = entry.getKey(); if (result.containsKey(key)) { V resultValue = result.get(key); resultValue.addAll(entry.getValue()); } else { result.put(key, entry.getValue()); } } } } return result; }
From source file:com.dotweblabs.twirl.gae.GaeMarshaller.java
/** * Process <code>EmbeddedEntity</code> and inner <code>EmbeddedEntity</code> * of this entity.//from w ww .j a v a 2 s. c o m * * @param ee {@code EmbeddedEntity} to unmarshall into map * @return unmarshalled */ public static Map<String, Object> createMapFromEmbeddedEntity(final EmbeddedEntity ee) { Map<String, Object> map = null; try { map = new HashMap<String, Object>(); map.putAll(ee.getProperties()); Map<String, Object> newMap = new HashMap<String, Object>(); Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Object> entry = it.next(); if (entry.getValue() instanceof EmbeddedEntity) { LOG.debug("Inner embedded entity found with keyType=" + entry.getKey()); // newMap.put(entry.getKey(), createMapFromEmbeddedEntity( (EmbeddedEntity) entry.getValue())); newMap.put(entry.getKey(), getMapOrList((EmbeddedEntity) entry.getValue())); it.remove(); } } map.putAll(newMap); } catch (Exception e) { // TODO Handle exception e.printStackTrace(); LOG.error("Error when processing EmbeddedEntity to Map"); } return map; }
From source file:com.fengduo.bee.commons.core.lang.CollectionUtils.java
public static <T extends Object> List<T> join(String property, Collection<T>... arrays) { Map<String, T> resultMap = new HashMap<String, T>(); for (Collection<T> array : arrays) { if (array == null || array.isEmpty()) continue; Map<String, T> map = toMap(array, property); resultMap.putAll(map); }// ww w .j a v a2s . c om return new ArrayList<T>(resultMap.values()); }
From source file:com.adeptj.modules.data.jpa.core.JpaProperties.java
public static Map<String, Object> from(EntityManagerFactoryConfig config) { Map<String, Object> jpaProperties = new HashMap<>(); jpaProperties.put(DDL_GENERATION, config.ddlGeneration()); jpaProperties.put(DDL_GENERATION_MODE, config.ddlGenerationOutputMode()); // DEPLOY_ON_STARTUP must be a string value jpaProperties.put(DEPLOY_ON_STARTUP, Boolean.toString(config.deployOnStartup())); jpaProperties.put(LOGGING_LEVEL, config.loggingLevel()); jpaProperties.put(TRANSACTION_TYPE, config.persistenceUnitTransactionType()); jpaProperties.put(ECLIPSELINK_PERSISTENCE_XML, config.persistenceXmlLocation()); jpaProperties.put(SHARED_CACHE_MODE, config.sharedCacheMode()); jpaProperties.put(VALIDATION_MODE, config.validationMode()); jpaProperties.put(PERSISTENCE_PROVIDER, config.persistenceProviderClassName()); if (config.useExceptionHandler()) { jpaProperties.put(EXCEPTION_HANDLER_CLASS, JpaExceptionHandler.class.getName()); }// w w w . ja v a 2 s. co m // Extra properties are in [key=value] format. jpaProperties.putAll(Stream.of(config.jpaProperties()).filter(StringUtils::isNotEmpty) .map(row -> row.split(EQ)).filter(mapping -> ArrayUtils.getLength(mapping) == 2) .collect(Collectors.toMap(elem -> elem[0], elem -> elem[1]))); return jpaProperties; }
From source file:com.music.util.persistence.HibernateExtendedJpaVendorAdapter.java
@Override public Map<String, Object> getJpaPropertyMap() { Map<String, Object> properties = super.getJpaPropertyMap(); properties.putAll(vendorProperties); return properties; }
From source file:com.glaf.core.entity.mybatis.MyBatisSessionFactory.java
public static Map<String, byte[]> getLibMappers() { List<String> includes = new ArrayList<String>(); includes.add("Mapper.xml"); Map<String, byte[]> dataMap = new HashMap<String, byte[]>(); String path = SystemProperties.getConfigRootPath() + "/lib"; File dir = new File(path); File contents[] = dir.listFiles(); if (contents != null) { ZipInputStream zipInputStream = null; for (int i = 0; i < contents.length; i++) { if (contents[i].isFile() && contents[i].getName().startsWith("glaf") && contents[i].getName().endsWith(".jar")) { try { zipInputStream = new ZipInputStream( FileUtils.getInputStream(contents[i].getAbsolutePath())); Map<String, byte[]> zipMap = getZipBytesMap(zipInputStream); if (zipMap != null && !zipMap.isEmpty()) { dataMap.putAll(zipMap); }/*from w w w .ja va 2 s.co m*/ } catch (Exception ex) { ex.printStackTrace(); } } } } return dataMap; }
From source file:com.nzion.util.UtilMisc.java
public static <K, V> Map<K, V> makeMapWritable(Map<K, ? extends V> map) { Map<K, V> result = new HashMap<K, V>(); if (map != null) result.putAll(map); return result; }
From source file:com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.java
/** * ??/*www.ja va 2 s. c o m*/ * * @param reportModel * @param area * @param queryAction * @return * @throws QueryModelBuildException */ private static Map<String, MetaCondition> buildQueryConditions(ReportDesignModel reportModel, ExtendArea area, QueryAction queryAction) throws QueryModelBuildException { Map<String, MetaCondition> rs = new HashMap<String, MetaCondition>(); Map<Item, Object> items = new HashMap<Item, Object>(); items.putAll(queryAction.getColumns()); items.putAll(queryAction.getRows()); items.putAll(queryAction.getSlices()); int firstIndex = 0; for (Map.Entry<Item, Object> entry : items.entrySet()) { Item item = entry.getKey(); OlapElement olapElement = ReportDesignModelUtils.getDimOrIndDefineWithId(reportModel.getSchema(), area.getCubeId(), item.getOlapElementId()); if (olapElement == null) { Cube cube = com.baidu.rigel.biplatform.ma.report.utils.QueryUtils.getCubeWithExtendArea(reportModel, area); for (Dimension dim : cube.getDimensions().values()) { if (dim.getId().equals(item.getOlapElementId())) { olapElement = dim; break; } } } if (olapElement == null) { continue; } if (olapElement instanceof Dimension) { DimensionCondition condition = new DimensionCondition(olapElement.getName()); Object valueObj = entry.getValue(); if (valueObj != null) { List<String> values = Lists.newArrayList(); if (valueObj instanceof String[]) { values = Lists.newArrayList(); String[] tmp = resetValues(olapElement.getName(), (String[]) valueObj); CollectionUtils.addAll(values, (String[]) tmp); } else { String tmp = resetValues(olapElement.getName(), valueObj.toString())[0]; values.add(tmp); } List<QueryData> datas = Lists.newArrayList(); // TODO ?UniqueName? String rootUniqueName = "[" + olapElement.getName() + "].[All_" + olapElement.getName(); // TODO QeuryData value? for (String value : values) { if (!queryAction.isChartQuery() && value.indexOf(rootUniqueName) != -1) { datas.clear(); break; } QueryData data = new QueryData(value); Object drillValue = queryAction.getDrillDimValues().get(item); String tmpValue = null; if (valueObj instanceof String[]) { tmpValue = ((String[]) valueObj)[0]; } else { tmpValue = valueObj.toString(); } if (drillValue != null && tmpValue.equals(drillValue)) { data.setExpand(true); } else if ((item.getPositionType() == PositionType.X || item.getPositionType() == PositionType.S) && queryAction.isChartQuery()) { data.setExpand(true); data.setShow(false); } // ? if (item.getParams().get(Constants.LEVEL) != null) { if (item.getParams().get(Constants.LEVEL).equals(1)) { data.setExpand(!queryAction.isChartQuery()); data.setShow(true); } else if (item.getParams().get(Constants.LEVEL).equals(2)) { data.setExpand(true); data.setShow(false); } if (MetaNameUtil.isAllMemberUniqueName(data.getUniqueName()) && queryAction.isChartQuery()) { data.setExpand(true); data.setShow(false); } } datas.add(data); } if (values.isEmpty() && queryAction.isChartQuery()) { QueryData data = new QueryData(rootUniqueName + "s]"); data.setExpand(true); data.setShow(false); datas.add(data); } condition.setQueryDataNodes(datas); } else { List<QueryData> datas = new ArrayList<QueryData>(); Dimension dim = (Dimension) olapElement; if ((item.getPositionType() == PositionType.X || item.getPositionType() == PositionType.S) && queryAction.isChartQuery()) { QueryData data = new QueryData(dim.getAllMember().getUniqueName()); data.setExpand(true); data.setShow(false); datas.add(data); } else if (dim.getType() == DimensionType.CALLBACK) { QueryData data = new QueryData(dim.getAllMember().getUniqueName()); data.setExpand(firstIndex == 0); data.setShow(firstIndex != 0); datas.add(data); } condition.setQueryDataNodes(datas); } // ?????? if (item.getPositionType() == PositionType.X && olapElement instanceof TimeDimension && firstIndex == 0 && !queryAction.isChartQuery()) { condition.setMemberSortType(SortType.DESC); ++firstIndex; } rs.put(condition.getMetaName(), condition); } } return rs; }