Package org.apache.directory.ldapstudio.browser.core.model

Examples of org.apache.directory.ldapstudio.browser.core.model.RDN


     * @param entry2 the second entry
     * @return a negative integer, zero, or a positive integer
     */
    private int compareRdns( IEntry entry1, IEntry entry2 )
    {
        RDN rdn1 = entry1.getRdn();
        RDN rdn2 = entry2.getRdn();

        if ( rdn1 == null && rdn2 == null )
        {
            return equal();
        }
        else if ( rdn1 == null && rdn2 != null )
        {
            return greaterThan();
        }
        else if ( rdn1 != null && rdn2 == null )
        {
            return lessThan();
        }
        else
        {
            return compare( rdn1.toString(), rdn2.toString() );
        }
    }
View Full Code Here


     * @return a negative integer, zero, or a positive integer
     */
    private int compareRdnValues( IEntry entry1, IEntry entry2 )
    {

        RDN rdn1 = entry1.getRdn();
        RDN rdn2 = entry2.getRdn();

        if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) )
            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) )
        {
            return equal();
        }
        else if ( ( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) )
            && !( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) )
        {
            return greaterThan();
        }
        else if ( !( rdn1 == null || rdn1.getValue() == null || "".equals( rdn1.getValue() ) )
            && ( rdn2 == null || rdn2.getValue() == null || "".equals( rdn2.getValue() ) ) )
        {
            return lessThan();
        }

        else if ( rdn1.getValue().matches( "\\d*" ) && !rdn2.getValue().matches( "\\d*" ) )
        {
            // return lessThan();
            return compare( rdn1.getValue(), rdn2.getValue() );
        }
        else if ( !rdn1.getValue().matches( "\\d*" ) && rdn2.getValue().matches( "\\d*" ) )
        {
            // return greaterThan();
            return compare( rdn1.getValue(), rdn2.getValue() );
        }
        else if ( rdn1.getValue().matches( "\\d*" ) && rdn2.getValue().matches( "\\d*" ) )
        {
            BigInteger bi1 = new BigInteger( rdn1.getValue() );
            BigInteger bi2 = new BigInteger( rdn2.getValue() );
            return compare( bi1, bi2 );
            // return Integer.parseInt(rdn1.getValue()) -
            // Integer.parseInt(rdn2.getValue());
        }
        else
        {
            return compare( rdn1.getValue(), rdn2.getValue() );
        }
    }
View Full Code Here

        {
            return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_BROWSER_SCHEMABROWSEREDITOR );
        }
        else
        {
            RDN rdn = entry.getRdn();
            RDNPart[] rdnParts = rdn.getParts();
            for ( int i = 0; i < rdnParts.length; i++ )
            {
                RDNPart part = rdnParts[i];
                if ( "cn".equals( part.getType() ) || "sn".equals( part.getType() ) || "uid".equals( part.getType() )
                    || "userid".equals( part.getType() ) )
View Full Code Here

        else if ( wizard.getSelectedEntry() != null )
        {
            parentDn = wizard.getSelectedEntry().getDn();
        }

        RDN rdn = newEntry.getRdn();

        dnBuilderWidget.setInput( wizard.getSelectedConnection(), attributeNames, rdn, parentDn );
    }
View Full Code Here

                    else
                    {
                        rdnLine.rdnDeleteButton.setEnabled( false );
                    }
                }
                rdn = new RDN( rdnNames, rdnValues, false );
            }
            catch ( Exception e )
            {
                rdnE = e;
                rdn = null;
View Full Code Here

    protected void renameEntry( final IEntry entry )
    {
        RenameEntryDialog renameDialog = new RenameEntryDialog( getShell(), entry );
        if ( renameDialog.open() == Dialog.OK )
        {
            RDN newRdn = renameDialog.getRdn();
            boolean deleteOldRdn = renameDialog.isDeleteOldRdn();
            if ( newRdn != null && !newRdn.equals( entry.getRdn() ) )
            {
                new RenameEntryJob( entry, newRdn, deleteOldRdn ).execute();
            }
        }
    }
View Full Code Here

    }


    public DN getDn()
    {
        DN dn = new DN( new RDN( this.rdn ), this.parent.getDn() );
        return dn;
    }
View Full Code Here

            {
                entryToCopy = srs[0].getEntry();
                IAttribute[] attributesToCopy = entryToCopy.getAttributes();

                // create new entry
                RDN rdn = entryToCopy.getRdn();
                IEntry newEntry = new Entry( parent, rdn );

                // change RDN if entry already exists
                ExtendedProgressMonitor testMonitor = new ExtendedProgressMonitor( monitor );
                IEntry testEntry = parent.getConnection().getEntry( newEntry.getDn(), testMonitor );
                if ( testEntry != null )
                {
                    String rdnValue = rdn.getValue();
                    String newRdnValue = BrowserCoreMessages.bind( BrowserCoreMessages.copy_n_of_s, "", rdnValue ); //$NON-NLS-1$
                    RDN newRdn = getNewRdn( rdn, newRdnValue );
                    newEntry = new Entry( parent, newRdn );
                    testEntry = parent.getConnection().getEntry( newEntry.getDn(), testMonitor );
                    for ( int i = 2; testEntry != null; i++ )
                    {
                        newRdnValue = BrowserCoreMessages.bind( BrowserCoreMessages.copy_n_of_s, i + " ", rdnValue ); //$NON-NLS-1$
                        newRdn = getNewRdn( rdn, newRdnValue );
                        newEntry = new Entry( parent, newRdn );
                        testEntry = parent.getConnection().getEntry( newEntry.getDn(), testMonitor );
                    }
                }

                // copy attributes
                for ( int i = 0; i < attributesToCopy.length; i++ )
                {
                    IAttribute attributeToCopy = attributesToCopy[i];

                    if ( SchemaUtils.isModifyable( attributeToCopy.getAttributeTypeDescription() )
                        || IAttribute.REFERRAL_ATTRIBUTE.equalsIgnoreCase( attributeToCopy.getDescription() ) )
                    {
                        IAttribute newAttribute = new Attribute( newEntry, attributeToCopy.getDescription() );
                        newEntry.addAttribute( newAttribute );
                        IValue[] valuesToCopy = attributeToCopy.getValues();
                        for ( int j = 0; j < valuesToCopy.length; j++ )
                        {
                            IValue valueToCopy = valuesToCopy[j];
                            IValue newValue = new Value( newAttribute, valueToCopy.getRawValue() );
                            newAttribute.addValue( newValue );
                        }
                    }
                }

                // check if RDN attributes ar present
                RDN newRdn = newEntry.getRdn();
                RDNPart[] oldRdnParts = rdn.getParts();
                for ( int i = 0; i < oldRdnParts.length; i++ )
                {
                    RDNPart part = oldRdnParts[i];
                    IAttribute rdnAttribute = newEntry.getAttribute( part.getType() );
                    if ( rdnAttribute != null )
                    {
                        IValue[] values = rdnAttribute.getValues();
                        for ( int ii = 0; ii < values.length; ii++ )
                        {
                            if ( part.getUnencodedValue().equals( values[ii].getRawValue() ) )
                            {
                                rdnAttribute.deleteValue( values[ii] );
                            }
                            if ( rdnAttribute.getValueSize() == 0 )
                            {
                                newEntry.deleteAttribute( rdnAttribute );
                            }
                        }
                    }
                }
                RDNPart[] newRdnParts = newRdn.getParts();
                for ( int i = 0; i < newRdnParts.length; i++ )
                {
                    RDNPart part = newRdnParts[i];
                    IAttribute rdnAttribute = newEntry.getAttribute( part.getType() );
                    if ( rdnAttribute == null )
View Full Code Here

    private RDN getNewRdn( RDN rdn, String newRdnValue ) throws NameException
    {
        String[] names = rdn.getTypes();
        String[] values = rdn.getValues();
        values[0] = newRdnValue;
        RDN newRdn = new RDN( names, values, true );
        return newRdn;
    }
View Full Code Here

     * @param entry2 the second entry
     * @return a negative integer, zero, or a positive integer
     */
    private int compareRdns( IEntry entry1, IEntry entry2 )
    {
        RDN rdn1 = entry1.getRdn();
        RDN rdn2 = entry2.getRdn();

        if ( rdn1 == null && rdn2 == null )
        {
            return equal();
        }
        else if ( rdn1 == null && rdn2 != null )
        {
            return greaterThan();
        }
        else if ( rdn1 != null && rdn2 == null )
        {
            return lessThan();
        }
        else
        {
            return compare( rdn1.toString(), rdn2.toString() );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.browser.core.model.RDN

Copyright © 2018 www.massapicom. 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.