Topia-commits
Threads by month
- ----- 2026 -----
- August
- July
- 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
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
August 2012
- 3 participants
- 47 discussions
r2629 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata
by tchemit@users.nuiton.org Aug. 18, 2012
by tchemit@users.nuiton.org Aug. 18, 2012
Aug. 18, 2012
Author: tchemit
Date: 2012-08-18 11:57:33 +0200 (Sat, 18 Aug 2012)
New Revision: 2629
Url: http://nuiton.org/repositories/revision/topia/2629
Log:
refs #2260: Add a metadata package in persistence (improve api)
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java 2012-08-17 13:58:26 UTC (rev 2628)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java 2012-08-18 09:57:33 UTC (rev 2629)
@@ -47,10 +47,13 @@
/** All types non editables. */
protected final Set<T> nonEditableTypes;
- public static <T extends TopiaEntityEnum> DbMeta<T> newDbMeta(T[] universe,
- T[] nonEditables,
- TopiaEntityEnumProvider<T> typeProvider) {
- return new DbMeta<T>(universe, nonEditables, typeProvider);
+ protected final TopiaEntityEnumProvider<T> entityEnumProvider;
+
+ public static <T extends TopiaEntityEnum> DbMeta<T> newDbMeta(
+ TopiaEntityEnumProvider<T> typeProvider,
+ T[] universe,
+ T... nonEditables) {
+ return new DbMeta<T>(typeProvider, universe, nonEditables);
}
public List<String> getTableNames() {
@@ -82,11 +85,14 @@
return getTables().iterator();
}
- protected DbMeta(T[] entityTypes, T[] nonEditableTypes, TopiaEntityEnumProvider<T> typeProvider) {
+ protected DbMeta(TopiaEntityEnumProvider<T> entityEnumProvider,
+ T[] entityTypes,
+ T... nonEditableTypes) {
+ this.entityEnumProvider = entityEnumProvider;
this.nonEditableTypes = Sets.newHashSet(nonEditableTypes);
tables = Lists.newArrayList();
for (T entityEnum : entityTypes) {
- TableMeta<T> tableMeta = TableMeta.newMeta(entityEnum, typeProvider);
+ TableMeta<T> tableMeta = TableMeta.newMeta(entityEnum, entityEnumProvider);
tables.add(tableMeta);
}
}
@@ -94,4 +100,8 @@
public boolean isEditable(TableMeta<T> meta) {
return !nonEditableTypes.contains(meta.getSource());
}
+
+ public TopiaEntityEnumProvider<T> getEntityEnumProvider() {
+ return entityEnumProvider;
+ }
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java 2012-08-17 13:58:26 UTC (rev 2628)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java 2012-08-18 09:57:33 UTC (rev 2629)
@@ -31,7 +31,7 @@
import java.util.List;
/**
- * USeful methods around metadatas.
+ * Useful methods around metadatas.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.6.12
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java 2012-08-17 13:58:26 UTC (rev 2628)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java 2012-08-18 09:57:33 UTC (rev 2629)
@@ -57,8 +57,8 @@
private static final long serialVersionUID = 1L;
- public static <T extends TopiaEntityEnum> TableMeta newMeta(T entityEnum,
- TopiaEntityEnumProvider<T> typeProvider) {
+ public static <T extends TopiaEntityEnum> TableMeta<T> newMeta(T entityEnum,
+ TopiaEntityEnumProvider<T> typeProvider) {
return new TableMeta<T>(entityEnum, typeProvider);
}
1
0
r2628 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv
by tchemit@users.nuiton.org Aug. 17, 2012
by tchemit@users.nuiton.org Aug. 17, 2012
Aug. 17, 2012
Author: tchemit
Date: 2012-08-17 15:58:26 +0200 (Fri, 17 Aug 2012)
New Revision: 2628
Url: http://nuiton.org/repositories/revision/topia/2628
Log:
refs #2266: Add some api about import / export in csv format (can import/export enum)
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java 2012-08-17 09:17:17 UTC (rev 2627)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java 2012-08-17 13:58:26 UTC (rev 2628)
@@ -29,6 +29,7 @@
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.TopiaId;
import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.csv.ValueParserFormatter;
import org.nuiton.util.csv.ext.AbstractImportExportModel;
import org.nuiton.util.decorator.Decorator;
@@ -47,6 +48,8 @@
protected final TableMeta<T> tableMeta;
+ protected boolean useOrdinalForEnum;
+
public static <T extends TopiaEntityEnum, E extends TopiaEntity> EntityCsvModel<T, E> newModel(
char separator,
TableMeta<T> tableMeta) {
@@ -65,16 +68,19 @@
return (E) tableMeta.newEntity();
}
+ public void setUseOrdinalForEnum(boolean useOrdinalForEnum) {
+ this.useOrdinalForEnum = useOrdinalForEnum;
+ }
+
public void addForeignKeyForExport(String propertyName,
Class<TopiaEntity> entityType) {
Map<String, TopiaEntity> universe = Collections.emptyMap();
- newColumnForExport(
- propertyName,
- TopiaCsvCommons.newForeignKeyValue(entityType,
- propertyName,
- universe)
+ newColumnForExport(propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
);
}
@@ -95,12 +101,11 @@
Map<String, E> universe = Maps.uniqueIndex(entities, transform);
- newMandatoryColumn(
- headerName,
- propertyName,
- TopiaCsvCommons.newForeignKeyValue(entityType,
- propertyName,
- universe)
+ newMandatoryColumn(headerName,
+ propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
);
}
@@ -128,11 +133,10 @@
Map<String, E> universe = Maps.uniqueIndex(entities,
TopiaId.GET_TOPIA_ID);
- newMandatoryColumn(
- propertyName,
- TopiaCsvCommons.newForeignKeyValue(entityType,
- propertyName,
- universe)
+ newMandatoryColumn(propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
);
}
@@ -148,75 +152,82 @@
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.DAY_TIME_SECOND_WITH_TIMESTAMP
- );
+ TopiaCsvCommons.DAY_TIME_SECOND_WITH_TIMESTAMP);
} else if (double.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.DOUBLE_PRIMITIVE
- );
+ TopiaCsvCommons.DOUBLE_PRIMITIVE);
} else if (Double.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.DOUBLE
- );
+ TopiaCsvCommons.DOUBLE);
} else if (long.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.PRIMITIVE_LONG
- );
+ TopiaCsvCommons.PRIMITIVE_LONG);
} else if (Long.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.LONG
- );
+ TopiaCsvCommons.LONG);
} else if (float.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.PRIMITIVE_FLOAT
- );
+ TopiaCsvCommons.PRIMITIVE_FLOAT);
} else if (Float.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.FLOAT
- );
+ TopiaCsvCommons.FLOAT);
} else if (int.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.PRIMITIVE_INTEGER
- );
+ TopiaCsvCommons.PRIMITIVE_INTEGER);
} else if (Integer.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.INTEGER
- );
+ TopiaCsvCommons.INTEGER);
} else if (boolean.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.PRIMITIVE_BOOLEAN
- );
+ TopiaCsvCommons.PRIMITIVE_BOOLEAN);
} else if (Boolean.class.equals(type)) {
newColumnForImportExport(
headerName,
propertyName,
- TopiaCsvCommons.BOOLEAN
- );
+ TopiaCsvCommons.BOOLEAN);
+ } else if (String.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName);
+ } else if (type.isEnum()) {
+
+ Class<Enum> enumType = (Class<Enum>) type;
+ ValueParserFormatter<Enum> valueParserFormatter;
+ if (useOrdinalForEnum) {
+ valueParserFormatter =
+ TopiaCsvCommons.newEnumByOrdinalParserFormatter(enumType);
+ } else {
+ valueParserFormatter =
+ TopiaCsvCommons.newEnumByNameParserFormatter(enumType);
+ }
+
+ newColumnForImportExport(headerName,
+ propertyName,
+ valueParserFormatter);
+
} else {
- // string
- newColumnForImportExport(
- headerName,
- propertyName
- );
+ throw new IllegalStateException(String.format(
+ "For header %s, property %s, no specific handler " +
+ "found for type %s", headerName, propertyName, type));
}
}
1
0
r2627 - in branches/topia-2.6.x/topia-persistence/src: main/java/org/nuiton/topia/persistence/csv main/java/org/nuiton/topia/persistence/csv/in main/java/org/nuiton/topia/persistence/csv/out main/java/org/nuiton/topia/persistence/metadata test/java/org/nuiton/topia/persistence
by tchemit@users.nuiton.org Aug. 17, 2012
by tchemit@users.nuiton.org Aug. 17, 2012
Aug. 17, 2012
Author: tchemit
Date: 2012-08-17 11:17:17 +0200 (Fri, 17 Aug 2012)
New Revision: 2627
Url: http://nuiton.org/repositories/revision/topia/2627
Log:
add missing headers + svn properties
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java
branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaContextFindTest.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* EchoBase :: Entities
*
* $Id$
- * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-entities/src/mai… $
+ * $HeadURL$
* %%
* Copyright (C) 2011 - 2012 Ifremer, Codelutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -1,4 +1,27 @@
package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -3,7 +3,7 @@
* #%L
* ToPIA :: Persistence
* $Id$
- * $HeadURL:$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaContextFindTest.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaContextFindTest.java 2012-08-17 08:47:17 UTC (rev 2626)
+++ branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaContextFindTest.java 2012-08-17 09:17:17 UTC (rev 2627)
@@ -1,8 +1,8 @@
/*
* #%L
* ToPIA :: Persistence :: Test Compatibility Kit
- * $Id: IsPersistentTest.java 2570 2012-05-31 10:46:40Z athimel $
- * $HeadURL: http://svn.nuiton.org/svn/topia/trunk/topia-persistence-tck/src/test/java/o… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2004 - 2012 CodeLutin
* %%
Property changes on: branches/topia-2.6.x/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaContextFindTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r2626 - in trunk: src/site topia-persistence/src/site topia-service-migration/src/site topia-service-replication/src/site topia-service-security/src/site
by tchemit@users.nuiton.org Aug. 17, 2012
by tchemit@users.nuiton.org Aug. 17, 2012
Aug. 17, 2012
Author: tchemit
Date: 2012-08-17 10:47:17 +0200 (Fri, 17 Aug 2012)
New Revision: 2626
Url: http://nuiton.org/repositories/revision/topia/2626
Log:
fix site scm metadata + site logos
Modified:
trunk/src/site/site_fr.xml
trunk/topia-persistence/src/site/site_fr.xml
trunk/topia-service-migration/src/site/site_fr.xml
trunk/topia-service-replication/src/site/site_fr.xml
trunk/topia-service-security/src/site/site_fr.xml
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2012-08-17 08:46:50 UTC (rev 2625)
+++ trunk/src/site/site_fr.xml 2012-08-17 08:47:17 UTC (rev 2626)
@@ -57,17 +57,17 @@
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
- img="${project.url}/images/logos/maven-feather.png"/>
+ img="http://maven-site.chorem.org/public/images/logos/maven-feather.png"/>
<logo href="http://maven-site.nuiton.org/jrst/" name="JRst"
- img="${project.url}/images/jrst-logo.png"/>
+ img="http://maven-site.chorem.org/public/images/logos/jrst-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html"
name="ReStructuredText"
- img="${project.url}/images/restructuredtext-logo.png"/>
+ img="http://maven-site.chorem.org/public/images/logos/restructuredtext-logo.png"/>
<logo href="http://argouml.tigris.org/" name="ArgoUML"
- img="images/argouml-logo.png"/>
+ img="http://maven-site.chorem.org/public/images/logos/argouml-logo.png"/>
</poweredBy>
<body>
@@ -101,7 +101,7 @@
projectversion='${project.version}'
platform='${project.platform}'
projectid='${project.projectId}'
- scm='${project.scm.connection}'
+ scm='${project.scm.developerConnection}'
scmwebeditorenabled='${project.scmwebeditorEnabled}'
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
Modified: trunk/topia-persistence/src/site/site_fr.xml
===================================================================
--- trunk/topia-persistence/src/site/site_fr.xml 2012-08-17 08:46:50 UTC (rev 2625)
+++ trunk/topia-persistence/src/site/site_fr.xml 2012-08-17 08:47:17 UTC (rev 2626)
@@ -93,7 +93,7 @@
projectversion='${project.version}'
platform='${project.platform}'
projectid='${project.projectId}'
- scm='${project.scm.connection}'
+ scm='${project.scm.developerConnection}'
scmwebeditorenabled='${project.scmwebeditorEnabled}'
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
Modified: trunk/topia-service-migration/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-migration/src/site/site_fr.xml 2012-08-17 08:46:50 UTC (rev 2625)
+++ trunk/topia-service-migration/src/site/site_fr.xml 2012-08-17 08:47:17 UTC (rev 2626)
@@ -65,7 +65,7 @@
projectversion='${project.version}'
platform='${project.platform}'
projectid='${project.projectId}'
- scm='${project.scm.connection}'
+ scm='${project.scm.developerConnection}'
scmwebeditorenabled='${project.scmwebeditorEnabled}'
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
Modified: trunk/topia-service-replication/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-replication/src/site/site_fr.xml 2012-08-17 08:46:50 UTC (rev 2625)
+++ trunk/topia-service-replication/src/site/site_fr.xml 2012-08-17 08:47:17 UTC (rev 2626)
@@ -62,7 +62,7 @@
projectversion='${project.version}'
platform='${project.platform}'
projectid='${project.projectId}'
- scm='${project.scm.connection}'
+ scm='${project.scm.developerConnection}'
scmwebeditorenabled='${project.scmwebeditorEnabled}'
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
Modified: trunk/topia-service-security/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-security/src/site/site_fr.xml 2012-08-17 08:46:50 UTC (rev 2625)
+++ trunk/topia-service-security/src/site/site_fr.xml 2012-08-17 08:47:17 UTC (rev 2626)
@@ -69,7 +69,7 @@
projectversion='${project.version}'
platform='${project.platform}'
projectid='${project.projectId}'
- scm='${project.scm.connection}'
+ scm='${project.scm.developerConnection}'
scmwebeditorenabled='${project.scmwebeditorEnabled}'
scmwebeditorurl='${project.scmwebeditorUrl}'
siteSourcesType='${project.siteSourcesType}'
1
0
r2625 - in trunk: . topia-persistence-tck topia-service-security
by tchemit@users.nuiton.org Aug. 17, 2012
by tchemit@users.nuiton.org Aug. 17, 2012
Aug. 17, 2012
Author: tchemit
Date: 2012-08-17 10:46:50 +0200 (Fri, 17 Aug 2012)
New Revision: 2625
Url: http://nuiton.org/repositories/revision/topia/2625
Log:
refs #2269: Updates to eugene 2.6
Modified:
trunk/pom.xml
trunk/topia-persistence-tck/pom.xml
trunk/topia-service-security/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-17 08:46:01 UTC (rev 2624)
+++ trunk/pom.xml 2012-08-17 08:46:50 UTC (rev 2625)
@@ -68,7 +68,7 @@
<projectId>topia</projectId>
<!-- libs version -->
- <eugeneVersion>2.4.3-SNAPSHOT</eugeneVersion>
+ <eugeneVersion>2.6-SNAPSHOT</eugeneVersion>
<nuitonUtilsVersion>2.4.8</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
Modified: trunk/topia-persistence-tck/pom.xml
===================================================================
--- trunk/topia-persistence-tck/pom.xml 2012-08-17 08:46:01 UTC (rev 2624)
+++ trunk/topia-persistence-tck/pom.xml 2012-08-17 08:46:50 UTC (rev 2625)
@@ -100,7 +100,7 @@
<defaultPackage>org.nuiton.topia.tck</defaultPackage>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
<execution>
@@ -122,7 +122,7 @@
<defaultPackage>org.nuiton.topia.tck.it</defaultPackage>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
<execution>
@@ -144,7 +144,7 @@
<defaultPackage>org.nuiton.topia.tck.legacy</defaultPackage>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
<execution>
@@ -161,7 +161,7 @@
<defaultPackage>org.nuiton.topia.tck.mapping</defaultPackage>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
</executions>
Modified: trunk/topia-service-security/pom.xml
===================================================================
--- trunk/topia-service-security/pom.xml 2012-08-17 08:46:01 UTC (rev 2624)
+++ trunk/topia-service-security/pom.xml 2012-08-17 08:46:50 UTC (rev 2625)
@@ -141,7 +141,7 @@
<overwrite>true</overwrite>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
</executions>
1
0
Author: tchemit
Date: 2012-08-17 10:46:01 +0200 (Fri, 17 Aug 2012)
New Revision: 2624
Url: http://nuiton.org/repositories/revision/topia/2624
Log:
remove site resources
Removed:
trunk/src/site/resources/images/
1
0
Author: tchemit
Date: 2012-08-17 10:22:12 +0200 (Fri, 17 Aug 2012)
New Revision: 2623
Url: http://nuiton.org/repositories/revision/topia/2623
Log:
fixes #2256: updates to eugene 2.5
Modified:
branches/topia-2.6.x/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-08-16 22:43:00 UTC (rev 2622)
+++ branches/topia-2.6.x/pom.xml 2012-08-17 08:22:12 UTC (rev 2623)
@@ -59,7 +59,7 @@
<projectId>topia</projectId>
<!-- libs version -->
- <eugeneVersion>2.5-SNAPSHOT</eugeneVersion>
+ <eugeneVersion>2.5</eugeneVersion>
<nuitonUtilsVersion>2.6-SNAPSHOT</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
1
0
r2622 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-17 00:43:00 +0200 (Fri, 17 Aug 2012)
New Revision: 2622
Url: http://nuiton.org/repositories/revision/topia/2622
Log:
refs #2266: Add some api about import / export in csv format (add useful export methods)
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java 2012-08-16 16:19:17 UTC (rev 2621)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java 2012-08-16 22:43:00 UTC (rev 2622)
@@ -37,7 +37,7 @@
*/
public interface ExportModelFactory<T extends TopiaEntityEnum> {
- <E extends TopiaEntity> ExportModel<E> buildForExport(TableMeta<T> meta, boolean asSeen);
+ <E extends TopiaEntity> ExportModel<E> buildForExport(TableMeta<T> meta);
<E extends TopiaEntity> ExportModel<E> buildForExport(AssociationMeta<T> associationMeta);
}
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java 2012-08-16 22:43:00 UTC (rev 2622)
@@ -0,0 +1,21 @@
+package org.nuiton.topia.persistence.csv.out;
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+
+import java.util.List;
+
+/**
+ * Prepare data to export.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public interface PrepareDataForExport<T extends TopiaEntityEnum> {
+
+ <E extends TopiaEntity> List<E> prepareData(TableMeta<T> tableMeta);
+
+ <E extends TopiaEntity> List<E> prepareData(AssociationMeta<T> associationMeta);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/PrepareDataForExport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-08-16 16:19:17 UTC (rev 2621)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-08-16 22:43:00 UTC (rev 2622)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -31,11 +32,14 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaRuntimeException;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.MetaFilenameAware;
import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.TimeLog;
+import org.nuiton.util.csv.Export;
import org.nuiton.util.csv.ExportModel;
import org.nuiton.util.csv.ext.RepeatableExport;
@@ -58,10 +62,94 @@
/** Logger. */
private static final Log log = LogFactory.getLog(TopiaCsvExports.class);
+
+ public static final TimeLog TIME_LOG = new TimeLog(TopiaCsvExports.class);
+
+
protected TopiaCsvExports() {
// no instance of this helper
}
+ public static <T extends TopiaEntityEnum> String exportData(TableMeta<T> tableMeta,
+ ExportModelFactory<T> modelFactory,
+ PrepareDataForExport<T> prepareDataForExport) {
+
+
+ long s1 = TimeLog.getTime();
+ Export<TopiaEntity> export = prepareExport(tableMeta, modelFactory, prepareDataForExport);
+ TIME_LOG.log(s1, "exportData::prepareExport");
+ long s2 = TimeLog.getTime();
+ String result;
+ try {
+ result = export.toString(Charsets.UTF_8);
+ } catch (Exception eee) {
+ throw new TopiaRuntimeException("Can not export datas", eee);
+ }
+ TIME_LOG.log(s2, "exportData::exportToString");
+ return result;
+ }
+
+ public static <T extends TopiaEntityEnum> void exportData(TableMeta<T> tableMeta,
+ ExportModelFactory<T> modelFactory,
+ PrepareDataForExport<T> prepareDataForExport,
+ File file) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Export table " + tableMeta + " to " + file);
+ }
+ long s1 = TimeLog.getTime();
+ Export<TopiaEntity> export = prepareExport(tableMeta, modelFactory, prepareDataForExport);
+ TIME_LOG.log(s1, "exportDatas::prepareExport");
+ long s2 = TimeLog.getTime();
+ try {
+ export.write(file, Charsets.UTF_8);
+ } catch (Exception eee) {
+ throw new TopiaRuntimeException("Can not export datas", eee);
+ }
+ TIME_LOG.log(s2, "exportData::exportToFile");
+ }
+
+ public static <T extends TopiaEntityEnum> void exportData(AssociationMeta<T> associationMeta,
+ ExportModelFactory<T> modelFactory,
+ PrepareDataForExport<T> prepareDataForExport,
+ File file) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Export association " + associationMeta + " to " + file);
+ }
+ long s1 = TimeLog.getTime();
+
+ Export<TopiaEntity> export = prepareExport(associationMeta, modelFactory, prepareDataForExport);
+ TIME_LOG.log(s1, "exportData::prepareExport");
+
+ long s2 = TimeLog.getTime();
+ try {
+ export.write(file, Charsets.UTF_8);
+ } catch (Exception eee) {
+ throw new TopiaRuntimeException("Can not export datas", eee);
+ }
+ TIME_LOG.log(s2, "exportData::exportToFile");
+ }
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> Export<E> prepareExport(TableMeta<T> tableMeta,
+ ExportModelFactory<T> modelFactory,
+ PrepareDataForExport<T> prepareDataForExport) {
+
+
+ List<E> datas = prepareDataForExport.prepareData(tableMeta);
+ ExportModel<E> model = modelFactory.buildForExport(tableMeta);
+ return Export.newExport(model, datas);
+ }
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> Export<E> prepareExport(AssociationMeta<T> associationMeta,
+ ExportModelFactory<T> modelFactory,
+ PrepareDataForExport<T> prepareDataForExport) {
+
+ List<E> datas = prepareDataForExport.prepareData(associationMeta);
+ ExportModel<E> model = modelFactory.buildForExport(associationMeta);
+ return Export.newExport(model, datas);
+ }
+
public static <T extends TopiaEntityEnum> Map<Class<?>, EntityExportContext> createReplicateEntityVisitorContexts(ExportModelFactory<T> modelFactory,
MetaFilenameAware<T>[] entityMetas,
Multimap<T, MetaFilenameAware<T>> associations,
@@ -80,7 +168,7 @@
Collection<MetaFilenameAware<T>> metaFilenameAwares = associations.get(source);
- ExportModel<TopiaEntity> model = modelFactory.buildForExport(meta, false);
+ ExportModel<TopiaEntity> model = modelFactory.buildForExport(meta);
EntityExportContext<T> exportContext = EntityExportContext.newExportContext(
model,
1
0
r2621 - in branches/topia-2.6.x/topia-persistence: . src/main/java/org/nuiton/topia/persistence src/main/java/org/nuiton/topia/persistence/csv src/main/java/org/nuiton/topia/persistence/csv/in src/main/java/org/nuiton/topia/persistence/csv/out
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-16 18:19:17 +0200 (Thu, 16 Aug 2012)
New Revision: 2621
Url: http://nuiton.org/repositories/revision/topia/2621
Log:
refs #2266: Add some api about import / export in csv format
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java
Modified:
branches/topia-2.6.x/topia-persistence/pom.xml
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-16 16:18:14 UTC (rev 2620)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-16 16:19:17 UTC (rev 2621)
@@ -24,7 +24,9 @@
#L%
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ 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>
@@ -49,6 +51,11 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
</dependency>
@@ -59,6 +66,11 @@
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
@@ -323,7 +335,9 @@
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
- <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath>
+ <localRepositoryPath>
+ ${basedir}/target/local-repo
+ </localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
<debug>${maven.verbose}</debug>
@@ -342,7 +356,7 @@
</plugins>
</build>
</profile>
-
+
<!-- reporting at release time -->
<profile>
<id>reporting</id>
@@ -360,6 +374,10 @@
<artifactId>plexus-maven-plugin</artifactId>
<version>1.3.8</version>
</plugin>
+
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ </plugin>
</plugins>
</reporting>
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,233 @@
+package org.nuiton.topia.persistence.csv;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.TopiaId;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.csv.ext.AbstractImportExportModel;
+import org.nuiton.util.decorator.Decorator;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * A model to import / export entities into csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class EntityCsvModel<T extends TopiaEntityEnum, E extends TopiaEntity> extends AbstractImportExportModel<E> {
+
+ protected final TableMeta<T> tableMeta;
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> EntityCsvModel<T, E> newModel(
+ char separator,
+ TableMeta<T> tableMeta) {
+ return new EntityCsvModel<T, E>(separator, tableMeta);
+ }
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> EntityCsvModel<T, E> newModel(
+ char separator,
+ TableMeta<T> tableMeta,
+ String idHeader) {
+ return new EntityCsvModel<T, E>(separator, tableMeta, idHeader);
+ }
+
+ @Override
+ public E newEmptyInstance() {
+ return (E) tableMeta.newEntity();
+ }
+
+ public void addForeignKeyForExport(String propertyName,
+ Class<TopiaEntity> entityType) {
+
+ Map<String, TopiaEntity> universe = Collections.emptyMap();
+
+ newColumnForExport(
+ propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
+ );
+ }
+
+ public <T> void addDecoratedForeignKeyForExport(String headerName,
+ String propertyName,
+ Decorator<T> decorator) {
+ modelBuilder.newColumnForExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.newForeignKeyDecoratedValue(decorator));
+ }
+
+ public <E extends TopiaEntity> void addForeignKeyForImport(String headerName,
+ String propertyName,
+ Class<E> entityType,
+ Collection<E> entities,
+ Function<E, String> transform) {
+
+ Map<String, E> universe = Maps.uniqueIndex(entities, transform);
+
+ newMandatoryColumn(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
+ );
+ }
+
+ public <E extends TopiaEntity> void addForeignKeyForAssociationForImport(String headerName,
+ String propertyName,
+ Class<E> entityType,
+ Collection<E> entities,
+ Function<E, String> transform) {
+
+ Map<String, E> universe = Maps.uniqueIndex(entities, transform);
+
+ newMandatoryColumn(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.newForeignKeyValueAssociation(entityType,
+ propertyName,
+ universe)
+ );
+ }
+
+ public <E extends TopiaEntity> void addForeignKeyForImport(String propertyName,
+ Class<E> entityType,
+ Collection<E> entities) {
+
+ Map<String, E> universe = Maps.uniqueIndex(entities,
+ TopiaId.GET_TOPIA_ID);
+
+ newMandatoryColumn(
+ propertyName,
+ TopiaCsvCommons.newForeignKeyValue(entityType,
+ propertyName,
+ universe)
+ );
+ }
+
+ public void addDefaultColumn(String propertyName, Class<?> type) {
+ addDefaultColumn(propertyName, propertyName, type);
+ }
+
+ public void addDefaultColumn(String headerName,
+ String propertyName,
+ Class<?> type) {
+
+ if (Date.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.DAY_TIME_SECOND_WITH_TIMESTAMP
+ );
+ } else if (double.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.DOUBLE_PRIMITIVE
+ );
+ } else if (Double.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.DOUBLE
+ );
+ } else if (long.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.PRIMITIVE_LONG
+ );
+ } else if (Long.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.LONG
+ );
+ } else if (float.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.PRIMITIVE_FLOAT
+ );
+ } else if (Float.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.FLOAT
+ );
+ } else if (int.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.PRIMITIVE_INTEGER
+ );
+ } else if (Integer.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.INTEGER
+ );
+ } else if (boolean.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.PRIMITIVE_BOOLEAN
+ );
+ } else if (Boolean.class.equals(type)) {
+ newColumnForImportExport(
+ headerName,
+ propertyName,
+ TopiaCsvCommons.BOOLEAN
+ );
+ } else {
+
+ // string
+ newColumnForImportExport(
+ headerName,
+ propertyName
+ );
+ }
+ }
+
+ protected EntityCsvModel(char separator, TableMeta<T> tableMeta) {
+ super(separator);
+ this.tableMeta = tableMeta;
+ }
+
+ protected EntityCsvModel(char separator, TableMeta<T> tableMeta,
+ String idHeader) {
+ this(separator, tableMeta);
+ newColumnForImportExport(idHeader, TopiaEntity.TOPIA_ID);
+ }
+}
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/EntityCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,262 @@
+package org.nuiton.topia.persistence.csv;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.collect.Lists;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.util.csv.ValueParser;
+import org.nuiton.util.csv.ValueParserFormatter;
+import org.nuiton.util.decorator.Decorator;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * More useful method added to {@link Common}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class TopiaCsvCommons extends Common {
+
+ protected TopiaCsvCommons() {
+ // no instance of this helper
+ }
+
+ public static final ValueParserFormatter<Date> DAY_TIME_SECOND_WITH_TIMESTAMP =
+ new DateValue("dd/MM/yyyy HH:mm:ss") {
+
+ @Override
+ public Date parse(String value) throws ParseException {
+
+ Date parse = super.parse(value);
+ if (parse != null) {
+ parse = new Timestamp(parse.getTime());
+ }
+ return parse;
+ }
+ };
+
+ public static final AssociationValueParser ASSOCIATION_VALUE_PARSER = new AssociationValueParser();
+
+ public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, String propertyName, Map<String, E> universe) {
+ return new ForeignKeyValue<E>(type, propertyName, universe);
+ }
+
+ public static <E extends TopiaEntity> ForeignKeyValueForAssociation<E> newForeignKeyValueAssociation(Class<E> type, String propertyName, Map<String, E> universe) {
+ return new ForeignKeyValueForAssociation<E>(type, propertyName, universe);
+ }
+
+ public static <E extends TopiaEntity> ValueFormatter<Collection<E>> newAssociationValueFormatter() {
+ return new AssociationValueParserFormatter<E>(null, null);
+ }
+
+ public static <E> ForeignKeyDecoratedValue<E> newForeignKeyDecoratedValue(Decorator<E> decorator) {
+ return new ForeignKeyDecoratedValue<E>(decorator);
+ }
+
+ /**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class AssociationValueParser implements ValueParser<String[]> {
+
+ @Override
+ public String[] parse(String value) throws ParseException {
+ String[] ids = value.split("\\|");
+ return ids;
+ }
+ }
+
+ /**
+ * @param <E>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class AssociationValueParserFormatter<E extends TopiaEntity> implements ValueParserFormatter<Collection<E>> {
+
+ protected final Class<E> entityType;
+
+ protected final Map<String, E> universe;
+
+ public AssociationValueParserFormatter(
+ Class<E> entityType,
+ Map<String, E> universe) {
+ this.entityType = entityType;
+ this.universe = universe;
+ }
+
+ @Override
+ public Collection<E> parse(String value) throws ParseException {
+ Collection<E> result = Lists.newArrayList();
+ if (StringUtils.isNotBlank(value)) {
+
+ String[] ids = value.split("\\|");
+ for (String id : ids) {
+ E association = universe.get(id);
+ association.setTopiaId(id);
+ result.add(association);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String format(Collection<E> e) {
+
+ String value;
+ if (CollectionUtils.isEmpty(e)) {
+ value = "";
+ } else {
+ Collection<String> ids = Lists.newArrayList();
+ for (E e1 : e) {
+ ids.add(e1.getTopiaId());
+ }
+ value = StringUtil.join(ids, "|", true);
+ }
+ return value;
+ }
+ }
+
+ /**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class ForeignKeyDecoratedValue<E> implements ValueFormatter<E> {
+
+ protected final Decorator<E> decorator;
+
+ public ForeignKeyDecoratedValue(Decorator<E> decorator) {
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+ value = decorator.toString(e);
+ }
+ return value;
+ }
+ }
+
+ /**
+ * @param <E>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class ForeignKeyValue<E extends TopiaEntity> implements ValueParserFormatter<E> {
+
+ protected final String propertyName;
+
+ protected final Class<E> entityType;
+
+ protected final Map<String, E> universe;
+
+ public ForeignKeyValue(Class<E> entityType,
+ String propertyName,
+ Map<String, E> universe) {
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.universe = universe;
+ }
+
+
+ @Override
+ public E parse(String value) throws ParseException {
+ E result = null;
+ if (StringUtils.isNotBlank(value)) {
+
+ // get entity from universe
+ result = universe.get(value);
+
+ if (result == null) {
+
+ // can not find entity this is a big problem for us...
+ throw new TopiaRuntimeException(
+ "Could not find entity of type " +
+ entityType.getSimpleName() + " with '" +
+ propertyName + "' = " + value);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+ value = e.getTopiaId();
+ }
+ return value;
+ }
+ }
+
+ public static class ForeignKeyValueForAssociation<E extends TopiaEntity> implements ValueParser<Collection<E>> {
+
+ protected final String propertyName;
+
+ protected final Class<E> entityType;
+
+ protected final Map<String, E> universe;
+
+ public ForeignKeyValueForAssociation(Class<E> entityType,
+ String propertyName,
+ Map<String, E> universe) {
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ this.universe = universe;
+ }
+
+ @Override
+ public Collection<E> parse(String value) throws ParseException {
+ E result = null;
+ if (StringUtils.isNotBlank(value)) {
+
+ // get entity from universe
+ result = universe.get(value);
+
+ if (result == null) {
+
+ // can not find entity this is a big problem for us...
+ throw new TopiaRuntimeException(
+ "Could not find entity with '" + propertyName + "' = " + value);
+ }
+ }
+ return Arrays.asList(result);
+ }
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/TopiaCsvCommons.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,50 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-entities/src/mai… $
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, 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.topia.persistence.csv.in;
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.csv.TopiaCsvCommons;
+
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractImportModel<E> extends org.nuiton.util.csv.ext.AbstractImportModel<E> {
+
+ public AbstractImportModel(char separator) {
+ super(separator);
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ public <E extends TopiaEntity> void newForeignKeyColumn(String headerName, String propertyName, Class<E> entityType, String foreignKeyName, Map<String, E> universe) {
+ newMandatoryColumn(headerName, propertyName, TopiaCsvCommons.newForeignKeyValue(entityType, foreignKeyName, universe));
+ }
+
+ public <E extends TopiaEntity> void newForeignKeyColumn(String propertyName, Class<E> entityType, String foreignKeyName, Map<String, E> universe) {
+ newMandatoryColumn(propertyName, propertyName, TopiaCsvCommons.newForeignKeyValue(entityType, foreignKeyName, universe));
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/AbstractImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,113 @@
+package org.nuiton.topia.persistence.csv.in;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * To keep result of the import of a file.
+ *
+ * @since 2.6.12
+ * @author tchemit <chemit(a)codelutin.com>
+ */
+public class CsvFileImportResult<T extends TopiaEntityEnum> implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the csv file to import. */
+ protected final String importFileName;
+
+ /** type of entity to import csv datas. */
+ protected final Set<T> entityTypes;
+
+ /** Count of created entities. */
+ protected final Map<T, Integer> numberCreated;
+
+ /** Count of updated entities. */
+ protected final Map<T, Integer> numberUpdated;
+
+ public static <T extends TopiaEntityEnum> CsvFileImportResult<T> newResult(String importFileName, T... universe) {
+ CsvFileImportResult<T> result = new CsvFileImportResult<T>(
+ importFileName, universe
+ );
+ return result;
+ }
+
+ public CsvFileImportResult(String importFileName, T... universe) {
+ this.importFileName = importFileName;
+ entityTypes = Sets.newHashSet();
+ numberCreated = Maps.newHashMap();
+ numberUpdated = Maps.newHashMap();
+ for (T t : universe) {
+ numberCreated.put(t, 0);
+ numberUpdated.put(t, 0);
+ }
+ }
+
+ public Set<T> getEntityTypes() {
+ return ImmutableSet.copyOf(entityTypes);
+ }
+
+ public int getNumberCreated(T entityType) {
+ return getInteger(numberCreated, entityType);
+ }
+
+ public int getNumberUpdated(T entityType) {
+ return getInteger(numberUpdated, entityType);
+ }
+
+ public String getImportFileName() {
+ return importFileName;
+ }
+
+ public void incrementsNumberCreated(T entityType) {
+ increments(numberCreated, entityType);
+ }
+
+ public void incrementsNumberUpdated(T entityType) {
+ increments(numberUpdated, entityType);
+ }
+
+ protected int getInteger(Map<T, Integer> map, T entityType) {
+ Integer result = map.get(entityType);
+ return result == null ? 0 : result;
+ }
+
+ protected void increments(Map<T, Integer> map, T entityType) {
+ Integer result = map.get(entityType);
+ if (result == null) {
+
+ entityTypes.add(entityType);
+ result = 0;
+ }
+ map.put(entityType, ++result);
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvFileImportResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,101 @@
+package org.nuiton.topia.persistence.csv.in;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+import java.io.Serializable;
+
+/**
+ * A simple csv result bean just to keep the number of created or
+ * updated entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class CsvImportResult<T extends TopiaEntityEnum> implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** type of entity to import csv datas. */
+ protected final T entityType;
+
+ /** Name of the csv file to import. */
+ protected final String importFileName;
+
+ /** Flag to authorize to create entities not found in db. */
+ protected final boolean createIfNotFound;
+
+ /** Count of created entities. */
+ protected int numberCreated;
+
+ /** Count of updated entities. */
+ protected int numberUpdated;
+
+ public static <T extends TopiaEntityEnum> CsvImportResult<T> newResult(T entityType,
+ String importFileName,
+ boolean createIfNotFound) {
+ CsvImportResult<T> result = new CsvImportResult<T>(entityType, importFileName,
+ createIfNotFound);
+ return result;
+ }
+
+ protected CsvImportResult(T entityType,
+ String importFileName,
+ boolean createIfNotFound) {
+ this.entityType = entityType;
+ this.importFileName = importFileName;
+ this.createIfNotFound = createIfNotFound;
+ }
+
+ public T getEntityType() {
+ return entityType;
+ }
+
+
+ public String getImportFileName() {
+ return importFileName;
+ }
+
+ public int getNumberCreated() {
+ return numberCreated;
+ }
+
+ public int getNumberUpdated() {
+ return numberUpdated;
+ }
+
+ public boolean isCreateIfNotFound() {
+ return createIfNotFound;
+ }
+
+ public void incrementsNumberCreated() {
+ numberCreated++;
+ }
+
+ public void incrementsNumberUpdated() {
+ numberUpdated++;
+ }
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/CsvImportResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,75 @@
+package org.nuiton.topia.persistence.csv.in;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.csv.TopiaCsvCommons;
+import org.nuiton.util.csv.ImportModel;
+
+import java.util.Map;
+
+/**
+ * A model to import associations of entities into csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class EntityAssociationImportModel extends AbstractImportModel<Map<String, Object>> {
+
+ protected final AssociationMeta meta;
+
+ public static ImportModel<Map<String, Object>> newImportModel(char separator,
+ AssociationMeta meta
+ ) {
+ EntityAssociationImportModel model = new EntityAssociationImportModel(
+ separator, meta);
+
+ // topiaId <-> topiaId
+ model.newMandatoryColumn(
+ TopiaEntity.TOPIA_ID,
+ TopiaCsvCommons.<Map<String, Object>, String>newMapProperty(TopiaEntity.TOPIA_ID)
+ );
+
+ // add association -> target
+ model.newMandatoryColumn(
+ meta.getName(),
+ TopiaCsvCommons.ASSOCIATION_VALUE_PARSER,
+ TopiaCsvCommons.<Map<String, Object>, String[]>newMapProperty("target")
+ );
+
+ return model;
+ }
+
+ @Override
+ public Map<String, Object> newEmptyInstance() {
+ return null;
+ }
+
+ public EntityAssociationImportModel(char separator, AssociationMeta meta) {
+ super(separator);
+ this.meta = meta;
+ }
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/EntityAssociationImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,47 @@
+package org.nuiton.topia.persistence.csv.in;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.csv.ImportModel;
+
+import java.util.Map;
+
+/**
+ * To produce import model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public interface ImportModelFactory<T extends TopiaEntityEnum> {
+
+ <E extends TopiaEntity> ImportModel<E> buildForImport(TableMeta<T> meta);
+
+ ImportModel<Map<String, Object>> buildForImport(AssociationMeta<T> meta);
+
+ boolean isNMAssociationMeta(AssociationMeta<T> meta);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/ImportModelFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,231 @@
+package org.nuiton.topia.persistence.csv.in;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.collect.Maps;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.metadata.MetaFilenameAware;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportToMap;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * Helper for csv imports.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class TopiaCsvImports {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TopiaCsvImports.class);
+
+ protected TopiaCsvImports() {
+ // no instance of this helper
+ }
+
+ public static <T extends TopiaEntityEnum> void importFile(TopiaContextImplementor tx,
+ ImportModelFactory<T> modelFactory,
+ MetaFilenameAware<T> entry,
+ Reader reader,
+ CsvImportResult<T> csvResult) throws IOException, TopiaException {
+
+ if (entry instanceof AssociationMeta) {
+
+ // load a association input
+ AssociationMeta<T> meta = (AssociationMeta<T>) entry;
+ ImportModel<Map<String, Object>> model =
+ modelFactory.buildForImport(meta);
+ ImportToMap importer = ImportToMap.newImportToMap(model, reader, false);
+
+ try {
+ if (modelFactory.isNMAssociationMeta(meta)) {
+ importNMAssociationFile(tx, meta, importer, csvResult, 1000);
+ } else {
+ importAssociationFile(tx, meta, importer, csvResult, 1000);
+ }
+ } finally {
+ importer.close();
+ }
+
+ } else {
+
+ // normal entity table import
+ TableMeta<T> meta = (TableMeta<T>) entry;
+ ImportModel<TopiaEntity> model = modelFactory.buildForImport(meta);
+ Import<TopiaEntity> importer = Import.newImport(model, reader);
+
+ try {
+ TopiaDAO<TopiaEntity> dao = (TopiaDAO<TopiaEntity>) tx.getDAO(meta.getSource().getContract());
+ importEntityFile(dao, meta, importer, csvResult);
+ } finally {
+ importer.close();
+ }
+ }
+
+ }
+
+ public static <T extends TopiaEntityEnum> Map<MetaFilenameAware<T>, ZipEntry> discoverEntries(
+ String entryPrefix,
+ MetaFilenameAware<T>[] entries,
+ ZipFile zipFile,
+ List<String> missingEntries) {
+
+ Map<MetaFilenameAware<T>, ZipEntry> result = Maps.newLinkedHashMap();
+
+ // check that all mandatories
+ for (MetaFilenameAware<T> entry : entries) {
+ String filename = entry.getFilename();
+ ZipEntry zipEntry = zipFile.getEntry(entryPrefix + filename);
+
+ if (zipEntry == null) {
+ missingEntries.add(filename);
+ } else {
+ result.put(entry, zipEntry);
+ }
+ }
+ return result;
+ }
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> void importEntityFile(TopiaDAO<E> dao,
+ TableMeta<T> meta,
+ Import<E> importer,
+ CsvImportResult<T> csvResult) throws TopiaException {
+
+ for (TopiaEntity entity : importer) {
+
+ Map<String, Object> properties = meta.prepareCreate(
+ entity, entity.getTopiaId());
+ E entityToSave = dao.create(properties);
+
+ meta.copy(entity, entityToSave);
+
+ csvResult.incrementsNumberUpdated();
+ }
+ }
+
+ public static <T extends TopiaEntityEnum> void importAssociationFile(TopiaContext tx, AssociationMeta<T> meta,
+ ImportToMap importer,
+ CsvImportResult<T> csvResult,
+ int nbRowBuffer) throws TopiaException {
+
+ T source = meta.getSource();
+ T target = meta.getTarget();
+
+ StringBuilder builder = new StringBuilder();
+
+ String targetTableName = target.getContract().getSimpleName();
+ String sourceTableName = source.getContract().getSimpleName();
+ String table = targetTableName;
+
+ String updateString = String.format("UPDATE %s SET %s = '%%s' WHERE topiaId ='%%s';", table, sourceTableName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will apply " + updateString);
+ }
+ int compt = 0;
+ for (Map<String, Object> row : importer) {
+ String topiaId = (String) row.get(TopiaEntity.TOPIA_ID);
+ String[] associations = (String[]) row.get("target");
+ for (String association : associations) {
+ if (StringUtils.isNotEmpty(association)) {
+ builder.append(String.format(updateString, topiaId, association)).append('\n');
+ compt++;
+ if (compt % nbRowBuffer == 0) {
+ // flush it
+ tx.executeSQL(builder.toString());
+ builder = new StringBuilder();
+ }
+ }
+ }
+ csvResult.incrementsNumberUpdated();
+ }
+ if (builder.length() > 0) {
+ tx.executeSQL(builder.toString());
+ }
+ }
+
+ public static <T extends TopiaEntityEnum> void importNMAssociationFile(TopiaContext tx, AssociationMeta<T> meta,
+ ImportToMap importer,
+ CsvImportResult<T> csvResult,
+ int nbRowBuffer) throws TopiaException {
+
+ T source = meta.getSource();
+ T target = meta.getTarget();
+
+ StringBuilder builder = new StringBuilder();
+
+
+ String targetTableName = target.getContract().getSimpleName();
+ String sourceTableName = source.getContract().getSimpleName();
+
+ // relation *-*
+ String table = TopiaEntityHelper.getNormalizedAssociationTableName(
+ sourceTableName, targetTableName);
+
+ String updateString = String.format("INSERT INTO %s (%s,%s) VALUES('%%s','%%s');", table, sourceTableName, targetTableName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will apply " + updateString);
+ }
+ int compt = 0;
+ for (Map<String, Object> row : importer) {
+ String topiaId = (String) row.get(TopiaEntity.TOPIA_ID);
+ String[] associations = (String[]) row.get("target");
+ for (String association : associations) {
+ if (StringUtils.isNotEmpty(association)) {
+ builder.append(String.format(updateString, topiaId, association)).append('\n');
+ compt++;
+ if (compt % nbRowBuffer == 0) {
+ // flush it
+ tx.executeSQL(builder.toString());
+ builder = new StringBuilder();
+ }
+ }
+ }
+ csvResult.incrementsNumberUpdated();
+ }
+ if (builder.length() > 0) {
+ tx.executeSQL(builder.toString());
+ }
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/TopiaCsvImports.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,7 @@
+/**
+ * Package for csv import of entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+package org.nuiton.topia.persistence.csv.in;
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/in/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,181 @@
+package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.topia.persistence.EntityVisitor;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.util.TimeLog;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * entity visitor to export data to csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public abstract class AbstractExportEntityVisitor<T extends TopiaEntityEnum> implements EntityVisitor {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AbstractExportEntityVisitor.class);
+
+ public static final TimeLog TIME_LOG =
+ new TimeLog(AbstractExportEntityVisitor.class);
+
+
+ protected abstract boolean isNoChildVisit(String propertyName, TopiaEntity entity);
+
+
+ /** Export for simple entity. */
+ protected final Map<Class<?>, TopiaCsvExports.EntityExportContext> entityExporters;
+
+ public AbstractExportEntityVisitor(Map<Class<?>, TopiaCsvExports.EntityExportContext> entityExporters) {
+ this.entityExporters = entityExporters;
+ }
+
+ public void export(TopiaEntity entity) {
+ Preconditions.checkNotNull(entity);
+ long s1 = TimeLog.getTime();
+ try {
+ entity.accept(this);
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(
+ "Could not export entity " + entity.getTopiaId(), e);
+ } finally {
+ TIME_LOG.log(s1, "export::" + entity.getTopiaId());
+ }
+ }
+
+ @Override
+ public void start(TopiaEntity entity) {
+ String topiaId = entity.getTopiaId();
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Starts export of entity " + topiaId);
+ }
+ TopiaCsvExports.EntityExportContext entityExporter =
+ entityExporters.get(entity.getClass());
+ entityExporter.write(entity);
+ } catch (Exception e) {
+ throw new TopiaRuntimeException(
+ "Could not export entity " + entity, e);
+ } finally {
+ if (log.isDebugEnabled()) {
+ log.debug("Ends export of entity " + topiaId);
+ }
+ }
+ }
+
+ @Override
+ public void end(TopiaEntity entity) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Starts export of association of entity " +
+ entity.getTopiaId());
+ }
+ TopiaCsvExports.EntityExportContext entityExporter =
+ entityExporters.get(entity.getClass());
+ entityExporter.writeAssociations(entity);
+ } catch (Exception e) {
+ throw new TopiaRuntimeException(
+ "Could not export associations of entity " + entity, e);
+ } finally {
+ if (log.isDebugEnabled()) {
+ log.debug("Ends export of association of entity " +
+ entity.getTopiaId());
+ }
+ }
+ }
+
+ @Override
+ public void visit(TopiaEntity entity, String propertyName,
+ Class<?> type, Object value) {
+ }
+
+ @Override
+ public void visit(TopiaEntity entity,
+ String propertyName,
+ Class<?> collectionType,
+ Class<?> type,
+ Object value) {
+
+ if (TopiaEntity.class.isAssignableFrom(type) &&
+ entityExporters.containsKey(type)) {
+ Collection<?> cValue = (Collection<?>) value;
+
+ if (CollectionUtils.isNotEmpty(cValue)) {
+
+ if (isNoChildVisit(propertyName, entity) &&
+ Entity2.class.isAssignableFrom(type)) {
+
+ // special case, when visiting a entity with no child
+ // visisting at this time...
+ for (Object currentValue : cValue) {
+ ((Entity2) currentValue).accept2(this);
+ }
+ } else {
+ for (Object currentValue : cValue) {
+ try {
+ ((TopiaEntity) currentValue).accept(this);
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can not visit entity " + value, e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void visit(TopiaEntity entity,
+ String propertyName,
+ Class<?> collectionType, Class<?> type,
+ int index,
+ Object value) {
+
+ // nothing to do
+ }
+
+ @Override
+ public void clear() {
+
+ // use at the end of visit (or later)
+
+ for (TopiaCsvExports.EntityExportContext exportContext : entityExporters.values()) {
+ IOUtils.closeQuietly(exportContext);
+ }
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/AbstractExportEntityVisitor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,40 @@
+package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.EntityVisitor;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * To mark some entites visitable but not by generatl
+ * {@link TopiaEntity#accept(EntityVisitor)} method.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public interface Entity2 {
+
+ void accept2(EntityVisitor visitor);
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/Entity2.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,64 @@
+package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.csv.TopiaCsvCommons;
+import org.nuiton.util.csv.ExportModel;
+import org.nuiton.util.csv.ext.AbstractExportModel;
+
+/**
+ * A model to export associations of entities into csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class EntityAssociationExportModel<T extends TopiaEntityEnum, E extends TopiaEntity> extends AbstractExportModel<E> {
+
+ protected final AssociationMeta meta;
+
+ public static <T extends TopiaEntityEnum, E extends TopiaEntity> ExportModel<E> newExportModel(char separator,
+ AssociationMeta<T> meta
+ ) {
+ EntityAssociationExportModel<T, E> model = new EntityAssociationExportModel<T, E>(
+ separator,
+ meta);
+
+ // topiaId <-> topiaId
+ model.newColumnForExport(TopiaEntity.TOPIA_ID);
+
+ model.newColumnForExport(
+ meta.getName(),
+ TopiaCsvCommons.newAssociationValueFormatter()
+ );
+ return model;
+ }
+
+ EntityAssociationExportModel(char separator, AssociationMeta<T> meta) {
+ super(separator);
+ this.meta = meta;
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/EntityAssociationExportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,43 @@
+package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.csv.ExportModel;
+
+/**
+* To produce export model.
+*
+* @author tchemit <chemit(a)codelutin.com>
+* @since 2.6.12
+*/
+public interface ExportModelFactory<T extends TopiaEntityEnum> {
+
+ <E extends TopiaEntity> ExportModel<E> buildForExport(TableMeta<T> meta, boolean asSeen);
+
+ <E extends TopiaEntity> ExportModel<E> buildForExport(AssociationMeta<T> associationMeta);
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/ExportModelFactory.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,283 @@
+package org.nuiton.topia.persistence.csv.out;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.metadata.AssociationMeta;
+import org.nuiton.topia.persistence.metadata.MetaFilenameAware;
+import org.nuiton.topia.persistence.metadata.TableMeta;
+import org.nuiton.util.csv.ExportModel;
+import org.nuiton.util.csv.ext.RepeatableExport;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper for csv exports.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class TopiaCsvExports {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TopiaCsvExports.class);
+
+ protected TopiaCsvExports() {
+ // no instance of this helper
+ }
+
+ public static <T extends TopiaEntityEnum> Map<Class<?>, EntityExportContext> createReplicateEntityVisitorContexts(ExportModelFactory<T> modelFactory,
+ MetaFilenameAware<T>[] entityMetas,
+ Multimap<T, MetaFilenameAware<T>> associations,
+ File container) {
+
+ Preconditions.checkNotNull(modelFactory);
+ Preconditions.checkNotNull(entityMetas);
+ Preconditions.checkNotNull(associations);
+ Preconditions.checkNotNull(container);
+
+ Map<Class<?>, EntityExportContext> contexts = Maps.newHashMap();
+
+ for (MetaFilenameAware<T> entityMeta : entityMetas) {
+ TableMeta<T> meta = (TableMeta<T>) entityMeta;
+ T source = meta.getSource();
+
+ Collection<MetaFilenameAware<T>> metaFilenameAwares = associations.get(source);
+
+ ExportModel<TopiaEntity> model = modelFactory.buildForExport(meta, false);
+
+ EntityExportContext<T> exportContext = EntityExportContext.newExportContext(
+ model,
+ meta,
+ container);
+
+ // save both for contract and implementation with same context
+ contexts.put(source.getContract(), exportContext);
+ contexts.put(source.getImplementation(), exportContext);
+
+ for (MetaFilenameAware<T> metaFilenameAware : metaFilenameAwares) {
+ AssociationMeta<T> associationMeta = (AssociationMeta<T>) metaFilenameAware;
+
+ ExportModel<TopiaEntity> associationModel =
+ modelFactory.buildForExport(associationMeta);
+ exportContext.addAssociationExportContext(associationMeta,
+ associationModel,
+ container);
+ }
+ }
+ return contexts;
+ }
+
+
+ /**
+ * to export entity as csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class EntityExportContext<T extends TopiaEntityEnum> implements Closeable {
+
+ /** meta to export. */
+ protected final TableMeta<T> meta;
+
+ /** Exporter object. */
+ protected final RepeatableExport export;
+
+ /** Where to export datas. */
+ protected final Writer writer;
+
+ /**
+ * Unique list to store data to export. (will be shared with
+ * association export contexts.)
+ */
+ private final List<TopiaEntity> data;
+
+ /** Association export context for this type of entity. */
+ protected final Collection<AssociationExportContext<T>> associationExportContexts;
+
+ protected final File entryFile;
+
+ public static <T extends TopiaEntityEnum> EntityExportContext<T> newExportContext(
+ ExportModel<TopiaEntity> model,
+ TableMeta<T> meta,
+ File container
+ ) {
+ return new EntityExportContext<T>(model, meta, container);
+ }
+
+ protected EntityExportContext(ExportModel<TopiaEntity> model,
+ TableMeta<T> meta,
+ File container) {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(meta);
+ Preconditions.checkNotNull(container);
+
+ this.meta = meta;
+ data = Lists.newArrayList();
+ export = RepeatableExport.newExport(model, data, true);
+ entryFile = meta.newFile(container);
+ if (log.isDebugEnabled()) {
+ log.debug("Creates EntityExportContext::" + meta + " - " +
+ entryFile.getName());
+ }
+ writer = meta.newWriter(container);
+ associationExportContexts = Lists.newArrayList();
+ }
+
+ public void addAssociationExportContext(AssociationMeta<T> meta,
+ ExportModel<TopiaEntity> model,
+ File container) {
+ associationExportContexts.add(
+ new AssociationExportContext<T>(model,
+ meta,
+ container,
+ data)
+ );
+ }
+
+ @Override
+ public void close() throws IOException {
+
+ try {
+ if (export.isHeaderWritten()) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Export table " + meta + " to " + entryFile);
+ }
+ writer.flush();
+ } else {
+ // this file was not used, delete it
+ FileUtils.deleteQuietly(entryFile);
+ }
+ } finally {
+ IOUtils.closeQuietly(writer);
+ for (AssociationExportContext<T> c : associationExportContexts) {
+ c.close();
+ }
+ }
+ }
+
+ public void write(TopiaEntity data) throws Exception {
+ this.data.add(data);
+ try {
+ export.write(writer);
+ } finally {
+ this.data.clear();
+ }
+ }
+
+ public void writeAssociations(TopiaEntity data) throws Exception {
+ this.data.add(data);
+ try {
+ for (AssociationExportContext<T> c : associationExportContexts) {
+ AssociationMeta<T> cMeta = c.meta;
+ boolean emptyChild = cMeta.isChildEmpty(data);
+ if (!emptyChild) {
+ c.write();
+ }
+ }
+ } finally {
+ this.data.clear();
+ }
+ }
+ }
+
+ /**
+ * To export associations as csv files.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+ public static class AssociationExportContext<T extends TopiaEntityEnum> implements Closeable {
+
+ /** association meta to export. */
+ protected final AssociationMeta<T> meta;
+
+ /** Exporter object. */
+ protected final RepeatableExport export;
+
+ /** Where to export datas. */
+ protected final Writer writer;
+
+ protected final File entryFile;
+
+ protected AssociationExportContext(ExportModel<TopiaEntity> model,
+ AssociationMeta<T> meta,
+ File container,
+ List<TopiaEntity> data) {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(meta);
+ Preconditions.checkNotNull(container);
+ Preconditions.checkNotNull(data);
+ this.meta = meta;
+
+ export = RepeatableExport.newExport(model, data, true);
+
+ entryFile = meta.newFile(container);
+ if (log.isDebugEnabled()) {
+ log.debug("Creates AssociationExportContext::" + meta +
+ " - " + entryFile.getName());
+ }
+ writer = meta.newWriter(container);
+ }
+
+ @Override
+ public void close() throws IOException {
+ try {
+ if (export.isHeaderWritten()) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Export association " + meta + " to " + entryFile);
+ }
+ writer.flush();
+ } else {
+
+ // this file was not used, delete it
+ FileUtils.deleteQuietly(entryFile);
+ }
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
+ public void write() throws Exception {
+ export.write(writer);
+ }
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/TopiaCsvExports.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,7 @@
+/**
+ * Package for csv export of entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+package org.nuiton.topia.persistence.csv.out;
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/out/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java 2012-08-16 16:19:17 UTC (rev 2621)
@@ -0,0 +1,7 @@
+/**
+ * Base package for csv import and export of entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+package org.nuiton.topia.persistence.csv;
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/csv/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r2620 - in branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence: . metadata
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-16 18:18:14 +0200 (Thu, 16 Aug 2012)
New Revision: 2620
Url: http://nuiton.org/repositories/revision/topia/2620
Log:
refs #2260: Add a metadata package in persistence
Added:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,146 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Charsets;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.topia.persistence.util.EntityOperatorStore;
+import org.nuiton.util.ObjectUtil;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.Collection;
+
+/**
+ * Define the meta data of a entity association field.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class AssociationMeta<T extends TopiaEntityEnum> implements Serializable, MetaFilenameAware<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Association source entity type. */
+ protected final T source;
+
+ /** Association target entity type. */
+ protected final T target;
+
+ /** Name fo the association. */
+ protected final String name;
+
+ /** Operator of the source entity used to get / set associations. */
+ protected transient EntityOperator<TopiaEntity> operator;
+
+ protected static <T extends TopiaEntityEnum> AssociationMeta<T> newMeta(T source,
+ T target,
+ String name) {
+ return new AssociationMeta<T>(source, target, name);
+ }
+
+ public AssociationMeta(T source,
+ T target,
+ String name) {
+ this.source = source;
+ this.target = target;
+ this.name = name;
+ }
+
+ @Override
+ public T getSource() {
+ return source;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getFilename() {
+ return source.name() + "_" + name + CSV_EXTENSION;
+ }
+
+ @Override
+ public File newFile(File container) {
+ return new File(container, getFilename());
+ }
+
+ @Override
+ public Writer newWriter(File container) {
+ File file = newFile(container);
+ try {
+ return new OutputStreamWriter(new FileOutputStream(file),
+ Charsets.UTF_8);
+ } catch (FileNotFoundException e) {
+ throw new TopiaRuntimeException("Could not find file " + file);
+ }
+ }
+
+ public T getTarget() {
+ return target;
+ }
+
+ public TopiaEntity newEntity() {
+ return ObjectUtil.newInstance(source.getImplementation());
+ }
+
+ public Object newAssociation() {
+ return ObjectUtil.newInstance(target.getImplementation());
+ }
+
+ public Collection<TopiaEntity> getChilds(TopiaEntity entity) {
+ Object o = getOperator().get(name, entity);
+ return (Collection<TopiaEntity>) o;
+ }
+
+ public void setChilds(TopiaEntity entity, Collection<TopiaEntity> childs) {
+ getOperator().addAllChild(name, entity, childs);
+ }
+
+ public boolean isChildEmpty(TopiaEntity entity) {
+ boolean result = getOperator().isChildEmpty(name, entity);
+ return result;
+ }
+
+ public EntityOperator<TopiaEntity> getOperator() {
+ if (operator == null) {
+ operator = EntityOperatorStore.getOperator(source);
+ }
+ return operator;
+ }
+
+ @Override
+ public String toString() {
+ return "<" + source + ":" + name + " " + target + ">";
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,94 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Define the meta data of a entity field.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class ColumnMeta implements Serializable {
+
+ protected static ColumnMeta newMeta(String name, Class<?> type) {
+ return new ColumnMeta(name, type);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the column. */
+ protected String name;
+
+ /** Type of the column. */
+ protected Class<?> type;
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getTypeSimpleName() {
+ return type.getSimpleName();
+ }
+
+ public String getColumnType() {
+ String result = "string";
+ if (boolean.class.equals(type)) {
+ result = "boolean";
+ } else if (Date.class.equals(type)) {
+ result = "date";
+ }
+ return result;
+ }
+
+ public boolean isFK() {
+ return TopiaEntity.class.isAssignableFrom(type);
+ }
+
+ public boolean isDate() {
+ return Date.class.isAssignableFrom(type);
+ }
+
+ public boolean isBoolean() {
+ return boolean.class.equals(type);
+ }
+
+ public boolean isNumber() {
+ return !isBoolean() && (type.isPrimitive() || Number.class.isAssignableFrom(type));
+ }
+
+ protected ColumnMeta(String name, Class<?> type) {
+ this.name = name;
+ this.type = type;
+ }
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,97 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Define metas about a db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class DbMeta<T extends TopiaEntityEnum> implements Iterable<TableMeta<T>> {
+
+ /** All metas of the db. */
+ protected final List<TableMeta<T>> tables;
+
+ /** All types non editables. */
+ protected final Set<T> nonEditableTypes;
+
+ public static <T extends TopiaEntityEnum> DbMeta<T> newDbMeta(T[] universe,
+ T[] nonEditables,
+ TopiaEntityEnumProvider<T> typeProvider) {
+ return new DbMeta<T>(universe, nonEditables, typeProvider);
+ }
+
+ public List<String> getTableNames() {
+ List<String> result = Lists.newArrayList();
+ for (TableMeta tableMeta : getTables()) {
+ result.add(tableMeta.getName());
+ }
+ return result;
+ }
+
+ public List<TableMeta<T>> getTables() {
+ return tables;
+ }
+
+ public TableMeta<T> getTable(T entityType) {
+ Preconditions.checkNotNull(entityType);
+ TableMeta<T> result = null;
+ for (TableMeta<T> tableMeta : getTables()) {
+ if (entityType.equals(tableMeta.getSource())) {
+ result = tableMeta;
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Iterator<TableMeta<T>> iterator() {
+ return getTables().iterator();
+ }
+
+ protected DbMeta(T[] entityTypes, T[] nonEditableTypes, TopiaEntityEnumProvider<T> typeProvider) {
+ this.nonEditableTypes = Sets.newHashSet(nonEditableTypes);
+ tables = Lists.newArrayList();
+ for (T entityEnum : entityTypes) {
+ TableMeta<T> tableMeta = TableMeta.newMeta(entityEnum, typeProvider);
+ tables.add(tableMeta);
+ }
+ }
+
+ public boolean isEditable(TableMeta<T> meta) {
+ return !nonEditableTypes.contains(meta.getSource());
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,52 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, 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.topia.persistence.metadata;
+
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+import java.io.File;
+import java.io.Writer;
+
+/**
+ * Contract to import or export some metas.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public interface MetaFilenameAware<T extends TopiaEntityEnum> {
+
+ String CSV_EXTENSION = ".csv";
+
+ T getSource();
+
+ String getName();
+
+ String getFilename();
+
+ File newFile(File container);
+
+ Writer newWriter(File container);
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,74 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Function;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+import java.util.List;
+
+/**
+ * USeful methods around metadatas.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class Metadatas {
+
+ public static <T extends TopiaEntityEnum> void addEntries(DbMeta<T> dbMeta,
+ List<MetaFilenameAware<T>> entities,
+ List<MetaFilenameAware<T>> associations,
+ T... types) {
+ for (T type : types) {
+
+ TableMeta<T> tableMeta = dbMeta.getTable(type);
+ if (entities != null) {
+ entities.add(tableMeta);
+ }
+ if (associations != null) {
+ associations.addAll(tableMeta.getAssociations());
+ }
+ }
+ }
+
+ public static <T extends TopiaEntityEnum> Multimap<T, MetaFilenameAware<T>> split(List<MetaFilenameAware<T>> metas) {
+ Function<MetaFilenameAware<T>, T> function = newMetaBySourcefunction();
+ Multimap<T, MetaFilenameAware<T>> associationsBySource = Multimaps.index(metas, function);
+ return associationsBySource;
+
+ }
+
+ protected static <T extends TopiaEntityEnum> Function<MetaFilenameAware<T>, T> newMetaBySourcefunction() {
+ return new Function<MetaFilenameAware<T>, T>() {
+
+ @Override
+ public T apply(MetaFilenameAware<T> input) {
+ return input.getSource();
+ }
+ };
+ }
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,256 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.topia.persistence.util.EntityOperatorStore;
+import org.nuiton.util.ObjectUtil;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Define metas of a given db table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public class TableMeta<T extends TopiaEntityEnum> implements Serializable, Iterable<ColumnMeta>, MetaFilenameAware<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static <T extends TopiaEntityEnum> TableMeta newMeta(T entityEnum,
+ TopiaEntityEnumProvider<T> typeProvider) {
+ return new TableMeta<T>(entityEnum, typeProvider);
+ }
+
+ /** Type of the entity. */
+ protected final T source;
+
+ /** List of columns of the entity. */
+ protected List<ColumnMeta> columns;
+
+ /** List of dependencies (says all property with a topiaentity type) */
+ protected final Set<T> dependencies;
+
+ /** List of associations of the entity. */
+ protected List<AssociationMeta<T>> associations;
+
+ /** Binder used to copy entities (lazy loaded). */
+ protected Binder<TopiaEntity, TopiaEntity> binder;
+
+ /** Entity operator used in generic algorithms. */
+ protected transient EntityOperator<TopiaEntity> operator;
+
+ protected boolean useNaturalIdsOrNotNulls;
+
+ @Override
+ public T getSource() {
+ return source;
+ }
+
+ @Override
+ public String getName() {
+ return source.name();
+ }
+
+ @Override
+ public String getFilename() {
+ return source.name() + ".csv";
+ }
+
+ @Override
+ public File newFile(File container) {
+ return new File(container, getFilename());
+ }
+
+ @Override
+ public Writer newWriter(File container) {
+ File file = newFile(container);
+ try {
+ return new OutputStreamWriter(new FileOutputStream(file),
+ Charsets.UTF_8);
+ } catch (FileNotFoundException e) {
+ throw new TopiaRuntimeException("Could not find file " + file);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "<" + source + ">";
+ }
+
+ public Class<? extends TopiaEntity> getEntityType() {
+ return source.getContract();
+ }
+
+ public ColumnMeta getColumns(String columnName) {
+ Preconditions.checkNotNull(columnName);
+ ColumnMeta result = null;
+ for (ColumnMeta columnMeta : getColumns()) {
+ if (columnName.equals(columnMeta.getName())) {
+ result = columnMeta;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public String[] getColumnNamesAsArray() {
+ List<String> columnNames = getColumnNames();
+ return columnNames.toArray(new String[columnNames.size()]);
+ }
+
+ public List<String> getColumnNames() {
+ List<String> result = Lists.newLinkedList();
+ for (ColumnMeta columnMeta : getColumns()) {
+ result.add(columnMeta.getName());
+ }
+ return result;
+ }
+
+ public List<ColumnMeta> getColumns() {
+ return columns;
+ }
+
+ public List<AssociationMeta<T>> getAssociations() {
+ return associations;
+ }
+
+ public Set<T> getDependencies() {
+ return dependencies;
+ }
+
+ public AssociationMeta<T> getAssociations(String name) {
+ AssociationMeta<T> result = null;
+ for (AssociationMeta<T> meta : getAssociations()) {
+ if (name.equals(meta.getName())) {
+ result = meta;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public void copy(TopiaEntity source, TopiaEntity target) {
+ getBinder().copy(source, target);
+ }
+
+ public Map<String, Object> prepareCreate(TopiaEntity bean,
+ String topiaId) {
+ Map<String, Object> result = getOperator().getNaturalIsdAndNotNulls(bean);
+ if (topiaId != null) {
+ result.put(TopiaEntity.TOPIA_ID, topiaId);
+ }
+ return result;
+ }
+
+ @Override
+ public Iterator<ColumnMeta> iterator() {
+ return getColumns().iterator();
+ }
+
+ public TopiaEntity newEntity() {
+ return ObjectUtil.newInstance(source.getImplementation());
+ }
+
+ protected Binder<TopiaEntity, TopiaEntity> getBinder() {
+ if (binder == null) {
+ BinderModelBuilder<TopiaEntity, TopiaEntity> binderModelBuilder =
+ (BinderModelBuilder<TopiaEntity, TopiaEntity>) BinderModelBuilder.newEmptyBuilder(getEntityType());
+ for (ColumnMeta columnMeta : this) {
+ binderModelBuilder.addSimpleProperties(columnMeta.getName());
+ }
+ binder = binderModelBuilder.toBinder();
+ }
+ return binder;
+ }
+
+ protected TableMeta(T source, TopiaEntityEnumProvider<T> typeProvider) {
+ Preconditions.checkNotNull(source);
+ this.source = source;
+
+ associations = Lists.newArrayList();
+ columns = Lists.newLinkedList();
+ Set<T> deps = Sets.newHashSet();
+
+ // fill associations
+ List<String> associationProperties = getOperator().getAssociationProperties();
+ for (String property : associationProperties) {
+ Class<?> propertyType = getOperator().getAssociationPropertyType(property);
+ if (TopiaEntity.class.isAssignableFrom(propertyType)) {
+
+ // only use it for entity
+ T targetEnum = typeProvider.getEntityEnum(propertyType);
+
+ AssociationMeta<T> meta = AssociationMeta.newMeta(source,
+ targetEnum,
+ property
+ );
+ associations.add(meta);
+ }
+ }
+
+ // fill properties (remove all asociations)
+ List<String> properties = Lists.newArrayList(getOperator().getProperties());
+ properties.removeAll(associationProperties);
+ for (String property : properties) {
+ Class<?> propertyType = getOperator().getPropertyType(property);
+ ColumnMeta meta = ColumnMeta.newMeta(property, propertyType);
+ columns.add(meta);
+ if (meta.isFK()) {
+ T dependency = typeProvider.getEntityEnum(propertyType);
+ deps.add(dependency);
+ }
+ }
+ dependencies = deps;
+
+ useNaturalIdsOrNotNulls = source.isUseNotNulls() ||
+ source.isUseNaturalIds();
+ }
+
+ public EntityOperator<TopiaEntity> getOperator() {
+ if (operator == null) {
+ operator = EntityOperatorStore.getOperator(source);
+ }
+ return operator;
+ }
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,38 @@
+package org.nuiton.topia.persistence.metadata;
+/*
+ * #%L
+ * ToPIA :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 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%
+ */
+
+import org.nuiton.topia.persistence.TopiaEntityEnum;
+
+/**
+ * Provider of {@link TopiaEntityEnum}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+public interface TopiaEntityEnumProvider<T extends TopiaEntityEnum> {
+
+ <E> T getEntityEnum(Class<E> type);
+
+}
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java 2012-08-16 16:18:14 UTC (rev 2620)
@@ -0,0 +1,7 @@
+/**
+ * Package to define metadatas over {@link TopiaEntity}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.12
+ */
+package org.nuiton.topia.persistence.metadata;
\ No newline at end of file
Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r2619 - in branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence: . util
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-16 18:13:00 +0200 (Thu, 16 Aug 2012)
New Revision: 2619
Url: http://nuiton.org/repositories/revision/topia/2619
Log:
fixes #2264: Add GET_TOPIA_ID function into TopiaId class (at last)
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaId.java
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaId.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaId.java 2012-08-16 15:56:13 UTC (rev 2618)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaId.java 2012-08-16 16:13:00 UTC (rev 2619)
@@ -38,6 +38,7 @@
package org.nuiton.topia.persistence;
+import com.google.common.base.Function;
import org.nuiton.topia.TopiaNotFoundException;
import java.io.Serializable;
@@ -46,9 +47,11 @@
/**
* TODO-fdesbois-20100508 : Need translation of javadoc.
- *
+ * <p/>
* Classe representant un Id, utilisable par JDO. Cette classe contient aussi un ensemble de methode
- * static utile pour la manipulation des topiaId
+ * static utile pour la manipulation des topiaId.
+ * <p/>
+ * TODO-tchemit-2012-08-16 Rename this class to {@code TopiaIds}.
*
* @author poussin <poussing(a)codelutin.com>
* @author tchemit <tchemit(a)codelutin.com>
@@ -60,6 +63,19 @@
/** */
private static final long serialVersionUID = 1L;
+ /**
+ * Function to obtain {@link TopiaEntity#getTopiaId()} from any entity.
+ *
+ * @since 2.6.12
+ */
+ public static final Function<TopiaEntity, String> GET_TOPIA_ID = new Function<TopiaEntity, String>() {
+
+ @Override
+ public String apply(TopiaEntity input) {
+ return input == null ? null : input.getTopiaId();
+ }
+ };
+
public String topiaId;
public TopiaId() {
@@ -106,7 +122,7 @@
random = Math.random();
}
return clazz.getName() + '#' + System.currentTimeMillis() + '#'
- + random;
+ + random;
}
/**
@@ -124,7 +140,7 @@
return result;
} catch (ClassNotFoundException eee) {
throw new TopiaNotFoundException("Can't find class for " + topiaId,
- eee);
+ eee);
}
}
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-08-16 15:56:13 UTC (rev 2618)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-08-16 16:13:00 UTC (rev 2619)
@@ -74,19 +74,6 @@
"%1$s[@" + TopiaEntity.TOPIA_ID + "=\"%2$s\"]";
/**
- * Function to obtain {@link TopiaEntity#getTopiaId()} form any entity.
- *
- * @since 2.6.12
- */
- public static final Function<TopiaEntity, String> TO_TOPIAID = new Function<TopiaEntity, String>() {
-
- @Override
- public String apply(TopiaEntity input) {
- return input.getTopiaId();
- }
- };
-
- /**
* Bind les valeurs techniques depuis une entitée vers une autre.
*
* @param from l'entité source
1
0
r2618 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-16 17:56:13 +0200 (Thu, 16 Aug 2012)
New Revision: 2618
Url: http://nuiton.org/repositories/revision/topia/2618
Log:
fixes #2264: Add ToTopiaId function (at last)
fixes #2265: Adds a method to compute the association table name for two different entity contract
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-08-16 12:39:27 UTC (rev 2617)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-08-16 15:56:13 UTC (rev 2618)
@@ -25,6 +25,7 @@
package org.nuiton.topia.persistence.util;
+import com.google.common.base.Function;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
@@ -73,6 +74,19 @@
"%1$s[@" + TopiaEntity.TOPIA_ID + "=\"%2$s\"]";
/**
+ * Function to obtain {@link TopiaEntity#getTopiaId()} form any entity.
+ *
+ * @since 2.6.12
+ */
+ public static final Function<TopiaEntity, String> TO_TOPIAID = new Function<TopiaEntity, String>() {
+
+ @Override
+ public String apply(TopiaEntity input) {
+ return input.getTopiaId();
+ }
+ };
+
+ /**
* Bind les valeurs techniques depuis une entitée vers une autre.
*
* @param from l'entité source
@@ -958,6 +972,7 @@
}
return ids;
}
+
/**
* Construit une list d'entite dont les ids sont tous dans la liste d'ids
* donnee.
@@ -1083,7 +1098,7 @@
Set<Class<? extends TopiaEntity>> interfaces,
Class<? extends TopiaEntity> klass) {
Iterator<Class<? extends TopiaEntity>> iterator = interfaces.iterator();
- for (; iterator.hasNext();) {
+ for (; iterator.hasNext(); ) {
Class<? extends TopiaEntity> next = iterator.next();
if (next.isAssignableFrom(klass)) {
// cette interface herite de klass
@@ -1182,4 +1197,29 @@
index, requiredType, foundType));
}
}
+
+ /**
+ * Given two names (representing two types of entity), obtains the
+ * association table name in the format {@code X_Y} where X est the table
+ * name smaller (in natural order on {@link String}).
+ * <p/>
+ * Example: from {@code A} and {@code B}, we get {@code A_B}.
+ *
+ * @param table1 the first table
+ * @param table2 the second table
+ * @return the normalized association table name
+ * @since 2.6.12
+ */
+ public static String getNormalizedAssociationTableName(String table1,
+ String table2) {
+ String result;
+ if (table1.compareTo(table2) > 0) {
+ // table1 > table 2
+ result = table2 + "_" + table1;
+ } else {
+ // table2 > table1
+ result = table1 + "_" + table2;
+ }
+ return result;
+ }
}
1
0
r2617 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence
by tchemit@users.nuiton.org Aug. 16, 2012
by tchemit@users.nuiton.org Aug. 16, 2012
Aug. 16, 2012
Author: tchemit
Date: 2012-08-16 14:39:27 +0200 (Thu, 16 Aug 2012)
New Revision: 2617
Url: http://nuiton.org/repositories/revision/topia/2617
Log:
fixes #2262: Add method name() on TopiaEntityEnum
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityEnum.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityEnum.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityEnum.java 2012-08-16 12:35:07 UTC (rev 2616)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntityEnum.java 2012-08-16 12:39:27 UTC (rev 2617)
@@ -50,6 +50,16 @@
*/
public interface TopiaEntityEnum extends Serializable {
+ /**
+ * This is a convinient method, as entity enum offers this
+ * method from {@link Enum#name()}.
+ *
+ * @return the name of the underlying entity type.
+ * @since 2.6.12
+ */
+ String name();
+
+
/** @return the contract class of the entity */
Class<? extends TopiaEntity> getContract();
1
0
Author: tchemit
Date: 2012-08-16 14:35:07 +0200 (Thu, 16 Aug 2012)
New Revision: 2616
Url: http://nuiton.org/repositories/revision/topia/2616
Log:
refs #2261: updates to nuiton-utils 2.6 + improve developers section
Modified:
branches/topia-2.6.x/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-08-14 18:55:38 UTC (rev 2615)
+++ branches/topia-2.6.x/pom.xml 2012-08-16 12:35:07 UTC (rev 2616)
@@ -44,14 +44,6 @@
<module>topia-service-replication</module>
<module>topia-service-migration</module>
<module>topia-service-security</module>
- <!--
- TC-20100403 (see Evolution #440)
- since version 2.3.2, those modules are not included until
- they are ready for production and fully useable
- -->
- <!--module>topia-soa</module-->
- <!--module>topia-service-index</module-->
- <!--module>topia-service-history</module-->
</modules>
<name>ToPIA</name>
@@ -68,7 +60,7 @@
<!-- libs version -->
<eugeneVersion>2.5-SNAPSHOT</eugeneVersion>
- <nuitonUtilsVersion>2.5.3</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.6-SNAPSHOT</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
@@ -95,14 +87,18 @@
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
<version>${nuitonUtilsVersion}</version>
- <scope>compile</scope>
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ <version>${nuitonUtilsVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
<version>${nuitonI18nVersion}</version>
- <scope>compile</scope>
</dependency>
<dependency>
@@ -151,7 +147,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${sl4jVersion}</version>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -181,9 +176,10 @@
<developer>
<name>Benjamin Poussin</name>
<id>bpoussin</id>
- <email>poussin(a)codelutin.com</email>
+ <email>poussin at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
<role>Debian packager</role>
@@ -193,9 +189,10 @@
<developer>
<name>Arnaud Thimel</name>
<id>athimel</id>
- <email>thimel(a)codelutin.com</email>
+ <email>thimel at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -204,9 +201,10 @@
<developer>
<name>Julien Ruchaud</name>
<id>jruchaud</id>
- <email>ruchaud(a)codelutin.com</email>
+ <email>ruchaud at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -215,9 +213,10 @@
<developer>
<name>Eric Chatellier</name>
<id>echatellier</id>
- <email>chatellier(a)codelutin.com</email>
+ <email>chatellier at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -226,9 +225,10 @@
<developer>
<name>Tony Chemit</name>
<id>tchemit</id>
- <email>chemit(a)codelutin.com</email>
+ <email>chemit at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -237,9 +237,10 @@
<developer>
<name>Sylvain Letellier</name>
<id>sletellier</id>
- <email>letellier(a)codelutin.com</email>
+ <email>letellier at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Parisrope/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -248,9 +249,10 @@
<developer>
<name>Florian Desbois</name>
<id>fdesbois</id>
- <email>desbois(a)codelutin.com</email>
+ <email>desbois at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -259,9 +261,10 @@
<developer>
<name>Brendan Le Ny</name>
<id>bleny</id>
- <email>bleny(a)codelutin.com</email>
+ <email>bleny at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Développeur</role>
</roles>
@@ -270,9 +273,10 @@
<developer>
<name>Jean Couteau</name>
<id>jcouteau</id>
- <email>couteau(a)codelutin.com</email>
+ <email>couteau at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
<roles>
<role>Documentation writer</role>
</roles>
@@ -282,39 +286,45 @@
<contributors>
<contributor>
<name>Nicolas Dupont</name>
- <email>ndupont(a)codelutin.com</email>
+ <email>ndupont at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
<contributor>
<name>Eduardo Ore</name>
- <email>eore(a)codelutin.com</email>
+ <email>eore at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
<contributor>
<name>Gabriel Landais</name>
- <email>glandais(a)codelutin.com</email>
+ <email>glandais at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
<contributor>
<name>Stéphane Chorlet</name>
- <email>schorlet(a)codelutin.com</email>
+ <email>schorlet at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
<contributor>
<name>Jonathan pepin</name>
- <email>jpepin(a)codelutin.com</email>
+ <email>jpepin at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
<contributor>
<name>Nolwenn Ranou</name>
- <email>nrannou(a)codelutin.com</email>
+ <email>nrannou at codelutin dot com</email>
<organization>CodeLutin</organization>
- <timezone>+2</timezone>
+ <organizationUrl>http://codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
</contributor>
</contributors>
1
0
Author: tchemit
Date: 2012-08-14 20:55:38 +0200 (Tue, 14 Aug 2012)
New Revision: 2615
Url: http://nuiton.org/repositories/revision/topia/2615
Log:
Update mavenpom4redmineAndCentral to 3.3.6.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-14 16:41:46 UTC (rev 2614)
+++ trunk/pom.xml 2012-08-14 18:55:38 UTC (rev 2615)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.5</version>
+ <version>3.3.6</version>
</parent>
<artifactId>topia</artifactId>
1
0
r2614 - branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator
by tchemit@users.nuiton.org Aug. 14, 2012
by tchemit@users.nuiton.org Aug. 14, 2012
Aug. 14, 2012
Author: tchemit
Date: 2012-08-14 18:41:46 +0200 (Tue, 14 Aug 2012)
New Revision: 2614
Url: http://nuiton.org/repositories/revision/topia/2614
Log:
fixes #2257: not null are not generated in XXXEntityEnum is not in naturalId
Modified:
branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java
Modified: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2012-08-14 16:03:27 UTC (rev 2613)
+++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2012-08-14 16:41:46 UTC (rev 2614)
@@ -324,16 +324,17 @@
StringBuilder notNullParams = new StringBuilder();
Set<ObjectModelAttribute> naturalIdsAttributes = TopiaGeneratorUtil.getNaturalIdAttributes(clazz);
- for (ObjectModelAttribute naturalIdAttributes : naturalIdsAttributes) {
+ for (ObjectModelAttribute attribute: naturalIdsAttributes) {
withNatural = true;
// attribut metier
- naturalIdsParams.append(", \"").append(naturalIdAttributes.getName()).append("\"");
- if (TopiaGeneratorUtil.isNotNull(naturalIdAttributes)) {
- withNotNull = true;
- // attribut not-null
- notNullParams.append(", \"").append(naturalIdAttributes.getName()).append("\"");
- }
+ naturalIdsParams.append(", \"").append(attribute.getName()).append("\"");
}
+ Set<ObjectModelAttribute> notNullIdsAttributes = TopiaGeneratorUtil.getNotNullAttributes(clazz);
+ for (ObjectModelAttribute attribute : notNullIdsAttributes) {
+ withNotNull = true;
+ // attribut not-null
+ notNullParams.append(", \"").append(attribute.getName()).append("\"");
+ }
StringBuilder params = new StringBuilder(clazzName + ".class");
if (withNotNull) {
1
0
Aug. 14, 2012
Author: tchemit
Date: 2012-08-14 18:03:27 +0200 (Tue, 14 Aug 2012)
New Revision: 2613
Url: http://nuiton.org/repositories/revision/topia/2613
Log:
fix release build (usage of some sun.xxx classes)
Modified:
branches/topia-2.6.x/topia-service-security/pom.xml
Modified: branches/topia-2.6.x/topia-service-security/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-security/pom.xml 2012-08-14 15:57:26 UTC (rev 2612)
+++ branches/topia-2.6.x/topia-service-security/pom.xml 2012-08-14 16:03:27 UTC (rev 2613)
@@ -132,6 +132,23 @@
</resources>
+ <pluginManagement>
+ <!-- TopiaSecurityutil uses some sun.xxx classes -->
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java16-sun</artifactId>
+ <version>1.10</version>
+ </signature>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
1
0
Aug. 14, 2012
Author: tchemit
Date: 2012-08-14 17:57:26 +0200 (Tue, 14 Aug 2012)
New Revision: 2612
Url: http://nuiton.org/repositories/revision/topia/2612
Log:
refs #2256: updates to eugene 2.5
Modified:
branches/topia-2.6.x/topia-persistence/pom.xml
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-14 15:48:02 UTC (rev 2611)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-14 15:57:26 UTC (rev 2612)
@@ -236,7 +236,7 @@
<defaultPackage>org.nuiton.topia</defaultPackage>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
</executions>
1
0
r2611 - in branches/topia-2.6.x: . topia-persistence topia-persistence/src/it/ANOMALIE-1640 topia-persistence/src/site/rst/user topia-service-security
by tchemit@users.nuiton.org Aug. 14, 2012
by tchemit@users.nuiton.org Aug. 14, 2012
Aug. 14, 2012
Author: tchemit
Date: 2012-08-14 17:48:02 +0200 (Tue, 14 Aug 2012)
New Revision: 2611
Url: http://nuiton.org/repositories/revision/topia/2611
Log:
fixes #2256: updates to eugene 2.5
fixes #2255: updates to mavenpom 3.3.6
fix some docs (use velicoty extension to have maven model properties in generated docs)
Added:
branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst.vm
branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst.vm
branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst.vm
Removed:
branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst
branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst
branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst
Modified:
branches/topia-2.6.x/pom.xml
branches/topia-2.6.x/topia-persistence/pom.xml
branches/topia-2.6.x/topia-persistence/src/it/ANOMALIE-1640/pom.xml
branches/topia-2.6.x/topia-service-security/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/pom.xml 2012-08-14 15:48:02 UTC (rev 2611)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.5</version>
+ <version>3.3.6</version>
</parent>
<artifactId>topia</artifactId>
@@ -67,14 +67,14 @@
<projectId>topia</projectId>
<!-- libs version -->
- <eugeneVersion>2.4.2</eugeneVersion>
- <nuitonUtilsVersion>2.5</nuitonUtilsVersion>
+ <eugeneVersion>2.5-SNAPSHOT</eugeneVersion>
+ <nuitonUtilsVersion>2.5.3</nuitonUtilsVersion>
<processorPluginVersion>1.2.2</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <sl4jVersion>1.6.4</sl4jVersion>
- <h2Version>1.3.167</h2Version>
+ <sl4jVersion>1.6.6</sl4jVersion>
+ <h2Version>1.3.168</h2Version>
<!-- i18n configuration -->
<i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles>
@@ -352,7 +352,7 @@
<plugin>
<groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
+ <artifactId>eugene-maven-plugin</artifactId>
<version>${eugeneVersion}</version>
<configuration>
<inputs>zargo</inputs>
Modified: branches/topia-2.6.x/topia-persistence/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-persistence/pom.xml 2012-08-14 15:48:02 UTC (rev 2611)
@@ -214,7 +214,7 @@
<plugin>
<groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
+ <artifactId>eugene-maven-plugin</artifactId>
<configuration>
</configuration>
Modified: branches/topia-2.6.x/topia-persistence/src/it/ANOMALIE-1640/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/it/ANOMALIE-1640/pom.xml 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-persistence/src/it/ANOMALIE-1640/pom.xml 2012-08-14 15:48:02 UTC (rev 2611)
@@ -109,7 +109,7 @@
<plugins>
<plugin>
<groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
+ <artifactId>eugene-maven-plugin</artifactId>
<version>${eugeneVersion}</version>
<configuration>
<inputs>zargo</inputs>
Deleted: branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst 2012-08-14 15:48:02 UTC (rev 2611)
@@ -1,113 +0,0 @@
-.. -
-.. * #%L
-.. * ToPIA :: Persistence
-.. *
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * Copyright (C) 2004 - 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%
-.. -
-
-======================
-Génération des modèles
-======================
-
-
-Le module "topia-persistence" de topia est capable de
-générer la persistence à partir d'un modèle UML.
-
-Nous allons détailler ici comme inclure la génération dans le
-cycle de compilation maven.
-
-
-Architecture maven
-------------------
-
-+---------------------------------+-----------------------------------------+
-| src/main/xmi/mymodel.zargo | exemple de modele UML avec argoUML |
-+---------------------------------+-----------------------------------------+
-| src/main/xmi/mymodel.properties | fichier de propriétés attaché au modele |
-+---------------------------------|-----------------------------------------+
-
-
-Configuration du pom.xml
-------------------------
-
-Pour générer les sources dans la phase "generate-sources" de maven, et utiliser
-les sources générées, et faut configurer le pom.
-
-Plugin eugene
-=============
-
-::
-
-<plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <!-- la version peut être plus récente -->
- <version>1.0.0</version>
- <executions>
- <execution>
- <id>Generator</id>
- <phase>generate-sources</phase>
- <configuration>
- <srcDirUml>src/main/xmi</srcDirUml>
- <srcXmiDest>target/generated-sources/xmi/</srcXmiDest>
- <fullPackagePath>org.company.package</fullPackagePath>
- <extractedPackages>org.company.package</extractedPackages>
- <srcGenDest>target/generated-sources/objectmodel/</srcGenDest>
- <includes>**/*.objectmodel</includes>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator</templates>
- <destDirGen>target/generated-sources/java</destDirGen>
- <defaultPackage>org.company.package</defaultPackage>
- </configuration>
- <goals>
- <goal>zargo2xmi</goal>
- <goal>xmi2objectmodel</goal>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <!-- la version peut être plus récente -->
- <version>2.2.0</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
-</plugin>
-
-Pour plus d'information à propos d'eugene, merci de consulter le site :
-http://maven-site.nuiton.org/eugene/
-
-Dépendances du projet
-=====================
-
-Il faut enfin ajouter "topia-persistence" en dépendance du projet :
-
-::
-
-<dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <!-- la version peut être plus récente -->
- <version>2.2.0</version>
- <scope>compile</scope>
-</dependency>
Copied: branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst.vm (from rev 2609, branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst.vm (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst.vm 2012-08-14 15:48:02 UTC (rev 2611)
@@ -0,0 +1,102 @@
+.. -
+.. * #%L
+.. * ToPIA :: Persistence
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2004 - 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%
+.. -
+
+======================
+Génération des modèles
+======================
+
+
+Le module "topia-persistence" de topia est capable de
+générer la persistence à partir d'un modèle UML.
+
+Nous allons détailler ici comme inclure la génération dans le
+cycle de compilation maven.
+
+
+Architecture maven
+------------------
+
++---------------------------------+-----------------------------------------+
+| src/main/xmi/mymodel.zargo | exemple de modele UML avec argoUML |
++---------------------------------+-----------------------------------------+
+| src/main/xmi/mymodel.properties | fichier de propriétés attaché au modele |
++---------------------------------|-----------------------------------------+
+
+
+Configuration du pom.xml
+------------------------
+
+Pour générer les sources dans la phase "generate-sources" de maven, et utiliser
+les sources générées, et faut configurer le pom.
+
+Plugin eugene
+=============
+
+::
+
+<plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-maven-plugin</artifactId>
+ <version>${eugeneVersion}</version>
+ <executions>
+ <execution>
+ <id>Generator</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <inputs>zargo</inputs>
+ <fullPackagePath>org.company.package</fullPackagePath>
+ <extractedPackages>org.company.package</extractedPackages>
+ <templates>org.nuiton.topia.generator.TopiaMetaGenerator</templates>
+ <defaultPackage>org.company.package</defaultPackage>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</plugin>
+
+Pour plus d'information à propos d'eugene, merci de consulter le site :
+http://maven-site.nuiton.org/eugene/
+
+Dépendances du projet
+=====================
+
+Il faut enfin ajouter "topia-persistence" en dépendance du projet :
+
+::
+
+<dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${project.version}</version>
+</dependency>
Property changes on: branches/topia-2.6.x/topia-persistence/src/site/rst/user/ModelGeneration.rst.vm
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst 2012-08-14 15:48:02 UTC (rev 2611)
@@ -1,157 +0,0 @@
-.. -
-.. * #%L
-.. * ToPIA :: Persistence
-.. *
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * Copyright (C) 2004 - 2011 CodeLutin, Chatellier Eric
-.. * %%
-.. * 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%
-.. -
-
-======
-How to
-======
-
-Ce document a pour objectif de prendre en main le framework Topia. Le document
-est constitué de 4 parties, la modélisation, la génération, la configuration et
-l'utilisation.
-
-Modélisation
-------------
-
-La première étape constiste à réaliser le modèle UML soit avec Argouml
-(http://argouml.tigris.org) soit avec Poséidon (http://www.gentleware.com)
-
-Le stérotype «entity» sur les classes permet de préciser que la classe est
-persistée par Topia. D'autre stérotypes (extern, service, ...) sont disponibles
-mais ne sont pas présentés.
-
-Le fichier de modélisation peut être complété par un fichier de configuration
-nommé <nom fichier modélisation>.properties. Il contient des informations
-techniques propres aux librairies utilisé par Topia.
-
-Exemple :
-
-::
-
- # Précise comment est mappé un type
- # model.tagvalue.<type java>=<type base de donnée>
- model.tagvalue.java.lang.String=text
-
- # Précise le schema de la base de données par défaut
- # model.tagvalue.dbSchema=<nom schéma>
- model.tagvalue.dbSchema=test
-
- # Précise l'entête de l'ensemble des fichiers générés
- # model.tagvalue.copyright=<valeur>
- model.tagvalue.copyright=/* *##%\n Copyright (C) 2011 Code Lutin\n *##% */
-
- # Force le chargement d'un attribut
- # <nom paquetage>.<nom entité>.attribute.<nom attribut>.tagvalue.lazy=false
- org.codelutin.Person.attribute.association.tagvalue.lazy=false
-
-Génération
-----------
-
-La génération des fichiers Topia se font par l'utilisation du plugin maven
-Eugene_. Ce plugin est disponible sur le repository central.
-
-Configuration du plugin maven :
-
-::
-
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <version>2.3.2</version>
- <executions>
- <execution>
- <phase>process-sources</phase>
- <!--Configuration of model generator-->
- <configuration>
- <inputs>zargo</inputs>
- <fullPackagePath>org.nuiton.topiatest</fullPackagePath>
- <defaultPackage>org.nuiton.topiatest</defaultPackage>
- <extractedPackages>org.nuiton.topiatest</extractedPackages>
- <templates>
- org.nuiton.topia.generator.TopiaMetaTransformer
- </templates>
- </configuration>
- <goals>
- <goal>smart-generate</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>2.5.2</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
-
-Le plugin utilise Eugene_ avec les templates de génération de Topia, le
-fichier argouml ou poséidon doit se trouver dans le répertoire
-``src/main/xmi``. Les fichiers sont générés dans le répertoire
-``target/generated-sources/java``. Il faut préciser au plugin les paquetages
-à traiter avec le ``defaultPackage`` et ``extractedPackages``.
-
-Ajout dans des dépendances de Topia pour la compilation des fichiers générés :
-
-::
-
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>2.5.2</version>
- <scope>compile</scope>
- </dependency>
-
-Pour une classe modélisée, nous retrouvons 6 fichiers :
- * Une interface
- * Une classe abstraite
- * Une implantation
- * Une configuration hibernate
- * Un DAO abstrait
- * Une implantation du DAO
-
-Une classe Helper est aussi générée, permettant l'accès à l'ensemble des DAO.
-
-Configuration
--------------
-
-Un fichier contenant les informations de connexion à la base de données et de
-configuration de Topia doit être créé au niveau des ressources du projet.
-Par convention, ce fichier est nommé ``TopiaContextImpl.properties``.
-
-
-Utilisation
------------
-
-Implantation des méthodes
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Si des méthodes ont été définies dans le modèle de données, il faut créer
-l'implantation correspondante. Le paquetage doit porter le même nom que celui de
-la génération.
-
-
-
-.. _Eugene: http://maven-site.nuiton.org/eugene/
Copied: branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst.vm (from rev 2609, branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst.vm (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst.vm 2012-08-14 15:48:02 UTC (rev 2611)
@@ -0,0 +1,156 @@
+.. -
+.. * #%L
+.. * ToPIA :: Persistence
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2004 - 2011 CodeLutin, Chatellier Eric
+.. * %%
+.. * 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%
+.. -
+
+======
+How to
+======
+
+Ce document a pour objectif de prendre en main le framework Topia. Le document
+est constitué de 4 parties, la modélisation, la génération, la configuration et
+l'utilisation.
+
+Modélisation
+------------
+
+La première étape constiste à réaliser le modèle UML soit avec Argouml
+(http://argouml.tigris.org) soit avec Poséidon (http://www.gentleware.com)
+
+Le stérotype «entity» sur les classes permet de préciser que la classe est
+persistée par Topia. D'autre stérotypes (extern, service, ...) sont disponibles
+mais ne sont pas présentés.
+
+Le fichier de modélisation peut être complété par un fichier de configuration
+nommé <nom fichier modélisation>.properties. Il contient des informations
+techniques propres aux librairies utilisé par Topia.
+
+Exemple :
+
+::
+
+ # Précise comment est mappé un type
+ # model.tagvalue.<type java>=<type base de donnée>
+ model.tagvalue.java.lang.String=text
+
+ # Précise le schema de la base de données par défaut
+ # model.tagvalue.dbSchema=<nom schéma>
+ model.tagvalue.dbSchema=test
+
+ # Précise l'entête de l'ensemble des fichiers générés
+ # model.tagvalue.copyright=<valeur>
+ model.tagvalue.copyright=/* *##%\n Copyright (C) 2011 Code Lutin\n *##% */
+
+ # Force le chargement d'un attribut
+ # <nom paquetage>.<nom entité>.attribute.<nom attribut>.tagvalue.lazy=false
+ org.codelutin.Person.attribute.association.tagvalue.lazy=false
+
+Génération
+----------
+
+La génération des fichiers Topia se font par l'utilisation du plugin maven
+Eugene_. Ce plugin est disponible sur le repository central.
+
+Configuration du plugin maven :
+
+::
+
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-maven-plugin</artifactId>
+ <version>${eugeneVersion}</version>
+ <executions>
+ <execution>
+ <phase>process-sources</phase>
+ <!--Configuration of model generator-->
+ <configuration>
+ <inputs>zargo</inputs>
+ <fullPackagePath>org.nuiton.topiatest</fullPackagePath>
+ <defaultPackage>org.nuiton.topiatest</defaultPackage>
+ <extractedPackages>org.nuiton.topiatest</extractedPackages>
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer
+ </templates>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+Le plugin utilise Eugene_ avec les templates de génération de Topia, le
+fichier argouml ou poséidon doit se trouver dans le répertoire
+``src/main/xmi``. Les fichiers sont générés dans le répertoire
+``target/generated-sources/java``. Il faut préciser au plugin les paquetages
+à traiter avec le ``defaultPackage`` et ``extractedPackages``.
+
+Ajout dans des dépendances de Topia pour la compilation des fichiers générés :
+
+::
+
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>2.5.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+Pour une classe modélisée, nous retrouvons 6 fichiers :
+ * Une interface
+ * Une classe abstraite
+ * Une implantation
+ * Une configuration hibernate
+ * Un DAO abstrait
+ * Une implantation du DAO
+
+Une classe Helper est aussi générée, permettant l'accès à l'ensemble des DAO.
+
+Configuration
+-------------
+
+Un fichier contenant les informations de connexion à la base de données et de
+configuration de Topia doit être créé au niveau des ressources du projet.
+Par convention, ce fichier est nommé ``TopiaContextImpl.properties``.
+
+
+Utilisation
+-----------
+
+Implantation des méthodes
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Si des méthodes ont été définies dans le modèle de données, il faut créer
+l'implantation correspondante. Le paquetage doit porter le même nom que celui de
+la génération.
+
+
+
+.. _Eugene: http://maven-site.nuiton.org/eugene/
Property changes on: branches/topia-2.6.x/topia-persistence/src/site/rst/user/howto.rst.vm
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst 2012-08-14 15:48:02 UTC (rev 2611)
@@ -1,247 +0,0 @@
-.. -
-.. * #%L
-.. * ToPIA :: Persistence
-.. *
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * Copyright (C) 2004 - 2011 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%
-.. -
-
-================================
-Démarrer un projet ToPIA - Maven
-================================
-
-Comment démarrer un projet à partir de rien.
-
-Créer le projet
-===============
-
-Pour commencer, il faut créer un projet maven en respectant les conventions
-habituelles. Partons d'un projet maven vide :
-
-::
-
- mvn archetype:generate -DgroupId=com.masociete -DartifactId=monapplication -DarchetypeArtifactId=maven-archetype-archetype
-
-Ajoutez un dossier ``src/main/xmi``, c'est ici que nous allons placer le modèle.
-
-::
-
- topia-tutorial
- ├── pom.xml
- └── src
- ├── main
- │ ├── java
- │ │ └── org
- │ │ └── nuiton
- │ │ └── topia
- │ │ └── tutorial
- │ │ └── library
- │ ├── resources
- │ │ ├── library-config.properties
- │ │ └── log4j.properties
- │ └── xmi
- │ ├── library.properties
- │ └── library.zargo
- └── test
- ├── java
- └── resources
-
-Dans le pom, on ajoute ToPIA en dépendance, et on configure la génération :
-
-::
-
- <properties>
- <topiaVersion>2.5.4</topiaVersion>
- <eugeneVersion>2.3.3</eugeneVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- <version>${topiaVersion}</version>
- </dependency>
- </dependencies>
-
-
- <plugins>
-
- <!-- ... -->
-
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <version>${eugeneVersion}</version>
- <configuration>
- <inputs>zargo</inputs>
- <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
- </configuration>
- <executions>
- <execution>
- <id>generate-entities</id>
- <phase>generate-sources</phase>
- <configuration>
- <!-- Corresponding to extracted package from zargo file -->
- <fullPackagePath>org.nuiton.topia.tutorial.library</fullPackagePath>
- <!-- DefaultPackage used for DAOHelper generation -->
- <defaultPackage>org.nuiton.topia.tutorial.library.model</defaultPackage>
- <templates>
- org.nuiton.topia.generator.TopiaMetaTransformer
- </templates>
- </configuration>
- <goals>
- <goal>smart-generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
-
-
-Créer le modèle
-===============
-
-Utiliser ArgoUML pour décrire le modèle
----------------------------------------
-
-Avec ArgoUML, créez un nouveau modèle et enregistrez-le dans ``xmi``. Nous
-allons créer un modèle simplifié pour une application de gestion de
-bibliothèque.
-
-Nous avons modélisé les entités ``Book`` et ``Author`` avec les champs
-appropriés. Faites attention à bien placer les entités dans le bon package, sinon
-elles ne seront pas générées. Pour que ToPIA sache que ces classes décrivent
-des entités qui ont vocation à être sauvées en base, il faut leur ajouter le
-stéréotype ``entity``.
-
-N'oubliez pas de donner un nom et une version au modèle.
-
-Les données associées aux éléments du modèle
---------------------------------------------
-
-Le modeleur n'est pas suffisant pour décrire toute les subtilités du modèle.
-Le modèle se voulant indépendant de la plate-forme cible, on ne peut y inclure
-directement des notions spécifiques à ToPIA. C'est pourquoi nous allons pouvoir
-ajouter ces informations spécifiques via le fichier ``library-config.properties``.
-
-
-C'est prêt !
-============
-
-Il suffit de construire l'application avec maven.
-
-::
-
- mvn compile
-
-
-La compilation va provoquer la phase de génération. Si on examine le contenu
-de notre dossier target :
-
-::
-
- topia-tutorial
- ├── pom.xml
- ├── src
- │ ├── main
- │ │ ├── java
- │ │ │ └── org
- │ │ │ └── nuiton
- │ │ │ └── topia
- │ │ │ └── tutorial
- │ │ │ └── library
- │ │ ├── resources
- │ │ │ ├── library-config.properties
- │ │ │ └── log4j.properties
- │ │ └── xmi
- │ │ ├── library.properties
- │ │ └── library.zargo
- │ └── test
- │ ├── java
- │ └── resources
- └── target
- ├── classes
- │ ├── library-config.properties
- │ ├── log4j.properties
- │ └── org
- │ └── nuiton
- │ └── topia
- │ └── tutorial
- │ └── library
- │ ├── LibraryConfig.class
- │ └── model
- │ ├── AuthorAbstract.class
- │ ├── Author.class
- │ ├── AuthorDAOAbstract.class
- │ .
- │ .
- │ .
- └── generated-sources
- ├── annotations
- ├── java
- │ └── org
- │ └── nuiton
- │ └── topia
- │ └── tutorial
- │ └── library
- │ └── model
- │ ├── AuthorAbstract.java
- │ ├── AuthorDAOAbstract.java
- │ ├── AuthorDAOImpl.java
- │ ├── AuthorDAO.java
- │ ├── AuthorImpl.hbm.xml
- │ ├── Author.java
- │ ├── BookAbstract.java
- │ ├── BookDAOAbstract.java
- │ ├── BookDAOImpl.java
- │ ├── BookDAO.java
- │ ├── BookImpl.hbm.xml
- │ ├── BookImpl.java
- │ ├── Book.java
- │ └── LibraryDAOHelper.java
- ├── models
- │ ├── library.objectmodel
- │ └── library.properties
- └── xmi
- ├── library.properties
- └── library.xmi
-
-
-
-On peut voir que ToPIA a généré ``LibraryDAOHelper`` qui va nous permettre de
-récupérer les différents DAO et, pour chaque entité de notre modèle :
- * Une interface
- * Une classe abstraite, qui implémente déjà tout le contrat
- * Une implantation (vide, seulement les constructeurs)
- * Un DAO abstrait
- * Une implantation du DAO
- * Un fichier de mapping hibernate (*.hbm.xml)
-
-Comme il s'agit d'une phase de compilation, maven va ajouter tout le code généré aux
-classpath le code généré sera compilé et lié en même temps que le reste de votre application.
-Tous les fichiers .class se retrouveront dans target/classes, dans la suite du processus, on
-ne distingue plus le code généré du code utilisateur.
-
-Par la suite, si vous changez le modèle, tout sera re-généré. À chaque ``clean``
-via maven, tout ce qui a été généré est effacé. Vous pouvez donc re-généré autant
-de fois que nécessaire. Attention, Maven ne détecte pas le changement du modèle
-si le fichier .zargo a été modifié : il faut donc faire un clean à chaque fois
-afin de forcer le re-génération du modèle dans sa dernière version.
Copied: branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst.vm (from rev 2609, branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst)
===================================================================
--- branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst.vm (rev 0)
+++ branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst.vm 2012-08-14 15:48:02 UTC (rev 2611)
@@ -0,0 +1,247 @@
+.. -
+.. * #%L
+.. * ToPIA :: Persistence
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2004 - 2011 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%
+.. -
+
+================================
+Démarrer un projet ToPIA - Maven
+================================
+
+Comment démarrer un projet à partir de rien.
+
+Créer le projet
+===============
+
+Pour commencer, il faut créer un projet maven en respectant les conventions
+habituelles. Partons d'un projet maven vide :
+
+::
+
+ mvn archetype:generate -DgroupId=com.masociete -DartifactId=monapplication -DarchetypeArtifactId=maven-archetype-archetype
+
+Ajoutez un dossier ``src/main/xmi``, c'est ici que nous allons placer le modèle.
+
+::
+
+ topia-tutorial
+ ├── pom.xml
+ └── src
+ ├── main
+ │ ├── java
+ │ │ └── org
+ │ │ └── nuiton
+ │ │ └── topia
+ │ │ └── tutorial
+ │ │ └── library
+ │ ├── resources
+ │ │ ├── library-config.properties
+ │ │ └── log4j.properties
+ │ └── xmi
+ │ ├── library.properties
+ │ └── library.zargo
+ └── test
+ ├── java
+ └── resources
+
+Dans le pom, on ajoute ToPIA en dépendance, et on configure la génération :
+
+::
+
+ <properties>
+ <topiaVersion>${project.version}</topiaVersion>
+ <eugeneVersion>${eugeneVersion}</eugeneVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topiaVersion}</version>
+ </dependency>
+ </dependencies>
+
+
+ <plugins>
+
+ <!-- ... -->
+
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-maven-plugin</artifactId>
+ <version>${eugeneVersion}</version>
+ <configuration>
+ <inputs>zargo</inputs>
+ <resolver>org.nuiton.util.FasterCachedResourceResolver</resolver>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-entities</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <!-- Corresponding to extracted package from zargo file -->
+ <fullPackagePath>org.nuiton.topia.tutorial.library</fullPackagePath>
+ <!-- DefaultPackage used for DAOHelper generation -->
+ <defaultPackage>org.nuiton.topia.tutorial.library.model</defaultPackage>
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer
+ </templates>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+
+Créer le modèle
+===============
+
+Utiliser ArgoUML pour décrire le modèle
+---------------------------------------
+
+Avec ArgoUML, créez un nouveau modèle et enregistrez-le dans ``xmi``. Nous
+allons créer un modèle simplifié pour une application de gestion de
+bibliothèque.
+
+Nous avons modélisé les entités ``Book`` et ``Author`` avec les champs
+appropriés. Faites attention à bien placer les entités dans le bon package, sinon
+elles ne seront pas générées. Pour que ToPIA sache que ces classes décrivent
+des entités qui ont vocation à être sauvées en base, il faut leur ajouter le
+stéréotype ``entity``.
+
+N'oubliez pas de donner un nom et une version au modèle.
+
+Les données associées aux éléments du modèle
+--------------------------------------------
+
+Le modeleur n'est pas suffisant pour décrire toute les subtilités du modèle.
+Le modèle se voulant indépendant de la plate-forme cible, on ne peut y inclure
+directement des notions spécifiques à ToPIA. C'est pourquoi nous allons pouvoir
+ajouter ces informations spécifiques via le fichier ``library-config.properties``.
+
+
+C'est prêt !
+============
+
+Il suffit de construire l'application avec maven.
+
+::
+
+ mvn compile
+
+
+La compilation va provoquer la phase de génération. Si on examine le contenu
+de notre dossier target :
+
+::
+
+ topia-tutorial
+ ├── pom.xml
+ ├── src
+ │ ├── main
+ │ │ ├── java
+ │ │ │ └── org
+ │ │ │ └── nuiton
+ │ │ │ └── topia
+ │ │ │ └── tutorial
+ │ │ │ └── library
+ │ │ ├── resources
+ │ │ │ ├── library-config.properties
+ │ │ │ └── log4j.properties
+ │ │ └── xmi
+ │ │ ├── library.properties
+ │ │ └── library.zargo
+ │ └── test
+ │ ├── java
+ │ └── resources
+ └── target
+ ├── classes
+ │ ├── library-config.properties
+ │ ├── log4j.properties
+ │ └── org
+ │ └── nuiton
+ │ └── topia
+ │ └── tutorial
+ │ └── library
+ │ ├── LibraryConfig.class
+ │ └── model
+ │ ├── AuthorAbstract.class
+ │ ├── Author.class
+ │ ├── AuthorDAOAbstract.class
+ │ .
+ │ .
+ │ .
+ └── generated-sources
+ ├── annotations
+ ├── java
+ │ └── org
+ │ └── nuiton
+ │ └── topia
+ │ └── tutorial
+ │ └── library
+ │ └── model
+ │ ├── AuthorAbstract.java
+ │ ├── AuthorDAOAbstract.java
+ │ ├── AuthorDAOImpl.java
+ │ ├── AuthorDAO.java
+ │ ├── AuthorImpl.hbm.xml
+ │ ├── Author.java
+ │ ├── BookAbstract.java
+ │ ├── BookDAOAbstract.java
+ │ ├── BookDAOImpl.java
+ │ ├── BookDAO.java
+ │ ├── BookImpl.hbm.xml
+ │ ├── BookImpl.java
+ │ ├── Book.java
+ │ └── LibraryDAOHelper.java
+ ├── models
+ │ ├── library.objectmodel
+ │ └── library.properties
+ └── xmi
+ ├── library.properties
+ └── library.xmi
+
+
+
+On peut voir que ToPIA a généré ``LibraryDAOHelper`` qui va nous permettre de
+récupérer les différents DAO et, pour chaque entité de notre modèle :
+ * Une interface
+ * Une classe abstraite, qui implémente déjà tout le contrat
+ * Une implantation (vide, seulement les constructeurs)
+ * Un DAO abstrait
+ * Une implantation du DAO
+ * Un fichier de mapping hibernate (*.hbm.xml)
+
+Comme il s'agit d'une phase de compilation, maven va ajouter tout le code généré aux
+classpath le code généré sera compilé et lié en même temps que le reste de votre application.
+Tous les fichiers .class se retrouveront dans target/classes, dans la suite du processus, on
+ne distingue plus le code généré du code utilisateur.
+
+Par la suite, si vous changez le modèle, tout sera re-généré. À chaque ``clean``
+via maven, tout ce qui a été généré est effacé. Vous pouvez donc re-généré autant
+de fois que nécessaire. Attention, Maven ne détecte pas le changement du modèle
+si le fichier .zargo a été modifié : il faut donc faire un clean à chaque fois
+afin de forcer le re-génération du modèle dans sa dernière version.
Property changes on: branches/topia-2.6.x/topia-persistence/src/site/rst/user/start.rst.vm
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: branches/topia-2.6.x/topia-service-security/pom.xml
===================================================================
--- branches/topia-2.6.x/topia-service-security/pom.xml 2012-08-14 15:45:47 UTC (rev 2610)
+++ branches/topia-2.6.x/topia-service-security/pom.xml 2012-08-14 15:48:02 UTC (rev 2611)
@@ -119,8 +119,6 @@
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
- <packaging>jar</packaging>
-
<build>
<resources>
@@ -138,7 +136,7 @@
<plugin>
<groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
+ <artifactId>eugene-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
@@ -152,7 +150,7 @@
<overwrite>true</overwrite>
</configuration>
<goals>
- <goal>smart-generate</goal>
+ <goal>generate</goal>
</goals>
</execution>
</executions>
1
0
Author: tchemit
Date: 2012-08-14 17:45:47 +0200 (Tue, 14 Aug 2012)
New Revision: 2610
Url: http://nuiton.org/repositories/revision/topia/2610
Log:
remove from svn old modules (don't worry nothing is lost)
Removed:
branches/topia-2.6.x/topia-service-history/
branches/topia-2.6.x/topia-service-index/
branches/topia-2.6.x/topia-soa/
branches/topia-2.6.x/topia-tutorial/
1
0
Author: tchemit
Date: 2012-08-07 09:51:41 +0200 (Tue, 07 Aug 2012)
New Revision: 2609
Url: http://nuiton.org/repositories/revision/topia/2609
Log:
Update mavenpom4redmine to 3.3.5.
Modified:
branches/topia-2.6.x/pom.xml
Modified: branches/topia-2.6.x/pom.xml
===================================================================
--- branches/topia-2.6.x/pom.xml 2012-08-07 07:51:38 UTC (rev 2608)
+++ branches/topia-2.6.x/pom.xml 2012-08-07 07:51:41 UTC (rev 2609)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.4</version>
+ <version>3.3.5</version>
</parent>
<artifactId>topia</artifactId>
1
0
Author: tchemit
Date: 2012-08-07 09:51:38 +0200 (Tue, 07 Aug 2012)
New Revision: 2608
Url: http://nuiton.org/repositories/revision/topia/2608
Log:
Update mavenpom4redmine to 3.3.5.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-09 16:44:29 UTC (rev 2607)
+++ trunk/pom.xml 2012-08-07 07:51:38 UTC (rev 2608)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.4</version>
+ <version>3.3.5</version>
</parent>
<artifactId>topia</artifactId>
1
0