Examples of ListOrderedMap


Examples of org.apache.commons.collections.map.ListOrderedMap

    }

    private List<Diff> compare(JCRNodeWrapper frozenNode, JCRNodeWrapper node, String basePath) throws RepositoryException {
        List<Diff> diffs = new ArrayList<Diff>();

        ListOrderedMap uuids1 = getChildEntries(frozenNode, node.getSession());
        ListOrderedMap uuids2 = getChildEntries(node, node.getSession());

        if (!uuids1.values().equals(uuids2.values())) {
            for (Iterator iterator = uuids2.keySet().iterator(); iterator.hasNext();) {
                String key = (String) iterator.next();
                if (uuids1.containsKey(key) && !uuids1.get(key).equals(uuids2.get(key))) {
                    diffs.add(new ChildRenamedDiff(key, addPath(basePath,(String) uuids1.get(key)),addPath(basePath, (String) uuids2.get(key))));
                }
            }
        }

        if (!uuids1.keyList().equals(uuids2.keyList())) {
            List<String> added = new ArrayList<String>(uuids2.keySet());
            added.removeAll(uuids1.keySet());
            List<String> removed = new ArrayList<String>(uuids1.keySet());
            removed.removeAll(uuids2.keySet());

            // Ordering
            Map<String,String> oldOrdering = getOrdering(uuids1, removed);
            Map<String,String> newOrdering = getOrdering(uuids2, added);
            if (!newOrdering.equals(oldOrdering)) {
                for (Map.Entry<String, String> entry : newOrdering.entrySet()) {
                    diffs.add(new ChildNodeReorderedDiff(entry.getKey(), newOrdering.get(entry.getKey()),
                            addPath(basePath,(String) uuids2.get(entry.getKey())), (String) uuids2.get(newOrdering.get(entry.getKey())),newOrdering));
                }
            }

            // Removed nodes
            for (String s : removed) {
                try {
                    sourceNode.getSession().getNodeByUUID(s);
                    // Item has been moved
                } catch (ItemNotFoundException e) {
                    diffs.add(new ChildRemovedDiff(s,addPath(basePath, (String) uuids1.get(s))));
                }

            }

            // Added nodes
            for (String s : added) {
                if (s.equals(uuids2.lastKey())) {
                    diffs.add(new ChildAddedDiff(s, addPath(basePath, (String) uuids2.get(s)), null));
                } else {
                    diffs.add(new ChildAddedDiff(s, addPath(basePath, (String) uuids2.get(s)), (String) uuids2.get(uuids2.get(uuids2.indexOf(s)+1))));
                }
            }
        }

        PropertyIterator pi1 = frozenNode.getProperties();
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

        return previousMap;
    }

    private ListOrderedMap getChildEntries(JCRNodeWrapper node, JCRSessionWrapper session) throws RepositoryException {
        NodeIterator ni1 = node.getNodes();
        ListOrderedMap childEntries = new ListOrderedMap();
        while (ni1.hasNext()) {
            Node child = (Node) ni1.next();
            try {
                if (child.isNodeType(Constants.NT_VERSIONEDCHILD)) {
                    VersionHistory vh = (VersionHistory) node.getSession().getNodeByIdentifier(child.getProperty("jcr:childVersionHistory").getValue().getString());
                    String uuid = vh.getRootVersion().getFrozenNode().getProperty(Constants.JCR_FROZENUUID).getValue().getString();
                    childEntries.put(uuid, child.getName());
                } else if (child.isNodeType(Constants.NT_FROZENNODE)) {
                    String uuid = child.getProperty(Constants.JCR_FROZENUUID).getValue().getString();
                    childEntries.put(uuid, child.getName());
                } else {
                    session.getNodeByUUID(child.getIdentifier());
                    childEntries.put(child.getIdentifier(), child.getName());
                }
            } catch (ItemNotFoundException e) {
                // item does not exist in this workspace
            }
        }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

    /**
    * Remove the stamp from stack (when resuming)
    */
    private static void popTransactionStartStamp() {
        ListOrderedMap map = (ListOrderedMap) suspendedTxStartStamps.get();
        if (map.size() > 0) {
            transactionStartStamp.set((Timestamp) map.remove(map.lastKey()));
        } else {
            Debug.logError("Error in transaction handling - no saved start stamp found - using NOW.", module);
            transactionStartStamp.set(UtilDateTime.nowTimestamp());
        }
    }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

   * @param m
   */
  @SuppressWarnings("static-access")
  public static void  populate(Object bean,HttpRequest request, Map<?, ?> m)
  {
    ListOrderedMap orderedMap = new ListOrderedMap();
    Map<?, ?> map=request.getParameterMap();
    orderedMap.putAll(map);
    PropertyUtils propertyUtils = new PropertyUtils();
    @SuppressWarnings("unchecked")
    List<String> list=orderedMap.asList();
    for (String string : list)
    {
      String[] name = StringUtils.split(string, ".");
     
      if (name.length==1)
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

    private class Entries {

        private final ListOrderedMap principalNamesToEntries;

        private Entries(NodeImpl node, Collection principalNames) throws RepositoryException {
            principalNamesToEntries = new ListOrderedMap();
            for (Iterator it = principalNames.iterator(); it.hasNext();) {
                principalNamesToEntries.put(it.next(), new ArrayList());
            }
            collectEntries(node);
        }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

     * @param table The table
     * @return The parameters
     */
    public Map getParametersFor(Table table)
    {
        ListOrderedMap result       = new ListOrderedMap();
        Map            globalParams = (Map)_parametersPerTable.get(null);
        Map            tableParams  = (Map)_parametersPerTable.get(table);

        if (globalParams != null)
        {
            result.putAll(globalParams);
        }
        if (tableParams != null)
        {
            result.putAll(tableParams);
        }
        return result;
    }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

        Map params = (Map)_parametersPerTable.get(table);

        if (params == null)
        {
            // we're using a list orderered map to retain the order
            params = new ListOrderedMap();
            _parametersPerTable.put(table, params);
        }
        params.put(paramName, paramValue);
    }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

    /**
     * {@inheritDoc}
     */
    protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
    {
        Map       fks    = new ListOrderedMap();
        ResultSet fkData = null;

        try
        {
            if (getPlatform().isDelimitedIdentifierModeOn())
          {
            // Jaybird has a problem when delimited identifiers are used as
            // it is not able to find the foreign key info for the table
            // So we have to filter manually below
              fkData = metaData.getForeignKeys(getDefaultTablePattern());
              while (fkData.next())
              {
                  Map values = readColumns(fkData, getColumnsForFK());
 
                    if (tableName.equals(values.get("FKTABLE_NAME")))
                    {
                      readForeignKey(metaData, values, fks);
                    }
              }
          }
            else
            {
              fkData = metaData.getForeignKeys(tableName);
              while (fkData.next())
              {
                  Map values = readColumns(fkData, getColumnsForFK());
 
                  readForeignKey(metaData, values, fks);
              }
            }
        }
        finally
        {
            if (fkData != null)
            {
                fkData.close();
            }
        }
        return fks.values();
    }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

     */
    protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
    {
        // Jaybird is not able to read indices when delimited identifiers are turned on,
        // so we gather the data manually using Firebird's system tables
        Map          indices = new ListOrderedMap();
        StringBuffer query   = new StringBuffer();
       
        query.append("SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE,");
        query.append(" a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE");
        query.append(" FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?");

        PreparedStatement stmt      = getConnection().prepareStatement(query.toString());
        ResultSet         indexData = null;

        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());

        try
        {
          indexData = stmt.executeQuery();

            while (indexData.next())
            {
                Map values = readColumns(indexData, getColumnsForIndex());

                // we have to reverse the meaning of the unique flag
                values.put("NON_UNIQUE", Boolean.FALSE.equals(values.get("NON_UNIQUE")) ? Boolean.TRUE : Boolean.FALSE);
                // and trim the names
                values.put("INDEX_NAME"((String)values.get("INDEX_NAME")).trim());
                values.put("TABLE_NAME"((String)values.get("TABLE_NAME")).trim());
                values.put("COLUMN_NAME", ((String)values.get("COLUMN_NAME")).trim());
                readIndex(metaData, values, indices);
            }
        }
        finally
        {
            if (indexData != null)
            {
                indexData.close();
            }
        }
        return indices.values();
    }
View Full Code Here

Examples of org.apache.commons.collections.map.ListOrderedMap

     * @param tableName The name of the table from which to retrieve FK information
     * @return The foreign keys
     */
    protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
    {
        Map       fks    = new ListOrderedMap();
        ResultSet fkData = null;

        try
        {
            fkData = metaData.getForeignKeys(tableName);

            while (fkData.next())
            {
                Map values = readColumns(fkData, getColumnsForFK());

                readForeignKey(metaData, values, fks);
            }
        }
        finally
        {
            if (fkData != null)
            {
                fkData.close();
            }
        }
        return fks.values();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.