List of usage examples for org.apache.commons.collections.iterators EntrySetMapIterator EntrySetMapIterator
public EntrySetMapIterator(Map map)
From source file:com.emergya.persistenceGeo.dbutils.DatabaseUtilsImpl.java
public void changeColumnNames(String tableName, Map<String, String> columns) { Set<String> oldColumnNames = columns.keySet(); Collection<String> newColumnNames = columns.values(); if (checkClashingColumnNames(oldColumnNames, newColumnNames)) { EntrySetMapIterator it = new EntrySetMapIterator(columns); while (it.hasNext()) { String oldName = (String) it.next(); String newName = (String) it.getValue(); try { changeColumnName(tableName, oldName, newName); } catch (SQLException e) { throw new DbUtilsException("Error while change column name. [tableName=" + tableName + ", oldColumn= " + oldName + ", newName=" + newName + "]", e); }/*ww w. jav a 2 s. c o m*/ } } else { throw new DbUtilsException("An old column name clash with a new name. [tableName=" + tableName + "]"); } }
From source file:fr.paris.lutece.plugins.workflow.web.WorkflowJspBean.java
/** * Copy the task whose key is specified in the Http request and update param * if exists/* w w w. j av a2s .c o m*/ * * @param taskToCopy * the task to copy * @param mapParamToChange * the map<String, String> of <Param, Value> to change * @throws NoSuchMethodException * NoSuchMethodException the {@link NoSuchMethodException} * @throws IllegalAccessException * IllegalAccessException the {@link IllegalAccessException} * @throws InvocationTargetException * InvocationTargetException the * {@link InvocationTargetException} */ public void doCopyTaskWithModifiedParam(ITask taskToCopy, Map<String, String> mapParamToChange) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Save nIdTaskToCopy Integer nIdTaskToCopy = taskToCopy.getId(); // get the maximum order number in this workflow and set max+1 int nMaximumOrder = _taskService.findMaximumOrderByActionId(taskToCopy.getAction().getId()); taskToCopy.setOrder(nMaximumOrder + 1); // Create the new task (taskToCopy id will be update with the new // idTask) _taskService.create(taskToCopy); // get all taskConfigService List<ITaskConfigService> listTaskConfigService = SpringContextService .getBeansOfType(ITaskConfigService.class); // For each taskConfigService, update parameter if exists for (ITaskConfigService taskConfigService : listTaskConfigService) { ITaskConfig taskConfig = taskConfigService.findByPrimaryKey(nIdTaskToCopy); if (taskConfig != null) { taskConfig.setIdTask(taskToCopy.getId()); if (mapParamToChange != null) { EntrySetMapIterator it = new EntrySetMapIterator(mapParamToChange); while (it.hasNext()) { String key = (String) it.next(); String value = (String) it.getValue(); MethodUtil.set(taskConfig, key, value); } } taskConfigService.create(taskConfig); } } }
From source file:org.apache.cocoon.el.impl.objectmodel.UnmodifiableMultiMap.java
public MapIterator mapIterator() { if (map instanceof IterableMap) { MapIterator it = ((IterableMap) map).mapIterator(); return UnmodifiableMapIterator.decorate(it); } else {//from w w w . java 2 s . c om MapIterator it = new EntrySetMapIterator(map); return UnmodifiableMapIterator.decorate(it); } }
From source file:org.openconcerto.sql.element.SQLElement.java
protected void archive(final TreesOfSQLRows trees, final boolean cutLinks) throws SQLException { if (trees.getElem() != this) throw new IllegalArgumentException(this + " != " + trees.getElem()); for (final SQLRow row : trees.getRows()) checkUndefined(row);// w w w . j av a 2s .c om SQLUtils.executeAtomic(this.getTable().getBase().getDataSource(), new SQLFactory<Object>() { @Override public Object create() throws SQLException { // reference // d'abord couper les liens qui pointent sur les futurs archivs if (cutLinks) { // TODO prend bcp de temps // FIXME update tableau pour chaque observation, ecrase les changements // faire : 'La base change voulez vous recharger ou garder vos modifs ?' final MultiMap externReferences = trees.getExternReferences(); // avoid toString() which might make requests to display rows (eg archived) if (Log.get().isLoggable(Level.FINEST)) Log.get().finest("will cut : " + externReferences); final MapIterator refIter = new EntrySetMapIterator(externReferences); while (refIter.hasNext()) { final SQLField refKey = (SQLField) refIter.next(); final Collection<?> refList = (Collection<?>) refIter.getValue(); final Iterator<?> listIter = refList.iterator(); while (listIter.hasNext()) { final SQLRow ref = (SQLRow) listIter.next(); ref.createEmptyUpdateRow().putEmptyLink(refKey.getName()).update(); } } Log.get().finest("done cutting links"); } // on archive tous nos descendants for (final SQLRowAccessor desc : trees.getFlatDescendants()) { getElement(desc.getTable()).archiveSingle(desc); // ne pas faire les fire aprs sinon qd on efface plusieurs lments de la mme // table : // on fire pour le 1er => updateSearchList => IListe.select(userID) // hors si userID a aussi t archiv (mais il n'y a pas eu son fire // correspondant), le component va lancer un RowNotFound DeletionMode.ArchiveMode.fireChange(desc); } // foreign field // nothing to do return null; } }); }