directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1065635 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager: SchemaEditorSchemaLoader.java SchemaEditorSchemaLoaderUtils.java
Date Mon, 31 Jan 2011 14:56:38 GMT
Author: pamarcelot
Date: Mon Jan 31 14:56:38 2011
New Revision: 1065635

URL: http://svn.apache.org/viewvc?rev=1065635&view=rev
Log:
Implemented a basic Schema Loader for the Schema Editor projects.

Modified:
    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/model/schemamanager/SchemaEditorSchemaLoaderUtils.java

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=1065635&r1=1065634&r2=1065635&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
Mon Jan 31 14:56:38 2011
@@ -26,8 +26,14 @@ import java.util.List;
 
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.model.schema.MatchingRule;
+import org.apache.directory.shared.ldap.model.schema.ObjectClass;
 import org.apache.directory.shared.ldap.model.schema.registries.AbstractSchemaLoader;
 import org.apache.directory.shared.ldap.model.schema.registries.Schema;
+import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.model.Project;
 
 
 /**
@@ -37,6 +43,9 @@ import org.apache.directory.shared.ldap.
  */
 public class SchemaEditorSchemaLoader extends AbstractSchemaLoader
 {
+    private Project project;
+
+
     /**
      * Creates a new instance of SchemaEditorSchemaLoader.
      *
@@ -53,6 +62,14 @@ public class SchemaEditorSchemaLoader ex
      */
     private void initializeSchemas()
     {
+        project = Activator.getDefault().getProjectsHandler().getProjects().get( 0 );
+
+        List<org.apache.directory.studio.schemaeditor.model.Schema> schemaObjects =
project.getSchemaHandler()
+            .getSchemas();
+        for ( org.apache.directory.studio.schemaeditor.model.Schema schemaObject : schemaObjects
)
+        {
+            schemaMap.put( schemaObject.getSchemaName(), schemaObject );
+        }
     }
 
 
@@ -96,6 +113,16 @@ public class SchemaEditorSchemaLoader ex
     {
         List<Entry> matchingRuleList = new ArrayList<Entry>();
 
+        for ( Schema schema : schemas )
+        {
+            List<MatchingRule> matchingRules = project.getSchemaHandler().getSchema(
schema.getSchemaName() )
+                .getMatchingRules();
+            for ( MatchingRule matchingRule : matchingRules )
+            {
+                matchingRuleList.add( SchemaEditorSchemaLoaderUtils.toEntry( matchingRule
) );
+            }
+        }
+
         return matchingRuleList;
     }
 
@@ -107,6 +134,15 @@ public class SchemaEditorSchemaLoader ex
     {
         List<Entry> syntaxList = new ArrayList<Entry>();
 
+        for ( Schema schema : schemas )
+        {
+            List<LdapSyntax> syntaxes = project.getSchemaHandler().getSchema( schema.getSchemaName()
).getSyntaxes();
+            for ( LdapSyntax syntax : syntaxes )
+            {
+                syntaxList.add( SchemaEditorSchemaLoaderUtils.toEntry( syntax ) );
+            }
+        }
+
         return syntaxList;
     }
 
@@ -118,6 +154,16 @@ public class SchemaEditorSchemaLoader ex
     {
         List<Entry> attributeTypeList = new ArrayList<Entry>();
 
+        for ( Schema schema : schemas )
+        {
+            List<AttributeType> attributeTypes = project.getSchemaHandler().getSchema(
schema.getSchemaName() )
+                .getAttributeTypes();
+            for ( AttributeType attributeType : attributeTypes )
+            {
+                attributeTypeList.add( SchemaEditorSchemaLoaderUtils.toEntry( attributeType
) );
+            }
+        }
+
         return attributeTypeList;
     }
 
@@ -173,6 +219,16 @@ public class SchemaEditorSchemaLoader ex
     {
         List<Entry> objectClassList = new ArrayList<Entry>();
 
+        for ( Schema schema : schemas )
+        {
+            List<ObjectClass> objectClasses = project.getSchemaHandler().getSchema(
schema.getSchemaName() )
+                .getObjectClasses();
+            for ( ObjectClass objectClass : objectClasses )
+            {
+                objectClassList.add( SchemaEditorSchemaLoaderUtils.toEntry( objectClass )
);
+            }
+        }
+
         return objectClassList;
     }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java?rev=1065635&r1=1065634&r2=1065635&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/schemamanager/SchemaEditorSchemaLoaderUtils.java
Mon Jan 31 14:56:38 2011
@@ -78,7 +78,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the attribute type converted to an equivalent entry representation
      * @throws LdapException
      */
-    public Entry toEntry( AttributeType attributeType ) throws LdapException
+    public static Entry toEntry( AttributeType attributeType ) throws LdapException
     {
         // Creating a blank entry
         Entry entry = new DefaultEntry();
@@ -129,7 +129,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the object class converted to an equivalent entry representation
      * @throws LdapException
      */
-    public Entry toEntry( MatchingRule matchingRule ) throws LdapException
+    public static Entry toEntry( MatchingRule matchingRule ) throws LdapException
     {
         // Creating a blank entry
         Entry entry = new DefaultEntry();
@@ -160,7 +160,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the object class converted to an equivalent entry representation
      * @throws LdapException
      */
-    public Entry toEntry( ObjectClass objectClass ) throws LdapException
+    public static Entry toEntry( ObjectClass objectClass ) throws LdapException
     {
         // Creating a blank entry
         Entry entry = new DefaultEntry();
@@ -196,7 +196,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the object class converted to an equivalent entry representation
      * @throws LdapException
      */
-    public Entry toEntry( LdapSyntax syntax ) throws LdapException
+    public static Entry toEntry( LdapSyntax syntax ) throws LdapException
     {
         // Creating a blank entry
         Entry entry = new DefaultEntry();
@@ -222,7 +222,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the DN for the given schema object in the given object path
      * @throws LdapInvalidDnException
      */
-    private Dn getDn( SchemaObject schemaObject, String objectPath ) throws LdapInvalidDnException
+    private static Dn getDn( SchemaObject schemaObject, String objectPath ) throws LdapInvalidDnException
     {
         return Dn.EMPTY_DN
             .add( new Rdn( M_OID, schemaObject.getOid() ) )
@@ -243,7 +243,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSchemaObjectValues( SchemaObject schemaObject, String objectClassValue,
Entry entry )
+    private static void addSchemaObjectValues( SchemaObject schemaObject, String objectClassValue,
Entry entry )
         throws LdapException
     {
         // ObjectClass
@@ -274,7 +274,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addObjectClassValue( SchemaObject schemaObject, String objectClassValue,
Entry entry )
+    private static void addObjectClassValue( SchemaObject schemaObject, String objectClassValue,
Entry entry )
         throws LdapException
     {
         EntryAttribute objectClassAttribute = new DefaultEntryAttribute( SchemaConstants.OBJECT_CLASS_AT
);
@@ -294,7 +294,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addOidValue( SchemaObject schemaObject, Entry entry ) throws LdapException
+    private static void addOidValue( SchemaObject schemaObject, Entry entry ) throws LdapException
     {
         String oid = schemaObject.getOid();
         if ( !Strings.isEmpty( oid ) )
@@ -314,7 +314,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addNamesValue( SchemaObject schemaObject, Entry entry ) throws LdapException
+    private static void addNamesValue( SchemaObject schemaObject, Entry entry ) throws LdapException
     {
         List<String> names = schemaObject.getNames();
         if ( ( names != null ) && ( names.size() > 0 ) )
@@ -339,7 +339,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addDescriptionValue( SchemaObject schemaObject, Entry entry ) throws LdapException
+    private static void addDescriptionValue( SchemaObject schemaObject, Entry entry ) throws
LdapException
     {
         String description = schemaObject.getDescription();
         if ( !Strings.isEmpty( description ) )
@@ -359,7 +359,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addObsoleteValue( SchemaObject schemaObject, Entry entry ) throws LdapException
+    private static void addObsoleteValue( SchemaObject schemaObject, Entry entry ) throws
LdapException
     {
         if ( schemaObject.isObsolete() )
         {
@@ -378,7 +378,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSuperiorValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addSuperiorValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         String superior = attributeType.getSuperiorName();
         if ( !Strings.isEmpty( superior ) )
@@ -398,7 +398,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addEqualityValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addEqualityValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         String equality = attributeType.getEqualityName();
         if ( !Strings.isEmpty( equality ) )
@@ -418,7 +418,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addOrderingValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addOrderingValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         String ordering = attributeType.getOrderingName();
         if ( !Strings.isEmpty( ordering ) )
@@ -438,7 +438,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSubstrValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addSubstrValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         String substr = attributeType.getSubstringName();
         if ( !Strings.isEmpty( substr ) )
@@ -458,7 +458,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSyntaxValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addSyntaxValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         String syntax = attributeType.getSyntaxName();
         if ( !Strings.isEmpty( syntax ) )
@@ -485,7 +485,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSingleValueValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addSingleValueValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         if ( attributeType.isSingleValued() )
         {
@@ -504,7 +504,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addCollectiveValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addCollectiveValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         if ( attributeType.isCollective() )
         {
@@ -523,7 +523,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addNoUserModificationValue( AttributeType attributeType, Entry entry ) throws
LdapException
+    private static void addNoUserModificationValue( AttributeType attributeType, Entry entry
) throws LdapException
     {
         if ( !attributeType.isUserModifiable() )
         {
@@ -542,7 +542,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addUsageValue( AttributeType attributeType, Entry entry ) throws LdapException
+    private static void addUsageValue( AttributeType attributeType, Entry entry ) throws
LdapException
     {
         UsageEnum usage = attributeType.getUsage();
         if ( usage != UsageEnum.USER_APPLICATIONS )
@@ -562,7 +562,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addSuperiorsValue( ObjectClass objectClass, Entry entry ) throws LdapException
+    private static void addSuperiorsValue( ObjectClass objectClass, Entry entry ) throws
LdapException
     {
         List<String> superiors = objectClass.getSuperiorOids();
         if ( ( superiors != null ) && ( superiors.size() > 0 ) )
@@ -587,7 +587,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addClassTypeValue( ObjectClass objectClass, Entry entry ) throws LdapException
+    private static void addClassTypeValue( ObjectClass objectClass, Entry entry ) throws
LdapException
     {
         ObjectClassTypeEnum classType = objectClass.getType();
         if ( classType != ObjectClassTypeEnum.STRUCTURAL )
@@ -607,7 +607,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addMustsValue( ObjectClass objectClass, Entry entry ) throws LdapException
+    private static void addMustsValue( ObjectClass objectClass, Entry entry ) throws LdapException
     {
         List<String> musts = objectClass.getMustAttributeTypeOids();
         if ( ( musts != null ) && ( musts.size() > 0 ) )
@@ -632,7 +632,7 @@ public class SchemaEditorSchemaLoaderUti
      *      the entry
      * @throws LdapException
      */
-    private void addMaysValue( ObjectClass objectClass, Entry entry ) throws LdapException
+    private static void addMaysValue( ObjectClass objectClass, Entry entry ) throws LdapException
     {
         List<String> mays = objectClass.getMayAttributeTypeOids();
         if ( ( mays != null ) && ( mays.size() > 0 ) )



Mime
View raw message