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

Examples of org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry


        super.setVisible( visible );

        if ( visible )
        {

            DummyEntry newEntry = wizard.getNewEntry();

            try
            {
                EventRegistry.suspendEventFireingInCurrentThread();

                // remove empty must attributes
                String[] oldMust = newEntry.getSubschema().getMustAttributeNames();
                for ( int i = 0; i < oldMust.length; i++ )
                {
                    IAttribute attribute = newEntry.getAttribute( oldMust[i] );
                    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
                String[] newMust = newEntry.getSubschema().getMustAttributeNames();
                for ( int i = 0; i < newMust.length; i++ )
                {
                    if ( newEntry.getAttribute( newMust[i] ) == null )
                    {
                        IAttribute att = new Attribute( newEntry, newMust[i] );
                        newEntry.addAttribute( att );
                        att.addEmptyValue();
                    }
                }
            }
            catch ( ModelModificationException e )
View Full Code Here


            try
            {
                EventRegistry.suspendEventFireingInCurrentThread();

                LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntries[0] );
                DummyEntry newEntry = ModelConverter.ldifContentRecordToEntry( record, connection );
                IAttribute[] attributes = newEntry.getAttributes();
                for ( int i = 0; i < attributes.length; i++ )
                {
                    if ( !SchemaUtils.isModifyable( attributes[i].getAttributeTypeDescription() ) )
                    {
                        newEntry.deleteAttribute( attributes[i] );
                    }
                }
                wizard.setNewEntry( newEntry );
            }
            catch ( Exception e )
            {
                e.printStackTrace();
            }
            finally
            {
                EventRegistry.resumeEventFireingInCurrentThread();
            }
        }
        else
        {
            wizard.setNewEntry( new DummyEntry( new DN(), wizard.getSelectedConnection() ) );
        }

        return super.getNextPage();
    }
View Full Code Here

        }

        if ( this.selectedConnection != null )
        {
            this.selectedConnection.suspend();
            this.newEntry = new DummyEntry( new DN(), this.selectedConnection );
        }
    }
View Full Code Here

        {
            availableObjectClasses.addAll( Arrays.asList( wizard.getSelectedConnection().getSchema()
                .getObjectClassDescriptionNames() ) );
        }

        DummyEntry newEntry = wizard.getNewEntry();
        IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
        if ( ocAttribute != null )
        {
            String[] ocValues = ocAttribute.getStringValues();
            for ( int i = 0; i < ocValues.length; i++ )
            {
View Full Code Here

    }


    private void saveState()
    {
        DummyEntry newEntry = wizard.getNewEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // set new objectClass values
            IAttribute ocAttribute = newEntry.getAttribute( IAttribute.OBJECTCLASS_ATTRIBUTE );
            if ( ocAttribute == null )
            {
                ocAttribute = new Attribute( newEntry, IAttribute.OBJECTCLASS_ATTRIBUTE );
                newEntry.addAttribute( ocAttribute );
            }
            IValue[] values = ocAttribute.getValues();
            for ( int i = 0; i < values.length; i++ )
            {
                ocAttribute.deleteValue( values[i] );
View Full Code Here


    private void loadState()
    {

        DummyEntry newEntry = this.wizard.getNewEntry();

        Subschema subschema = newEntry.getSubschema();
        String[] attributeNames = subschema.getAllAttributeNames();

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

        RDN rdn = newEntry.getRdn();

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

    }


    private void saveState()
    {
        DummyEntry newEntry = wizard.getNewEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // remove old RDN
            RDNPart[] oldRdnParts = newEntry.getRdn().getParts();
            for ( int i = 0; i < oldRdnParts.length; i++ )
            {
                IAttribute attribute = newEntry.getAttribute( oldRdnParts[i].getType() );
                if ( attribute != null )
                {
                    IValue[] values = attribute.getValues();
                    for ( int v = 0; v < values.length; v++ )
                    {
                        if ( values[v].getStringValue().equals( oldRdnParts[i].getUnencodedValue() ) )
                        {
                            attribute.deleteValue( values[v] );
                        }
                    }
                }
            }

            // set new DN
            DN dn = new DN( this.dnBuilderWidget.getRdn(), this.dnBuilderWidget.getParentDn() );
            newEntry.setDn( dn );

            // add new RDN
            RDNPart[] newRdnParts = dn.getRdn().getParts();
            for ( int i = 0; i < newRdnParts.length; i++ )
            {
                IAttribute rdnAttribute = newEntry.getAttribute( newRdnParts[i].getType() );
                if ( rdnAttribute == null )
                {
                    rdnAttribute = new Attribute( newEntry, newRdnParts[i].getType() );
                    newEntry.addAttribute( rdnAttribute );
                }
                String rdnValue = newRdnParts[i].getUnencodedValue();
                String[] stringValues = rdnAttribute.getStringValues();
                if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                {
View Full Code Here

        LdifPart[] parts = ldifRecord.getParts();

        EventRegistry.suspendEventFireingInCurrentThread();

        DummyEntry entry = new DummyEntry( new DN( ldifRecord.getDnLine().getValueAsString() ), connection );

        for ( int i = 0; i < parts.length; i++ )
        {
            if ( parts[i] instanceof LdifAttrValLine )
            {
                LdifAttrValLine line = ( LdifAttrValLine ) parts[i];
                String attributeName = line.getUnfoldedAttributeDescription();
                Object value = line.getValueAsObject();
                IAttribute attribute = entry.getAttribute( attributeName );
                if ( attribute == null )
                {
                    attribute = new Attribute( entry, attributeName );
                    entry.addAttribute( attribute );
                }
                attribute.addValue( new Value( attribute, value ) );
            }
            else if ( !( parts[i] instanceof LdifDnLine ) && !( parts[i] instanceof LdifSepLine ) )
            {
                String name = parts[i].toRawString();
                name = name.replaceAll( "\n", "" );
                name = name.replaceAll( "\r", "" );
                IAttribute attribute = new Attribute( entry, name );
                attribute.addValue( new Value( attribute, parts[i] ) );
                entry.addAttribute( attribute );
                // IAttribute attribute = entry.getAttribute("");
                // if(attribute == null) {
                // attribute = new Attribute(entry, "");
                // entry.addAttribute(attribute, null);
                // }
View Full Code Here

     * Initializes the DN builder widget with the DN of
     * the prototype entry. Called when this page becomes visible.
     */
    private void loadState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        Subschema subschema = newEntry.getSubschema();
        String[] attributeNames = subschema.getAllAttributeNames();

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

        RDN rdn = newEntry.getRdn();

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

    /**
     * Saves the DN of the DN builder widget to the prototype entry.
     */
    private void saveState()
    {
        DummyEntry newEntry = wizard.getPrototypeEntry();

        try
        {
            EventRegistry.suspendEventFireingInCurrentThread();

            // remove old RDN
            RDNPart[] oldRdnParts = newEntry.getRdn().getParts();
            for ( int i = 0; i < oldRdnParts.length; i++ )
            {
                IAttribute attribute = newEntry.getAttribute( oldRdnParts[i].getType() );
                if ( attribute != null )
                {
                    IValue[] values = attribute.getValues();
                    for ( int v = 0; v < values.length; v++ )
                    {
                        if ( values[v].getStringValue().equals( oldRdnParts[i].getUnencodedValue() ) )
                        {
                            attribute.deleteValue( values[v] );
                        }
                    }
                }
            }

            // set new DN
            DN dn = new DN( dnBuilderWidget.getRdn(), dnBuilderWidget.getParentDn() );
            newEntry.setDn( dn );

            // add new RDN
            RDNPart[] newRdnParts = dn.getRdn().getParts();
            for ( int i = 0; i < newRdnParts.length; i++ )
            {
                IAttribute rdnAttribute = newEntry.getAttribute( newRdnParts[i].getType() );
                if ( rdnAttribute == null )
                {
                    rdnAttribute = new Attribute( newEntry, newRdnParts[i].getType() );
                    newEntry.addAttribute( rdnAttribute );
                }
                String rdnValue = newRdnParts[i].getUnencodedValue();
                String[] stringValues = rdnAttribute.getStringValues();
                if ( !Arrays.asList( stringValues ).contains( rdnValue ) )
                {
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.browser.core.internal.model.DummyEntry

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.