this is a bit overly complex so Im looking for any suggestions to slim down the code GoraCompiler main method will need an argument of Collection base class //args[1] list of String arguments consisting of names of absolute path for each asvc//args[2] name of the schema (schema name)from asvc //args[3] name of the document (document name) from asvc //args[4] namespace see the prefix in the asvc and round back up to xlmns:name=namespace to obtain namespace org.apache.gora.compiler.GoraCompiler contains a main method
http://www.jarvana.com/jarvana/view/org/apache/gora/gora-core/0.1-incubating/gora-core-0.1-incubating-javadoc.jar!/org/apache/gora/compiler/GoraCompiler.html public static void main(String []args) { //assuming args[1] is a collection of strings representing the names of the asvc filesArrayList<String> array=args[1]; //construct a Names objectorg.apache.avro.Schema.Names names=org.apache.avro.Schema.Names(); String space=" "; while (array.iterator().hasNext() ) {String name=(String)array.iterator().next(); org.apache.avro.Schema.Name schema_name=new org.apache.avro.Schema.Name( name, space) ; org.apache.avro.Schema schema=names.put(schema_name, Schema schema) } // end loop //getting the schema is a bit of a challenge since we will be expected to know both the schema_name and the document_name String schema_nm = args[2]; String document_name=args[3]; String namespace=args[4]; /** Create an enum schema. */ org.apache.avro.Schema schema=org.apache.avro.Schema .createEnum(schema_nm,document_name, namespace,(List<String>)array) ; //construct a JsonNode from the schema element called "fields" org.codehaus.jackson.JsonNode fieldsJsonNode = schema.get("fields"); //call Schema parse method with JsonNode fieldsJsonNode and constructedNames argument schema=org.apache.avro.Schema.parse(fieldsJsonNode, names) } http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.avro/avro/1.7.2/org/apache/avro/Schema.java/?v=source HTH Martin ______________________________________________ Catherine Zeta Jones:...I didn't know Porsche made things like this. Sean Connery:........ they don't... > Date: Mon, 3 Dec 2012 16:28:27 +0000 > Subject: Re: Correct configuration for reading a list into a Java class > From: lewis.mcgibb...@gmail.com > To: user@ant.apache.org > > Hi Martin, > > Yes, I need a List[] of avro schemas. I need to compile the lot. > > I am curious as to an Apache Ant problem or a GoraCompiler problem > > I have a spade and I am digging > > On Mon, Dec 3, 2012 at 4:06 PM, Martin Gainty <mgai...@hotmail.com> wrote: > > > > MG>GoraCompiler main method calls compileSchema with one input src and > > output dest MG>nearest i can tell GoraCompiler compileSchema references one > > src file > > > > MG>http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.gora/gora-core/0.2.1/org/apache/gora/compiler/GoraCompiler.java/?v=source > > > > MG>this Factory.parse is expecting 1 file input to parse method > > MG>http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.avro/avro/1.7.2/org/apache/avro/Schema.java/?v=source > > MG>in order to parse a collection the op would need to tweak GoraCompiler > > to call compileSchema and pass in a constructed JSONNode and Names as in > > MG>static Schema parse(JsonNode schema, Names names) MG>where Names is a > > LinkedHashMap > > MG>http://grepcode.com/file/repo1.maven.org/maven2/org.apache.avro/avro/1.7.2/org/apache/avro/Schema.java#Schema.Names > > MG>Lewis..does this conform to your understanding? > > > > Martin Gainty > > > > ______________________________________________ > > Please do not alter or disrupt this transmission..Thank You > > > > > Date: Mon, 3 Dec 2012 08:44:24 -0500 > >> From: sflo...@nc.rr.com > >> To: user@ant.apache.org > >> Subject: RE: Correct configuration for reading a list into a Java class > >> > >> > >> Lewis, > >> > >> By command line params, I mean what params does GoraCompiler require (can > >> I see examples as if you'd manually execute from command line)... > >> > >> On Mon, 3 Dec 2012, Scot P. Floess wrote: > >> > >> > > >> > Martin, > >> > > >> > I don't know the GoraCompiler at all. Again, I was just guessing what he > >> > might need to do :) > >> > > >> > > >> > Lewis, > >> > > >> > Can you provide either a doc link or some of the command line params > >> > that you > >> > need? > >> > > >> > > >> > > >> > On Sun, 2 Dec 2012, Martin Gainty wrote: > >> > > >> >> > >> >> MG>scott do you know the default folder delimiter GoraCompiler > >> >> expectsMG>if > >> >> lewis implements the arg element with space delimiter in his line > >> >> attribute as inMG><arg line="${goraavscfiles} ${src.dir}">MG>can we > >> >> assume > >> >> GoraCompiler should implement space delimiter for folders instead of > >> >> colon > >> >> (:)> Date: Sun, 2 Dec 2012 12:43:05 -0500 > >> >>> From: sflo...@nc.rr.com > >> >>> To: lewis.mcgibb...@gmail.com > >> >>> CC: user@ant.apache.org > >> >>> Subject: Re: Correct configuration for reading a list into a Java class > >> >>> > >> >>> > >> >>> I don't know the GoraCompiler nor any of its command line arguments... > >> >>> > >> >>> But have you tried the java <arg line=""> sub element? I don't know > >> >>> if it > >> >>> will help you but this may work: > >> >>> > >> >>> <java classname="org.apache.gora.compiler.GoraCompiler" fork="true"> > >> >>> <classpath refid="classpath"/> > >> >>> <arg line="${goraavscfiles} ${src.dir}"/> > >> >>> </java> > >> >>> > >> >>> I did a minor bit of googling - but didn't quickly find the command > >> >>> line > >> >>> options or I may have had a firmer "I think this will work" statement > >> >>> :) > >> >>> > >> >>> > >> >>> > >> >>> On Sat, 1 Dec 2012, Lewis John Mcgibbney wrote: > >> >>> > >> >>>> Hi All, > >> >>>> > >> >>>> I've done a fiar bit of digging on this one on user@ archives and > >> >>>> there have been various threads on the topic. I understand that the > >> >>>> solution to reading in multiple files an executing them with the java > >> >>>> element is a custom solution. The problem is pretty simple. I have a > >> >>>> directory of avro schemas which I would like to pass to a GoraCompiler > >> >>>> class to be compiled. > >> >>>> > >> >>>> So far I've got > >> >>>> > >> >>>> <!-- ====================================================== --> > >> >>>> <!-- Generate the Java files from the GORA schemas --> > >> >>>> <!-- Will call this automatically later --> > >> >>>> <!-- ====================================================== --> > >> >>>> <!-- map for the gora .avsc files contained in ./src/gora/ > >> >>>> so they can be passed as a list to the GoraCompiler > >> >>>> via the generate-gora-src target --> > >> >>>> <fileset dir="${gora.avsc.dir}" id="gora.avsc.files"> > >> >>>> <include name="*.avsc"/> > >> >>>> </fileset> > >> >>>> <pathconvert property="goraavscfiles" refid="gora.avsc.files"> > >> >>>> <map from="${goraavscdir}" to=""/> > >> >>>> </pathconvert> > >> >>>> > >> >>>> <target name="generate-gora-src" > >> >>>> description="> generate the Java files from the Gora schema(s) in > >> >>>> src/gora/*.avsc"> > >> >>>> <java classname="org.apache.gora.compiler.GoraCompiler" fork="true"> > >> >>>> <classpath refid="classpath"/> > >> >>>> <arg value="${goraavscfiles}"/> > >> >>>> <arg value="${src.dir}"/> > >> >>>> </java> > >> >>>> </target> > >> >>>> > >> >>>> When I execute I get > >> >>>> > >> >>>> generate-gora-src: > >> >>>> [java] 12/12/01 16:22:09 INFO compiler.GoraCompiler: Compiling > >> >>>> schema file: > >> >>>> /home/lewismc/ASF/2.x/src/gora/host.avsc:/home/lewismc/ASF/2.x/src/gora/webpage.avsc > >> >>>> to: ./src/java > >> >>>> [java] Exception in thread "main" java.io.FileNotFoundException: > >> >>>> /home/lewismc/ASF/2.x/src/gora/host.avsc:/home/lewismc/ASF/2.x/src/gora/webpage.avsc > >> >>>> (No such file or directory) > >> >>>> [java] at java.io.FileInputStream.open(Native Method) > >> >>>> [java] at > >> >>>> java.io.FileInputStream.<init>(FileInputStream.java:120) > >> >>>> [java] at > >> >>>> org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:325) > >> >>>> [java] at org.apache.avro.Schema.parse(Schema.java:794) > >> >>>> [java] at > >> >>>> org.apache.gora.compiler.GoraCompiler.compileSchema(GoraCompiler.java:87) > >> >>>> [java] at > >> >>>> org.apache.gora.compiler.GoraCompiler.main(GoraCompiler.java:509) > >> >>>> [java] Java Result: 1 > >> >>>> > >> >>>> BUILD SUCCESSFUL > >> >>>> Total time: 6 seconds > >> >>>> > >> >>>> If someone could please help me to understand how to separate the > >> >>>> files into the required File [] list then that would be great. I > >> >>>> should make it clear that I've discovered pathconvert's pathsep > >> >>>> attribute but it still seems to be a string being passed as oppose to > >> >>>> a separated list of files. > >> >>>> I should also note that making the target accept a single explicit > >> >>>> file works perfectly, so I know my configuration is in the way I'm > >> >>>> constructing the mappings. > >> >>>> > >> >>>> Thanks very much in advance > >> >>>> > >> >>>> Lewis > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> -- > >> >>>> Lewis > >> >>>> > >> >>>> --------------------------------------------------------------------- > >> >>>> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > >> >>>> For additional commands, e-mail: user-h...@ant.apache.org > >> >>>> > >> >>>> > >> >>> > >> >>> Scot P. Floess RHCT (Certificate Number 605010084735240) > >> >>> Chief Architect FlossWare http://sourceforge.net/projects/flossware > >> >>> http://flossware.sourceforge.net > >> >>> https://github.com/organizations/FlossWare > >> >>> > >> >>> --------------------------------------------------------------------- > >> >>> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > >> >>> For additional commands, e-mail: user-h...@ant.apache.org > >> >>> > >> >> > >> > > >> > Scot P. Floess RHCT (Certificate Number 605010084735240) > >> > Chief Architect FlossWare http://sourceforge.net/projects/flossware > >> > http://flossware.sourceforge.net > >> > https://github.com/organizations/FlossWare > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > >> > For additional commands, e-mail: user-h...@ant.apache.org > >> > > >> > > >> > >> Scot P. Floess RHCT (Certificate Number 605010084735240) > >> Chief Architect FlossWare http://sourceforge.net/projects/flossware > >> http://flossware.sourceforge.net > >> https://github.com/organizations/FlossWare > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > >> For additional commands, e-mail: user-h...@ant.apache.org > >> > > > > > > -- > Lewis > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org >