You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/07/20 16:55:08 UTC

svn commit: r558013 [2/2] - in /directory/studio/trunk/studio-apacheds-schemaeditor: resources/icons/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/ src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/difference/ src...

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaDifferenceSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaDifferenceSorter.java?view=auto&rev=558013
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaDifferenceSorter.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaDifferenceSorter.java Fri Jul 20 07:55:03 2007
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
+
+
+import java.util.Comparator;
+
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.difference.SchemaDifference;
+
+
+/**
+ * This class is used to compare and sort ascending two Schemas
+ */
+public class SchemaDifferenceSorter implements Comparator<Object>
+{
+    /* (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare( Object o1, Object o2 )
+    {
+        if ( ( o1 instanceof SchemaDifference ) && ( o2 instanceof SchemaDifference ) )
+        {
+            SchemaDifference sd1 = ( SchemaDifference ) o1;
+            SchemaDifference sd2 = ( SchemaDifference ) o2;
+
+            String name1 = "";
+            String name2 = "";
+            switch ( sd1.getType() )
+            {
+                case ADDED:
+                    name1 = ( ( Schema ) sd1.getDestination() ).getName();
+                    break;
+                case MODIFIED:
+                    name1 = ( ( Schema ) sd1.getDestination() ).getName();
+                    break;
+                case REMOVED:
+                    name1 = ( ( Schema ) sd1.getSource() ).getName();
+                    break;
+                case IDENTICAL:
+                    name1 = ( ( Schema ) sd1.getDestination() ).getName();
+                    break;
+            }
+
+            switch ( sd2.getType() )
+            {
+                case ADDED:
+                    name2 = ( ( Schema ) sd2.getDestination() ).getName();
+                    break;
+                case MODIFIED:
+                    name2 = ( ( Schema ) sd2.getDestination() ).getName();
+                    break;
+                case REMOVED:
+                    name2 = ( ( Schema ) sd2.getSource() ).getName();
+                    break;
+                case IDENTICAL:
+                    name2 = ( ( Schema ) sd2.getDestination() ).getName();
+                    break;
+            }
+
+            return name1.compareToIgnoreCase( name2 );
+        }
+
+        // Default
+        return o1.toString().compareToIgnoreCase( o2.toString() );
+    }
+}

Copied: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/TypeSorter.java (from r557690, directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidgetTypeSorter.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/TypeSorter.java?view=diff&rev=558013&p1=directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidgetTypeSorter.java&r1=557690&p2=directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/TypeSorter.java&r2=558013
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidgetTypeSorter.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/TypeSorter.java Fri Jul 20 07:55:03 2007
@@ -26,13 +26,13 @@
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.ClassTypeDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.CollectiveDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.DescriptionDifference;
-import org.apache.directory.studio.apacheds.schemaeditor.model.difference.Difference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.EqualityDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.MandatoryATDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.NoUserModificationDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.ObsoleteDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.OptionalATDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.OrderingDifference;
+import org.apache.directory.studio.apacheds.schemaeditor.model.difference.PropertyDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.SingleValueDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.SubstringDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.SuperiorATDifference;
@@ -48,12 +48,12 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class DifferencesWidgetTypeSorter implements Comparator<Difference>
+public class TypeSorter implements Comparator<PropertyDifference>
 {
     /* (non-Javadoc)
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( Difference diff1, Difference diff2 )
+    public int compare( PropertyDifference diff1, PropertyDifference diff2 )
     {
         return getWeight( diff1 ) - getWeight( diff2 );
     }
@@ -67,7 +67,7 @@
      * @return
      *      the weight of the difference
      */
-    private int getWeight( Difference diff )
+    private int getWeight( PropertyDifference diff )
     {
         if ( diff instanceof AliasDifference )
         {

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java?view=diff&rev=558013&r1=558012&r2=558013
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java Fri Jul 20 07:55:03 2007
@@ -25,9 +25,14 @@
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SchemaImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.AliasDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.DescriptionDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.Difference;
+import org.apache.directory.studio.apacheds.schemaeditor.model.difference.DifferenceEngine;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.DifferenceType;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.PropertyDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.view.widget.DifferencesWidget;
@@ -74,11 +79,61 @@
         DifferencesWidget differencesWidget = new DifferencesWidget();
         differencesWidget.createWidget( composite );
 
+        SchemaImpl schema1Old = new SchemaImpl( "Schema1" );
+        SchemaImpl schema1New = new SchemaImpl( "Schema1" );
+        SchemaImpl schema2 = new SchemaImpl( "Schema2" );
+        SchemaImpl schema3 = new SchemaImpl( "Schema3" );
+        SchemaImpl schema4 = new SchemaImpl( "Schema4" );
+
+        List<Schema> schemasListOld = new ArrayList<Schema>();
+        schemasListOld.add( schema1Old );
+        schemasListOld.add( schema2 );
+        schemasListOld.add( schema4 );
+
+        List<Schema> schemasListNew = new ArrayList<Schema>();
+        schemasListNew.add( schema4 );
+        schemasListNew.add( schema1New );
+        schemasListNew.add( schema3 );
+
+        AttributeTypeImpl at1 = new AttributeTypeImpl( "1.2.1" );
+        at1.setNames( new String[]
+            { "AT1", "AttributeType1" } );
+        AttributeTypeImpl at2 = new AttributeTypeImpl( "1.2.2" );
+        at2.setNames( new String[]
+            { "AT2", "AttributeType2" } );
+        AttributeTypeImpl at2Bis = new AttributeTypeImpl( "1.2.2" );
+        at2Bis.setNames( new String[]
+            { "AT2" } );
+        AttributeTypeImpl at3 = new AttributeTypeImpl( "1.2.3" );
+        at3.setNames( new String[]
+            { "AT3" } );
+        schema1Old.addAttributeType( at1 );
+        schema1Old.addAttributeType( at2 );
+        schema1New.addAttributeType( at2Bis );
+        schema1New.addAttributeType( at3 );
+        
+        ObjectClassImpl oc1 = new ObjectClassImpl( "1.2.10" );
+        oc1.setNames( new String[]
+            { "OC1", "ObjectClass1" } );
+        ObjectClassImpl oc2 = new ObjectClassImpl( "1.2.11" );
+        oc2.setNames( new String[]
+            { "OC2", "ObjectClass2" } );
+        ObjectClassImpl oc2Bis = new ObjectClassImpl( "1.2.11" );
+        oc2Bis.setNames( new String[]
+            { "OC2" } );
+        ObjectClassImpl oc3 = new ObjectClassImpl( "1.2.12" );
+        oc3.setNames( new String[]
+            { "OC3" } );
+        schema1Old.addObjectClass( oc1 );
+        schema1Old.addObjectClass( oc2 );
+        schema1New.addObjectClass( oc2Bis );
+        schema1New.addObjectClass( oc3 );
+
         List<Difference> differences = new ArrayList<Difference>();
         PropertyDifference diff = new AliasDifference( null, null, DifferenceType.ADDED );
         diff.setNewValue( "alias1" );
         differences.add( diff );
-        
+
         diff = new AliasDifference( null, null, DifferenceType.REMOVED );
         diff.setOldValue( "alias2" );
         differences.add( diff );
@@ -86,50 +141,17 @@
         diff = new DescriptionDifference( null, null, DifferenceType.ADDED );
         diff.setNewValue( "Description" );
         differences.add( diff );
-        
+
         diff = new DescriptionDifference( null, null, DifferenceType.MODIFIED );
         diff.setOldValue( "Old Description" );
         diff.setNewValue( "New Description" );
         differences.add( diff );
-        
+
         diff = new DescriptionDifference( null, null, DifferenceType.REMOVED );
         diff.setOldValue( "Description" );
         differences.add( diff );
-        
 
-        //        differences.add( new AddEqualityDifference( null, null, "equality" ) );
-        //        differences.add( new ModifyEqualityDifference( null, null, "old equality", "new equality" ) );
-        //        differences.add( new RemoveEqualityDifference( null, null, "equality" ) );
-        //        differences.add( new AddMandatoryATDifference( null, null, "name" ) );
-        //        differences.add( new RemoveMandatoryATDifference( null, null, "name2" ) );
-        //        differences.add( new AddOptionalATDifference( null, null, "name" ) );
-        //        differences.add( new RemoveOptionalATDifference( null, null, "name2" ) );
-        //        differences.add( new AddOrderingDifference( null, null, "ordering" ) );
-        //        differences.add( new ModifyOrderingDifference( null, null, "old ordering", "new ordering" ) );
-        //        differences.add( new RemoveOrderingDifference( null, null, "ordering" ) );
-        //        differences.add( new AddSubstringDifference( null, null, "substring" ) );
-        //        differences.add( new ModifySubstringDifference( null, null, "old substring", "new substring" ) );
-        //        differences.add( new RemoveSubstringDifference( null, null, "substring" ) );
-        //        differences.add( new AddSuperiorATDifference( null, null, "supAT" ) );
-        //        differences.add( new ModifySuperiorATDifference( null, null, "oldSupAT", "newSupAT" ) );
-        //        differences.add( new RemoveSuperiorATDifference( null, null, "supAT" ) );
-        //        differences.add( new AddSuperiorOCDifference( null, null, "supOC" ) );
-        //        differences.add( new RemoveSuperiorOCDifference( null, null, "supOC" ) );
-        //        differences.add( new AddSyntaxDifference( null, null, "syntax" ) );
-        //        differences.add( new ModifySyntaxDifference( null, null, "syntax1", "syntax2" ) );
-        //        differences.add( new RemoveSyntaxDifference( null, null, "syntax" ) );
-        //        differences.add( new AddSyntaxLengthDifference( null, null, 1234 ) );
-        //        differences.add( new ModifySyntaxLengthDifference( null, null, 1234, 12345 ) );
-        //        differences.add( new RemoveSyntaxLengthDifference( null, null, 1234 ) );
-        //        differences.add( new ModifyClassTypeDifference( null, null, ObjectClassTypeEnum.AUXILIARY,
-        //            ObjectClassTypeEnum.ABSTRACT ) );
-        //        differences.add( new ModifyCollectiveDifference( null, null, false, true ) );
-        //        differences.add( new ModifyNoUserModificationDifference( null, null, true, false ) );
-        //        differences.add( new ModifyObsoleteDifference( null, null, true, false ) );
-        //        differences.add( new ModifySingleValueDifference( null, null, true, false ) );
-        //        differences.add( new ModifyUsageDifference( null, null, UsageEnum.DISTRIBUTED_OPERATION,
-        //            UsageEnum.DSA_OPERATION ) );
-        differencesWidget.setInput( differences );
+        differencesWidget.setInput( DifferenceEngine.getDifferences( schemasListOld, schemasListNew ) );
 
         initFields();
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java?view=diff&rev=558013&r1=558012&r2=558013
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesWizard.java Fri Jul 20 07:55:03 2007
@@ -21,7 +21,6 @@
 
 
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.IExportWizard;
 import org.eclipse.ui.IWorkbench;