Examples of SortKey


Examples of org.apache.directory.api.ldap.model.message.controls.SortKey

        SortRequestDecorator decorator = new SortRequestDecorator( codec );
        SortRequest control = ( SortRequest ) decorator.decode( buffer.array() );
       
        assertEquals( 1, control.getSortKeys().size() );
       
        SortKey sk = control.getSortKeys().get( 0 );
        assertEquals( "cn", sk.getAttributeTypeDesc() );
        assertNull( sk.getMatchingRuleId() );
        assertFalse( sk.isReverseOrder() );
       
        ByteBuffer encoded = ByteBuffer.allocate( buffer.capacity() );
        decorator.computeLength();
        decorator.encode( encoded );
        assertTrue( Arrays.equals( buffer.array(), encoded.array() ) );
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.controls.SortKey

                if ( IS_DEBUG )
                {
                    LOG.debug( "AttributeTypeDesc = " + atDesc );
                }
               
                SortKey sk = new SortKey( atDesc );
                container.setCurrentKey( sk );
                container.getControl().addSortKey( sk );
            }

        };
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.controls.SortKey

        List<SortKey> lst = getSortKeys();

        for ( int i = 0; i < lst.size(); i++ )
        {
            SortKey sk = lst.get( i );
            int skLen = sortKeyLenList.get( i );

            buffer.put( UniversalTag.SEQUENCE.getValue() );
            buffer.put( TLV.getBytes( skLen ) );

            BerValue.encode( buffer, sk.getAttributeTypeDesc() );

            if ( sk.getMatchingRuleId() != null )
            {
                BerValue.encode( buffer, sk.getMatchingRuleId() );
            }

            BerValue.encode( buffer, sk.isReverseOrder() );
        }

        return buffer;
    }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.controls.SortKey

            ldapResult.setDiagnosticMessage( "Cannot sort results based on more than one attribute" );
            resp.setSortResult( SortResultCode.UNWILLINGTOPERFORM );
            return resp;
        }
       
        SortKey sk = keys.get( 0 );
       
        AttributeType at = schemaManager.getAttributeType( sk.getAttributeTypeDesc() );
       
        if ( at == null )
        {
           ldapResult.setDiagnosticMessage( "No attribute with the name " + sk.getAttributeTypeDesc() + " exists in the server's schema" );
           resp.setSortResult( SortResultCode.NOSUCHATTRIBUTE );
           resp.setAttributeName( sk.getAttributeTypeDesc() );
           return resp;
        }
       
        String mrOid = sk.getMatchingRuleId();
       
        if( mrOid != null )
        {
            MatchingRule mr = at.getOrdering();
           
            if( mr != null )
            {
                if( !mrOid.equals( mr.getOid() ) )
                {
                    ldapResult.setDiagnosticMessage( "Given matchingrule " + mrOid + " is not applicable for the attribute " + sk.getAttributeTypeDesc() );
                    resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
                    resp.setAttributeName( sk.getAttributeTypeDesc() );
                    return resp;       
                }
            }
           
            try
            {
                schemaManager.lookupComparatorRegistry( mrOid );
            }
            catch ( LdapException e )
            {
                ldapResult.setDiagnosticMessage( "Given matchingrule " + mrOid + " is not supported" );
                resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
                resp.setAttributeName( sk.getAttributeTypeDesc() );
                return resp;       
            }
        }
        else
        {
            MatchingRule mr = at.getOrdering();
           
            if( mr == null )
            {
                mr = at.getEquality();
            }
           
            ldapResult.setDiagnosticMessage( "Matchingrule is required for sorting by the attribute " + sk.getAttributeTypeDesc() );
            resp.setSortResult( SortResultCode.INAPPROPRIATEMATCHING );
            resp.setAttributeName( sk.getAttributeTypeDesc() );
           
            if( mr == null )
            {
                return resp;
            }
View Full Code Here

Examples of org.apache.directory.api.ldap.model.message.controls.SortKey

            unsortedEntries.beforeFirst();
           
            return unsortedEntries;
        }
       
        SortKey sk = control.getSortKeys().get( 0 );
       
        AttributeType at = schemaManager.getAttributeType( sk.getAttributeTypeDesc() );
       
        SortedEntryComparator comparator = new SortedEntryComparator( at, sk.getMatchingRuleId(), sk.isReverseOrder(), schemaManager );
       
        SortedEntrySerializer keySerializer = new SortedEntrySerializer( comparator );
       
        PersistedBTreeConfiguration<Entry, String> config = new PersistedBTreeConfiguration<Entry, String>();
        config.setName( UUID.randomUUID().toString() );
View Full Code Here

Examples of org.jdesktop.swingx.decorator.SortKey

            List<SortKey> newSortKeys = new ArrayList<SortKey>(getSortKeys());

            // see if we're already sorting with this column
            SortOrder columnSortOrder = SortOrder.ASCENDING;
            for(Iterator<? extends SortKey> s = newSortKeys.iterator(); s.hasNext(); ) {
                SortKey sortKey = s.next();
                if(sortKey.getSortOrder() == SortOrder.UNSORTED) continue;
                if(sortKey.getColumn() == columnIndex) {
                    columnSortOrder = (sortKey.getSortOrder() == SortOrder.ASCENDING) ? SortOrder.DESCENDING : SortOrder.ASCENDING;
                    s.remove();
                    break;
                }
            }

            // prepare the new sort order
            if(!multipleColumnSort) newSortKeys.clear();
            newSortKeys.add(new SortKey(columnSortOrder, columnIndex));

            // kick off the sort
            setSortKeys(newSortKeys);
        }
View Full Code Here

Examples of org.jdesktop.swingx.decorator.SortKey

            this.sortKeys.addAll(sortKeys);

            // rebuild the SortedList's comparator
            List<Comparator> comparators = new ArrayList<Comparator>(this.sortKeys.size());
            for(int k = 0; k < this.sortKeys.size(); k++) {
                SortKey sortKey = this.sortKeys.get(k);
                if(sortKey.getSortOrder() == SortOrder.UNSORTED) continue;

                Comparator comparator = getComparator(sortKey.getColumn());
                if(sortKey.getSortOrder() == SortOrder.DESCENDING) comparator = GlazedLists.reverseComparator(comparator);

                comparators.add(comparator);
            }

            // figure out the final comparator
View Full Code Here

Examples of org.jdesktop.swingx.decorator.SortKey

        }

        /** {@inheritDoc} */
        public SortOrder getSortOrder(int columnIndex) {
            for(int k = 0; k < this.sortKeys.size(); k++) {
                SortKey s = this.sortKeys.get(k);
                if(s.getColumn() == columnIndex) return s.getSortOrder();
            }
            return SortOrder.UNSORTED;
        }
View Full Code Here

Examples of org.nasutekds.server.types.SortKey

   */
  @Test()
  public void testRequestConstructor1()
              throws Exception
  {
    SortKey sortKey = new SortKey(givenNameType, true);
    SortOrder sortOrder = new SortOrder(sortKey);
    new ServerSideSortRequestControl(sortOrder).toString();
    sortKey.toString();
    sortOrder.toString();

    sortKey = new SortKey(givenNameType, false);
    sortOrder = new SortOrder(sortKey);
    new ServerSideSortRequestControl(sortOrder).toString();
    sortKey.toString();
    sortOrder.toString();

    SortKey[] sortKeys =
    {
      new SortKey(snType, true),
      new SortKey(givenNameType, true)
    };
    sortOrder = new SortOrder(sortKeys);
    new ServerSideSortRequestControl(sortOrder).toString();
    sortOrder.toString();
  }
View Full Code Here

Examples of org.nasutekds.server.types.SortKey

    SortKey[] sortKeys = sortOrder.getSortKeys();
    values = new AttributeValue[sortKeys.length];
    for (int i=0; i < sortKeys.length; i++)
    {
      SortKey sortKey = sortKeys[i];
      AttributeType attrType = sortKey.getAttributeType();
      List<Attribute> attrList = entry.getAttribute(attrType);
      if (attrList != null)
      {
        AttributeValue sortValue = null;

        // There may be multiple versions of this attribute in the target entry
        // (e.g., with different sets of options), and it may also be a
        // multivalued attribute.  In that case, we need to find the value that
        // is the best match for the corresponding sort key (i.e., for sorting
        // in ascending order, we want to find the lowest value; for sorting in
        // descending order, we want to find the highest value).  This is
        // handled by the SortKey.compareValues method.
        for (Attribute a : attrList)
        {
          for (AttributeValue v : a)
          {
            if (sortValue == null)
            {
              sortValue = v;
            }
            else if (sortKey.compareValues(v, sortValue) < 0)
            {
              sortValue = v;
            }
          }
        }
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.