Kogie / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

Manage FieldsMetadata with @annotations #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Today FieldsMetada which is used to set loop for table row, text styling, image 
etc is configurated at hand or by loading Java classes. I think it should be 
cool if we could use Java 5 annotations to manage that like this : 

---------------------------------------------
public class Project {

   @TextStyling("Html")
   private String comment;

   public String getComment() {
     return comment;
   }
}
---------------------------------------------

Original issue reported on code.google.com by angelo.z...@gmail.com on 28 Oct 2012 at 9:50

GoogleCodeExporter commented 9 years ago
Hi to all.
here is my proposal for this functionality. 
As we have already defined SytaxKind enum, where are defined all supported 
syntaxes, I decide to use this enum. so we have following annotation:

@Target(value={ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Syntax {
    public SyntaxKind value();
}

addField will be modified like:

Method method = currentField.getReadMethod();       
Syntax syntax = method.getAnnotation(Syntax.class);
fieldsMetadata.addField(fieldName.toString(), isList, null, 
syntax.value().name(), null);

Please, tell me if It what I'm doing is what you mean in this issue.

Original comment by ruslancu...@gmail.com on 26 Feb 2013 at 7:38

GoogleCodeExporter commented 9 years ago
Check please attached patch with functionality and junit test

Original comment by ruslancu...@gmail.com on 26 Feb 2013 at 8:34

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

At first XDocReport provides several enum like SyntaxKind, TemplateEngineKind 
etc which defines the supported syntax, template engine in XDocReport. But as 
XDocReport is modular it's possisble to add a new custom syntax kind with 
String.

So I think it should be better to support String and enum both (or just String)

After I tell me that perhaps it's better to have just one an annotation 
@FieldMetadata which manages the fieldsmetadata :

----------------------------------------------------------------
@FieldMetadata(syntaxKind="html", description="bla bla bla")
public String getComment() {
   return comment;
}
----------------------------------------------------------------

instead of several annotations (@TextStyling, etc).

What do you think about that?

Regards Angelo

Original comment by angelo.z...@gmail.com on 26 Feb 2013 at 8:37

GoogleCodeExporter commented 9 years ago
Many thank's for the patch, but before developping something I would like 
specify the whole cases.

We have 2 means : 

1) One annotation: 

----------------------------------------------------------------
@FieldMetadata(syntaxKind="html", description="bla bla bla")
public String getComment() {
   return comment;
}
----------------------------------------------------------------

1) Several annotations: 

----------------------------------------------------------------
@SyntaxKind("html")
@Description("bla bla bla")
public String getComment() {
   return comment;
}
----------------------------------------------------------------

What is the best? The 1)?, the 2)? The 1) and 2)?

Once we have choosen that, we must specify the annotations.

Regards Angelo

Original comment by angelo.z...@gmail.com on 26 Feb 2013 at 9:19

GoogleCodeExporter commented 9 years ago
Hi to all.

Please check the patch.
Now it is used one annotation for FieldMetadata properties; syntaxKind, 
description and syntaxWithDirective. 

Original comment by ruslancu...@gmail.com on 26 Feb 2013 at 10:23

Attachments:

GoogleCodeExporter commented 9 years ago
Rlated to coment #4, I used first solution. name of Annotation is the same as 
Name of class to which will be applyed parameters(@FieldMetadata and 
FieldMetadata). I think that this will simplify understanding the scope of this 
annotation. As Annotations have default values, I think that is not reasonable 
to split this in many annotations. Also it will not be a problem to implement 
both solutions. We can take annotation precedence: First get values from 
FieldMetadata, later get values from all other annotations(like SyntaxKind, 
Description etc...), but my personal opinion using many annotations instead of 
one is just repeating already existing functionality, I mean everything we can 
do only with FieldMetadata annotation(et least what is required in this issue)

Original comment by ruslancu...@gmail.com on 26 Feb 2013 at 10:28

GoogleCodeExporter commented 9 years ago
Wow, that's very cool!

Many thank's! 

@Pascal if you have time, could you apply this last patch. Thank's

We should too update the wiki with this new annotations. 

Regards Angelo

Original comment by angelo.z...@gmail.com on 26 Feb 2013 at 10:41

GoogleCodeExporter commented 9 years ago
Integrated in commit e1b6053b1f58c373f4c5de806e70cb73d41f604e.

Thanks for contribution !

Original comment by pascal.leclercq on 1 Mar 2013 at 8:49

GoogleCodeExporter commented 9 years ago
Done.

Original comment by angelo.z...@gmail.com on 16 Sep 2013 at 2:30