Wikitty-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
November 2010
- 8 participants
- 82 discussions
r516 - trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by jcouteau@users.nuiton.org 24 Nov '10
by jcouteau@users.nuiton.org 24 Nov '10
24 Nov '10
Author: jcouteau
Date: 2010-11-24 18:33:00 +0100 (Wed, 24 Nov 2010)
New Revision: 516
Url: http://nuiton.org/repositories/revision/wikitty/516
Log:
Fix copyFrom method in DTO generator
Modified:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 17:21:14 UTC (rev 515)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 17:33:00 UTC (rev 516)
@@ -540,12 +540,12 @@
addParameter(copyFrom, "BusinessEntity", "source");
String copyFromBody = ""
/*{
- if (source instanceof <%=entityName%>){
+ if (!(source instanceof <%=entityName%>)){
throw new WikittyException("Can't copy source object " + source +
". They are not of the same type");
}
- <%=dtoClassName%> sourceCopy = (<%=dtoClassName%>)source;
+ <%=entityName%> sourceCopy = (<%=entityName%>)source;
this.setWikittyVersion(sourceCopy.getWikittyVersion());
}*/;
1
0
r515 - trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by jcouteau@users.nuiton.org 24 Nov '10
by jcouteau@users.nuiton.org 24 Nov '10
24 Nov '10
Author: jcouteau
Date: 2010-11-24 18:21:14 +0100 (Wed, 24 Nov 2010)
New Revision: 515
Url: http://nuiton.org/repositories/revision/wikitty/515
Log:
Generate copyFrom method
Improve generated abstract and helper
Modified:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyHelperGenerator.java
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java 2010-11-24 17:05:48 UTC (rev 514)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyAbstractGenerator.java 2010-11-24 17:21:14 UTC (rev 515)
@@ -313,6 +313,8 @@
attributeName = attribute.getTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME);
}
+ String capitalizedAttributeName = StringUtils.capitalize(attributeName);
+
String getterName;
if (WikittyTransformerUtil.isAttributeCollection(attribute)) {
@@ -333,18 +335,19 @@
}*/;
setOperationBody(getter, getterBody);
- String setterName = "set" + StringUtils.capitalize(attributeName);
+ String setterName = "set" + capitalizedAttributeName;
ObjectModelOperation setter = addOperation(abstractClass, setterName, "void");
addAnnotation(abstractClass, setter, "Override");
addParameter(setter, attributeTypeSimpleNameInSet, attributeName);
String setterBody = ""
/*{
+ <%=attributeTypeSimpleNameInSet%> oldValue = get<%=capitalizedAttributeName%>();
<%=helperClassName%>.<%=setterName%>(getWikitty(), <%=attributeName%>);
- getPropertyChangeSupport().firePropertyChange(<%=fieldVariableName%>, null, <%= getter.getName() %>());
+ getPropertyChangeSupport().firePropertyChange(<%=fieldVariableName%>, oldValue, <%= getter.getName() %>());
}*/;
setOperationBody(setter, setterBody);
- String addName = "add" + StringUtils.capitalize(attributeName);
+ String addName = "add" + capitalizedAttributeName;
ObjectModelOperation adder = addOperation(abstractClass, addName, "void");
addAnnotation(abstractClass, adder, "Override");
addParameter(adder, "String", "element");
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 17:05:48 UTC (rev 514)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 17:21:14 UTC (rev 515)
@@ -131,7 +131,7 @@
ObjectModelClass abstractClassForThisEntity = processedClasses.get(clazz);
addConstructors(abstractClassForThisEntity);
addToString(clazz, abstractClassForThisEntity);
- addBusinessEntityMethods(abstractClassForThisEntity);
+ addBusinessEntityMethods(clazz, abstractClassForThisEntity);
addModelOperations(clazz, abstractClassForThisEntity);
}
@@ -400,8 +400,12 @@
return clazz.getName() + "DTO";
}
- protected void addBusinessEntityMethods(ObjectModelClass dtoClass) {
+ protected void addBusinessEntityMethods(ObjectModelClass entity, ObjectModelClass dtoClass) {
+ //needed in templates
+ String entityName = entity.getName();
+ String dtoClassName = businessEntityToDTOName(entity);
+
//adding wikittyId attribute
addAttribute(dtoClass, "wikittyId", "String");
@@ -530,8 +534,92 @@
throw new UnsupportedOperationException("Not supported yet.");
}*/);
+ //adding copyFrom method
+ ObjectModelOperation copyFrom = addOperation(dtoClass, "copyFrom", "void");
+ addAnnotation(dtoClass, copyFrom, "Override");
+ addParameter(copyFrom, "BusinessEntity", "source");
+ String copyFromBody = ""
+/*{
+ if (source instanceof <%=entityName%>){
+ throw new WikittyException("Can't copy source object " + source +
+ ". They are not of the same type");
+ }
+
+ <%=dtoClassName%> sourceCopy = (<%=dtoClassName%>)source;
+
+ this.setWikittyVersion(sourceCopy.getWikittyVersion());
+}*/;
+
+ copyFromBody = addCopyFromAttributes(entity, dtoClass, copyFromBody);
+
+ addImport(dtoClass, "org.nuiton.wikitty.WikittyException");
+
+ setOperationBody(copyFrom, copyFromBody);
}
+ protected String addCopyFromAttributes(ObjectModelClass businessEntity,
+ ObjectModelClass dtoClass,
+ String methodBody){
+
+ // generating operations with bodies to realize contract
+ for (ObjectModelAttribute attribute : businessEntity.getAttributes()) {
+ if (attribute.isNavigable()) {
+ // needed below, in templates
+ String attributeType = WikittyTransformerUtil.generateResultType(attribute, false);
+ String attributeName = attribute.getName();
+
+
+ //If alternative name, use it
+ if (attribute.hasTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME)) {
+ attributeName = attribute.getTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME);
+ }
+
+ String capitalizedAttributeName = StringUtils.capitalize(attributeName);
+
+ methodBody += ""
+/*{
+ this.set<%=capitalizedAttributeName%>(sourceCopy.get<%=capitalizedAttributeName%>());
+}*/;
+ }
+ }
+
+
+ // add attributes and methods inherited from super classes
+ for (ObjectModelClass superClass : businessEntity.getSuperclasses()) {
+
+ // process super classes first, so we will get inherited operations from superclass
+ addCopyFromAttributes(superClass, dtoClass, methodBody);
+
+ if (WikittyTransformerUtil.isBusinessEntity(superClass)) {
+
+ // generating operations with bodies to realize contract
+ for (ObjectModelAttribute attribute : businessEntity.getAttributes()) {
+ if (attribute.isNavigable()) {
+ // needed below, in templates
+ String attributeType = WikittyTransformerUtil.generateResultType(attribute, false);
+ String attributeName = attribute.getName();
+
+
+ //If alternative name, use it
+ if (attribute.hasTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME)) {
+ attributeName = attribute.getTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME);
+ }
+
+ String capitalizedAttributeName = StringUtils.capitalize(attributeName);
+
+ methodBody+=""
+/*{
+ this.set<%=capitalizedAttributeName%>(source.get<%=capitalizedAttributeName%>());
+}*/;
+ }
+ }
+ }
+ }
+
+ return methodBody;
+
+ }
+
protected void addModelOperations(ObjectModelClass businessEntity, ObjectModelClass dtoClass){
Collection<ObjectModelOperation> operations = businessEntity.getOperations();
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyHelperGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyHelperGenerator.java 2010-11-24 17:05:48 UTC (rev 514)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyHelperGenerator.java 2010-11-24 17:21:14 UTC (rev 515)
@@ -126,8 +126,10 @@
addParameter(setter, attributeTypeSimpleNameInSet, attributeName);
String setterBody = ""
/*{
- for (String id:<%=attributeName%>){
- add<%=attributeNameCapitalized%>(wikitty, id);
+ if(<%=attributeName%> != null){
+ for (String id:<%=attributeName%>){
+ add<%=attributeNameCapitalized%>(wikitty, id);
+ }
}
}*/;
setOperationBody(setter, setterBody);
1
0
r514 - in trunk/wikitty-dto/src: main/java/org/nuiton/wikitty/dto test/java/org/nuiton/wikitty/dto
by bpoussin@users.nuiton.org 24 Nov '10
by bpoussin@users.nuiton.org 24 Nov '10
24 Nov '10
Author: bpoussin
Date: 2010-11-24 18:05:48 +0100 (Wed, 24 Nov 2010)
New Revision: 514
Url: http://nuiton.org/repositories/revision/wikitty/514
Log:
use new copyFrom method to convert BusinessEntityWikitty <-> Dto
Modified:
trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/dto/DTOHelper.java
trunk/wikitty-dto/src/test/java/org/nuiton/wikitty/dto/WikittyDTOTest.java
Modified: trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/dto/DTOHelper.java
===================================================================
--- trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/dto/DTOHelper.java 2010-11-24 17:00:26 UTC (rev 513)
+++ trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/dto/DTOHelper.java 2010-11-24 17:05:48 UTC (rev 514)
@@ -24,17 +24,11 @@
*/
package org.nuiton.wikitty.dto;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.ObjectUtil;
-import org.nuiton.wikitty.WikittyException;
import org.nuiton.wikitty.WikittyProxy;
import org.nuiton.wikitty.entities.BusinessEntity;
-import org.nuiton.wikitty.entities.Wikitty;
-import org.nuiton.wikitty.entities.WikittyField;
/**
* User: couteau
@@ -44,7 +38,7 @@
static Log log = LogFactory.getLog(DTOHelper.class);
- public static <E extends BusinessEntity, F extends BusinessEntity> E toDto(F w) {
+ public static <E extends BusinessEntity> E toDto(E w) {
Class clazz = w.getClass();
String dtoClassName = clazz.getName().replace("Impl", "DTO").replace("CopyOnWrite", "DTO");
E result = null;
@@ -52,73 +46,17 @@
String wikittyId = w.getWikittyId();
result = (E)ObjectUtil.newInstance(dtoClassName+"("+wikittyId+")");
- result.setWikittyVersion(w.getWikittyVersion());
-
- //get all fields
- Class entityClass = result.getClass();
- Field[] fields = entityClass.getDeclaredFields();
-
- for (Field field : fields) {
- //for each field that got WikittyField annotation
- if (field.isAnnotationPresent(WikittyField.class)) {
-
- //get the attribute's wikitty fqn
- WikittyField annotation = field.getAnnotation(WikittyField.class);
- String fieldFQN = annotation.fqn();
-
- //extract extension and field name from fqn
- String ext = fieldFQN.substring(0,fieldFQN.lastIndexOf("."));
- String fieldName = fieldFQN.substring(fieldFQN.lastIndexOf(".")+1);
-
- //set the value
- Object value = w.getField(ext,fieldName);
- Method m = entityClass.getMethod("set" + StringUtils.capitalize(field.getName()), field.getType());
- m.invoke(result,value);
- }
- }
-
- result.setWikittyVersion(w.getWikittyVersion());
-
+ result.copyFrom(w);
}catch (Exception eee){
log.error("Could not transform Wikitty to DTO", eee);
}
return result;
}
- public static <E extends BusinessEntity, F extends BusinessEntity> E fromDto(WikittyProxy proxy, Class<E> clazz, F dto) {
+ public static <E extends BusinessEntity> E fromDto(WikittyProxy proxy, Class<E> clazz, E dto) {
- E result = proxy.restore(clazz, dto.getWikittyId());
-
-
- try {
-
- //get all fields
- Class entityClass = dto.getClass();
- Class resultClass = result.getClass();
- Field[] fields = entityClass.getDeclaredFields();
-
- for (Field field : fields) {
- //for each field that got WikittyField annotation
- if (field.isAnnotationPresent(WikittyField.class)) {
-
- //get the attribute's wikitty fqn
- WikittyField annotation = field.getAnnotation(WikittyField.class);
-
- //get the value from dto
- Method m = entityClass.getMethod("get" + StringUtils.capitalize(field.getName()));
- Object value = m.invoke(dto);
-
- //set the value on entity
- m = resultClass.getMethod("set" + StringUtils.capitalize(field.getName()), field.getType());
- m.invoke(result, value);
- }
- }
-
- } catch (Exception eee) {
- log.error("Could not transform Wikitty to DTO", eee);
- }
-
- result.setWikittyVersion(dto.getWikittyVersion());
+ E result = (E)proxy.restore(clazz, dto.getWikittyId());
+ result.copyFrom(dto);
return result;
}
Modified: trunk/wikitty-dto/src/test/java/org/nuiton/wikitty/dto/WikittyDTOTest.java
===================================================================
--- trunk/wikitty-dto/src/test/java/org/nuiton/wikitty/dto/WikittyDTOTest.java 2010-11-24 17:00:26 UTC (rev 513)
+++ trunk/wikitty-dto/src/test/java/org/nuiton/wikitty/dto/WikittyDTOTest.java 2010-11-24 17:05:48 UTC (rev 514)
@@ -32,7 +32,7 @@
proxy.store(label);
//make conversion
- WikittyLabelDTO dto = DTOHelper.toDto(label);
+ WikittyLabel dto = DTOHelper.toDto(label);
//check that dto fields are the same than the wikitty ones
Assert.assertNotNull(dto);
1
0
r513 - in trunk/wikitty-api/src: main/java/org/nuiton/wikitty main/java/org/nuiton/wikitty/entities test/java test/java/entities test/java/org/nuiton/wikitty/api
by bpoussin@users.nuiton.org 24 Nov '10
by bpoussin@users.nuiton.org 24 Nov '10
24 Nov '10
Author: bpoussin
Date: 2010-11-24 18:00:26 +0100 (Wed, 24 Nov 2010)
New Revision: 513
Url: http://nuiton.org/repositories/revision/wikitty/513
Log:
add copyFrom on BusinessEntity
add copyBean on WikittyUtil
add test for this methods
Added:
trunk/wikitty-api/src/test/java/entities/
trunk/wikitty-api/src/test/java/entities/BusinessEntityImplTest.java
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntity.java
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntityImpl.java
trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 15:44:21 UTC (rev 512)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 17:00:26 UTC (rev 513)
@@ -25,6 +25,7 @@
package org.nuiton.wikitty;
+import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.commons.lang.StringUtils;
@@ -58,6 +59,7 @@
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.FastDateFormat;
@@ -981,4 +983,44 @@
return result;
}
+ /**
+ * Copy all properties (get/set) from source to destination,
+ * except wikitty property
+ *
+ * @param source
+ * @param dest
+ * @throws Exception
+ */
+ static public void copyBean(Object source, Object dest) throws Exception {
+ BeanUtilsBean bu = BeanUtilsBean.getInstance();
+ PropertyDescriptor[] origDescriptors =
+ bu.getPropertyUtils().getPropertyDescriptors(source);
+
+ for (int i = 0; i < origDescriptors.length; i++) {
+ String name = origDescriptors[i].getName();
+ if (log.isDebugEnabled()) {
+ log.debug("work on prop :" + name);
+ }
+ if ("class".equals(name)) {
+ continue; // No point in trying to set an object's class
+ }
+ if ("wikitty".equals(name)) {
+ continue; // No point in trying to set an wikitty
+ }
+ if (bu.getPropertyUtils().isReadable(source, name)
+ && bu.getPropertyUtils().isWriteable(dest, name)) {
+ if (log.isDebugEnabled()) {
+ log.debug("prop is copiable:" + name);
+ }
+ try {
+ Object value =
+ bu.getPropertyUtils().getSimpleProperty(source, name);
+ bu.copyProperty(dest, name, value);
+ } catch (NoSuchMethodException e) {
+ // Should not happen
+ }
+ }
+ }
+ }
+
}
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntity.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntity.java 2010-11-24 15:44:21 UTC (rev 512)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntity.java 2010-11-24 17:00:26 UTC (rev 513)
@@ -97,6 +97,13 @@
public void setField(String ext, String fieldName, Object value);
/**
+ * Copy all field version included from source to current bean (only
+ * id is not copied, but must be the same)
+ * @param source
+ */
+ public void copyFrom(BusinessEntity source);
+
+ /**
* Return the field type.
*
* @param ext extension
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntityImpl.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntityImpl.java 2010-11-24 15:44:21 UTC (rev 512)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/entities/BusinessEntityImpl.java 2010-11-24 17:00:26 UTC (rev 513)
@@ -28,6 +28,9 @@
import java.beans.PropertyChangeSupport;
import java.util.Collection;
import java.util.Collections;
+import org.apache.commons.beanutils.BeanUtils;
+import org.nuiton.wikitty.WikittyException;
+import org.nuiton.wikitty.WikittyUtil;
/**
*
@@ -97,6 +100,21 @@
public Wikitty getWikitty() {
return wikitty;
}
+
+ /**
+ * this copy used introspection, you can override it in generated class
+ * to optimize it
+ * @param source
+ */
+ @Override
+ public void copyFrom(BusinessEntity source) {
+ try {
+ WikittyUtil.copyBean(source, this);
+ } catch(Exception eee) {
+ throw new WikittyException(String.format(
+ "Can't copy source object %s", source), eee);
+ }
+ }
@Override
public Collection<String> getExtensionNames() {
Added: trunk/wikitty-api/src/test/java/entities/BusinessEntityImplTest.java
===================================================================
--- trunk/wikitty-api/src/test/java/entities/BusinessEntityImplTest.java (rev 0)
+++ trunk/wikitty-api/src/test/java/entities/BusinessEntityImplTest.java 2010-11-24 17:00:26 UTC (rev 513)
@@ -0,0 +1,43 @@
+package entities;
+
+
+import java.beans.PropertyDescriptor;
+import java.util.Arrays;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.wikitty.WikittyUtil;
+import org.nuiton.wikitty.entities.WikittyLabel;
+import org.nuiton.wikitty.entities.WikittyLabelImpl;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class BusinessEntityImplTest {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(BusinessEntityImplTest.class);
+
+ @Test
+ public void testCopyFrom() throws Exception {
+ WikittyLabel source = new WikittyLabelImpl();
+ source.addLabels("1erLabel");
+ source.addLabels("2emeLabel");
+
+ WikittyLabel dest = new WikittyLabelImpl();
+
+ dest.copyFrom(source);
+ Assert.assertFalse(source.getWikittyId().equals(dest.getWikittyId()));
+ Assert.assertEquals(source.getWikittyVersion(), dest.getWikittyVersion());
+ Assert.assertEquals(source.getLabels(), dest.getLabels());
+ }
+
+}
Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java
===================================================================
--- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java 2010-11-24 15:44:21 UTC (rev 512)
+++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java 2010-11-24 17:00:26 UTC (rev 513)
@@ -25,6 +25,7 @@
package org.nuiton.wikitty.api;
+import entities.BusinessEntityImplTest;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.text.ParseException;
@@ -35,6 +36,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,6 +44,8 @@
import org.junit.Test;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.wikitty.WikittyConfig;
+import org.nuiton.wikitty.WikittyException;
+import org.nuiton.wikitty.entities.BusinessEntity;
import org.nuiton.wikitty.entities.FieldType;
import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.entities.WikittyField;
@@ -519,9 +523,8 @@
ws.store(null, Collections.singleton(labelWikitty), false);
- LabelDTO dto = new LabelDTO();
+ LabelDTO dto = new LabelDTO(wikittyId);
dto.addLabels("toto");
- dto.setWikittyId(wikittyId);
dto.setWikittyVersion("2.0");
Wikitty w = WikittyUtil.getWikitty(ws, null, dto);
@@ -532,14 +535,57 @@
Assert.assertEquals(dto.getLabels(), l.getLabels());
}
+ @Test
+ public void testCopyBean() throws Exception {
+ WikittyLabel source = new WikittyLabelImpl();
+ source.addLabels("toto");
+ WikittyLabel dest = new WikittyLabelImpl();
+
+ WikittyUtil.copyBean(source, dest);
+
+ Assert.assertFalse(source.getWikittyId().equals(dest.getWikittyId()));
+ Assert.assertEquals(source.getWikittyVersion(), dest.getWikittyVersion());
+ Assert.assertEquals(source.getLabels(), dest.getLabels());
+ }
+
+ @Test
+ public void testCopyFrom() throws Exception {
+ {
+// System.out.println("Dto => W");
+ WikittyLabel source = new LabelDTO(WikittyUtil.genUID());
+ source.addLabels("toto");
+ source.addLabels("titi");
+ WikittyLabel dest = new WikittyLabelImpl();
+
+ dest.copyFrom(source);
+ Assert.assertFalse(source.getWikittyId().equals(dest.getWikittyId()));
+ Assert.assertEquals(source.getWikittyVersion(), dest.getWikittyVersion());
+ Assert.assertEquals(source.getLabels(), dest.getLabels());
+ }
+ {
+// System.out.println("W => Dto");
+ WikittyLabel source = new WikittyLabelImpl();
+ source.addLabels("toto");
+ source.addLabels("titi");
+ WikittyLabel dest = new LabelDTO(WikittyUtil.genUID());
+
+ dest.copyFrom(source);
+ Assert.assertFalse(source.getWikittyId().equals(dest.getWikittyId()));
+ Assert.assertEquals(source.getWikittyVersion(), dest.getWikittyVersion());
+ Assert.assertEquals(source.getLabels(), dest.getLabels());
+ }
+
+
+ }
+
static public class LabelDTO implements WikittyLabel {
protected String wikittyId;
- protected String wikittyVersion;
+ protected String wikittyVersion = "0.0";
@WikittyField(fqn="WikittyLabel.labels")
protected Set<String> labels = new HashSet<String>();
- public void setWikittyId(String wikittyId) {
+ public LabelDTO(String wikittyId) {
this.wikittyId = wikittyId;
}
@@ -598,6 +644,16 @@
}
@Override
+ public void copyFrom(BusinessEntity source) {
+ try {
+ BeanUtils.copyProperties(this, source);
+ } catch (Exception eee) {
+ throw new WikittyException(String.format(
+ "Can't copy source object %s", source), eee);
+ }
+ }
+
+ @Override
public Collection<String> getExtensionFields(String ext) {
throw new UnsupportedOperationException("Not supported yet.");
}
1
0
r512 - trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by jcouteau@users.nuiton.org 24 Nov '10
by jcouteau@users.nuiton.org 24 Nov '10
24 Nov '10
Author: jcouteau
Date: 2010-11-24 16:44:21 +0100 (Wed, 24 Nov 2010)
New Revision: 512
Url: http://nuiton.org/repositories/revision/wikitty/512
Log:
Remove wikitty constructor
Modified:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 15:19:51 UTC (rev 511)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 15:44:21 UTC (rev 512)
@@ -157,13 +157,6 @@
}*/);
constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
- addParameter(constructor, WikittyTransformerUtil.WIKITTY_CLASS_FQN, "wikitty");
- setOperationBody(constructor, ""
-/*{
- wikittyId=wikitty.getId();
-}*/);
-
- constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
addParameter(constructor, "String", "wikittyId");
setOperationBody(constructor, ""
/*{
1
0
r511 - trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by jcouteau@users.nuiton.org 24 Nov '10
by jcouteau@users.nuiton.org 24 Nov '10
24 Nov '10
Author: jcouteau
Date: 2010-11-24 16:19:51 +0100 (Wed, 24 Nov 2010)
New Revision: 511
Url: http://nuiton.org/repositories/revision/wikitty/511
Log:
Add methods from super-super-classes in DTO
Modified:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
Modified: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 15:19:34 UTC (rev 510)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 15:19:51 UTC (rev 511)
@@ -315,13 +315,11 @@
*/
protected void addInheritedOperations(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
- if (!entitiesWithInheritedOperations.contains(businessEntity)) {
-
// add attributes and methods inherited from super classes
for (ObjectModelClass superClass : businessEntity.getSuperclasses()) {
// process super classes first, so we will get inherited operations from superclass
- addInheritedOperations(superClass, processedClasses.get(superClass));
+ addInheritedOperations(superClass, abstractClass);
if (WikittyTransformerUtil.isBusinessEntity(superClass)) {
@@ -331,7 +329,6 @@
}
entitiesWithInheritedOperations.add(businessEntity);
- }
}
/**
1
0
r510 - in trunk: wikitty-api/src/license wikitty-api/src/main/java/org/nuiton/wikitty wikitty-api/src/main/java/org/nuiton/wikitty/services wikitty-dto/src/license wikitty-hessian-client/src/license wikitty-hessian-server/src/license wikitty-jdbc-impl/src/license wikitty-solr-impl/src/license wikitty-ui-zk/src/license
by sletellier@users.nuiton.org 24 Nov '10
by sletellier@users.nuiton.org 24 Nov '10
24 Nov '10
Author: sletellier
Date: 2010-11-24 16:19:34 +0100 (Wed, 24 Nov 2010)
New Revision: 510
Url: http://nuiton.org/repositories/revision/wikitty/510
Log:
- Prevent NPE
- Update THIRD-PARTY
Modified:
trunk/wikitty-api/src/license/THIRD-PARTY.properties
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyConfig.java
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceFactory.java
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java
trunk/wikitty-dto/src/license/THIRD-PARTY.properties
trunk/wikitty-hessian-client/src/license/THIRD-PARTY.properties
trunk/wikitty-hessian-server/src/license/THIRD-PARTY.properties
trunk/wikitty-jdbc-impl/src/license/THIRD-PARTY.properties
trunk/wikitty-solr-impl/src/license/THIRD-PARTY.properties
trunk/wikitty-ui-zk/src/license/THIRD-PARTY.properties
Modified: trunk/wikitty-api/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-api/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-api/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -7,7 +7,6 @@
# - BSD style
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Public License Version 1.0
-# - Indiana University Extreme! Lab Software License
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - LGPL 2.1
# - Lesser General Public License (LGPL) v 3.0
@@ -29,4 +28,4 @@
org.springframework--spring-core--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
org.springframework--spring-expression--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
org.springframework--spring-test--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
-xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme\! Lab Software License
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyConfig.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyConfig.java 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyConfig.java 2010-11-24 15:19:34 UTC (rev 510)
@@ -209,7 +209,6 @@
+ " or org.nuiton.wikitty.services.WikittyServiceInMemoryJdbcSolr)"),
WikittyServiceInMemory.class.getName(), String.class, false, false),
-
WIKITTY_SERVER_CONFIG(
"wikitty.service.server.config",
_("Jetty server configuration file name"),
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceFactory.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceFactory.java 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyServiceFactory.java 2010-11-24 15:19:34 UTC (rev 510)
@@ -157,7 +157,7 @@
* Par exemple pour org.nuiton.wikitty.WikittyService le nom simple est
* WikittyService.
* La valeur doit contenir une liste de classes separer par des ','.
- * *
+ *
* @param config
* @param clazz
* @return la liste de classe trouvee ou null si la cle n'existe pas
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 15:19:34 UTC (rev 510)
@@ -115,6 +115,9 @@
}
static public String formatDate(Date date) throws ParseException {
+ if (date == null) {
+ return null;
+ }
return solrDateFormat.format(date);
}
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/services/WikittyServiceCached.java 2010-11-24 15:19:34 UTC (rev 510)
@@ -253,7 +253,9 @@
for (Wikitty w : missingInCache) {
// add missing object
- fromCache.put(w.getId(), w);
+ if (w != null) {
+ fromCache.put(w.getId(), w);
+ }
}
Collection<Wikitty> tmp = fromCache.values();
@@ -344,7 +346,10 @@
Collection<Wikitty> wikitties, boolean force) {
WikittyEvent result = ws.store(securityToken, wikitties, force);
- cache.putAllWikitty(result.getWikitties().values());
+ Map<String, Wikitty> wikittiesToCache = result.getWikitties();
+ if (wikittiesToCache != null) {
+ cache.putAllWikitty(wikittiesToCache.values());
+ }
return result;
}
Modified: trunk/wikitty-dto/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-dto/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-dto/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,27 +1,3 @@
-###
-# #%L
-# Wikitty :: dto
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -29,23 +5,25 @@
# - Apache Software License, version 1.1
# - BSD License
# - BSD style
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - LGPL
# - LGPL 2.1
# - Lesser General Public License (LGPL) v 3.0
# - Public Domain
# - The Apache Software License, Version 2.0
+# - http://jaxen.codehaus.org/license.html
# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Sat Nov 20 14:37:54 CET 2010
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-dom4j--dom4j--1.6.1=BSD License
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-jaxen--jaxen--1.1.1=http\://jaxen.codehaus.org/license.html
-jdom--jdom--1.0=The Apache Software License, Version 2.0
-org.jgroups--jgroups--2.10.0.GA=LGPL 2.1
-xalan--xalan--2.6.0=The Apache Software License, Version 2.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
+#Tue Nov 23 12:45:02 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+dom4j--dom4j--1.6.1--jar=BSD License
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+jaxen--jaxen--1.1.1--jar=http\://jaxen.codehaus.org/license.html
+jdom--jdom--1.0--jar=The Apache Software License, Version 2.0
+org.jgroups--jgroups--2.10.0.GA--jar=LGPL 2.1
+xalan--xalan--2.6.0--jar=The Apache Software License, Version 2.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
Modified: trunk/wikitty-hessian-client/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-hessian-client/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-hessian-client/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,27 +1,3 @@
-###
-# #%L
-# Wikitty :: hessian client
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -36,12 +12,13 @@
# - Public Domain
# - The Apache Software License, Version 1.1
# - The Apache Software License, Version 2.0
+# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Fri Oct 15 16:37:07 CEST 2010
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.jgroups--jgroups--2.10.0.GA=Lesser General Public License (LGPL) v 3.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
\ No newline at end of file
+#Tue Nov 23 12:51:21 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+org.jgroups--jgroups--2.10.0.GA--jar=Lesser General Public License (LGPL) v 3.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
Modified: trunk/wikitty-hessian-server/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-hessian-server/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-hessian-server/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,35 +1,15 @@
-###
-# #%L
-# Wikitty :: hessian server
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - Apache 2
# - Apache License
+# - Apache Software License - Version 2.0
# - Apache Software License, version 1.1
# - BSD License
+# - BSD style
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# - Common Public License Version 1.0
+# - Eclipse Public License - Version 1.0
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - LGPL 2.1
# - LGPL 2.1 / The Apache Software License - Version 2.0
@@ -38,15 +18,16 @@
# - Public Domain
# - The Apache Software License, Version 1.1
# - The Apache Software License, Version 2.0
+# - The H2 License, Version 1.0
+# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Wed Jul 21 13:45:24 CEST 2010
-com.experlog--xapool--1.5.0=Lesser General Public License (LGPL) v 3.0
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.jgroups--jgroups--2.10.0.GA=Lesser General Public License (LGPL) v 3.0
-woodstox--wstx-asl--3.2.7=LGPL 2.1 / The Apache Software License - Version 2.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
+#Tue Nov 23 12:53:04 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.servlet--servlet-api--2.5--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+org.jgroups--jgroups--2.10.0.GA--jar=Lesser General Public License (LGPL) v 3.0
+woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / The Apache Software License - Version 2.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
Modified: trunk/wikitty-jdbc-impl/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-jdbc-impl/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-jdbc-impl/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,27 +1,3 @@
-###
-# #%L
-# Wikitty :: wikitty-jdbc-impl
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2009 - 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -43,22 +19,22 @@
# - Public Domain
# - The Apache Software License, Version 2.0
# - The H2 License, Version 1.0
+# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Fri Oct 15 14:54:04 CEST 2010
-com.experlog--xapool--1.5.0=Lesser General Public License (LGPL) v 3.0
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.jgroups--jgroups--2.10.0.GA=Lesser General Public License (LGPL) v 3.0
-org.springframework--spring-aop--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-asm--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-beans--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-context--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-core--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-expression--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-test--3.0.1.RELEASE=The Apache Software License, Version 2.0
-woodstox--wstx-asl--3.2.7=LGPL 2.1 / The Apache Software License - Version 2.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
+#Tue Nov 23 12:43:03 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.servlet--servlet-api--2.5--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+org.jgroups--jgroups--2.10.0.GA--jar=Lesser General Public License (LGPL) v 3.0
+org.springframework--spring-aop--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-asm--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-beans--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-context--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-core--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-expression--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-test--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / The Apache Software License - Version 2.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
Modified: trunk/wikitty-solr-impl/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-solr-impl/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-solr-impl/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,27 +1,3 @@
-###
-# #%L
-# Wikitty :: wikitty-solr-impl
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2009 - 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -40,21 +16,22 @@
# - MIT License
# - Public Domain
# - The Apache Software License, Version 2.0
+# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Fri Oct 15 14:42:19 CEST 2010
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=Common Development and Distribution License (CDDL) v1.0
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.jgroups--jgroups--2.10.0.GA=Lesser General Public License (LGPL) v 3.0
-org.springframework--spring-aop--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-asm--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-beans--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-context--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-core--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-expression--3.0.1.RELEASE=The Apache Software License, Version 2.0
-org.springframework--spring-test--3.0.1.RELEASE=The Apache Software License, Version 2.0
-woodstox--wstx-asl--3.2.7=LGPL 2.1 / The Apache Software License - Version 2.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
+#Tue Nov 23 12:40:39 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.servlet--servlet-api--2.5--jar=Common Development and Distribution License (CDDL) v1.0
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+org.jgroups--jgroups--2.10.0.GA--jar=Lesser General Public License (LGPL) v 3.0
+org.springframework--spring-aop--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-asm--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-beans--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-context--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-core--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-expression--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+org.springframework--spring-test--3.0.1.RELEASE--jar=The Apache Software License, Version 2.0
+woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / The Apache Software License - Version 2.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
\ No newline at end of file
Modified: trunk/wikitty-ui-zk/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/wikitty-ui-zk/src/license/THIRD-PARTY.properties 2010-11-24 14:22:43 UTC (rev 509)
+++ trunk/wikitty-ui-zk/src/license/THIRD-PARTY.properties 2010-11-24 15:19:34 UTC (rev 510)
@@ -1,27 +1,3 @@
-###
-# #%L
-# Wikitty :: ui-zk
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
# Generated by org.nuiton.license.plugin.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -42,14 +18,15 @@
# - The Apache Software License, Version 1.1
# - The Apache Software License, Version 2.0
# - The H2 License, Version 1.0
+# - https://svn.codehaus.org/picocontainer/java/picocontainer/2.x/trunk/LICENSE…
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
-#Fri Oct 15 15:54:16 CEST 2010
-commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
-javax.servlet--servlet-api--2.5=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-org.jgroups--jgroups--2.10.0.GA=Lesser General Public License (LGPL) v 3.0
-woodstox--wstx-asl--3.2.7=LGPL 2.1 / The Apache Software License - Version 2.0
-xpp3--xpp3_min--1.1.3.4.O=Indiana University Extreme! Lab Software License
+#Tue Nov 23 12:46:48 CET 2010
+commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0
+javax.servlet--servlet-api--2.5--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+org.jgroups--jgroups--2.10.0.GA--jar=Lesser General Public License (LGPL) v 3.0
+woodstox--wstx-asl--3.2.7--jar=LGPL 2.1 / The Apache Software License - Version 2.0
+xpp3--xpp3_min--1.1.3.4.O--jar=Indiana University Extreme! Lab Software License, vesion 1.1.1
1
0
r509 - in trunk: . wikitty-api wikitty-dto wikitty-dto/src/main/java/org/nuiton/wikitty/generator wikitty-generators/src/main/java/org/nuiton/wikitty/generator
by tchemit@users.nuiton.org 24 Nov '10
by tchemit@users.nuiton.org 24 Nov '10
24 Nov '10
Author: tchemit
Date: 2010-11-24 15:22:43 +0100 (Wed, 24 Nov 2010)
New Revision: 509
Url: http://nuiton.org/repositories/revision/wikitty/509
Log:
move DTO generator + fix poms
Added:
trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
Removed:
trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
Modified:
trunk/pom.xml
trunk/wikitty-api/pom.xml
trunk/wikitty-dto/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-11-24 13:39:47 UTC (rev 508)
+++ trunk/pom.xml 2010-11-24 14:22:43 UTC (rev 509)
@@ -191,7 +191,7 @@
<dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
- <version>1.2.2</version>
+ <version>${nuitonI18nVersion}</version>
<scope>compile</scope>
</dependency>
@@ -522,6 +522,9 @@
<!-- common versions used in sub-poms -->
<eugeneVersion>2.2.1-SNAPSHOT</eugeneVersion>
<nuitonUtilsVersion>1.5.2-SNAPSHOT</nuitonUtilsVersion>
+ <nuitonI18nVersion>2.0</nuitonI18nVersion>
+ <processPluginVersion>1.0.3</processPluginVersion>
+
<springVersion>3.0.1.RELEASE</springVersion>
<jettyMorbayVersion>6.1.22</jettyMorbayVersion>
@@ -558,8 +561,15 @@
<plugin>
<groupId>org.nuiton.processor</groupId>
<artifactId>maven-processor-plugin</artifactId>
- <version>1.0.3</version>
+ <version>${processPluginVersion}</version>
</plugin>
+
+ <!-- eugene plugin -->
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <version>${eugeneVersion}</version>
+ </plugin>
</plugins>
</pluginManagement>
</build>
Modified: trunk/wikitty-api/pom.xml
===================================================================
--- trunk/wikitty-api/pom.xml 2010-11-24 13:39:47 UTC (rev 508)
+++ trunk/wikitty-api/pom.xml 2010-11-24 14:22:43 UTC (rev 509)
@@ -155,7 +155,6 @@
<plugin>
<groupId>org.nuiton.eugene</groupId>
<artifactId>maven-eugene-plugin</artifactId>
- <version>${eugeneVersion}</version>
<dependencies>
<dependency>
<groupId>org.nuiton.wikitty</groupId>
Modified: trunk/wikitty-dto/pom.xml
===================================================================
--- trunk/wikitty-dto/pom.xml 2010-11-24 13:39:47 UTC (rev 508)
+++ trunk/wikitty-dto/pom.xml 2010-11-24 14:22:43 UTC (rev 509)
@@ -3,156 +3,165 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>wikitty</artifactId>
- <version>3.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>wikitty</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
- <groupId>org.nuiton.wikitty</groupId>
- <artifactId>wikitty-dto</artifactId>
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-dto</artifactId>
- <dependencies>
+ <dependencies>
- <!-- sibling dependencies -->
+ <!-- sibling dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>wikitty-generators</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>wikitty-api</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>wikitty-generators</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>wikitty-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <dependency>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>eugene</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ </dependency>
-
- <!-- TEST -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
+ <!-- TEST -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
+ </dependencies>
- <name>Wikitty :: dto</name>
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
- <description>Provide DTOs for Wikitty</description>
- <inceptionYear>2010</inceptionYear>
+ <name>Wikitty :: dto</name>
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
+ <description>Provide DTOs for Wikitty</description>
+ <inceptionYear>2010</inceptionYear>
- <packaging>jar</packaging>
- <properties>
-
- <!-- extra files to include in release -->
- <redmine.releaseFiles>
- target/${project.build.finalName}.${project.packaging}
- </redmine.releaseFiles>
- </properties>
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
- <build>
+ <properties>
- <plugins>
- <!-- processor plugin -->
- <plugin>
- <groupId>org.nuiton.processor</groupId>
- <artifactId>maven-processor-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>process</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includes>**/*.java</includes>
- <filters>
- org.nuiton.processor.filters.GeneratorTemplatesFilter
- </filters>
- </configuration>
- </plugin>
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>
+ target/${project.build.finalName}.${project.packaging}
+ </redmine.releaseFiles>
+ </properties>
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <executions>
- <execution>
- <id>api-dto-generation</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <testPhase>true</testPhase>
- <inputs>
- <input>classpath:model:/:wikitty.objectmodel</input>
- </inputs>
- <fullPackagePath>org.nuiton.wikitty.entities
- </fullPackagePath>
- <defaultPackage>org.nuiton.wikitty.entities
- </defaultPackage>
- <extractedPackages>org.nuiton.wikitty.entities
- </extractedPackages>
- <templates>
- org.nuiton.wikitty.generator.WikittyDTOGenerator
- </templates>
- </configuration>
- <goals>
- <goal>smart-generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <build>
- <!-- expose new plexus components -->
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate-metadata</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <plugins>
+ <!-- processor plugin -->
+ <plugin>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includes>**/*.java</includes>
+ <filters>
+ org.nuiton.processor.filters.GeneratorTemplatesFilter
+ </filters>
+ </configuration>
+ </plugin>
- </build>
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>api-dto-generation</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <testPhase>true</testPhase>
+ <inputs>
+ <input>classpath:model:/:wikitty.objectmodel</input>
+ </inputs>
+ <fullPackagePath>
+ org.nuiton.wikitty.entities
+ </fullPackagePath>
+ <defaultPackage>
+ org.nuiton.wikitty.entities
+ </defaultPackage>
+ <extractedPackages>
+ org.nuiton.wikitty.entities
+ </extractedPackages>
+ <templates>
+ org.nuiton.wikitty.generator.WikittyDTOGenerator
+ </templates>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <!--dependencies>
+ <dependency>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wikitty-dto</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies-->
+ </plugin>
+ <!-- expose new plexus components -->
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+
</project>
Deleted: trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java
===================================================================
--- trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 13:39:47 UTC (rev 508)
+++ trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 14:22:43 UTC (rev 509)
@@ -1,562 +0,0 @@
-/*
- * #%L
- * Wikitty :: dto
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.wikitty.generator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.Transformer;
-import org.nuiton.eugene.java.ObjectModelTransformerToJava;
-import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelModifier;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
-
-
-/*{generator option: writeString = }*/
-/*{generator option: parentheses = false}*/
-/*{generator option: writeString = +}*/
-
-/**
- * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.wikitty.generator.WikittyDTOGenerator"
- */
-public class WikittyDTOGenerator extends ObjectModelTransformerToJava {
-
- private static final Log log = LogFactory.getLog(WikittyDTOGenerator.class);
-
- /**
- * map busines entity from source model to generated abstract class
- */
- protected Map<ObjectModelClass, ObjectModelClass> processedClasses =
- new HashMap<ObjectModelClass, ObjectModelClass>();
-
- /**
- * pattern to parse toString tagValue
- * for the string "abc{foo|bar}defrzeg{uvw|xyz}oeira"
- * will match {foo|bar} and {uvw|xyz} with groups for foo, bar, uvw and xyz
- */
- protected Pattern toStringTagValuePattern = Pattern.compile("\\{(([^|}])*)(?:\\|([^}]*))?\\}");
-
- /**
- * map "Client.name" to "getName()" or any getter to read this attribute
- * those getter names are stored while generating in order to be found
- * later when generating toString()
- */
- protected Map<String, String> attributeToGetterName = new HashMap<String, String>();
-
- @Override
- protected Transformer<ObjectModel, ObjectModel> initPreviousTransformer() {
- return new WikittyPurifierTransformer();
- }
-
- protected List<ObjectModelClass> entitiesWithInheritedOperations =
- new ArrayList<ObjectModelClass>();
-
- @Override
- public void transformFromModel(ObjectModel model) {
-
- // contains boths businessEntities and metaExtensions
- // elements may have one of the two sterotypes or both
- // but elements with none of them aren't in this list
- List<ObjectModelClass> modelBoth = new ArrayList<ObjectModelClass>();
-
- // fill modelBusinessEntities with entities found in model
- for (ObjectModelClass clazz : model.getClasses()) {
- if (WikittyTransformerUtil.isBusinessEntity(clazz) ||
- WikittyTransformerUtil.isMetaExtension(clazz)) {
- modelBoth.add(clazz);
- }
- }
-
- for (ObjectModelClass clazz : modelBoth) {
- ObjectModelClass abstractClass = createClass(
- businessEntityToDTOName(clazz),
- clazz.getPackageName());
- processedClasses.put(clazz, abstractClass);
- addInterface(abstractClass, clazz.getQualifiedName());
- }
-
- for (ObjectModelClass clazz : modelBoth) {
- if (WikittyTransformerUtil.isMetaExtension(clazz)) {
- addMetaExtensionOperations(clazz, processedClasses.get(clazz));
- } else if (WikittyTransformerUtil.isBusinessEntity(clazz)) {
- addOperations(clazz, processedClasses.get(clazz));
- }
- }
-
- // at this time, all operations in generated abstracts are just the operations
- // like get/set etc. we will copy all operations of a given class to all children
- // that's why constructors and others operations are not yet added
- for (ObjectModelClass clazz : modelBoth) {
- if (WikittyTransformerUtil.isBusinessEntity(clazz)) {
- addInheritedOperations(clazz, processedClasses.get(clazz));
- }
- }
-
- for (ObjectModelClass clazz : modelBoth) {
- ObjectModelClass abstractClassForThisEntity = processedClasses.get(clazz);
- addConstructors(abstractClassForThisEntity);
- addToString(clazz, abstractClassForThisEntity);
- addBusinessEntityMethods(abstractClassForThisEntity);
- addModelOperations(clazz, abstractClassForThisEntity);
- }
-
- processedClasses.clear();
- }
-
- protected void addSerialVersionUID(ObjectModelClass clazz) {
- // adding a generated serialVersionUID
- Random random = new Random();
- Long serialVersionUIDs = random.nextLong();
- addConstant(clazz,
- "serialVersionUID",
- "long",
- serialVersionUIDs.toString() + "L",
- ObjectModelModifier.PRIVATE);
- }
-
- protected void addConstructors(ObjectModelClass clazz) {
-
- ObjectModelOperation constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
- setOperationBody(constructor, ""
-/*{
-}*/);
-
- constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
- addParameter(constructor, WikittyTransformerUtil.WIKITTY_CLASS_FQN, "wikitty");
- setOperationBody(constructor, ""
-/*{
- wikittyId=wikitty.getId();
-}*/);
-
- constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
- addParameter(constructor, "String", "wikittyId");
- setOperationBody(constructor, ""
-/*{
- this.wikittyId=wikittyId;
-}*/);
-
- }
-
- protected void addOperations(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
- // generating operations with bodies to realize contract
- for (ObjectModelAttribute attribute : businessEntity.getAttributes()) {
- if (attribute.isNavigable()) {
- // needed below, in templates
- String attributeType = WikittyTransformerUtil.generateResultType(attribute, false);
- String attributeName = attribute.getName();
-
- //add necessary import
- addImport(abstractClass, attribute.getType());
-
- //If alternative name, use it
- if (attribute.hasTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME)) {
- attributeName = attribute.getTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME);
- }
-
- String getterName;
-
- if (WikittyTransformerUtil.isAttributeCollection(attribute)) {
- // attribute is a collection, we will generate operations
- // get, add, remove and clear
- String collectionType = WikittyTransformerUtil.getCollectionTypeName(attribute);
- if (collectionType.equals("Set")){
- addImport(abstractClass, java.util.Set.class);
- }
- if (collectionType.equals("List")){
- addImport(abstractClass, java.util.List.class);
-
- }
-
- String attributeTypeInSet = WikittyTransformerUtil.generateResultType(attribute, true);
-
- //adding the attribute
- ObjectModelAttribute modelAttribute = addAttribute(abstractClass, attributeName, attributeTypeInSet);
- String annotation = "WikittyField(fqn=\""+ businessEntity.getName() + "." + attributeName +"\")";
- addAnnotation(abstractClass, modelAttribute, annotation);
- addImport(abstractClass, org.nuiton.wikitty.entities.WikittyField.class);
-
-
- // adding the getter
- getterName = "get" + StringUtils.capitalize(attributeName);
- ObjectModelOperation getter = addOperation(abstractClass, getterName, attributeTypeInSet);
- addAnnotation(abstractClass, getter, "Override");
- String getterBody = ""
-/*{
- return <%=attributeName%>;
-}*/;
- setOperationBody(getter, getterBody);
-
- // adding the setter
- getterName = "set" + StringUtils.capitalize(attributeName);
- ObjectModelOperation setter = addOperation(abstractClass, getterName, "void");
- addAnnotation(abstractClass, setter, "Override");
- addParameter(setter, attributeTypeInSet, attributeName);
- String setterBody = ""
-/*{
- this.<%=attributeName%>=<%=attributeName%>;
-}*/;
- setOperationBody(setter, setterBody);
-
- //adding the add method
- String addName = "add" + StringUtils.capitalize(attributeName);
- ObjectModelOperation adder = addOperation(abstractClass, addName, "void");
- addAnnotation(abstractClass, adder, "Override");
- addParameter(adder, attributeType, "element");
- String adderBody = ""
-/*{
- <%=attributeName%>.add(element);
-}*/;
- setOperationBody(adder, adderBody);
-
- //adding the remove method
- String removeName = "remove" + StringUtils.capitalize(attributeName);
- ObjectModelOperation remover = addOperation(abstractClass, removeName, "void");
- addAnnotation(abstractClass, remover, "Override");
- addParameter(remover, attributeType, "element");
- String removerBody = ""
-/*{
- <%=attributeName%>.remove(element);
-}*/;
- setOperationBody(remover, removerBody);
-
- //adding the clear method
- String clearName = "clear" + StringUtils.capitalize(attributeName);
- ObjectModelOperation clear = addOperation(abstractClass, clearName, "void");
- addAnnotation(abstractClass, clear, "Override");
- String clearBody = ""
-/*{
- <%=attributeName%>.clear();
-}*/;
- setOperationBody(clear, clearBody);
-
- } else {
- //No multiplicity
-
- //add necessary import
- addImport(abstractClass, attribute.getType());
-
- //adding the attribute
- ObjectModelAttribute modelAttribute = addAttribute(abstractClass, attributeName, attributeType);
- String annotation = "WikittyField(fqn=\"" + businessEntity.getName() + "."+attributeName + "\")";
- addAnnotation(abstractClass, modelAttribute, annotation);
- addImport(abstractClass, org.nuiton.wikitty.entities.WikittyField.class);
-
- // adding getter
- getterName = "get" + StringUtils.capitalize(attributeName);
- ObjectModelOperation getter = addOperation(abstractClass, getterName, attributeType);
- addAnnotation(abstractClass, getter, "Override");
- setOperationBody(getter, ""
-/*{
- return <%=attributeName%>;
-}*/);
-
- //adding setter
- String setterName = "set" + StringUtils.capitalize(attributeName);
- ObjectModelOperation setter = addOperation(abstractClass, setterName, "void");
- addAnnotation(abstractClass, setter, "Override");
- addParameter(setter, attributeType, attributeName);
- setOperationBody(setter, ""
-/*{
- this.<%=attributeName%>=<%=attributeName%>;
-}*/);
- }
-
- // save the getter name for this attribute
- attributeToGetterName.put(businessEntity.getName() + "." + attributeName, getterName);
- }
- }
- }
-
- /**
- * Add inherited operations to the abstract generated from an entity.
- * Method browse superClasses to copy methods and their bodies. The method
- * deal with imports, cause bodies call the Helper of the classe where
- * the attribute was declared.
- * <p/>
- * If A inherit from B and B inherit from and A, B, C not in the same package
- * we B need to import CHelper and A need to import BHelper. But, since A
- * has C attributes too, it needs CHelper too. So when we will process B,
- * we will save needed imports, A will get them thus import CHelper.
- */
- protected void addInheritedOperations(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
-
- if (!entitiesWithInheritedOperations.contains(businessEntity)) {
-
- // add attributes and methods inherited from super classes
- for (ObjectModelClass superClass : businessEntity.getSuperclasses()) {
-
- // process super classes first, so we will get inherited operations from superclass
- addInheritedOperations(superClass, processedClasses.get(superClass));
-
- if (WikittyTransformerUtil.isBusinessEntity(superClass)) {
-
- //Add operations for the super class
- addOperations(superClass, abstractClass);
- }
- }
-
- entitiesWithInheritedOperations.add(businessEntity);
- }
- }
-
- /**
- * add a toString method
- * if a toString tagValue is attached to businessEntity, it will be used
- * to generate a toString as this :
- * <p/>
- * given "hello {Person.name|unknow}"
- * <p/>
- * will try to replace first {...} by name field value for extension Person.
- * if this information is not available, will do unknow.
- */
- protected void addToString(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
-
- String toStringOperationBody;
-
- if (businessEntity.hasTagValue(WikittyTransformerUtil.TAG_TO_STRING)) {
- String toStringPattern = businessEntity.getTagValue(WikittyTransformerUtil.TAG_TO_STRING);
-
- // toStringPattern is something like
- // "hello {Person.name|unknow} employe of {Company.name|unknow}"
- //
-
- Matcher matcher = toStringTagValuePattern.matcher(toStringPattern);
-
- while (matcher.find()) {
- String wholeMatch = matcher.group(0); // "{foo|bar}"
- String variableName = matcher.group(1); // "foo"
- String defaultValue = matcher.group(3); // "bar", may be null
-
- if (defaultValue == null) {
- defaultValue = "";
- }
-
- if (attributeToGetterName.containsKey(variableName)) {
- String getterName = attributeToGetterName.get(variableName);
- toStringPattern = toStringPattern.replace(wholeMatch, ""
-/*{"
- + <%=getterName%>().toString() +
- "}*/);
- } else {
- log.warn("no field " + variableName + " in " + businessEntity.getQualifiedName());
- toStringPattern = toStringPattern.replace(wholeMatch, defaultValue);
- }
- }
-
- toStringOperationBody = ""
-/*{
- return "<%=toStringPattern%>";
-}*/;
- } else {
- // no toString tagValue provided, generating a default toString
- toStringOperationBody = ""
-/*{
- return "dto:"+getWikittyId()+":"+getWikittyVersion();
-}*/;
- }
-
- ObjectModelOperation toString = addOperation(abstractClass, "toString", "String");
- addAnnotation(abstractClass, toString, "Override");
- setOperationBody(toString, toStringOperationBody);
- }
-
- protected void addMetaExtensionOperations(ObjectModelClass metaExtension,
- ObjectModelClass abstractClassForThisMetaExtension) {
-
- //add standard attribute operations for meta-extension
- addOperations(metaExtension, abstractClassForThisMetaExtension);
-
- }
-
- /**
- * Method to get the generated class name
- */
- protected String businessEntityToDTOName(ObjectModelClass clazz) {
- return clazz.getName() + "DTO";
- }
-
- protected void addBusinessEntityMethods(ObjectModelClass dtoClass) {
-
- //adding wikittyId attribute
- addAttribute(dtoClass, "wikittyId", "String");
-
- //adding getWikittyId method
- ObjectModelOperation getter = addOperation(dtoClass, "getWikittyId", "String");
- addAnnotation(dtoClass, getter, "Override");
- setOperationBody(getter, ""
-/*{
- return wikittyId;
-}*/);
-
- //adding setWikittyId method
- ObjectModelOperation setter = addOperation(dtoClass, "setWikittyId", "void");
- addParameter(setter, "String", "wikittyId");
- setOperationBody(setter, ""
-/*{
- this.wikittyId=wikittyId;
-}*/);
-
- //adding wikittyVersion attribute
- addAttribute(dtoClass, "wikittyVersion", "String");
-
-
-
- //adding getWikittyVersion method
- ObjectModelOperation getWikittyVersion = addOperation(dtoClass,
- "getWikittyVersion", "String");
- addAnnotation(dtoClass, getWikittyVersion, "Override");
- setOperationBody(getWikittyVersion, ""
-/*{
- return wikittyVersion;
-}*/);
-
- //adding setWikittyVersion method
- ObjectModelOperation setWikittyVersion = addOperation(dtoClass,
- "setWikittyVersion", "void");
- addParameter(setWikittyVersion, "String", "wikittyVersion");
- setOperationBody(setWikittyVersion, ""
-/*{
- this.wikittyVersion=wikittyVersion;
-}*/);
-
- //adding necessary imports
- addImport(dtoClass, java.beans.PropertyChangeListener.class);
- addImport(dtoClass, java.util.Collection.class);
-
- // adding addPropertyChangeListener
- ObjectModelOperation addPropertyChangeListener = addOperation(dtoClass,
- "addPropertyChangeListener", "void");
- addAnnotation(dtoClass, addPropertyChangeListener, "Override");
- addParameter(addPropertyChangeListener, "PropertyChangeListener", "listener");
- setOperationBody(addPropertyChangeListener, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- // adding removePropertyChangeListener
- ObjectModelOperation removePropertyChangeListener = addOperation(dtoClass,
- "removePropertyChangeListener", "void");
- addAnnotation(dtoClass, removePropertyChangeListener, "Override");
- addParameter(removePropertyChangeListener, "PropertyChangeListener", "listener");
- setOperationBody(removePropertyChangeListener, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- // adding addPropertyChangeListener 2 parameters
- ObjectModelOperation addPropertyChangeListener2 = addOperation(dtoClass,
- "addPropertyChangeListener", "void");
- addAnnotation(dtoClass, addPropertyChangeListener2, "Override");
- addParameter(addPropertyChangeListener2, "String", "property");
- addParameter(addPropertyChangeListener2, "PropertyChangeListener", "listener");
- setOperationBody(addPropertyChangeListener2, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- // adding removePropertyChangeListener 2 parameters
- ObjectModelOperation removePropertyChangeListener2 = addOperation(dtoClass,
- "removePropertyChangeListener", "void");
- addAnnotation(dtoClass, removePropertyChangeListener2, "Override");
- addParameter(removePropertyChangeListener2, "String", "property");
- addParameter(removePropertyChangeListener2, "PropertyChangeListener", "listener");
- setOperationBody(removePropertyChangeListener2, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- //adding getExtensionFields method
- ObjectModelOperation getExtensionFields = addOperation(dtoClass,
- "getExtensionFields", "Collection<String>");
- addAnnotation(dtoClass, getExtensionFields, "Override");
- addParameter(getExtensionFields, "String", "ext");
- setOperationBody(getExtensionFields, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- //adding getExtensionNames method
- ObjectModelOperation getExtensionNames = addOperation(dtoClass,
- "getExtensionNames", "Collection<String>");
- addAnnotation(dtoClass, getExtensionNames, "Override");
- setOperationBody(getExtensionNames, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- //adding getField method
- ObjectModelOperation getField = addOperation(dtoClass, "getField", "Object");
- addAnnotation(dtoClass, getField, "Override");
- addParameter(getField, "String", "ext");
- addParameter(getField, "String", "fieldName");
- setOperationBody(getField, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- //adding setField method
- ObjectModelOperation setField = addOperation(dtoClass, "setField", "void");
- addAnnotation(dtoClass, setField, "Override");
- addParameter(setField, "String", "ext");
- addParameter(setField, "String", "fieldName");
- addParameter(setField, "Object", "value");
- setOperationBody(setField, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
-
- }
-
- protected void addModelOperations(ObjectModelClass businessEntity, ObjectModelClass dtoClass){
- Collection<ObjectModelOperation> operations = businessEntity.getOperations();
-
- for (ObjectModelOperation operation:operations){
- ObjectModelOperation dtoOperation = addOperation(dtoClass,
- operation.getName(), operation.getReturnType());
-
- Collection<ObjectModelParameter> parameters = operation.getParameters();
- for (ObjectModelParameter parameter:parameters){
- addParameter(dtoOperation, parameter.getType(), parameter.getName());
- }
- addAnnotation(dtoClass, dtoOperation, "Override");
- setOperationBody(dtoOperation, ""
-/*{
- throw new UnsupportedOperationException("Not supported yet.");
-}*/);
- }
- }
-
-}
Copied: trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java (from rev 506, trunk/wikitty-dto/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java)
===================================================================
--- trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java (rev 0)
+++ trunk/wikitty-generators/src/main/java/org/nuiton/wikitty/generator/WikittyDTOGenerator.java 2010-11-24 14:22:43 UTC (rev 509)
@@ -0,0 +1,564 @@
+/*
+ * #%L
+ * Wikitty :: dto
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.wikitty.generator;
+
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.Transformer;
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelModifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+import org.nuiton.eugene.models.object.ObjectModelParameter;
+
+
+/*{generator option: writeString = }*/
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+/**
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.wikitty.generator.WikittyDTOGenerator"
+ */
+public class WikittyDTOGenerator extends ObjectModelTransformerToJava {
+
+ private static final Log log = LogFactory.getLog(WikittyDTOGenerator.class);
+
+ /**
+ * map busines entity from source model to generated abstract class
+ */
+ protected Map<ObjectModelClass, ObjectModelClass> processedClasses =
+ new HashMap<ObjectModelClass, ObjectModelClass>();
+
+ /**
+ * pattern to parse toString tagValue
+ * for the string "abc{foo|bar}defrzeg{uvw|xyz}oeira"
+ * will match {foo|bar} and {uvw|xyz} with groups for foo, bar, uvw and xyz
+ */
+ protected Pattern toStringTagValuePattern = Pattern.compile("\\{(([^|}])*)(?:\\|([^}]*))?\\}");
+
+ /**
+ * map "Client.name" to "getName()" or any getter to read this attribute
+ * those getter names are stored while generating in order to be found
+ * later when generating toString()
+ */
+ protected Map<String, String> attributeToGetterName = new HashMap<String, String>();
+
+ @Override
+ protected Transformer<ObjectModel, ObjectModel> initPreviousTransformer() {
+ return new WikittyPurifierTransformer();
+ }
+
+ protected List<ObjectModelClass> entitiesWithInheritedOperations =
+ new ArrayList<ObjectModelClass>();
+
+ @Override
+ public void transformFromModel(ObjectModel model) {
+
+ // contains boths businessEntities and metaExtensions
+ // elements may have one of the two sterotypes or both
+ // but elements with none of them aren't in this list
+ List<ObjectModelClass> modelBoth = new ArrayList<ObjectModelClass>();
+
+ // fill modelBusinessEntities with entities found in model
+ for (ObjectModelClass clazz : model.getClasses()) {
+ if (WikittyTransformerUtil.isBusinessEntity(clazz) ||
+ WikittyTransformerUtil.isMetaExtension(clazz)) {
+ modelBoth.add(clazz);
+ }
+ }
+
+ for (ObjectModelClass clazz : modelBoth) {
+ ObjectModelClass abstractClass = createClass(
+ businessEntityToDTOName(clazz),
+ clazz.getPackageName());
+ processedClasses.put(clazz, abstractClass);
+ addInterface(abstractClass, clazz.getQualifiedName());
+ }
+
+ for (ObjectModelClass clazz : modelBoth) {
+ if (WikittyTransformerUtil.isMetaExtension(clazz)) {
+ addMetaExtensionOperations(clazz, processedClasses.get(clazz));
+ } else if (WikittyTransformerUtil.isBusinessEntity(clazz)) {
+ addOperations(clazz, processedClasses.get(clazz));
+ }
+ }
+
+ // at this time, all operations in generated abstracts are just the operations
+ // like get/set etc. we will copy all operations of a given class to all children
+ // that's why constructors and others operations are not yet added
+ for (ObjectModelClass clazz : modelBoth) {
+ if (WikittyTransformerUtil.isBusinessEntity(clazz)) {
+ addInheritedOperations(clazz, processedClasses.get(clazz));
+ }
+ }
+
+ for (ObjectModelClass clazz : modelBoth) {
+ ObjectModelClass abstractClassForThisEntity = processedClasses.get(clazz);
+ addConstructors(abstractClassForThisEntity);
+ addToString(clazz, abstractClassForThisEntity);
+ addBusinessEntityMethods(abstractClassForThisEntity);
+ addModelOperations(clazz, abstractClassForThisEntity);
+ }
+
+ processedClasses.clear();
+ }
+
+ protected void addSerialVersionUID(ObjectModelClass clazz) {
+ // adding a generated serialVersionUID
+ Random random = new Random();
+ Long serialVersionUIDs = random.nextLong();
+ addConstant(clazz,
+ "serialVersionUID",
+ "long",
+ serialVersionUIDs.toString() + "L",
+ ObjectModelModifier.PRIVATE);
+ }
+
+ protected void addConstructors(ObjectModelClass clazz) {
+
+ ObjectModelOperation constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
+ setOperationBody(constructor, ""
+/*{
+}*/);
+
+ constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
+ addParameter(constructor, WikittyTransformerUtil.WIKITTY_CLASS_FQN, "wikitty");
+ setOperationBody(constructor, ""
+/*{
+ wikittyId=wikitty.getId();
+}*/);
+
+ constructor = addConstructor(clazz, ObjectModelModifier.PUBLIC);
+ addParameter(constructor, "String", "wikittyId");
+ setOperationBody(constructor, ""
+/*{
+ this.wikittyId=wikittyId;
+}*/);
+
+ }
+
+ protected void addOperations(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
+ // generating operations with bodies to realize contract
+ for (ObjectModelAttribute attribute : businessEntity.getAttributes()) {
+ if (attribute.isNavigable()) {
+ // needed below, in templates
+ String attributeType = WikittyTransformerUtil.generateResultType(attribute, false);
+ String attributeName = attribute.getName();
+
+ //add necessary import
+ addImport(abstractClass, attribute.getType());
+
+ //If alternative name, use it
+ if (attribute.hasTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME)) {
+ attributeName = attribute.getTagValue(WikittyTransformerUtil.TAG_ALTERNATIVE_NAME);
+ }
+
+ String getterName;
+
+ if (WikittyTransformerUtil.isAttributeCollection(attribute)) {
+ // attribute is a collection, we will generate operations
+ // get, add, remove and clear
+ String collectionType = WikittyTransformerUtil.getCollectionTypeName(attribute);
+ if (collectionType.equals("Set")){
+ addImport(abstractClass, Set.class);
+ }
+ if (collectionType.equals("List")){
+ addImport(abstractClass, List.class);
+
+ }
+
+ String attributeTypeInSet = WikittyTransformerUtil.generateResultType(attribute, true);
+
+ //adding the attribute
+ ObjectModelAttribute modelAttribute = addAttribute(abstractClass, attributeName, attributeTypeInSet);
+ String annotation = "WikittyField(fqn=\""+ businessEntity.getName() + "." + attributeName +"\")";
+ addAnnotation(abstractClass, modelAttribute, annotation);
+ addImport(abstractClass, "org.nuiton.wikitty.entities.WikittyField");
+
+
+ // adding the getter
+ getterName = "get" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation getter = addOperation(abstractClass, getterName, attributeTypeInSet);
+ addAnnotation(abstractClass, getter, "Override");
+ String getterBody = ""
+/*{
+ return <%=attributeName%>;
+}*/;
+ setOperationBody(getter, getterBody);
+
+ // adding the setter
+ getterName = "set" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation setter = addOperation(abstractClass, getterName, "void");
+ addAnnotation(abstractClass, setter, "Override");
+ addParameter(setter, attributeTypeInSet, attributeName);
+ String setterBody = ""
+/*{
+ this.<%=attributeName%>=<%=attributeName%>;
+}*/;
+ setOperationBody(setter, setterBody);
+
+ //adding the add method
+ String addName = "add" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation adder = addOperation(abstractClass, addName, "void");
+ addAnnotation(abstractClass, adder, "Override");
+ addParameter(adder, attributeType, "element");
+ String adderBody = ""
+/*{
+ <%=attributeName%>.add(element);
+}*/;
+ setOperationBody(adder, adderBody);
+
+ //adding the remove method
+ String removeName = "remove" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation remover = addOperation(abstractClass, removeName, "void");
+ addAnnotation(abstractClass, remover, "Override");
+ addParameter(remover, attributeType, "element");
+ String removerBody = ""
+/*{
+ <%=attributeName%>.remove(element);
+}*/;
+ setOperationBody(remover, removerBody);
+
+ //adding the clear method
+ String clearName = "clear" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation clear = addOperation(abstractClass, clearName, "void");
+ addAnnotation(abstractClass, clear, "Override");
+ String clearBody = ""
+/*{
+ <%=attributeName%>.clear();
+}*/;
+ setOperationBody(clear, clearBody);
+
+ } else {
+ //No multiplicity
+
+ //add necessary import
+ addImport(abstractClass, attribute.getType());
+
+ //adding the attribute
+ ObjectModelAttribute modelAttribute = addAttribute(abstractClass, attributeName, attributeType);
+ String annotation = "WikittyField(fqn=\"" + businessEntity.getName() + "."+attributeName + "\")";
+ addAnnotation(abstractClass, modelAttribute, annotation);
+ addImport(abstractClass, "org.nuiton.wikitty.entities.WikittyField");
+
+ // adding getter
+ getterName = "get" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation getter = addOperation(abstractClass, getterName, attributeType);
+ addAnnotation(abstractClass, getter, "Override");
+ setOperationBody(getter, ""
+/*{
+ return <%=attributeName%>;
+}*/);
+
+ //adding setter
+ String setterName = "set" + StringUtils.capitalize(attributeName);
+ ObjectModelOperation setter = addOperation(abstractClass, setterName, "void");
+ addAnnotation(abstractClass, setter, "Override");
+ addParameter(setter, attributeType, attributeName);
+ setOperationBody(setter, ""
+/*{
+ this.<%=attributeName%>=<%=attributeName%>;
+}*/);
+ }
+
+ // save the getter name for this attribute
+ attributeToGetterName.put(businessEntity.getName() + "." + attributeName, getterName);
+ }
+ }
+ }
+
+ /**
+ * Add inherited operations to the abstract generated from an entity.
+ * Method browse superClasses to copy methods and their bodies. The method
+ * deal with imports, cause bodies call the Helper of the classe where
+ * the attribute was declared.
+ * <p/>
+ * If A inherit from B and B inherit from and A, B, C not in the same package
+ * we B need to import CHelper and A need to import BHelper. But, since A
+ * has C attributes too, it needs CHelper too. So when we will process B,
+ * we will save needed imports, A will get them thus import CHelper.
+ */
+ protected void addInheritedOperations(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
+
+ if (!entitiesWithInheritedOperations.contains(businessEntity)) {
+
+ // add attributes and methods inherited from super classes
+ for (ObjectModelClass superClass : businessEntity.getSuperclasses()) {
+
+ // process super classes first, so we will get inherited operations from superclass
+ addInheritedOperations(superClass, processedClasses.get(superClass));
+
+ if (WikittyTransformerUtil.isBusinessEntity(superClass)) {
+
+ //Add operations for the super class
+ addOperations(superClass, abstractClass);
+ }
+ }
+
+ entitiesWithInheritedOperations.add(businessEntity);
+ }
+ }
+
+ /**
+ * add a toString method
+ * if a toString tagValue is attached to businessEntity, it will be used
+ * to generate a toString as this :
+ * <p/>
+ * given "hello {Person.name|unknow}"
+ * <p/>
+ * will try to replace first {...} by name field value for extension Person.
+ * if this information is not available, will do unknow.
+ */
+ protected void addToString(ObjectModelClass businessEntity, ObjectModelClass abstractClass) {
+
+ String toStringOperationBody;
+
+ if (businessEntity.hasTagValue(WikittyTransformerUtil.TAG_TO_STRING)) {
+ String toStringPattern = businessEntity.getTagValue(WikittyTransformerUtil.TAG_TO_STRING);
+
+ // toStringPattern is something like
+ // "hello {Person.name|unknow} employe of {Company.name|unknow}"
+ //
+
+ Matcher matcher = toStringTagValuePattern.matcher(toStringPattern);
+
+ while (matcher.find()) {
+ String wholeMatch = matcher.group(0); // "{foo|bar}"
+ String variableName = matcher.group(1); // "foo"
+ String defaultValue = matcher.group(3); // "bar", may be null
+
+ if (defaultValue == null) {
+ defaultValue = "";
+ }
+
+ if (attributeToGetterName.containsKey(variableName)) {
+ String getterName = attributeToGetterName.get(variableName);
+ toStringPattern = toStringPattern.replace(wholeMatch, ""
+/*{"
+ + <%=getterName%>().toString() +
+ "}*/);
+ } else {
+ log.warn("no field " + variableName + " in " + businessEntity.getQualifiedName());
+ toStringPattern = toStringPattern.replace(wholeMatch, defaultValue);
+ }
+ }
+
+ toStringOperationBody = ""
+/*{
+ return "<%=toStringPattern%>";
+}*/;
+ } else {
+ // no toString tagValue provided, generating a default toString
+ toStringOperationBody = ""
+/*{
+ return "dto:"+getWikittyId()+":"+getWikittyVersion();
+}*/;
+ }
+
+ ObjectModelOperation toString = addOperation(abstractClass, "toString", "String");
+ addAnnotation(abstractClass, toString, "Override");
+ setOperationBody(toString, toStringOperationBody);
+ }
+
+ protected void addMetaExtensionOperations(ObjectModelClass metaExtension,
+ ObjectModelClass abstractClassForThisMetaExtension) {
+
+ //add standard attribute operations for meta-extension
+ addOperations(metaExtension, abstractClassForThisMetaExtension);
+
+ }
+
+ /**
+ * Method to get the generated class name
+ */
+ protected String businessEntityToDTOName(ObjectModelClass clazz) {
+ return clazz.getName() + "DTO";
+ }
+
+ protected void addBusinessEntityMethods(ObjectModelClass dtoClass) {
+
+ //adding wikittyId attribute
+ addAttribute(dtoClass, "wikittyId", "String");
+
+ //adding getWikittyId method
+ ObjectModelOperation getter = addOperation(dtoClass, "getWikittyId", "String");
+ addAnnotation(dtoClass, getter, "Override");
+ setOperationBody(getter, ""
+/*{
+ return wikittyId;
+}*/);
+
+ //adding setWikittyId method
+ ObjectModelOperation setter = addOperation(dtoClass, "setWikittyId", "void");
+ addParameter(setter, "String", "wikittyId");
+ setOperationBody(setter, ""
+/*{
+ this.wikittyId=wikittyId;
+}*/);
+
+ //adding wikittyVersion attribute
+ addAttribute(dtoClass, "wikittyVersion", "String");
+
+
+
+ //adding getWikittyVersion method
+ ObjectModelOperation getWikittyVersion = addOperation(dtoClass,
+ "getWikittyVersion", "String");
+ addAnnotation(dtoClass, getWikittyVersion, "Override");
+ setOperationBody(getWikittyVersion, ""
+/*{
+ return wikittyVersion;
+}*/);
+
+ //adding setWikittyVersion method
+ ObjectModelOperation setWikittyVersion = addOperation(dtoClass,
+ "setWikittyVersion", "void");
+ addParameter(setWikittyVersion, "String", "wikittyVersion");
+ setOperationBody(setWikittyVersion, ""
+/*{
+ this.wikittyVersion=wikittyVersion;
+}*/);
+
+ //adding necessary imports
+ addImport(dtoClass, PropertyChangeListener.class);
+ addImport(dtoClass, Collection.class);
+
+ // adding addPropertyChangeListener
+ ObjectModelOperation addPropertyChangeListener = addOperation(dtoClass,
+ "addPropertyChangeListener", "void");
+ addAnnotation(dtoClass, addPropertyChangeListener, "Override");
+ addParameter(addPropertyChangeListener, "PropertyChangeListener", "listener");
+ setOperationBody(addPropertyChangeListener, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ // adding removePropertyChangeListener
+ ObjectModelOperation removePropertyChangeListener = addOperation(dtoClass,
+ "removePropertyChangeListener", "void");
+ addAnnotation(dtoClass, removePropertyChangeListener, "Override");
+ addParameter(removePropertyChangeListener, "PropertyChangeListener", "listener");
+ setOperationBody(removePropertyChangeListener, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ // adding addPropertyChangeListener 2 parameters
+ ObjectModelOperation addPropertyChangeListener2 = addOperation(dtoClass,
+ "addPropertyChangeListener", "void");
+ addAnnotation(dtoClass, addPropertyChangeListener2, "Override");
+ addParameter(addPropertyChangeListener2, "String", "property");
+ addParameter(addPropertyChangeListener2, "PropertyChangeListener", "listener");
+ setOperationBody(addPropertyChangeListener2, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ // adding removePropertyChangeListener 2 parameters
+ ObjectModelOperation removePropertyChangeListener2 = addOperation(dtoClass,
+ "removePropertyChangeListener", "void");
+ addAnnotation(dtoClass, removePropertyChangeListener2, "Override");
+ addParameter(removePropertyChangeListener2, "String", "property");
+ addParameter(removePropertyChangeListener2, "PropertyChangeListener", "listener");
+ setOperationBody(removePropertyChangeListener2, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ //adding getExtensionFields method
+ ObjectModelOperation getExtensionFields = addOperation(dtoClass,
+ "getExtensionFields", "Collection<String>");
+ addAnnotation(dtoClass, getExtensionFields, "Override");
+ addParameter(getExtensionFields, "String", "ext");
+ setOperationBody(getExtensionFields, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ //adding getExtensionNames method
+ ObjectModelOperation getExtensionNames = addOperation(dtoClass,
+ "getExtensionNames", "Collection<String>");
+ addAnnotation(dtoClass, getExtensionNames, "Override");
+ setOperationBody(getExtensionNames, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ //adding getField method
+ ObjectModelOperation getField = addOperation(dtoClass, "getField", "Object");
+ addAnnotation(dtoClass, getField, "Override");
+ addParameter(getField, "String", "ext");
+ addParameter(getField, "String", "fieldName");
+ setOperationBody(getField, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ //adding setField method
+ ObjectModelOperation setField = addOperation(dtoClass, "setField", "void");
+ addAnnotation(dtoClass, setField, "Override");
+ addParameter(setField, "String", "ext");
+ addParameter(setField, "String", "fieldName");
+ addParameter(setField, "Object", "value");
+ setOperationBody(setField, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+
+ }
+
+ protected void addModelOperations(ObjectModelClass businessEntity, ObjectModelClass dtoClass){
+ Collection<ObjectModelOperation> operations = businessEntity.getOperations();
+
+ for (ObjectModelOperation operation:operations){
+ ObjectModelOperation dtoOperation = addOperation(dtoClass,
+ operation.getName(), operation.getReturnType());
+
+ Collection<ObjectModelParameter> parameters = operation.getParameters();
+ for (ObjectModelParameter parameter:parameters){
+ addParameter(dtoOperation, parameter.getType(), parameter.getName());
+ }
+ addAnnotation(dtoClass, dtoOperation, "Override");
+ setOperationBody(dtoOperation, ""
+/*{
+ throw new UnsupportedOperationException("Not supported yet.");
+}*/);
+ }
+ }
+
+}
1
0
24 Nov '10
Author: tchemit
Date: 2010-11-24 14:39:47 +0100 (Wed, 24 Nov 2010)
New Revision: 508
Url: http://nuiton.org/repositories/revision/wikitty/508
Log:
fix unused imports
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 13:39:04 UTC (rev 507)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 13:39:47 UTC (rev 508)
@@ -27,10 +27,6 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;
import org.nuiton.wikitty.entities.BusinessEntity;
import org.nuiton.wikitty.entities.WikittyExtension;
1
0
24 Nov '10
Author: tchemit
Date: 2010-11-24 14:39:04 +0100 (Wed, 24 Nov 2010)
New Revision: 507
Url: http://nuiton.org/repositories/revision/wikitty/507
Log:
add a new pattern for people whose computer locale is english
Modified:
trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java
===================================================================
--- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 12:42:33 UTC (rev 506)
+++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-24 13:39:04 UTC (rev 507)
@@ -87,7 +87,8 @@
public static final String[] DATE_FORMAT_ALLOWED = {
DATE_FORMAT,
new SimpleDateFormat().toPattern(),
- "dd/MM/yy"
+ "dd/MM/yy",
+ "dd/MM/yy hh:mm",
};
/** to use log facility, just put in your code: log.info(\"...\"); */
1
0