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

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


            dispose();

            // cleanup attribute hierarchy after editing
            for ( Iterator<IAttribute> it = attributeHierarchy.iterator(); it.hasNext(); )
            {
                IAttribute attribute = it.next();
                if ( attribute != null )
                {
                    // remove empty values
                    IValue[] values = attribute.getValues();
                    for ( int i = 0; i < values.length; i++ )
                    {
                        if ( values[i].isEmpty() )
                        {
                            attribute.deleteEmptyValue();
                        }
                    }

                    // delete attribute from entry if all values were deleted
                    if ( attribute.getValueSize() == 0 )
                    {
                        attribute.getEntry().deleteAttribute( attribute );
                    }
                }
            }
        }
        return returnValue;
View Full Code Here


        universalListener.setInput( attributeHierarchy );

        // start edit mode if an empty value exists
        for ( Iterator<IAttribute> it = attributeHierarchy.iterator(); it.hasNext(); )
        {
            IAttribute attribute = it.next();
            IValue[] values = attribute.getValues();
            for ( int i = 0; i < values.length; i++ )
            {
                IValue value = values[i];
                if ( value.isEmpty() )
                {
View Full Code Here

        if ( wizard.getSelectedConnection() != null )
        {
            availableObjectClasses.addAll( wizard.getSelectedConnection().getSchema().getObjectClassDescriptions() );

            DummyEntry newEntry = wizard.getPrototypeEntry();
            IAttribute ocAttribute = newEntry.getAttribute( SchemaConstants.OBJECT_CLASS_AT );
            if ( ocAttribute != null )
            {
                for ( IValue ocValue : ocAttribute.getValues() )
                {
                    if ( !ocValue.isEmpty() )
                    {
                        ObjectClassDescription ocd = wizard.getSelectedConnection().getSchema()
                            .getObjectClassDescription( ocValue.getStringValue() );
View Full Code Here

        try
        {
            EventRegistry.suspendEventFiringInCurrentThread();

            // set new objectClass values
            IAttribute ocAttribute = newEntry.getAttribute( SchemaConstants.OBJECT_CLASS_AT );
            if ( ocAttribute == null )
            {
                ocAttribute = new Attribute( newEntry, SchemaConstants.OBJECT_CLASS_AT );
                newEntry.addAttribute( ocAttribute );
            }
            IValue[] values = ocAttribute.getValues();
            for ( IValue value : values )
            {
                ocAttribute.deleteValue( value );
            }
            for ( ObjectClassDescription ocd : selectedObjectClasses )
            {
                ocAttribute.addValue( new Value( ocAttribute, ocd.getNames().get( 0 ) ) );
            }
        }
        finally
        {
            EventRegistry.resumeEventFiringInCurrentThread();
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void run()
    {
        IAttribute attribute = null;
        if ( getSelectedValues().length == 1 )
        {
            attribute = getSelectedValues()[0].getAttribute();
        }
        else if ( getSelectedAttributes().length == 1 )
        {
            attribute = getSelectedAttributes()[0];
        }
        else if ( getSelectedAttributeHierarchies().length == 1 )
        {
            attribute = getSelectedAttributeHierarchies()[0].getAttribute();
        }

        attribute.addEmptyValue();
    }
View Full Code Here

                || ( !hasEMR && modifyModeNoEMR == ModifyMode.ADD_DELETE );
            boolean isOrderedValue = atd.getExtensions().containsKey( "X-ORDERED" )
                && atd.getExtensions().get( "X-ORDERED" ).contains( "VALUES" );

            // get old an new values for comparison
            IAttribute oldAttribute = oldEntry.getAttribute( attributeDescription );
            Set<String> oldValues = new HashSet<String>();
            Map<String, LdifAttrValLine> oldAttrValLines = new LinkedHashMap<String, LdifAttrValLine>();
            if ( oldAttribute != null )
            {
                for ( IValue value : oldAttribute.getValues() )
                {
                    LdifAttrValLine attrValLine = computeDiffCreateAttrValLine( value );
                    oldValues.add( attrValLine.getUnfoldedValue() );
                    oldAttrValLines.put( attrValLine.getUnfoldedValue(), attrValLine );
                }
            }
            IAttribute newAttribute = newEntry.getAttribute( attributeDescription );
            Set<String> newValues = new HashSet<String>();
            Map<String, LdifAttrValLine> newAttrValLines = new LinkedHashMap<String, LdifAttrValLine>();
            if ( newAttribute != null )
            {
                for ( IValue value : newAttribute.getValues() )
                {
                    LdifAttrValLine attrValLine = computeDiffCreateAttrValLine( value );
                    newValues.add( attrValLine.getUnfoldedValue() );
                    newAttrValLines.put( attrValLine.getUnfoldedValue(), attrValLine );
                }
            }

            // check what to do
            if ( oldAttribute != null && newAttribute == null )
            {
                // attribute only exists in the old entry: delete all values
                LdifModSpec modSpec;
                if ( isReplaceForced )
                {
                    // replace (empty value list)
                    modSpec = LdifModSpec.createReplace( attributeDescription );
                }
                else
                // addDelForced or default
                {
                    // delete all
                    modSpec = LdifModSpec.createDelete( attributeDescription );
                }
                modSpec.finish( LdifModSpecSepLine.create() );
                record.addModSpec( modSpec );
            }
            else if ( oldAttribute == null && newAttribute != null )
            {
                // attribute only exists in the new entry: add all values
                LdifModSpec modSpec;
                if ( isReplaceForced )
                {
                    // replace (all values)
                    modSpec = LdifModSpec.createReplace( attributeDescription );
                }
                else
                // addDelForced or default
                {
                    // add (all new values)
                    modSpec = LdifModSpec.createAdd( attributeDescription );
                }
                for ( IValue value : newAttribute.getValues() )
                {
                    modSpec.addAttrVal( computeDiffCreateAttrValLine( value ) );
                }
                modSpec.finish( LdifModSpecSepLine.create() );
                record.addModSpec( modSpec );
            }
            else if ( oldAttribute != null && newAttribute != null && !oldValues.equals( newValues ) )
            {
                // attribute exists in both entries, check modifications
                if ( isReplaceForced )
                {
                    // replace (all new values)
                    LdifModSpec modSpec = LdifModSpec.createReplace( attributeDescription );
                    for ( IValue value : newAttribute.getValues() )
                    {
                        modSpec.addAttrVal( computeDiffCreateAttrValLine( value ) );
                    }
                    modSpec.finish( LdifModSpecSepLine.create() );
                    record.addModSpec( modSpec );
View Full Code Here

     */
    public AttributeHierarchy getAttributeWithSubtypes( String attributeDescription )
    {
        List<IAttribute> attributeList = new ArrayList<IAttribute>();

        IAttribute myAttribute = getAttribute( attributeDescription );
        if ( myAttribute != null )
        {
            attributeList.add( myAttribute );
        }

View Full Code Here


    public Collection<ObjectClassDescription> getObjectClassDescriptions()
    {
        Collection<ObjectClassDescription> ocds = new ArrayList<ObjectClassDescription>();
        IAttribute ocAttribute = getAttribute( SchemaConstants.OBJECT_CLASS_AT );
        if ( ocAttribute != null )
        {
            String[] ocNames = ocAttribute.getStringValues();
            Schema schema = getBrowserConnection().getSchema();
            for ( String ocName : ocNames )
            {
                ObjectClassDescription ocd = schema.getObjectClassDescription( ocName );
                ocds.add( ocd );
View Full Code Here

        // check argument
        if ( o == null || !( o instanceof IAttribute ) )
        {
            return false;
        }
        IAttribute a = ( IAttribute ) o;

        // compare entries
        if ( !getEntry().equals( a.getEntry() ) )
        {
            return false;
        }

        // compare attribute description
        return getDescription().equals( a.getDescription() );
    }
View Full Code Here

    }


    private static LdifAttrValLine computeDiffCreateAttrValLine( IValue value )
    {
        IAttribute attribute = value.getAttribute();
        if ( attribute.isBinary() )
        {
            return LdifAttrValLine.create( attribute.getDescription(), value.getBinaryValue() );
        }
        else
        {
            return LdifAttrValLine.create( attribute.getDescription(), value.getStringValue() );
        }
    }
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.