directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1547588 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor: model/ model/io/ model/schemamanager/ view/views/ view/wizards/
Date Tue, 03 Dec 2013 21:06:47 GMT
Author: seelmann
Date: Tue Dec  3 21:06:46 2013
New Revision: 1547588

URL: http://svn.apache.org/r1547588
Log:
* Fix for DIRSTUDIO-958: Order schema objects hierarchically in OpenLdapSchemeFileExporter
* Remove duplicate functionality in ExportSchemasForADSWizard
* Also changed return type MutableObjectClass to its super type

Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/DependenciesComputer.java
Tue Dec  3 21:06:46 2013
@@ -30,7 +30,6 @@ import org.apache.commons.collections.ma
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.LdapSyntax;
 import org.apache.directory.api.ldap.model.schema.MatchingRule;
-import org.apache.directory.api.ldap.model.schema.MutableObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.SchemaObject;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
@@ -98,7 +97,7 @@ public class DependenciesComputer
                     }
                 }
 
-                List<MutableObjectClass> objectClasses = schema.getObjectClasses();
+                List<ObjectClass> objectClasses = schema.getObjectClasses();
                 if ( objectClasses != null )
                 {
                     for ( ObjectClass objectClass : objectClasses )

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Schema.java
Tue Dec  3 21:06:46 2013
@@ -45,7 +45,7 @@ public class Schema extends DefaultSchem
     private List<AttributeType> attributeTypes = new ArrayList<AttributeType>();
 
     /** The ObjectClass List */
-    private List<MutableObjectClass> objectClasses = new ArrayList<MutableObjectClass>();
+    private List<ObjectClass> objectClasses = new ArrayList<ObjectClass>();
 
     /** The MatchingRule List */
     private List<MatchingRule> matchingRules = new ArrayList<MatchingRule>();
@@ -258,7 +258,7 @@ public class Schema extends DefaultSchem
      * @return
      *      all the ObjectClass objects contained in the Schema
      */
-    public List<MutableObjectClass> getObjectClasses()
+    public List<ObjectClass> getObjectClasses()
     {
         return objectClasses;
     }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/OpenLdapSchemaFileExporter.java
Tue Dec  3 21:06:46 2013
@@ -23,6 +23,7 @@ package org.apache.directory.studio.sche
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.SchemaObjectRenderer;
+import org.apache.directory.api.ldap.model.schema.SchemaObjectSorter;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 
 
@@ -46,13 +47,13 @@ public class OpenLdapSchemaFileExporter
     {
         StringBuffer sb = new StringBuffer();
 
-        for ( AttributeType at : schema.getAttributeTypes() )
+        for ( AttributeType at : SchemaObjectSorter.hierarchicalOrdered( schema.getAttributeTypes()
) )
         {
             sb.append( toSourceCode( at ) );
             sb.append( "\n" ); //$NON-NLS-1$
         }
 
-        for ( ObjectClass oc : schema.getObjectClasses() )
+        for ( ObjectClass oc : SchemaObjectSorter.sortObjectClasses( schema.getObjectClasses()
) )
         {
             sb.append( toSourceCode( oc ) );
             sb.append( "\n" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/XMLSchemaFileExporter.java
Tue Dec  3 21:06:46 2013
@@ -28,7 +28,6 @@ import java.util.List;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.LdapSyntax;
 import org.apache.directory.api.ldap.model.schema.MatchingRule;
-import org.apache.directory.api.ldap.model.schema.MutableObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum;
 import org.apache.directory.api.ldap.model.schema.UsageEnum;
@@ -205,7 +204,7 @@ public class XMLSchemaFileExporter
             }
 
             // Object Classes
-            List<MutableObjectClass> ocs = schema.getObjectClasses();
+            List<ObjectClass> ocs = schema.getObjectClasses();
             if ( ( ocs != null ) && ( ocs.size() >= 1 ) )
             {
                 Element objectClassesNode = element.addElement( OBJECT_CLASSES_TAG );

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoader.java
Tue Dec  3 21:06:46 2013
@@ -29,7 +29,6 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.LdapSyntax;
 import org.apache.directory.api.ldap.model.schema.MatchingRule;
-import org.apache.directory.api.ldap.model.schema.MutableObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.registries.AbstractSchemaLoader;
 import org.apache.directory.api.ldap.model.schema.registries.Schema;
@@ -246,7 +245,7 @@ public class SchemaEditorSchemaLoader ex
 
                 if ( schemaHandlerSchema != null )
                 {
-                    List<MutableObjectClass> objectClasses = schemaHandlerSchema.getObjectClasses();
+                    List<ObjectClass> objectClasses = schemaHandlerSchema.getObjectClasses();
 
                     for ( ObjectClass objectClass : objectClasses )
                     {

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/views/SchemaViewContentProvider.java
Tue Dec  3 21:06:46 2013
@@ -1254,7 +1254,7 @@ public class SchemaViewContentProvider i
             attributeTypeAddedHierarchicalPresentation( at );
         }
 
-        for ( MutableObjectClass oc : schema.getObjectClasses() )
+        for ( ObjectClass oc : schema.getObjectClasses() )
         {
             objectClassAddedHierarchicalPresentation( oc );
         }
@@ -1348,7 +1348,7 @@ public class SchemaViewContentProvider i
             Folder ocFolder = new Folder( FolderType.OBJECT_CLASS, schemaWrapper );
             schemaWrapper.addChild( ocFolder );
 
-            for ( MutableObjectClass objectClass : schema.getObjectClasses() )
+            for ( ObjectClass objectClass : schema.getObjectClasses() )
             {
                 ObjectClassWrapper ocw = new ObjectClassWrapper( objectClass, ocFolder );
                 ocw.getParent().addChild( ocw );
@@ -1364,7 +1364,7 @@ public class SchemaViewContentProvider i
                 elementsToWrappersMap.put( attributeType, atw );
             }
 
-            for ( MutableObjectClass objectClass : schema.getObjectClasses() )
+            for ( ObjectClass objectClass : schema.getObjectClasses() )
             {
                 ObjectClassWrapper ocw = new ObjectClassWrapper( objectClass, schemaWrapper
);
                 ocw.getParent().addChild( ocw );

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/ExportSchemasForADSWizard.java
Tue Dec  3 21:06:46 2013
@@ -28,7 +28,6 @@ import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -40,8 +39,8 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.name.Rdn;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
-import org.apache.directory.api.ldap.model.schema.MutableObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
+import org.apache.directory.api.ldap.model.schema.SchemaObjectSorter;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginUtils;
@@ -353,7 +352,7 @@ public class ExportSchemasForADSWizard e
         sb.append( "\n" ); //$NON-NLS-1$
 
         // Generating LDIF for Object Classes
-        List<MutableObjectClass> sortedObjectClasses = getSortedObjectClasses( schema.getObjectClasses()
);
+        Iterable<ObjectClass> sortedObjectClasses = SchemaObjectSorter.sortObjectClasses(
schema.getObjectClasses() );
         for ( ObjectClass oc : sortedObjectClasses )
         {
             ObjectClassHolder holder = new ObjectClassHolder( oc.getOid() );
@@ -405,66 +404,6 @@ public class ExportSchemasForADSWizard e
 
 
     /**
-     * Sorts the object classes by hierarchy.
-     *
-     * @param objectClasses the unsorted object classes
-     * @return the sorted object classes
-     */
-    private List<MutableObjectClass> getSortedObjectClasses( List<MutableObjectClass>
objectClasses )
-    {
-        // clone the unsorted list
-        List<MutableObjectClass> unsortedObjectClasses = new ArrayList<MutableObjectClass>(
objectClasses );
-
-        // list of all existing names
-        Set<String> objectClassNames = new HashSet<String>();
-        for ( ObjectClass oc : unsortedObjectClasses )
-        {
-            for ( String name : oc.getNames() )
-            {
-                objectClassNames.add( Strings.toLowerCase( name ) );
-            }
-        }
-
-        // sort object classes
-        List<MutableObjectClass> sortedObjectClasses = new ArrayList<MutableObjectClass>();
-        Set<String> movedObjectClasses = new HashSet<String>();
-        boolean moved = true;
-        while ( !unsortedObjectClasses.isEmpty() && moved )
-        {
-            moved = false;
-            Iterator<MutableObjectClass> unsortedIterator = unsortedObjectClasses.iterator();
-            while ( unsortedIterator.hasNext() )
-            {
-                MutableObjectClass oc = unsortedIterator.next();
-                for ( String superName : oc.getSuperiorOids() )
-                {
-                    if ( !objectClassNames.contains( Strings.toLowerCase( superName ) )
-                        || movedObjectClasses.contains( Strings.toLowerCase( superName )
) )
-                    {
-                        unsortedIterator.remove();
-                        sortedObjectClasses.add( oc );
-                        for ( String name : oc.getNames() )
-                        {
-                            movedObjectClasses.add( Strings.toLowerCase( name ) );
-                        }
-                        moved = true;
-                        break;
-                    }
-                }
-            }
-        }
-
-        // add the rest
-        for ( MutableObjectClass oc : unsortedObjectClasses )
-        {
-            sortedObjectClasses.add( oc );
-        }
-
-        return sortedObjectClasses;
-    }
-
-
-    /**
      * Gets the schema dependencies.
      *
      * @param schema

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java?rev=1547588&r1=1547587&r2=1547588&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/MergeSchemasWizard.java
Tue Dec  3 21:06:46 2013
@@ -153,7 +153,7 @@ public class MergeSchemasWizard extends 
             {
                 ObjectClassFolder ocf = ( ObjectClassFolder ) sourceObject;
                 Schema targetSchema = getTargetSchema( ocf.schema.getProject(), targetProject,
targetSchemas );
-                List<MutableObjectClass> sourceObjectClasses = ocf.schema.getObjectClasses();
+                List<ObjectClass> sourceObjectClasses = ocf.schema.getObjectClasses();
                 for ( ObjectClass sourceObjectClass : sourceObjectClasses )
                 {
                     mergeObjectClass( sourceObjectClass, targetProject, targetSchema, processedObjects,
errorMessages,
@@ -223,7 +223,7 @@ public class MergeSchemasWizard extends 
                 replaceUnknownSyntax, mergeDependencies, pullUpAttributes );
         }
 
-        List<MutableObjectClass> sourceObjectClasses = sourceSchema.getObjectClasses();
+        List<ObjectClass> sourceObjectClasses = sourceSchema.getObjectClasses();
         for ( ObjectClass sourceObjectClass : sourceObjectClasses )
         {
             mergeObjectClass( sourceObjectClass, targetProject, targetSchema, processedObjects,
errorMessages,



Mime
View raw message