directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1529454 - in /directory/escimo/branches/json-schema-experiment/json2java/src/main: java/org/apache/directory/scim/JsonToJava.java resources/resource-class.st
Date Sat, 05 Oct 2013 13:50:49 GMT
Author: kayyagari
Date: Sat Oct  5 13:50:49 2013
New Revision: 1529454

URL: http://svn.apache.org/r1529454
Log:
improved class generation

Modified:
    directory/escimo/branches/json-schema-experiment/json2java/src/main/java/org/apache/directory/scim/JsonToJava.java
    directory/escimo/branches/json-schema-experiment/json2java/src/main/resources/resource-class.st

Modified: directory/escimo/branches/json-schema-experiment/json2java/src/main/java/org/apache/directory/scim/JsonToJava.java
URL: http://svn.apache.org/viewvc/directory/escimo/branches/json-schema-experiment/json2java/src/main/java/org/apache/directory/scim/JsonToJava.java?rev=1529454&r1=1529453&r2=1529454&view=diff
==============================================================================
--- directory/escimo/branches/json-schema-experiment/json2java/src/main/java/org/apache/directory/scim/JsonToJava.java
(original)
+++ directory/escimo/branches/json-schema-experiment/json2java/src/main/java/org/apache/directory/scim/JsonToJava.java
Sat Oct  5 13:50:49 2013
@@ -33,6 +33,7 @@ import java.util.List;
 
 import org.antlr.stringtemplate.StringTemplate;
 import org.antlr.stringtemplate.StringTemplateGroup;
+import org.apache.directory.scim.schema.SchemaUtil;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -111,7 +112,7 @@ public class JsonToJava extends Abstract
         if ( useDefaultSchemas )
         {
             log.info( "Generating sources for the default schemas" );
-            lst = getDefaultSchemas();
+            lst = SchemaUtil.getDefaultSchemas();
 
             if ( lst.isEmpty() )
             {
@@ -166,23 +167,6 @@ public class JsonToJava extends Abstract
     }
 
 
-    private List<URL> getDefaultSchemas()
-    {
-        String[] stockNames =
-            { "user-schema.json", "group-schema.json", "enterprise-user-schema.json" };
-        List<URL> lst = new ArrayList<URL>();
-
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        for ( String s : stockNames )
-        {
-            URL u = cl.getResource( s );
-            lst.add( u );
-        }
-
-        return lst;
-    }
-
-
     public void compileAndSave( String schema, File srcDir )  throws MojoExecutionException
     {
         JsonParser parser = new JsonParser();
@@ -244,15 +228,24 @@ public class JsonToJava extends Abstract
             template.setAttribute( "resourceDesc", desc );
         }
 
+        List<AttributeDetail> simpleAttributes = new ArrayList<AttributeDetail>();
+
         if ( parent != null )
         {
             template.setAttribute( "static", "static" );
+            
+            boolean multiValued = json.get( "multiValued" ).getAsBoolean();
+            if ( multiValued )
+            {
+                AttributeDetail operation = new AttributeDetail( "operation", "String" );
+                
+                simpleAttributes.add( operation );
+            }
         }
 
         String className = json.get( "name" ).getAsString();
         template.setAttribute( "className", className );
 
-        List<AttributeDetail> simpleAttributes = new ArrayList<AttributeDetail>();
 
         JsonArray attributes;
 
@@ -296,7 +289,7 @@ public class JsonToJava extends Abstract
                     // special case for Address'es'
                     if ( javaType.endsWith( "Addresses" ) )
                     {
-                        endPos += 1;
+                        endPos -= 1;
                     }
 
                     javaType = javaType.substring( 0, endPos );

Modified: directory/escimo/branches/json-schema-experiment/json2java/src/main/resources/resource-class.st
URL: http://svn.apache.org/viewvc/directory/escimo/branches/json-schema-experiment/json2java/src/main/resources/resource-class.st?rev=1529454&r1=1529453&r2=1529454&view=diff
==============================================================================
--- directory/escimo/branches/json-schema-experiment/json2java/src/main/resources/resource-class.st
(original)
+++ directory/escimo/branches/json-schema-experiment/json2java/src/main/resources/resource-class.st
Sat Oct  5 13:50:49 2013
@@ -19,24 +19,24 @@ $!/*
  */!$
 $if(package)$
 package $package$;
+
+import org.apache.directory.scim.schema.*;
 $endif$
 
-$visibility$ $static$ class $className$
+$visibility$ $static$ class $className$ $if(package)$extends CoreResource$endif$
 {
 
-    $if(schemaId)$
-    public static final String schemaId = "$schemaId$";
-    $endif$
-    
-    $if(resourceDesc)$
-    public static final String resourceDesc = "$resourceDesc$";
-    $endif$
-    
     $allAttrs: { attr | private $attr.javaType$ $attr.name$;}; separator="\n\n"$
     
     public $className$()
     {
-    
+	    $if(schemaId)$
+	     super.setSchemaId( "$schemaId$" );
+	    $endif$
+	    
+	    $if(resourceDesc)$
+	     super.setResourceDesc( "$resourceDesc$" );
+	    $endif$
     }
    
    $allAttrs: { attr | 



Mime
View raw message