Package org.apache.directory.studio.ldapbrowser.core.model

Examples of org.apache.directory.studio.ldapbrowser.core.model.IAttribute


                    AttributeHierarchy ah = entry.getAttributeWithSubtypes( ras[r] );
                    if ( ah != null )
                    {
                        for ( Iterator<IAttribute> it = ah.iterator(); it.hasNext(); )
                        {
                            IAttribute attribute = it.next();
                            entry.deleteAttribute( attribute );
                        }
                    }
                }
            }
            else
            {
                // clear all
                IAttribute[] oldAttributes = entry.getAttributes();
                for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
                {
                    entry.deleteAttribute( oldAttributes[i] );
                }
            }

            // additional clear old attributes if the record contains the attribute
            NamingEnumeration<? extends Attribute> attributeEnumeration = sr.getAttributes().getAll();
            while ( attributeEnumeration.hasMore() )
            {
                Attribute attribute = attributeEnumeration.next();
                String attributeDescription = attribute.getID();
                IAttribute oldAttribute = entry.getAttribute( attributeDescription );
                if ( oldAttribute != null )
                {
                    entry.deleteAttribute( oldAttribute );
                }
            }

            // set new attributes and values
            attributeEnumeration = sr.getAttributes().getAll();
            while ( attributeEnumeration.hasMore() )
            {
                Attribute attribute = attributeEnumeration.next();
                String attributeDescription = attribute.getID();

                if ( attribute.getAll().hasMore() )
                {
                    IAttribute studioAttribute = null;
                    if ( entry.getAttribute( attributeDescription ) == null )
                    {
                        studioAttribute = new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute( entry,
                            attributeDescription );
                        entry.addAttribute( studioAttribute );
                    }
                    else
                    {
                        studioAttribute = entry.getAttribute( attributeDescription );
                    }

                    NamingEnumeration<?> valueEnumeration = attribute.getAll();
                    while ( valueEnumeration.hasMore() )
                    {
                        Object value = valueEnumeration.next();
                        studioAttribute.addValue( new Value( studioAttribute, value ) );
                    }
                }
            }
        }
    }
View Full Code Here


    /**
     * Opens the editor and adds the new value to the list.
     */
    private void addValue()
    {
        IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
        IValue value = new Value( attribute, "" ); //$NON-NLS-1$
        Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

        CellEditor cellEditor = valueEditor.getCellEditor();
        cellEditor.setValue( oldRawValue );
View Full Code Here

    private void editValue()
    {
        String oldValue = getSelectedValue();
        if ( oldValue != null )
        {
            IAttribute attribute = new Attribute( context.getEntry(), "" ); //$NON-NLS-1$
            IValue value = new Value( attribute, oldValue ); //$NON-NLS-1$
            Object oldRawValue = valueEditor.getRawValue( value ); //$NON-NLS-1$

            CellEditor cellEditor = valueEditor.getCellEditor();
            cellEditor.setValue( oldRawValue );
View Full Code Here

            if ( dialog.open() == WizardDialog.OK )
            {
                String newAttributeDescription = wizard.getAttributeDescription();
                if ( newAttributeDescription != null && !"".equals( newAttributeDescription ) ) //$NON-NLS-1$
                {
                    IAttribute att = entry.getAttribute( newAttributeDescription );
                    if ( att == null )
                    {
                        att = new Attribute( entry, newAttributeDescription );
                        entry.addAttribute( att );
                    }

                    att.addEmptyValue();
                }
            }
        }
    }
View Full Code Here

            pageId = BrowserCommonConstants.PROP_ATTRIBUTE;
            title = getSelectedAttributes()[0].toString();
        }
        else if ( getSelectedAttributeHierarchies().length == 1 )
        {
            IAttribute att = getSelectedAttributeHierarchies()[0].getAttribute();
            element = att;
            pageId = BrowserCommonConstants.PROP_ATTRIBUTE;
            title = att.toString();
        }
        else if ( getSelectedSearches().length == 1 )
        {
            element = ( IAdaptable ) getSelectedSearches()[0];
            pageId = BrowserCommonConstants.PROP_SEARCH;
View Full Code Here

                // necessary when navigating back, modifying object classes
                // and DN and navigation forward again.
                Collection<AttributeTypeDescription> oldMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeTypeDescription oldMust : oldMusts )
                {
                    IAttribute attribute = newEntry.getAttribute( oldMust.getNumericOid() );
                    if ( attribute != null )
                    {
                        IValue[] values = attribute.getValues();
                        for ( int v = 0; v < values.length; v++ )
                        {
                            if ( values[v].isEmpty() )
                            {
                                attribute.deleteValue( values[v] );
                            }
                        }
                        if ( attribute.getValueSize() == 0 )
                        {
                            newEntry.deleteAttribute( attribute );
                        }
                    }
                }

                // add must attributes
                Collection<AttributeTypeDescription> newMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
                for ( AttributeTypeDescription newMust : newMusts )
                {
                    if ( newEntry.getAttributeWithSubtypes( newMust.getNumericOid() ) == null )
                    {
                        String friendlyIdentifier = SchemaUtils.getFriendlyIdentifier( newMust );
                        IAttribute att = new Attribute( newEntry, friendlyIdentifier );
                        newEntry.addAttribute( att );
                        att.addEmptyValue();
                    }
                }
            }
            finally
            {
View Full Code Here

                            }
                        }
                    }
                    else if ( object instanceof IAttribute )
                    {
                        IAttribute attribute = ( IAttribute ) object;
                        entry = attribute.getEntry();
                        IValue[] values = attribute.getValues();
                        for ( int v = 0; v < values.length; v++ )
                        {
                            filterSet.add( LdapFilterUtils.getFilter( values[v] ) );
                        }
                    }
View Full Code Here

                        else
                        {
                            return null;
                        }

                        IAttribute attribute = null;
                        if ( readIn.available() > 1 && entry != null )
                        {
                            int size = readIn.readInt();
                            byte[] attributeName = new byte[size];
                            readIn.read( attributeName );
                            attribute = entry.getAttribute( new String( attributeName, "UTF-8" ) ); //$NON-NLS-1$
                        }
                        else
                        {
                            return null;
                        }

                        IValue value = null;
                        if ( readIn.available() > 1 && attribute != null )
                        {
                            boolean isString = readIn.readBoolean();
                            int size = readIn.readInt();
                            byte[] val = new byte[size];
                            readIn.read( val );
                            String test = new String( val, "UTF-8" ); //$NON-NLS-1$

                            IValue[] values = attribute.getValues();
                            for ( int i = 0; i < values.length; i++ )
                            {
                                if ( isString && values[i].isString() && test.equals( values[i].getStringValue() ) )
                                {
                                    value = values[i];
View Full Code Here

    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        if ( wizard.isNewContextEntry() )
        {
            IAttribute attribute = wizard.getSelectedConnection().getRootDSE().getAttribute(
                SchemaConstants.NAMING_CONTEXTS_AT );
            if ( attribute != null )
            {
                String[] values = attribute.getStringValues();

                // content proposals
                contextEntryDnComboCPA.setContentProposalProvider( new ListContentProposalProvider( values ) );

                // fill namingContext values into combo
View Full Code Here

            {
                Iterator<AttributeTypeAndValue> atavIterator = newEntry.getRdn().iterator();
                while ( atavIterator.hasNext() )
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    IAttribute attribute = newEntry.getAttribute( atav.getUpType() );
                    if ( attribute != null )
                    {
                        IValue[] values = attribute.getValues();
                        for ( int v = 0; v < values.length; v++ )
                        {
                            if ( values[v].getStringValue().equals( atav.getNormValue().getString() ) )
                            {
                                attribute.deleteValue( values[v] );
                            }
                        }

                        // If we have removed all the values of the attribute,
                        // then we also need to remove this attribute from the
                        // entry.
                        // This test has been added to fix DIRSTUDIO-222
                        if ( attribute.getValueSize() == 0 )
                        {
                            newEntry.deleteAttribute( attribute );
                        }
                    }
                }
            }

            // set new DN
            LdapDN dn;
            if ( wizard.isNewContextEntry() )
            {
                try
                {
                    dn = new LdapDN( contextEntryDnCombo.getText() );
                }
                catch ( InvalidNameException e )
                {
                    dn = LdapDN.EMPTY_LDAPDN;
                }
            }
            else
            {
                dn = DnUtils.composeDn( dnBuilderWidget.getRdn(), dnBuilderWidget.getParentDn() );
            }
            newEntry.setDn( dn );

            // add new RDN
            if ( dn.getRdn().size() > 0 )
            {
                Iterator<AttributeTypeAndValue> atavIterator = dn.getRdn().iterator();
                while ( atavIterator.hasNext() )
                {
                    AttributeTypeAndValue atav = atavIterator.next();
                    IAttribute rdnAttribute = newEntry.getAttribute( atav.getUpType() );
                    if ( rdnAttribute == null )
                    {
                        rdnAttribute = new Attribute( newEntry, atav.getUpType() );
                        newEntry.addAttribute( rdnAttribute );
                    }
                    Object rdnValue = atav.getNormValue().getString();
                    String[] stringValues = rdnAttribute.getStringValues();
                    if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                    {
                        rdnAttribute.addValue( new Value( rdnAttribute, rdnValue ) );
                    }
                }
            }

        }
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.IAttribute

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.