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

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


     */
    public int compare( TreeNode o1, TreeNode o2 )
    {
        if ( ( o1 instanceof SchemaWrapper ) && ( o2 instanceof SchemaWrapper ) )
        {
            Schema s1 = ( ( SchemaWrapper ) o1 ).getSchema();
            Schema s2 = ( ( SchemaWrapper ) o2 ).getSchema();

            return s1.getName().compareToIgnoreCase( s2.getName() );
        }

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


                    + exceptionMessage.columnNumber + ", Cause: " + exceptionMessage.cause ) );
        }

        String schemaName = getNameFromPath( path );

        Schema schema = new SchemaImpl( schemaName );

        List<?> ats = parser.getAttributeTypes();
        for ( int i = 0; i < ats.size(); i++ )
        {
            AttributeTypeImpl at = convertAttributeType( ( AttributeTypeLiteral ) ats.get( i ) );
            at.setSchema( schemaName );
            schema.addAttributeType( at );
        }

        List<?> ocs = parser.getObjectClassTypes();
        for ( int i = 0; i < ocs.size(); i++ )
        {
            ObjectClassImpl oc = convertObjectClass( ( ObjectClassLiteral ) ocs.get( i ) );
            oc.setSchema( schemaName );
            schema.addObjectClass( oc );
        }

        return schema;
    }
View Full Code Here

        }

        // Looping on schemas from the first list
        for ( Schema schemaFromL1 : l1 )
        {
            Schema schemaFromL2 = mapL2.get( schemaFromL1.getName().toLowerCase() );
            if ( schemaFromL2 == null )
            {
                SchemaDifference schemaDifference = new SchemaDifference( schemaFromL1, null, DifferenceType.REMOVED );
                differences.add( schemaDifference );

                // Adding attribute types
                for ( AttributeTypeImpl at : schemaFromL1.getAttributeTypes() )
                {
                    schemaDifference.addAttributeTypeDifference( new AttributeTypeDifference( null, at,
                        DifferenceType.REMOVED ) );
                }

                // Adding object classes
                for ( ObjectClassImpl oc : schemaFromL1.getObjectClasses() )
                {
                    schemaDifference.addObjectClassDifference( new ObjectClassDifference( null, oc,
                        DifferenceType.REMOVED ) );
                }
            }
            else
            {
                SchemaDifference schemaDifference = new SchemaDifference( schemaFromL1, schemaFromL2,
                    DifferenceType.IDENTICAL );
                differences.add( schemaDifference );

                // Building Maps for attribute types
                Map<String, AttributeTypeImpl> atMapL1 = new HashMap<String, AttributeTypeImpl>();
                for ( AttributeTypeImpl at : schemaFromL1.getAttributeTypes() )
                {
                    atMapL1.put( at.getOid(), at );
                }
                Map<String, AttributeTypeImpl> atMapL2 = new HashMap<String, AttributeTypeImpl>();
                for ( AttributeTypeImpl at : schemaFromL2.getAttributeTypes() )
                {
                    atMapL2.put( at.getOid(), at );
                }

                // Looping on the attribute types from the Schema from the first list
                for ( AttributeTypeImpl atFromL1 : schemaFromL1.getAttributeTypes() )
                {
                    AttributeTypeImpl atFromL2 = atMapL2.get( atFromL1.getOid() );
                    if ( atFromL2 == null )
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1, null,
                            DifferenceType.REMOVED );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );
                        schemaDifference.setType( DifferenceType.MODIFIED );
                    }
                    else
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( atFromL1,
                            atFromL2, DifferenceType.IDENTICAL );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );

                        List<PropertyDifference> atDifferences = getDifferences( atFromL1, atFromL2 );
                        if ( atDifferences.size() > 0 )
                        {
                            attributeTypeDifference.setType( DifferenceType.MODIFIED );
                            attributeTypeDifference.addDifferences( atDifferences );
                            schemaDifference.setType( DifferenceType.MODIFIED );
                        }
                    }
                }

                // Looping on the attribute types from the Schema from the second list
                for ( AttributeTypeImpl atFromL2 : schemaFromL2.getAttributeTypes() )
                {
                    AttributeTypeImpl atFromL1 = atMapL1.get( atFromL2.getOid() );
                    if ( atFromL1 == null )
                    {
                        AttributeTypeDifference attributeTypeDifference = new AttributeTypeDifference( null, atFromL2,
                            DifferenceType.ADDED );
                        schemaDifference.addAttributeTypeDifference( attributeTypeDifference );
                        schemaDifference.setType( DifferenceType.MODIFIED );
                    }
                    // If atFromL1 exists, then it has already been processed when looping on the first list.
                }

                // Building Maps for object classes
                Map<String, ObjectClassImpl> ocMapL1 = new HashMap<String, ObjectClassImpl>();
                for ( ObjectClassImpl oc : schemaFromL1.getObjectClasses() )
                {
                    ocMapL1.put( oc.getOid(), oc );
                }
                Map<String, ObjectClassImpl> ocMapL2 = new HashMap<String, ObjectClassImpl>();
                for ( ObjectClassImpl oc : schemaFromL2.getObjectClasses() )
                {
                    ocMapL2.put( oc.getOid(), oc );
                }

                // Looping on the object classes from the Schema from the first list
                for ( ObjectClassImpl ocFromL1 : schemaFromL1.getObjectClasses() )
                {
                    ObjectClassImpl ocFromL2 = ocMapL2.get( ocFromL1.getOid() );
                    if ( ocFromL2 == null )
                    {
                        ObjectClassDifference objectClassDifference = new ObjectClassDifference( ocFromL1, null,
                            DifferenceType.REMOVED );
                        schemaDifference.addObjectClassDifference( objectClassDifference );
                        schemaDifference.setType( DifferenceType.MODIFIED );
                    }
                    else
                    {
                        ObjectClassDifference objectClassDifference = new ObjectClassDifference( ocFromL1, ocFromL2,
                            DifferenceType.IDENTICAL );
                        schemaDifference.addObjectClassDifference( objectClassDifference );

                        List<PropertyDifference> ocDifferences = getDifferences( ocFromL1, ocFromL2 );
                        if ( ocDifferences.size() > 0 )
                        {
                            objectClassDifference.setType( DifferenceType.MODIFIED );
                            objectClassDifference.addDifferences( ocDifferences );
                            schemaDifference.setType( DifferenceType.MODIFIED );
                        }
                    }
                }

                // Looping on the object classes from the Schema from the second list
                for ( ObjectClassImpl ocFromL2 : schemaFromL2.getObjectClasses() )
                {
                    ObjectClassImpl ocFromL1 = ocMapL1.get( ocFromL2.getOid() );
                    if ( ocFromL1 == null )
                    {
                        ObjectClassDifference objectClassDifference = new ObjectClassDifference( null, ocFromL2,
                            DifferenceType.ADDED );
                        schemaDifference.addObjectClassDifference( objectClassDifference );
                        schemaDifference.setType( DifferenceType.MODIFIED );
                    }
                    // If ocFromL1 exists, then it has already been processed when looping on the first list.
                }
            }
        }

        // Looping on schemas from the second list
        for ( Schema schemaFromL2 : l2 )
        {
            Schema schemaFromL1 = mapL1.get( schemaFromL2.getName().toLowerCase() );
            if ( schemaFromL1 == null )
            {
                SchemaDifference schemaDifference = new SchemaDifference( null, schemaFromL2, DifferenceType.ADDED );
                differences.add( schemaDifference );
View Full Code Here

    public String getSchemaValue()
    {
        StructuredSelection selection = ( StructuredSelection ) schemaComboViewer.getSelection();
        if ( !selection.isEmpty() )
        {
            Schema schema = ( Schema ) selection.getFirstElement();

            return schema.getName();
        }
        else
        {
            return null;
        }
View Full Code Here

     * @see org.eclipse.jface.action.Action#run()
     */
    public void run()
    {
        // Getting the selection
        Schema selectedSchema = null;

        int presentation = Activator.getDefault().getPreferenceStore().getInt(
            PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION );
        if ( presentation == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT )
        {
View Full Code Here

                for ( Iterator<?> iterator = selection.iterator(); iterator.hasNext(); )
                {
                    Object selectedItem = iterator.next();
                    if ( selectedItem instanceof SchemaWrapper )
                    {
                        Schema schema = ( ( SchemaWrapper ) selectedItem ).getSchema();
                        schemasMap.put( schema.getName().toLowerCase(), schema );
                    }
                    else if ( selectedItem instanceof AttributeTypeWrapper )
                    {
                        AttributeTypeImpl at = ( ( AttributeTypeWrapper ) selectedItem ).getAttributeType();
                        schemaObjectsList.add( at );
View Full Code Here

                    for ( File schemaFile : selectedSchemasFiles )
                    {
                        monitor.subTask( schemaFile.getName() );
                        try
                        {
                            Schema schema = OpenLdapSchemaFileImporter.getSchema( new FileInputStream( schemaFile ),
                                schemaFile.getAbsolutePath() );
                            schemaHandler.addSchema( schema );
                        }
                        catch ( OpenLdapSchemaFileImportException e )
                        {
View Full Code Here

        if ( ( selectedSchemas != null ) && ( serverType != null ) )
        {
            SchemaHandler schemaHandler = project.getSchemaHandler();
            for ( String selectedSchema : selectedSchemas )
            {
                Schema schema = PluginUtils.loadCoreSchema( serverType, selectedSchema );
                if ( schema != null )
                {
                    schemaHandler.addSchema( schema );
                }
            }
View Full Code Here

        throws NamingException
    {
        monitor.subTask( "Reading schema '" + name + "'" );

        // Creating the schema
        Schema schema = new SchemaImpl( name );

        // Looking for the nodes of the schema
        SearchControls constraintSearch = new SearchControls();
        constraintSearch.setSearchScope( SearchControls.SUBTREE_SCOPE );

        NamingEnumeration<SearchResult> answer = wrapper.search( "cn=" + name + ", ou=schema", "(objectclass=*)",
            constraintSearch, DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, monitor, null );
        if ( answer != null )
        {
            while ( answer.hasMoreElements() )
            {
                SearchResult searchResult = ( SearchResult ) answer.nextElement();
                switch ( getNodeType( searchResult ) )
                {
                    case ATTRIBUTE_TYPE:
                        AttributeTypeImpl at = createAttributeType( searchResult );
                        at.setSchema( name );
                        schema.addAttributeType( at );
                        break;
                    case OBJECT_CLASS:
                        ObjectClassImpl oc = createObjectClass( searchResult );
                        oc.setSchema( name );
                        schema.addObjectClass( oc );
                        break;
                    case MATCHING_RULE:
                        MatchingRuleImpl mr = createMatchingRule( searchResult );
                        mr.setSchema( name );
                        schema.addMatchingRule( mr );
                        break;
                    case SYNTAX:
                        SyntaxImpl syntax = createSyntax( searchResult );
                        syntax.setSchema( name );
                        schema.addSyntax( syntax );
                        break;
                    default:
                        break;
                }
            }
View Full Code Here

    public String getSchemaValue()
    {
        StructuredSelection selection = ( StructuredSelection ) schemaComboViewer.getSelection();
        if ( !selection.isEmpty() )
        {
            Schema schema = ( Schema ) selection.getFirstElement();

            return schema.getName();
        }
        else
        {
            return null;
        }
View Full Code Here

TOP

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

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.