Package org.apache.directory.studio.schemaeditor.model

Examples of org.apache.directory.studio.schemaeditor.model.ObjectClassImpl


                    o1Names = at1.getNames();
                    o2Names = at2.getNames();
                }
                else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof ObjectClassImpl ) )
                {
                    ObjectClassImpl oc1 = ( ObjectClassImpl ) o1;
                    ObjectClassImpl oc2 = ( ObjectClassImpl ) o2;

                    o1Names = oc1.getNames();
                    o2Names = oc2.getNames();
                }
                else if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof ObjectClassImpl ) )
                {
                    AttributeTypeImpl at = ( AttributeTypeImpl ) o1;
                    ObjectClassImpl oc = ( ObjectClassImpl ) o2;

                    o1Names = at.getNames();
                    o2Names = oc.getNames();
                }
                else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof AttributeTypeImpl ) )
                {
                    ObjectClassImpl oc = ( ObjectClassImpl ) o1;
                    AttributeTypeImpl at = ( AttributeTypeImpl ) o2;

                    o1Names = oc.getNames();
                    o2Names = at.getNames();
                }

                // Comparing the First Name
                if ( ( o1Names != null ) && ( o2Names != null ) )
                {
                    if ( ( o1Names.length > 0 ) && ( o2Names.length > 0 ) )
                    {
                        return o1Names[0].compareToIgnoreCase( o2Names[0] );
                    }
                    else if ( ( o1Names.length == 0 ) && ( o2Names.length > 0 ) )
                    {
                        return "".compareToIgnoreCase( o2Names[0] );
                    }
                    else if ( ( o1Names.length > 0 ) && ( o2Names.length == 0 ) )
                    {
                        return o1Names[0].compareToIgnoreCase( "" );
                    }
                }

                // Default
                return o1.toString().compareToIgnoreCase( o2.toString() );
            }
        };

        oidSorter = new Comparator<SchemaObject>()
        {
            public int compare( SchemaObject o1, SchemaObject o2 )
            {
                if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof AttributeTypeImpl ) )
                {
                    AttributeTypeImpl at1 = ( AttributeTypeImpl ) o1;
                    AttributeTypeImpl at2 = ( AttributeTypeImpl ) o2;

                    return at1.getOid().compareToIgnoreCase( at2.getOid() );
                }
                else if ( ( o1 instanceof ObjectClassImpl ) && ( o2 instanceof ObjectClassImpl ) )
                {
                    ObjectClassImpl oc1 = ( ObjectClassImpl ) o1;
                    ObjectClassImpl oc2 = ( ObjectClassImpl ) o2;

                    return oc1.getOid().compareToIgnoreCase( oc2.getOid() );
                }
                else if ( ( o1 instanceof AttributeTypeImpl ) && ( o2 instanceof ObjectClassImpl ) )
                {
                    AttributeTypeImpl at = ( AttributeTypeImpl ) o1;
                    ObjectClassImpl oc = ( ObjectClassImpl ) o2;

                    return at.getOid().compareToIgnoreCase( oc.getOid() );
                }
                else if ( ( o1 instanceof ObjectClassWrapper ) && ( o2 instanceof AttributeTypeImpl ) )
                {
                    ObjectClassImpl oc = ( ObjectClassImpl ) o1;
                    AttributeTypeImpl at = ( AttributeTypeImpl ) o2;

                    return oc.getOid().compareToIgnoreCase( at.getOid() );
                }

                // Default
                return o1.toString().compareToIgnoreCase( o2.toString() );
            }
View Full Code Here


                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }
        else if ( element instanceof ObjectClassImpl )
        {
            ObjectClassImpl oc = ( ObjectClassImpl ) element;

            // Label
            if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = ViewUtils.concateAliases( names );
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
            {
                label = oc.getOid();
            }
            else
            // Default
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }

            // Abbreviate
            if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
            {
                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }

        // Secondary Label
        if ( secondaryLabelDisplay )
        {
            String secondaryLabel = ""; //$NON-NLS-1$
            if ( element instanceof AttributeTypeImpl )
            {
                AttributeTypeImpl at = ( AttributeTypeImpl ) element;

                if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
                {
                    secondaryLabel = at.getOid();
                }
            }
            else if ( element instanceof ObjectClassImpl )
            {
                ObjectClassImpl oc = ( ObjectClassImpl ) element;

                if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SEARCH_VIEW_LABEL_OID )
                {
                    secondaryLabel = oc.getOid();
                }
            }

            if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
            {
View Full Code Here

        attributeTypes = schemaHandler.getAttributeTypes();
        objectClasses = schemaHandler.getObjectClasses();

        if ( parentElement instanceof ObjectClassImpl )
        {
            ObjectClassImpl oc = ( ObjectClassImpl ) parentElement;

            ObjectClassWrapper ocw = new ObjectClassWrapper( oc, null );
            children = new ArrayList<TreeNode>();
            children.add( ocw );
        }
        else if ( parentElement instanceof AttributeTypeImpl )
        {
            AttributeTypeImpl at = ( AttributeTypeImpl ) parentElement;

            AttributeTypeWrapper atw = new AttributeTypeWrapper( at, null );
            children = new ArrayList<TreeNode>();
            children.add( atw );
        }
        else if ( parentElement instanceof ObjectClassWrapper )
        {
            ObjectClassWrapper ocw = ( ObjectClassWrapper ) parentElement;
            ObjectClassImpl oc = ocw.getObjectClass();

            if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUPERTYPE )
            {
                String[] superiors = oc.getSuperClassesNames();
                for ( String superior : superiors )
                {
                    if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
                    {
                        ObjectClassImpl supOC = schemaHandler.getObjectClass( superior );
                        if ( supOC != null )
                        {
                            ObjectClassWrapper supOCW = new ObjectClassWrapper( supOC, ocw );
                            ocw.addChild( supOCW );
                        }
                    }
                }
            }
            else if ( mode == PluginConstants.PREFS_HIERARCHY_VIEW_MODE_SUBTYPE )
            {
                for ( ObjectClassImpl objectClass : objectClasses )
                {
                    String[] superiors = objectClass.getSuperClassesNames();
                    for ( String superior : superiors )
                    {
                        if ( superior != null || "".equals( superior ) ) //$NON-NLS-1$
                        {
                            ObjectClassImpl supOC = schemaHandler.getObjectClass( superior );
                            if ( supOC != null && oc.equals( supOC ) )
                            {
                                ObjectClassWrapper supOCW = new ObjectClassWrapper( objectClass, ocw );
                                ocw.addChild( supOCW );
                            }
View Full Code Here

            message.append( " with OID '" + source.getOid() + "' does not have any alias." );
        }
        else if ( element instanceof ClassTypeHierarchyError )
        {
            ClassTypeHierarchyError classTypeHierarchyError = ( ClassTypeHierarchyError ) element;
            ObjectClassImpl source = ( ObjectClassImpl ) classTypeHierarchyError.getSource();
            ObjectClassImpl superior = ( ObjectClassImpl ) classTypeHierarchyError.getSuperior();

            if ( source.getType().equals( ObjectClassTypeEnum.ABSTRACT ) )
            {
                message.append( "Abstract object class '" + getDisplayName( source ) + "' can not extend " );

                if ( superior.getType().equals( ObjectClassTypeEnum.STRUCTURAL ) )
                {
                    message.append( "Structural object class :'" + getDisplayName( superior ) + "'." );
                }
                else if ( superior.getType().equals( ObjectClassTypeEnum.AUXILIARY ) )
                {
                    message.append( "Auxiliary object class :'" + getDisplayName( superior ) + "'." );
                }
            }
            else if ( source.getType().equals( ObjectClassTypeEnum.AUXILIARY ) )
            {
                message.append( "Auxiliary object class '" + getDisplayName( source ) + "' can not extend " );

                if ( superior.getType().equals( ObjectClassTypeEnum.STRUCTURAL ) )
                {
                    message.append( "Structural object class :'" + getDisplayName( superior ) + "'." );
                }
            }
        }
View Full Code Here

            List<Object> results = new ArrayList<Object>();

            String[] superiors = ( String[] ) inputElement;
            for ( String superior : superiors )
            {
                ObjectClassImpl oc = schemaHandler.getObjectClass( superior );
                if ( oc != null )
                {
                    results.add( oc );
                }
                else
View Full Code Here

     */
    public String getColumnText( Object element, int columnIndex )
    {
        if ( element instanceof ObjectClassImpl )
        {
            ObjectClassImpl oc = ( ObjectClassImpl ) element;

            String[] names = oc.getNames();
            if ( ( names != null ) && ( names.length > 0 ) )
            {
                return ViewUtils.concateAliases( names ) + "  -  (" + oc.getOid() + ")";
            }
            else
            {
                return "(None)  -  (" + oc.getOid() + ")";
            }
        }
        else if ( element instanceof NonExistingObjectClass )
        {
            return ( ( NonExistingObjectClass ) element ).getDisplayName();
View Full Code Here

                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }
        else if ( element instanceof ObjectClassWrapper )
        {
            ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();

            // Label
            if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = ViewUtils.concateAliases( names );
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
            {
                label = oc.getOid();
            }
            else
            // Default
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }

            // Abbreviate
            if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
            {
                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }
        else if ( element instanceof Folder )
        {
            Folder folder = ( Folder ) element;

            return folder.getName() + " (" + folder.getChildren().size() + ")";
        }

        // Secondary Label
        if ( secondaryLabelDisplay )
        {
            String secondaryLabel = ""; //$NON-NLS-1$
            if ( element instanceof AttributeTypeWrapper )
            {
                AttributeTypeImpl at = ( ( AttributeTypeWrapper ) element ).getAttributeType();

                if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
                {
                    secondaryLabel = at.getOid();
                }
            }
            else if ( element instanceof ObjectClassWrapper )
            {
                ObjectClassImpl oc = ( ( ObjectClassWrapper ) element ).getObjectClass();

                if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_VIEW_LABEL_OID )
                {
                    secondaryLabel = oc.getOid();
                }
            }

            if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
            {
View Full Code Here

                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }
        else if ( obj instanceof ObjectClassWrapper )
        {
            ObjectClassImpl oc = ( ( ObjectClassWrapper ) obj ).getObjectClass();

            // Label
            if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = ViewUtils.concateAliases( names );
                }
                else
                {
                    label = NONE;
                }
            }
            else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
            {
                label = oc.getOid();
            }
            else
            // Default
            {
                String[] names = oc.getNames();
                if ( ( names != null ) && ( names.length > 0 ) )
                {
                    label = names[0];
                }
                else
                {
                    label = NONE;
                }
            }

            // Abbreviate
            if ( abbreviate && ( abbreviateMaxLength < label.length() ) )
            {
                label = label.substring( 0, abbreviateMaxLength ) + "..."; //$NON-NLS-1$
            }
        }

        // Secondary Label
        if ( secondaryLabelDisplay )
        {
            String secondaryLabel = ""; //$NON-NLS-1$
            if ( obj instanceof AttributeTypeWrapper )
            {
                AttributeTypeImpl at = ( ( AttributeTypeWrapper ) obj ).getAttributeType();

                if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = at.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
                {
                    secondaryLabel = at.getOid();
                }
            }
            else if ( obj instanceof ObjectClassWrapper )
            {
                ObjectClassImpl oc = ( ( ObjectClassWrapper ) obj ).getObjectClass();

                if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_FIRST_NAME )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = names[0];
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES )
                {
                    String[] names = oc.getNames();
                    if ( ( names != null ) && ( names.length > 0 ) )
                    {
                        secondaryLabel = ViewUtils.concateAliases( names );
                    }
                    else
                    {
                        secondaryLabel = NONE;
                    }
                }
                else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
                {
                    secondaryLabel = oc.getOid();
                }
            }

            if ( secondaryLabelAbbreviate && ( secondaryLabelAbbreviateMaxLength < secondaryLabel.length() ) )
            {
View Full Code Here

     *
     * @throws Exception
     */
    public void testAddMandatoryATDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setMustNamesList( new String[]
            { "must" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

     *
     * @throws Exception
     */
    public void testAddOptionalATDifference() throws Exception
    {
        ObjectClassImpl o1 = new ObjectClassImpl( "1.2.3.4" );
        ObjectClassImpl o2 = new ObjectClassImpl( "1.2.3.4" );
        o2.setMayNamesList( new String[]
            { "may" } );

        List<PropertyDifference> differences = DifferenceEngine.getDifferences( o1, o2 );

        assertEquals( 1, differences.size() );
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.schemaeditor.model.ObjectClassImpl

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.