List of usage examples for org.apache.commons.collections.map LinkedMap values
public Collection values()
From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java
public List<WGUpdateLog> getUpdateLogs(Comparable fromRevision) throws WGAPIException { try {//from w w w . j av a2s .c o m Iterator logEntries; if (_ddlVersion >= WGDatabase.CSVERSION_WGA5) { Query logEntriesQ = getSession().createQuery( "from de.innovationgate.webgate.api.jdbc.LogEntry as logentry where id > :start order by id asc"); logEntriesQ.setLong("start", ((Long) fromRevision).longValue()); logEntries = logEntriesQ.iterate(); } else { Date cutoff = (Date) fromRevision; Query logEntriesQ = getSession().createQuery( "from de.innovationgate.webgate.api.jdbc.LogEntry as logentry where logtime >= :start order by logtime asc"); logEntriesQ.setTimestamp("start", new java.sql.Timestamp(cutoff.getTime())); logEntries = logEntriesQ.iterate(); } List wgLogs = new ArrayList(); LinkedMap wgLogsByTarget = new LinkedMap(); Map conflictTargets = new HashMap(); LogEntry entry; // First pass: Create update logs while (logEntries.hasNext()) { entry = (LogEntry) logEntries.next(); WGUpdateLog newLog = null; WGUpdateLog oldLog = null; Date currentTime = null; if (entry.getTarget() != null && !entry.getTarget().equals("#UNKNOWN#")) { newLog = readUpdateLog(entry); wgLogs.add(newLog); List logsList = (List) wgLogsByTarget.get(entry.getTarget()); if (logsList == null) { logsList = new ArrayList(); wgLogsByTarget.put(entry.getTarget(), logsList); } logsList.add(newLog); } } // Second pass for CS version < 5 to workaround some weaknesses of the CS3/4 history log if (_ddlVersion < WGDatabase.CSVERSION_WGA5) { // Determine conflicting log entries, where update and delete is done on the same time and the same document Iterator wgLogsByTargetIt = wgLogsByTarget.values().iterator(); while (wgLogsByTargetIt.hasNext()) { List logs = (List) wgLogsByTargetIt.next(); WGUtils.sortByProperty(logs, "date"); Iterator logsIt = logs.iterator(); Date lastTime = null; List<WGUpdateLog> logsAtSameTime = new ArrayList(); while (logsIt.hasNext()) { WGUpdateLog log = (WGUpdateLog) logsIt.next(); if (log.getDate().equals(lastTime)) { logsAtSameTime.add(log); } else { resolveLogConflicts(wgLogs, logsAtSameTime); logsAtSameTime.clear(); } lastTime = log.getDate(); } } // Order logentries that have the same time in an order that assures dependency documents are created before their dependent documents Collections.sort(wgLogs, new DocumentDependencyComparator()); } return wgLogs; } catch (HibernateException e) { throw new WGBackendException("Unable to retrieve updated documents", e); } }
From source file:org.apache.jackrabbit.core.lock.LockManagerImpl.java
/** * Consolidate an event iterator obtained from observation, merging * add and remove operations on nodes with the same UUID into a move * operation.//from www .j a v a 2 s. c o m */ private Iterator consolidateEvents(EventIterator events) { LinkedMap eventMap = new LinkedMap(); while (events.hasNext()) { EventImpl event = (EventImpl) events.nextEvent(); HierarchyEvent he; try { he = new HierarchyEvent(event.getChildId(), session.getQPath(event.getPath()).getNormalizedPath(), event.getType()); } catch (MalformedPathException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } catch (RepositoryException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.id); if (heExisting != null) { heExisting.merge(he); } else { eventMap.put(he.id, he); } } return eventMap.values().iterator(); }
From source file:org.apache.jackrabbit.core.lock.LockManagerImpl.java
/** * Consolidate an event iterator obtained from observation, merging * add and remove operations on nodes with the same UUID into a move * operation.//w w w .ja v a 2 s . c o m */ private Iterator consolidateEvents(EventIterator events) { LinkedMap eventMap = new LinkedMap(); while (events.hasNext()) { EventImpl event = (EventImpl) events.nextEvent(); HierarchyEvent he; try { he = new HierarchyEvent(event.getChildId(), resolver.getQPath(event.getPath()).getNormalizedPath(), event.getType()); } catch (MalformedPathException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } catch (RepositoryException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.id); if (heExisting != null) { heExisting.merge(he); } else { eventMap.put(he.id, he); } } return eventMap.values().iterator(); }
From source file:org.apache.jackrabbit.core.lock.LockManagerImpl.java
/** * Consolidate an event iterator obtained from observation, merging * add and remove operations on nodes with the same UUID into a move * operation./*from w w w . j a v a 2s . com*/ */ @SuppressWarnings("unchecked") private Iterator<HierarchyEvent> consolidateEvents(EventIterator events) { LinkedMap eventMap = new LinkedMap(); while (events.hasNext()) { EventImpl event = (EventImpl) events.nextEvent(); HierarchyEvent he; try { he = new HierarchyEvent(event.getChildId(), sysSession.getQPath(event.getPath()).getNormalizedPath(), event.getType()); } catch (MalformedPathException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } catch (RepositoryException e) { log.info("Unable to get event's path: " + e.getMessage()); continue; } HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.id); if (heExisting != null) { heExisting.merge(he); } else { eventMap.put(he.id, he); } } return eventMap.values().iterator(); }
From source file:org.lainsoft.forge.view.customize.PortletIncluder.java
private List merge(List userDef, List scannedPort, ZoneConfiguration zoneConfiguration) { LinkedMap temp = new LinkedMap(); addToMap(temp, userDef);//from w w w. j a va 2s .c o m if (fillWithDefaults) addToMap(temp, zoneConfiguration.getPortletsFor(zone)); addToMap(temp, scannedPort); return new ArrayList(temp.values()); }
From source file:org.lockss.test.FuncCommons.java
public void testLinkedMap() { LinkedMap lm = new LinkedMap(); lm.put("foo", "1"); lm.put("bar", null); assertIsomorphic(ListUtil.list("foo", "bar").iterator(), lm.keySet().iterator()); assertIsomorphic(ListUtil.list("1", null).iterator(), lm.values().iterator()); }