directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r509218 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas: model/Schema.java model/SchemaPool.java view/viewers/HierarchicalContentProvider.java
Date Mon, 19 Feb 2007 14:53:00 GMT
Author: pamarcelot
Date: Mon Feb 19 06:52:59 2007
New Revision: 509218

URL: http://svn.apache.org/viewvc?view=rev&rev=509218
Log:
Fixed a bug which caused some duplicates to appear in both Hierarchy View and Schemas View
when AT and OC contained various aliases.

Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java?view=diff&rev=509218&r1=509217&r2=509218
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/Schema.java
Mon Feb 19 06:52:59 2007
@@ -28,7 +28,9 @@
 import java.net.URL;
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Set;
 
 import org.apache.directory.ldapstudio.schemas.controller.Application;
 import org.apache.directory.ldapstudio.schemas.io.SchemaParser;
@@ -294,8 +296,9 @@
      */
     public ObjectClass[] getObjectClassesAsArray()
     {
-        return objectClassTable.values().toArray( new ObjectClass[]
-            {} );
+        Set<ObjectClass> set = new HashSet<ObjectClass>();
+        set.addAll(objectClassTable.values());
+        return set.toArray(new ObjectClass[0]);
     }
 
 
@@ -305,8 +308,9 @@
      */
     public AttributeType[] getAttributeTypesAsArray()
     {
-        return attributeTypeTable.values().toArray( new AttributeType[]
-            {} );
+        Set<AttributeType> set = new HashSet<AttributeType>();
+        set.addAll(attributeTypeTable.values());
+        return set.toArray(new AttributeType[0]);
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java?view=diff&rev=509218&r1=509217&r2=509218
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/SchemaPool.java
Mon Feb 19 06:52:59 2007
@@ -25,7 +25,9 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Set;
 
 import org.apache.directory.ldapstudio.schemas.controller.Application;
 import org.apache.directory.ldapstudio.schemas.view.preferences.SchemaPreferencePage;
@@ -514,8 +516,9 @@
      */
     public ObjectClass[] getObjectClassesAsArray()
     {
-        return getObjectClassesAsHashTableByName().values().toArray( new ObjectClass[]
-            {} );
+        Set<ObjectClass> set = new HashSet<ObjectClass>();
+        set.addAll(getObjectClassesAsHashTableByName().values());
+        return set.toArray(new ObjectClass[0]);
     }
 
 
@@ -525,8 +528,9 @@
      */
     public AttributeType[] getAttributeTypesAsArray()
     {
-        return getAttributeTypesAsHashTableByName().values().toArray( new AttributeType[]
-            {} );
+        Set<AttributeType> set = new HashSet<AttributeType>();
+        set.addAll(getAttributeTypesAsHashTableByName().values());
+        return set.toArray(new AttributeType[0]);
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java?view=diff&rev=509218&r1=509217&r2=509218
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchicalContentProvider.java
Mon Feb 19 06:52:59 2007
@@ -22,10 +22,7 @@
 
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.directory.ldapstudio.schemas.Activator;
@@ -59,10 +56,10 @@
     private SchemaPool schemaPool;
 
     /** The HashTable containing all the object classes */
-    private Hashtable<String, ObjectClass> objectClassTable;
+    private ObjectClass[] objectClasses;
 
     /** The HashTable containing all the attribute types */
-    private Hashtable<String, AttributeType> attributeTypeTable;
+    private AttributeType[] attributeTypes;
 
     /** The FirstName Sorter */
     private HierarchyViewFirstNameSorter firstNameSorter;
@@ -81,8 +78,8 @@
     {
         this.schemaPool = SchemaPool.getInstance();
 
-        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
-        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+        objectClasses = schemaPool.getObjectClassesAsArray();
+        attributeTypes = schemaPool.getAttributeTypesAsArray();
 
         firstNameSorter = new HierarchyViewFirstNameSorter();
         oidSorter = new HierarchyViewOidSorter();
@@ -115,12 +112,9 @@
             //we are looking for the childrens of the contained objectClass
             ObjectClass objectClass = ( ( ObjectClassWrapper ) parentElement ).getMyObjectClass();
 
-            //-> we need to compare each and every other objectClass's sup against them

-            //-> we also need to find a better way to do this (complexity wise)
-            Collection<ObjectClass> objectClasses = objectClassTable.values();
-            for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
+            for ( int i = 0; i < objectClasses.length; i++ )
             {
-                ObjectClass oClass = ( ObjectClass ) iter.next();
+                ObjectClass oClass = objectClasses[i];
 
                 //not this object class
                 if ( oClass.getOid() != objectClass.getOid() )
@@ -128,7 +122,7 @@
                     String[] sups = oClass.getSuperiors();
                     for ( String sup : sups )
                     {
-                        ObjectClass oClassSup = objectClassTable.get( sup );
+                        ObjectClass oClassSup = schemaPool.getObjectClass( sup );
                         if ( oClassSup != null )
                         {
                             //the current object class is a sup of oClass
@@ -167,12 +161,9 @@
             //we are looking for the childrens of the contained attribute type
             AttributeType attributeType = ( ( AttributeTypeWrapper ) parentElement ).getMyAttributeType();
 
-            //-> we need to compare each and every other attribute type sup against them

-            //-> we also need to find a better way to do this (complexity wise)
-            Collection<AttributeType> attributeTypes = attributeTypeTable.values();
-            for ( Iterator iter = attributeTypes.iterator(); iter.hasNext(); )
+            for ( int i = 0; i < attributeTypes.length; i++ )
             {
-                AttributeType aType = ( AttributeType ) iter.next();
+                AttributeType aType = attributeTypes[i];
 
                 //not this attribute type
                 if ( aType.getOid() != attributeType.getOid() )
@@ -180,7 +171,7 @@
                     String aTypeSupName = aType.getSuperior();
                     if ( aTypeSupName != null )
                     {
-                        AttributeType aTypeSup = attributeTypeTable.get( aType.getSuperior()
);
+                        AttributeType aTypeSup = schemaPool.getAttributeType( aType.getSuperior()
);
                         if ( aTypeSup != null )
                         {
                             //the current object class is a sup of oClass
@@ -234,11 +225,10 @@
                         ocList.add( topWrapper );
                     }
 
-                    //add the unresolved object-classes to the top of the hierarchy
-                    Collection<ObjectClass> objectClasses = objectClassTable.values();
-                    for ( Iterator iter = objectClasses.iterator(); iter.hasNext(); )
+
+                    for ( int i = 0; i < objectClasses.length; i++ )
                     {
-                        ObjectClass oClass = ( ObjectClass ) iter.next();
+                        ObjectClass oClass = objectClasses[i];
                         String[] sups = oClass.getSuperiors();
                         //if no supperiors had been set
                         if ( sups.length == 0 )
@@ -252,7 +242,7 @@
                         {
                             for ( String sup : sups )
                             {
-                                ObjectClass oClassSup = objectClassTable.get( sup );
+                                ObjectClass oClassSup = schemaPool.getObjectClass( sup );
                                 if ( oClassSup == null )
                                 {
                                     ObjectClassWrapper wrapper = new ObjectClassWrapper(
oClass, intermediate );
@@ -268,11 +258,10 @@
                 if ( !Activator.getDefault().getDialogSettings().getBoolean(
                     HideAttributeTypesAction.HIDE_ATTRIBUTE_TYPES_DS_KEY ) )
                 {
-                    //add the unresolved object-classes to the top of the hierarchy
-                    Collection<AttributeType> attributeTypes = attributeTypeTable.values();
-                    for ( Iterator iter = attributeTypes.iterator(); iter.hasNext(); )
+                    
+                    for ( int i = 0; i < attributeTypes.length; i++ )
                     {
-                        AttributeType aType = ( AttributeType ) iter.next();
+                        AttributeType aType = attributeTypes[i];
                         String sup = aType.getSuperior();
                         //if no superior had been set
                         if ( sup == null )
@@ -413,9 +402,8 @@
      */
     private void refreshOcsAndAts()
     {
-        objectClassTable = schemaPool.getObjectClassesAsHashTableByName();
-
-        attributeTypeTable = schemaPool.getAttributeTypesAsHashTableByName();
+        objectClasses = schemaPool.getObjectClassesAsArray();
+        attributeTypes = schemaPool.getAttributeTypesAsArray();
     }
 
 



Mime
View raw message