Echobase-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- 1820 discussions
r122 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor echobase-ui/src/main/resources/config
by tchemit@users.forge.codelutin.com 25 Nov '11
by tchemit@users.forge.codelutin.com 25 Nov '11
25 Nov '11
Author: tchemit
Date: 2011-11-25 13:09:41 +0100 (Fri, 25 Nov 2011)
New Revision: 122
Url: http://forge.codelutin.com/repositories/revision/echobase/122
Log:
-fix dbeditor save operation
-fix action mapping
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-25 11:51:24 UTC (rev 121)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-25 12:09:41 UTC (rev 122)
@@ -230,8 +230,7 @@
"Modification utilisateur",
entity,
user,
- false,
- null
+ false
);
commitTransaction("Could not commit transaction");
}
@@ -260,13 +259,20 @@
try {
while (iterator.hasNext()) {
TopiaEntity entity = iterator.next();
- saveEntity(tableMeta,
- messagePrefix,
- entity,
- user,
- createIfNotFound,
- result
+ boolean create = saveEntity(tableMeta,
+ messagePrefix,
+ entity,
+ user,
+ createIfNotFound
);
+
+ if (create) {
+
+ result.incrementsNumberCreated();
+ } else {
+
+ result.incrementsNumberUpdated();
+ }
}
} finally {
@@ -303,12 +309,11 @@
}
}
- protected void saveEntity(TableMeta tableMeta,
- String messagePrefix,
- TopiaEntity entity,
- EchoBaseUser user,
- boolean createIfNotFound,
- CsvImportResult result) {
+ protected boolean saveEntity(TableMeta tableMeta,
+ String messagePrefix,
+ TopiaEntity entity,
+ EchoBaseUser user,
+ boolean createIfNotFound) {
String[] columnNames = tableMeta.getColumnNamesAsArray();
BeanMonitor monitor = null;
@@ -322,10 +327,11 @@
// Find or create entity if no id
boolean create = StringUtils.isEmpty(id);
+
if (create) {
entityToSave = dao.create();
- result.incrementsNumberCreated();
+
} else {
entityToSave = dao.findByTopiaId(id);
@@ -337,14 +343,16 @@
throw new EchoBaseTechnicalException("Could not found entity with id " + id);
} else {
entityToSave = dao.create(TopiaEntity.TOPIA_ID, id);
-
+ create = true;
}
}
+ }
+
+ if (!create) {
+
// monitor the existing bean
monitor = new BeanMonitor(columnNames);
monitor.setBean(entityToSave);
-
- result.incrementsNumberUpdated();
}
tableMeta.copy(entity, entityToSave);
@@ -359,6 +367,7 @@
user,
propertyDiffs
);
+ return create;
} catch (Exception eee) {
throw new EchoBaseTechnicalException("Could not update entity", eee);
} finally {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-11-25 11:51:24 UTC (rev 121)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-11-25 12:09:41 UTC (rev 122)
@@ -55,6 +55,10 @@
protected Map<String, String[]> params;
+ public EchoBaseEntityEnum getEntityType() {
+ return entityType;
+ }
+
public void setEntityType(EchoBaseEntityEnum entityType) {
this.entityType = entityType;
}
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-25 11:51:24 UTC (rev 121)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-25 12:09:41 UTC (rev 122)
@@ -36,7 +36,7 @@
class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
<param name="namespace">/dbeditor</param>
<param name="actionName">dbeditor</param>
- <param name="tableName">${tableName}</param>
+ <param name="entityType">${entityType}</param>
<param name="supressEmptyParameters">true</param>
</result-type>
</result-types>
1
0
r121 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/export
by tchemit@users.forge.codelutin.com 25 Nov '11
by tchemit@users.forge.codelutin.com 25 Nov '11
25 Nov '11
Author: tchemit
Date: 2011-11-25 12:51:24 +0100 (Fri, 25 Nov 2011)
New Revision: 121
Url: http://forge.codelutin.com/repositories/revision/echobase/121
Log:
- fix sql export
- fix submit value
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java 2011-11-25 09:36:01 UTC (rev 120)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java 2011-11-25 11:51:24 UTC (rev 121)
@@ -51,7 +51,8 @@
for (String columnHeader : columnHeaders) {
modelBuilder.newColumnForExport(
columnHeader,
- columnHeader
+ columnHeader,
+ CsvModelUtil.TO_STRING_FORMATTER
);
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-25 09:36:01 UTC (rev 120)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-25 11:51:24 UTC (rev 121)
@@ -39,6 +39,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-25 09:36:01 UTC (rev 120)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-25 11:51:24 UTC (rev 121)
@@ -107,18 +107,19 @@
if (sqlQueries.isEmpty()) {
// no query saved
addActionMessage(_("echobase.info.no.sqlQuery.saved"));
- }
+ } else {
- String selectedQueryId = getQuery().getTopiaId();
+ String selectedQueryId = getQuery().getTopiaId();
- if (StringUtils.isEmpty(selectedQueryId)) {
+ if (StringUtils.isEmpty(selectedQueryId)) {
- // no query selected
- addActionMessage(_("echobase.info.no.sqlQuery.selected"));
- } else {
+ // no query selected
+ addActionMessage(_("echobase.info.no.sqlQuery.selected"));
+ } else {
- // load query from database
- query = service.getEntityById(ExportQuery.class, selectedQueryId);
+ // load query from database
+ query = service.getEntityById(ExportQuery.class, selectedQueryId);
+ }
}
}
}
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-25 09:36:01 UTC (rev 120)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-25 11:51:24 UTC (rev 121)
@@ -52,7 +52,7 @@
echobase.header.user.gridTitle=Liste des utilisateurs
echobase.header.voyageSelect=Selectionnez une campagne
echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données
-echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré
+echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistrée
echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée
echobase.info.no.table.selected=Aucune table sélectionnée
echobase.label.createIfNotFound=Créer les entités non trouvées en base
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-25 09:36:01 UTC (rev 120)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-25 11:51:24 UTC (rev 121)
@@ -45,7 +45,7 @@
<s:hidden key="sql" label=""/>
<s:textfield key="fileName" required="true" size="100"
label="%{getText('echobase.label.exportFileName')}"/>
- <s:submit key="echobase.action.exportSqlData" align="left"/>
+ <s:submit value="%{getText('echobase.action.exportSqlData')}" align="left"/>
<br/>
<sjg:grid id="rows" caption="%{getText('echobase.header.request.result')}"
dataType="json" href="%{loadUrl}" gridModel="datas"
1
0
r120 - in trunk/echobase-entities/src: main/resources/i18n test/java/fr/ifremer/echobase/entities
by tchemit@users.forge.codelutin.com 25 Nov '11
by tchemit@users.forge.codelutin.com 25 Nov '11
25 Nov '11
Author: tchemit
Date: 2011-11-25 10:36:01 +0100 (Fri, 25 Nov 2011)
New Revision: 120
Url: http://forge.codelutin.com/repositories/revision/echobase/120
Log:
i18n + svn properties
Modified:
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-25 09:00:46 UTC (rev 119)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-25 09:36:01 UTC (rev 120)
@@ -4,8 +4,7 @@
echobase.common.acquisitionSoftwareVersion=
echobase.common.addOffset=
echobase.common.admin=Administrateur
-echobase.common.age=
-echobase.common.ageClass=ageClass
+echobase.common.age=Age
echobase.common.aggregationHierarchy=
echobase.common.aggregationLevel=
echobase.common.aggregationLevelName=
@@ -41,12 +40,9 @@
echobase.common.cellType=
echobase.common.citation=
echobase.common.classCode=
-echobase.common.classGroupId=
-echobase.common.classMeaning=
echobase.common.codeMemo=
echobase.common.comment=
echobase.common.commonName=
-echobase.common.count=
echobase.common.data=data
echobase.common.dataAcquisition=dataAcquisition
echobase.common.dataCentre=
@@ -63,7 +59,6 @@
echobase.common.dateCreated=
echobase.common.datum=datum
echobase.common.depthStratum=depthStratum
-echobase.common.depthStratumId=
echobase.common.depthStratumMeaning=
echobase.common.depthStratumType=
echobase.common.description=Description
@@ -82,12 +77,7 @@
echobase.common.elevationRatio=
echobase.common.email=Courriel
echobase.common.endDate=
-echobase.common.endPort=
echobase.common.endTimeFillageEngin=
-echobase.common.engine=
-echobase.common.engineCaracteristic=
-echobase.common.engineParameter=
-echobase.common.engineType=
echobase.common.entityId=Identifiant de l'entité
echobase.common.entityModificationLog=Journal des modifications
echobase.common.entityModificationLogDTO=
@@ -119,21 +109,14 @@
echobase.common.iMO=
echobase.common.id=Identifiant
echobase.common.impacte=
-echobase.common.individu=
echobase.common.individual=
-echobase.common.individualMeasureParameter=
-echobase.common.individualMeasureParameterValue=
echobase.common.individualValue=
echobase.common.institution=
echobase.common.keywords=
echobase.common.label=
echobase.common.lastModifiedDate=Date de dernière modification
echobase.common.lastModifiedUser=Utilisateur de dernière modification
-echobase.common.latitudeEndFillageEngin=
-echobase.common.latitudeStartFillageEngin=
echobase.common.length=
-echobase.common.lengthClass=lengthClass
-echobase.common.libelle=
echobase.common.licence=
echobase.common.linestring=
echobase.common.localisation=
@@ -144,40 +127,32 @@
echobase.common.loggedDataDatatype=
echobase.common.loggedDataFormat=
echobase.common.longName=
-echobase.common.longitudeEndFillageEngin=
-echobase.common.longitudeStartFillageEngin=
echobase.common.meaning=
-echobase.common.measureStep=
echobase.common.measureType=
-echobase.common.measureUnit=
echobase.common.measurementBinSize=
echobase.common.measurementMetadata=
echobase.common.measurementMetadataName=
echobase.common.measurementTypeName=
echobase.common.measurementUnit=
echobase.common.metadata=metadata
-echobase.common.metadataClass=metadataClass
echobase.common.mission=mission
echobase.common.missionAbstract=
echobase.common.missionName=
echobase.common.missionReferences=
echobase.common.modificationDate=Date de modification
echobase.common.modificationText=Modification
-echobase.common.modificationUser=
+echobase.common.modificationUser=Utilisateur
echobase.common.name=Nom
echobase.common.notes=
echobase.common.numberAtAge=
echobase.common.numberAtLength=
echobase.common.numberSampled=
echobase.common.operation=
-echobase.common.operationEngineParameterValue=
echobase.common.operationGearMetadataValue=
echobase.common.operationMeasurementMetadataValue=
echobase.common.operationMetadata=
echobase.common.operationMetadataName=
echobase.common.operationMetadataValue=
-echobase.common.operationParameter=
-echobase.common.operationParameterValue=
echobase.common.operationType=
echobase.common.operationTypeName=
echobase.common.operator=
@@ -198,35 +173,27 @@
echobase.common.referenceMeaning=
echobase.common.referenceType=
echobase.common.referenceValue=
-echobase.common.references=
echobase.common.referencingMethod=
-echobase.common.region=region
-echobase.common.regionName=
echobase.common.relatedActivity=
echobase.common.sample=
echobase.common.sampleAge=
echobase.common.sampleAggregation=
-echobase.common.sampleCSJ=
echobase.common.sampleLength=
echobase.common.sampleWeight=
echobase.common.scaleFactor=
-echobase.common.scientistName=
echobase.common.seafloorSubstrate=
echobase.common.size=
echobase.common.soundSpeedCalculations=
echobase.common.sounderConstant=
echobase.common.source=
-echobase.common.species=
-echobase.common.speciesClass=speciesClass
-echobase.common.sqlQuery=Requête SQL
+echobase.common.species=espèce
+echobase.common.sqlQuery=requête SQL
echobase.common.standardName=
echobase.common.startDate=
-echobase.common.startPort=
echobase.common.startTimeFillageEngin=
echobase.common.station=station
echobase.common.stationStartLatitude=
echobase.common.stationStartLongitude=
-echobase.common.surface=
echobase.common.timeCoverageEnd=
echobase.common.timeCoverageStart=
echobase.common.title=
@@ -270,11 +237,9 @@
echobase.common.transitStartTime=
echobase.common.transitVessel=
echobase.common.units=
-echobase.common.user=Utilisateur
echobase.common.validMax=
echobase.common.validMin=
echobase.common.value=
-echobase.common.vernacullaireName=
echobase.common.vessel=Navire
echobase.common.vesselCode=
echobase.common.vesselEnginePower=
@@ -282,7 +247,6 @@
echobase.common.vesselName=
echobase.common.vesselNoiseDesign=
echobase.common.vesselTonnage=
-echobase.common.vesselTransit=
echobase.common.vesselType=
echobase.common.voyage=Campagne
echobase.common.voyageDescription=Description de campagne
@@ -291,5 +255,4 @@
echobase.common.voyageName=Nom de la campagne
echobase.common.voyageStartDate=Date de début de campagne
echobase.common.voyageStartHarbour=Port de début de campagne
-echobase.common.weight=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java
===================================================================
--- trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java 2011-11-25 09:00:46 UTC (rev 119)
+++ trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java 2011-11-25 09:36:01 UTC (rev 120)
@@ -1,3 +1,26 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package fr.ifremer.echobase.entities;
import com.google.common.collect.Lists;
Property changes on: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r119 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase/entities echobase-entities/src/main/resources/i18n echobase-entities/src/main/xmi echobase-entities/src/test/java/fr/ifremer/echobase echobase-entities/src/test/java/fr/ifremer/echobase/entities echobase-services/src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 25 Nov '11
by tchemit@users.forge.codelutin.com 25 Nov '11
25 Nov '11
Author: tchemit
Date: 2011-11-25 10:00:46 +0100 (Fri, 25 Nov 2011)
New Revision: 119
Url: http://forge.codelutin.com/repositories/revision/echobase/119
Log:
- fix model (some properties are reserved keyword on pg)
- add tests
- prune some empty directories
Added:
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java
Removed:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-11-24 23:43:49 UTC (rev 118)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-11-25 09:00:46 UTC (rev 119)
@@ -24,9 +24,7 @@
package fr.ifremer.echobase.entities;
import com.google.common.collect.Lists;
-import org.nuiton.topia.persistence.TopiaEntity;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -38,11 +36,13 @@
public class EntitiesUtil {
/**
- * @return the entity types of reference in correct order for replication
+ * @return the entity types of data in correct order for replication
* purpose.
*/
- public static EchoBaseEntityEnum[] getReferenceTypes() {
+ public static EchoBaseEntityEnum[] getDataTypes() {
+
List<EchoBaseEntityEnum> result = Lists.newLinkedList();
+
result.add(EchoBaseEntityEnum.Voyage);
result.add(EchoBaseEntityEnum.Echotype);
result.add(EchoBaseEntityEnum.EchotypeDepthStratum);
@@ -69,10 +69,10 @@
}
/**
- * @return the entity types of data in correct order for replication
+ * @return the entity types of reference in correct order for replication
* purpose.
*/
- public static EchoBaseEntityEnum[] getDataTypes() {
+ public static EchoBaseEntityEnum[] getReferenceTypes() {
List<EchoBaseEntityEnum> result = Lists.newLinkedList();
result.add(EchoBaseEntityEnum.Mission);
result.add(EchoBaseEntityEnum.AcousticInstrument);
@@ -97,7 +97,6 @@
result.add(EchoBaseEntityEnum.Localisation);
result.add(EchoBaseEntityEnum.MeasurementMetadata);
result.add(EchoBaseEntityEnum.MeasureType);
- result.add(EchoBaseEntityEnum.Mission);
result.add(EchoBaseEntityEnum.OperationMetadata);
result.add(EchoBaseEntityEnum.OperationType);
result.add(EchoBaseEntityEnum.ReferenceDatum);
@@ -108,23 +107,5 @@
return result.toArray(new EchoBaseEntityEnum[result.size()]);
}
- /**
- * Used to get all contract of a package
- *
- * @param entitiesPackage package contening desired entities
- * @return contracts contained in entitiesPackage
- */
- public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) {
- EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values();
- List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>();
- for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) {
- // Get all entities in package fr.ifremer.echobase.entities.references
- Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract();
- if (contract.getPackage().equals(entitiesPackage)) {
- refClasses.add(echoBaseEntityEnum);
- }
- }
- return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]);
- }
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java 2011-11-24 23:43:49 UTC (rev 118)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java 2011-11-25 09:00:46 UTC (rev 119)
@@ -40,7 +40,7 @@
result.setEntityId(getEntityId());
result.setModificationDate(getModificationDate());
result.setModificationText(getModificationText());
- result.setUser(getUser().toDTO());
+ result.setModificationUser(getModificationUser().toDTO());
return result;
}
}
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-24 23:43:49 UTC (rev 118)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-25 09:00:46 UTC (rev 119)
@@ -160,8 +160,10 @@
echobase.common.mission=mission
echobase.common.missionAbstract=
echobase.common.missionName=
+echobase.common.missionReferences=
echobase.common.modificationDate=Date de modification
echobase.common.modificationText=Modification
+echobase.common.modificationUser=
echobase.common.name=Nom
echobase.common.notes=
echobase.common.numberAtAge=
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Added: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java
===================================================================
--- trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java (rev 0)
+++ trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/EntitiesUtilTest.java 2011-11-25 09:00:46 UTC (rev 119)
@@ -0,0 +1,74 @@
+package fr.ifremer.echobase.entities;
+
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.references.Mission;
+import junit.framework.Assert;
+import org.junit.Test;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * To test the class {@link EntitiesUtil}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class EntitiesUtilTest {
+
+ @Test
+ public void getReferenceTypes() {
+
+ EchoBaseEntityEnum[] types = EntitiesUtil.getReferenceTypes();
+
+ List<EchoBaseEntityEnum> expectedTypes =
+ Lists.newArrayList(getContractsOf(Mission.class.getPackage()));
+
+ Assert.assertNotNull(types);
+ Assert.assertEquals(expectedTypes.size(), types.length);
+
+ for (EchoBaseEntityEnum referenceType : types) {
+ Assert.assertTrue("Missing type : " + referenceType,
+ expectedTypes.contains(referenceType));
+ }
+ }
+
+ @Test
+ public void getDataTypes() {
+
+ EchoBaseEntityEnum[] types = EntitiesUtil.getDataTypes();
+
+ List<EchoBaseEntityEnum> expectedTypes =
+ Lists.newArrayList(getContractsOf(Voyage.class.getPackage()));
+
+ Assert.assertNotNull(types);
+ Assert.assertEquals(expectedTypes.size(), types.length);
+
+ for (EchoBaseEntityEnum referenceType : types) {
+ Assert.assertTrue("Missing type : " + referenceType,
+ expectedTypes.contains(referenceType));
+ }
+ }
+
+ /**
+ * Used to get all contract of a package
+ *
+ * @param entitiesPackage package contening desired entities
+ * @return contracts contained in entitiesPackage
+ */
+ public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) {
+ EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values();
+ List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>();
+ for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) {
+
+ // Get all entities in package fr.ifremer.echobase.entities.references
+ Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract();
+ if (entitiesPackage.equals(contract.getPackage())) {
+ refClasses.add(echoBaseEntityEnum);
+ }
+ }
+ return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]);
+ }
+}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-24 23:43:49 UTC (rev 118)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-25 09:00:46 UTC (rev 119)
@@ -427,7 +427,7 @@
dao.create(
EntityModificationLog.PROPERTY_ENTITY_TYPE, tableMeta.getEntityEnum().name(),
EntityModificationLog.PROPERTY_ENTITY_ID, topiaId,
- EntityModificationLog.PROPERTY_USER, user,
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user,
EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
);
1
0
Author: tchemit
Date: 2011-11-25 00:43:49 +0100 (Fri, 25 Nov 2011)
New Revision: 118
Url: http://forge.codelutin.com/repositories/revision/echobase/118
Log:
optimize dependencies
Modified:
trunk/echobase-entities/pom.xml
Modified: trunk/echobase-entities/pom.xml
===================================================================
--- trunk/echobase-entities/pom.xml 2011-11-24 23:42:22 UTC (rev 117)
+++ trunk/echobase-entities/pom.xml 2011-11-24 23:43:49 UTC (rev 118)
@@ -56,10 +56,10 @@
<artifactId>commons-collections</artifactId>
</dependency-->
- <dependency>
+ <!--dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- </dependency>
+ </dependency-->
<dependency>
<groupId>com.google.guava</groupId>
1
0
24 Nov '11
Author: tchemit
Date: 2011-11-25 00:42:22 +0100 (Fri, 25 Nov 2011)
New Revision: 117
Url: http://forge.codelutin.com/repositories/revision/echobase/117
Log:
- do not expose entities module as test just to obtain basedir :(
- avoid to create a class for one method
- do NOT use a none hand build entity types for replication
- optimize dependencies
Added:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java
Removed:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
Modified:
trunk/echobase-entities/pom.xml
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-services/pom.xml
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
trunk/echobase-ui/pom.xml
Modified: trunk/echobase-entities/pom.xml
===================================================================
--- trunk/echobase-entities/pom.xml 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-entities/pom.xml 2011-11-24 23:42:22 UTC (rev 117)
@@ -54,12 +54,12 @@
<!--dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- </dependency>
+ </dependency-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- </dependency-->
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -132,19 +132,8 @@
<build>
<plugins>
+
<plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-test</id>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<groupId>org.nuiton.eugene</groupId>
<artifactId>maven-eugene-plugin</artifactId>
<configuration>
@@ -212,13 +201,6 @@
</plugins>
- <testResources>
- <testResource>
- <directory>${maven.src.dir}/test/resources</directory>
- <filtering>true</filtering>
- </testResource>
- </testResources>
-
</build>
</project>
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -23,13 +23,14 @@
*/
package fr.ifremer.echobase.entities;
+import com.google.common.collect.Lists;
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.ArrayList;
import java.util.List;
/**
- * Utility method for enities
+ * Utility method for entities.
*
* @author sletellier <letellier(a)codelutin.com>
* @since 0.2
@@ -37,6 +38,77 @@
public class EntitiesUtil {
/**
+ * @return the entity types of reference in correct order for replication
+ * purpose.
+ */
+ public static EchoBaseEntityEnum[] getReferenceTypes() {
+ List<EchoBaseEntityEnum> result = Lists.newLinkedList();
+ result.add(EchoBaseEntityEnum.Voyage);
+ result.add(EchoBaseEntityEnum.Echotype);
+ result.add(EchoBaseEntityEnum.EchotypeDepthStratum);
+ result.add(EchoBaseEntityEnum.Transit);
+ result.add(EchoBaseEntityEnum.TransitVessel);
+ result.add(EchoBaseEntityEnum.Transect);
+ result.add(EchoBaseEntityEnum.TransectAcousticInstrument);
+ result.add(EchoBaseEntityEnum.DataAcquisition);
+ result.add(EchoBaseEntityEnum.DataProcessing);
+ result.add(EchoBaseEntityEnum.Cell);
+ result.add(EchoBaseEntityEnum.Data);
+ result.add(EchoBaseEntityEnum.Operation);
+ result.add(EchoBaseEntityEnum.OperationMetadataValue);
+ result.add(EchoBaseEntityEnum.OperationMeasurementMetadataValue);
+ result.add(EchoBaseEntityEnum.Individual);
+ result.add(EchoBaseEntityEnum.OperationGearMetadataValue);
+ result.add(EchoBaseEntityEnum.Sample);
+ result.add(EchoBaseEntityEnum.SampleAge);
+ result.add(EchoBaseEntityEnum.SampleLength);
+ result.add(EchoBaseEntityEnum.SampleAggregation);
+ result.add(EchoBaseEntityEnum.AggregationLevel);
+
+ return result.toArray(new EchoBaseEntityEnum[result.size()]);
+ }
+
+ /**
+ * @return the entity types of data in correct order for replication
+ * purpose.
+ */
+ public static EchoBaseEntityEnum[] getDataTypes() {
+ List<EchoBaseEntityEnum> result = Lists.newLinkedList();
+ result.add(EchoBaseEntityEnum.Mission);
+ result.add(EchoBaseEntityEnum.AcousticInstrument);
+ result.add(EchoBaseEntityEnum.AreaOfOperation);
+ result.add(EchoBaseEntityEnum.Calibration);
+ result.add(EchoBaseEntityEnum.Category);
+ result.add(EchoBaseEntityEnum.CategoryMeaning);
+ result.add(EchoBaseEntityEnum.CategoryRef);
+ result.add(EchoBaseEntityEnum.CategoryType);
+ result.add(EchoBaseEntityEnum.CellMethod);
+ result.add(EchoBaseEntityEnum.CellType);
+ result.add(EchoBaseEntityEnum.DataMetadata);
+ result.add(EchoBaseEntityEnum.DataMetadataName);
+ result.add(EchoBaseEntityEnum.DataQuality);
+ result.add(EchoBaseEntityEnum.DepthStratum);
+ result.add(EchoBaseEntityEnum.DepthStratumType);
+ result.add(EchoBaseEntityEnum.Gear);
+ result.add(EchoBaseEntityEnum.GearMetadata);
+ result.add(EchoBaseEntityEnum.GearMetadataValue);
+ result.add(EchoBaseEntityEnum.GearType);
+ result.add(EchoBaseEntityEnum.Impacte);
+ result.add(EchoBaseEntityEnum.Localisation);
+ result.add(EchoBaseEntityEnum.MeasurementMetadata);
+ result.add(EchoBaseEntityEnum.MeasureType);
+ result.add(EchoBaseEntityEnum.Mission);
+ result.add(EchoBaseEntityEnum.OperationMetadata);
+ result.add(EchoBaseEntityEnum.OperationType);
+ result.add(EchoBaseEntityEnum.ReferenceDatum);
+ result.add(EchoBaseEntityEnum.ReferencingMethod);
+ result.add(EchoBaseEntityEnum.Species);
+ result.add(EchoBaseEntityEnum.Station);
+ result.add(EchoBaseEntityEnum.Vessel);
+ return result.toArray(new EchoBaseEntityEnum[result.size()]);
+ }
+
+ /**
* Used to get all contract of a package
*
* @param entitiesPackage package contening desired entities
Deleted: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -1,45 +0,0 @@
-/*
- * #%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 Affero 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 Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.entities.data;
-
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import fr.ifremer.echobase.entities.EntitiesUtil;
-
-/**
- * Data method utility
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.2
- */
-public class DataUtil {
-
- /**
- * Used to get all contract of a data package
- *
- * @return contracts in package data
- */
- public static EchoBaseEntityEnum[] getDataContracts() {
- return EntitiesUtil.getContractsOf(DataUtil.class.getPackage());
- }
-}
Deleted: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -1,45 +0,0 @@
-/*
- * #%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 Affero 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 Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.entities.references;
-
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import fr.ifremer.echobase.entities.EntitiesUtil;
-
-/**
- * References method utility
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.2
- */
-public class ReferencesUtil {
-
- /**
- * Used to get all contract of a referenciel package
- *
- * @return contracts in package referenciel
- */
- public static EchoBaseEntityEnum[] getReferencielContracts() {
- return EntitiesUtil.getContractsOf(ReferencesUtil.class.getPackage());
- }
-}
Deleted: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
===================================================================
--- trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -1,54 +0,0 @@
-/*
- * #%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 Affero 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 Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Ignore;
-
-import java.io.File;
-
-/**
- * Utility methods for tests
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.2
- */
-@Ignore
-public class TestHelper {
-
- protected static File basedir;
-
- public static File getBasedir() {
- if (basedir == null) {
-// String tmp = System.getProperty("basedir");
-// if (tmp == null) {
-// tmp = new File("").getAbsolutePath();
-// }
-// basedir = new File(tmp);
- basedir = FileUtils.getTempDirectory();
- }
- return basedir;
- }
-
-}
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-services/pom.xml 2011-11-24 23:42:22 UTC (rev 117)
@@ -24,14 +24,6 @@
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>echobase-entities</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
-
<!--dependency>
<groupId>fr.ird</groupId>
<artifactId>msaccess-importer</artifactId>
@@ -51,10 +43,10 @@
<artifactId>nuiton-csv</artifactId>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
- </dependency-->
+ </dependency>
<!-- comons dependencies -->
@@ -68,10 +60,10 @@
<artifactId>xwork-core</artifactId>
</dependency-->
- <!--dependency>
+ <dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- </dependency-->
+ </dependency>
<dependency>
<groupId>commons-logging</groupId>
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -28,9 +28,8 @@
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntitiesUtil;
import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.data.DataUtil;
-import fr.ifremer.echobase.entities.references.ReferencesUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -251,7 +250,7 @@
protected void replicateVoyages(TopiaContext topiaContextDest, String... voyagesIds) throws TopiaException {
TopiaReplicationService service = getTransaction().getService(TopiaReplicationService.class);
- ReplicationModel replicationModel = service.prepare(DataUtil.getDataContracts(), true, voyagesIds);
+ ReplicationModel replicationModel = service.prepare(EntitiesUtil.getDataTypes(), true, voyagesIds);
try {
service.doReplicate(replicationModel, topiaContextDest);
} catch (Exception eee) {
@@ -263,7 +262,7 @@
protected void replicateReferentiel(TopiaContext topiaContextDest) throws TopiaException {
// Get all referenciel contracts
- EchoBaseEntityEnum[] referencielClass = ReferencesUtil.getReferencielContracts();
+ EchoBaseEntityEnum[] referencielClass = EntitiesUtil.getReferenceTypes();
TopiaReplicationService service = getTransaction().getService(TopiaReplicationService.class);
ReplicationModel replicationModel = service.prepareForAll(referencielClass);
try {
Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java (from rev 116, trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java)
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -0,0 +1,56 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Ignore;
+
+import java.io.File;
+
+/**
+ * Utility methods for tests
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+@Ignore
+public class TestHelper {
+
+ protected static File basedir;
+
+ public static File getBasedir() {
+ //FIXME : No we do not want to go in tmp directory :( We want to stay
+ // inside of the project. So a mvn clean will remove all tests data.
+ if (basedir == null) {
+// String tmp = System.getProperty("basedir");
+// if (tmp == null) {
+// tmp = new File("").getAbsolutePath();
+// }
+// basedir = new File(tmp);
+ basedir = FileUtils.getTempDirectory();
+ }
+ return basedir;
+ }
+
+}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -47,7 +47,8 @@
public class MockEntityVisitorCreator implements EntityVisitor {
/** Logger. */
- private static final Log log = LogFactory.getLog(MockEntityVisitorCreator.class);
+ private static final Log log =
+ LogFactory.getLog(MockEntityVisitorCreator.class);
protected TopiaContext transaction;
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java 2011-11-24 23:42:22 UTC (rev 117)
@@ -57,7 +57,6 @@
@After
public void after() throws TopiaException {
if (transaction != null && !transaction.isClosed()) {
- transaction.rollbackTransaction();
transaction.closeContext();
}
}
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-24 23:06:43 UTC (rev 116)
+++ trunk/echobase-ui/pom.xml 2011-11-24 23:42:22 UTC (rev 117)
@@ -135,6 +135,11 @@
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
1
0
24 Nov '11
Author: tchemit
Date: 2011-11-25 00:06:43 +0100 (Fri, 25 Nov 2011)
New Revision: 116
Url: http://forge.codelutin.com/repositories/revision/echobase/116
Log:
- cinematic for import data
- use generic dao methods in services
- add svn properties
- add topia connection provider in configuration (there is still some problems in pg)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java
trunk/echobase-services/src/test/resources/echobase.properties
trunk/echobase-ui/pom.xml
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java
trunk/echobase-ui/src/main/resources/config/struts-import.xml
trunk/echobase-ui/src/main/resources/echobase.properties
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp
trunk/pom.xml
trunk/src/doc/reunions/reunion-2011-11-15.txt
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -113,8 +113,8 @@
return file;
}
- public char getCsvCharSeparator() {
- char csvSeparator = applicationConfig.getOption(char.class, EchoBaseConfigurationOption.CSV_CHAR_SEPARATOR.key);
+ public char getCsvSeparator() {
+ char csvSeparator = applicationConfig.getOption(char.class, EchoBaseConfigurationOption.CSV_SEPARATOR.key);
Preconditions.checkNotNull(csvSeparator);
return csvSeparator;
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -50,7 +50,7 @@
SITE_URL("project.siteUrl",
"URL du site de l'application",
"", URL.class),
- CSV_CHAR_SEPARATOR("csv.separator",
+ CSV_SEPARATOR("csv.separator",
"Caractère de séparation pour les fichiers csv",
";", char.class),
WAR_DIRECTORY("war.directory",
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116)
@@ -61,7 +61,7 @@
echobase.common.dataQualityFlagValue=
echobase.common.dataValue=
echobase.common.dateCreated=
-echobase.common.datum=
+echobase.common.datum=datum
echobase.common.depthStratum=depthStratum
echobase.common.depthStratumId=
echobase.common.depthStratumMeaning=
@@ -283,11 +283,11 @@
echobase.common.vesselTransit=
echobase.common.vesselType=
echobase.common.voyage=Campagne
-echobase.common.voyageDescription=
-echobase.common.voyageEndDate=
-echobase.common.voyageEndHarbour=
-echobase.common.voyageName=
-echobase.common.voyageStartDate=
-echobase.common.voyageStartHarbour=
+echobase.common.voyageDescription=Description de campagne
+echobase.common.voyageEndDate=Date de fin de campagne
+echobase.common.voyageEndHarbour=Port de fin de campagne
+echobase.common.voyageName=Nom de la campagne
+echobase.common.voyageStartDate=Date de début de campagne
+echobase.common.voyageStartHarbour=Port de début de campagne
echobase.common.weight=
echobase.config.data.directory.description=Chemin de l'application
Property changes on: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase;
+
+import java.io.File;
+import java.io.Serializable;
+
+/**
+ * Object to receive a uploaded file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class InputFile implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the file (from the client side). */
+ protected String fileName;
+
+ /** Location of the uploaded file (from the server side). */
+ protected File file;
+
+ /** Content type of the uploaded file. */
+ protected String contentType;
+
+ /** Label of the import. */
+ protected String label;
+
+ public InputFile(String label) {
+ this.label = label;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -23,11 +23,13 @@
*/
package fr.ifremer.echobase.services;
+import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.meta.DbMeta;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
@@ -35,6 +37,7 @@
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
+import java.util.List;
import java.util.Locale;
/**
@@ -50,6 +53,30 @@
this.serviceContext = serviceContext;
}
+ public <E extends TopiaEntity> List<E> getEntities(Class<E> entityType) {
+ Preconditions.checkNotNull(entityType);
+ try {
+ List<E> result = getDAO(entityType).findAll();
+ return result;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(
+ "Could not obtain data for type " + entityType, eee);
+ }
+ }
+
+ public <E extends TopiaEntity> E getEntityById(Class<E> entityType, String id) {
+ Preconditions.checkNotNull(entityType);
+ Preconditions.checkArgument(StringUtils.isNotEmpty(id));
+ try {
+ E result = getDAO(entityType).findByTopiaId(id);
+ return result;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(
+ "Could not obtain data of id [" + id + "] for type " +
+ entityType, eee);
+ }
+ }
+
protected TopiaContext getTransaction() {
return serviceContext.getTransaction();
}
@@ -94,7 +121,7 @@
protected Date newDate() {
Date result = new Date();
- DateUtils.setMilliseconds(result,0);
+ DateUtils.setMilliseconds(result, 0);
return result;
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -461,7 +461,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForImport(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -488,7 +488,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForSave(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -519,7 +519,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForExport(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -546,7 +546,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForLoad(TableMeta tableMetas,
boolean addDecorated) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -140,7 +140,7 @@
for (StartFiles startFile : StartFiles.values()) {
InputStream inputStream =
- getClass().getResourceAsStream(startFile.getFilePath());
+ getClass().getResourceAsStream(startFile.getFilePath());
File startFileDest = new File(zipDirectory, startFile.getFileName());
OutputStream outputStream = new FileOutputStream(startFileDest);
@@ -172,7 +172,7 @@
}
protected TopiaContext createH2Batabase(File zipDirectory,
- String... voyageIds) throws IOException, TopiaException {
+ String... voyageIds) throws IOException, TopiaException {
return createH2Batabase(zipDirectory, true, voyageIds);
}
@@ -212,7 +212,7 @@
newService(ExportSqlService.class);
// get all export queries from application
- List<ExportQuery> queries = exportSqlService.getQueries();
+ List<ExportQuery> queries = exportSqlService.getEntities(ExportQuery.class);
// remove link to application user
for (ExportQuery query : queries) {
@@ -227,7 +227,7 @@
newServiceContext.newService(ExportSqlService.class);
// get all queries from h2 db
- queries = exportSqlService.getQueries();
+ queries = exportSqlService.getEntities(ExportQuery.class);
// attach them to default created admin user in the db
for (ExportQuery query : queries) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -24,10 +24,8 @@
package fr.ifremer.echobase.services;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.ExportQueryDAO;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,6 +33,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.util.csv.Export;
import java.sql.Connection;
@@ -55,28 +54,10 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ExportSqlService.class);
- public List<ExportQuery> getQueries() {
+ public ExportQuery createOrUpdate(ExportQuery exportQuery,
+ EchoBaseUser user) {
try {
- List<ExportQuery> result = getDAO().findAll();
- return result;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException("Could not obtain export queries", eee);
- }
- }
-
- public ExportQuery getQueryById(String queryId) {
-
- try {
- ExportQuery result = getDAO().findByTopiaId(queryId);
- return result;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException("Could not obtain export query with id " + queryId, eee);
- }
- }
-
- public ExportQuery createOrUpdate(ExportQuery exportQuery, EchoBaseUser user) {
- try {
- ExportQueryDAO dao = getDAO();
+ TopiaDAO<ExportQuery> dao = getDAO(ExportQuery.class);
ExportQuery entityToSave;
// No id, creating new one entity
@@ -103,7 +84,7 @@
public void delete(String topiaId) {
try {
- ExportQueryDAO dao = getDAO();
+ TopiaDAO<ExportQuery> dao = getDAO(ExportQuery.class);
ExportQuery entityToDelete = dao.findByTopiaId(topiaId);
dao.delete(entityToDelete);
@@ -118,7 +99,8 @@
// get a query to count all rows for the request
GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, pager);
try {
- List<Map<String, Object>> result = sqlQuery.getResult(getTransaction());
+ List<Map<String, Object>> result =
+ sqlQuery.getResult(getTransaction());
return result.toArray(new Map[result.size()]);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not execute sql query", eee);
@@ -152,22 +134,17 @@
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not execute sql query", eee);
}
- ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(getConfiguration().getCsvCharSeparator());
+ char csvSeparator = getConfiguration().getCsvSeparator();
+ ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(csvSeparator);
Export<Map<String, Object>> exporter = Export.newExport(csvModel, rows);
- String content = null;
try {
- content = exporter.startExportAsString();
+ String content = exporter.startExportAsString();
return content;
} catch (Exception eee) {
throw new EchoBaseTechnicalException("Could not export sql", eee);
}
-
}
- protected ExportQueryDAO getDAO() throws TopiaException {
- return EchoBaseDAOHelper.getExportQueryDAO(getTransaction());
- }
-
private static class GenericSQLQuery extends TopiaSQLQuery<Map<String, Object>> {
protected String[] columnNames;
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,134 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.InputFile;
+import fr.ifremer.echobase.entities.data.Voyage;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * Configuration of an import data action.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ImportDataConfiguration implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Voyage used for the import (may not be in db if needed to be created). */
+ protected Voyage voyage;
+
+ protected InputFile acousticFile;
+
+ protected InputFile captureFile;
+
+ protected InputFile lectureAgeGenFile;
+
+ protected InputFile eventsFile;
+
+ protected InputFile typeEchoSpeciesFile;
+
+ protected int nbSteps;
+
+ private float stepIncrement;
+
+ protected float progression;
+
+ public ImportDataConfiguration(Locale locale) {
+ acousticFile = new InputFile(l_(locale, "echobase.common.acousticImport"));
+ captureFile = new InputFile(l_(locale, "echobase.common.captureImport"));
+ lectureAgeGenFile = new InputFile(l_(locale, "echobase.common.lectureAgeGenImport"));
+ eventsFile = new InputFile(l_(locale, "echobase.common.eventsImport"));
+ typeEchoSpeciesFile = new InputFile(l_(locale, "echobase.common.typeEchoSpeciesImport"));
+ }
+
+ public Voyage getVoyage() {
+ return voyage;
+ }
+
+ public InputFile getAcousticFile() {
+ return acousticFile;
+ }
+
+ public InputFile getCaptureFile() {
+ return captureFile;
+ }
+
+ public InputFile getLectureAgeGenFile() {
+ return lectureAgeGenFile;
+ }
+
+ public InputFile getEventsFile() {
+ return eventsFile;
+ }
+
+ public InputFile getTypeEchoSpeciesFile() {
+ return typeEchoSpeciesFile;
+ }
+
+ public int getNbSteps() {
+ return nbSteps;
+ }
+
+ public float getProgression() {
+ return progression;
+ }
+
+ public void setVoyage(Voyage voyage) {
+ this.voyage = voyage;
+ }
+
+ public void setProgression(float progression) {
+ this.progression = progression;
+ }
+
+ public void incrementsProgression() {
+ setProgression(progression + stepIncrement);
+ }
+
+ public void computeSteps() {
+ nbSteps = 0;
+ if (acousticFile.getFile() != null) {
+ nbSteps++;
+ }
+ if (captureFile.getFile() != null) {
+ nbSteps++;
+ }
+ if (lectureAgeGenFile.getFile() != null) {
+ nbSteps++;
+ }
+ if (eventsFile.getFile() != null) {
+ nbSteps++;
+ }
+ if (typeEchoSpeciesFile.getFile() != null) {
+ nbSteps++;
+ }
+ stepIncrement = 100f / nbSteps;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,198 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.InputFile;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * Service to import datas.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ImportDataService extends AbstractEchoBaseService {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ImportDataService.class);
+
+ public Map<InputFile, CsvImportResult> startImport(ImportDataConfiguration configuration) {
+
+ Map<InputFile, CsvImportResult> result = Maps.newHashMap();
+
+ Voyage voyage = configuration.getVoyage();
+
+ // compute nb step to treate (means nb imports to do)
+ configuration.computeSteps();
+
+ if (log.isInfoEnabled()) {
+ log.info("Starts data import with voyage " +
+ voyage.getVoyageName());
+ }
+
+ InputFile acousticFile = configuration.getAcousticFile();
+ if (acousticFile.getFile() != null) {
+
+ // do acoustic import
+ try {
+ CsvImportResult importResult = importAcoustic(voyage, acousticFile);
+ configuration.incrementsProgression();
+ result.put(acousticFile, importResult);
+ } finally {
+ deleteFile(acousticFile);
+ }
+ }
+
+ InputFile captureFile = configuration.getCaptureFile();
+ if (captureFile.getFile() != null) {
+
+ // do capture import
+ try {
+ CsvImportResult importResult = importCapture(voyage, captureFile);
+ configuration.incrementsProgression();
+ result.put(captureFile, importResult);
+ } finally {
+ deleteFile(captureFile);
+ }
+ }
+
+ InputFile eventsFile = configuration.getEventsFile();
+ if (eventsFile.getFile() != null) {
+
+ // do events import
+ try {
+ CsvImportResult importResult = importEvents(voyage, eventsFile);
+ configuration.incrementsProgression();
+ result.put(eventsFile, importResult);
+ } finally {
+ deleteFile(eventsFile);
+ }
+ }
+
+ InputFile lectureAgeGenFile = configuration.getLectureAgeGenFile();
+ if (lectureAgeGenFile.getFile() != null) {
+
+ // do lecture age gen import
+ try {
+ CsvImportResult importResult = importLectureAgeGen(voyage, lectureAgeGenFile);
+ configuration.incrementsProgression();
+ result.put(lectureAgeGenFile, importResult);
+ } finally {
+ deleteFile(lectureAgeGenFile);
+ }
+ }
+
+ InputFile typeEchoSpeciesFile = configuration.getTypeEchoSpeciesFile();
+ if (typeEchoSpeciesFile.getFile() != null) {
+
+ // do echo species import
+ try {
+ CsvImportResult importResult = importTypeEchoSpecies(voyage, typeEchoSpeciesFile);
+ configuration.incrementsProgression();
+ result.put(typeEchoSpeciesFile, importResult);
+ } finally {
+ deleteFile(typeEchoSpeciesFile);
+ }
+ }
+
+ return result;
+ }
+
+ protected void deleteFile(InputFile input) {
+ File file = input.getFile();
+
+ if (log.isInfoEnabled()) {
+ log.info("Will delete import file " + file);
+ }
+ boolean wasDel = file.delete();
+ if (!wasDel) {
+ throw new EchoBaseTechnicalException("Could not delete file " + file);
+ }
+ }
+
+ protected CsvImportResult importAcoustic(Voyage voyage, InputFile importFile) {
+ if (log.isInfoEnabled()) {
+ log.info("Starts " + importFile.getLabel() + " with file " +
+ importFile.getFile());
+ }
+ CsvImportResult result = new CsvImportResult();
+ prepareImport();
+ return result;
+ }
+
+ protected CsvImportResult importCapture(Voyage voyage, InputFile importFile) {
+ if (log.isInfoEnabled()) {
+ log.info("Starts " + importFile.getLabel() + " with file " +
+ importFile.getFile());
+ }
+ CsvImportResult result = new CsvImportResult();
+ prepareImport();
+ return result;
+ }
+
+ protected CsvImportResult importEvents(Voyage voyage, InputFile importFile) {
+ if (log.isInfoEnabled()) {
+ log.info("Starts " + importFile.getLabel() + " with file " +
+ importFile.getFile());
+ }
+ CsvImportResult result = new CsvImportResult();
+ prepareImport();
+ return result;
+ }
+
+ protected CsvImportResult importLectureAgeGen(Voyage voyage, InputFile importFile) {
+ if (log.isInfoEnabled()) {
+ log.info("Starts " + importFile.getLabel() + " with file " +
+ importFile.getFile());
+ }
+ CsvImportResult result = new CsvImportResult();
+ prepareImport();
+ return result;
+ }
+
+ protected CsvImportResult importTypeEchoSpecies(Voyage voyage, InputFile importFile) {
+ if (log.isInfoEnabled()) {
+ log.info("Starts " + importFile.getLabel() + " with file " +
+ importFile.getFile());
+ }
+ CsvImportResult result = new CsvImportResult();
+ prepareImport();
+ return result;
+ }
+
+ protected void prepareImport() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserDAO;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
@@ -76,15 +75,6 @@
}
}
- public EchoBaseUser getUserById(String topiaId) {
- try {
- EchoBaseUser user = getDAO().findByTopiaId(topiaId);
- return user;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(eee);
- }
- }
-
public EchoBaseUser getUserByEmail(String email) {
Preconditions.checkNotNull(email);
try {
@@ -162,6 +152,6 @@
}
protected EchoBaseUserDAO getDAO() throws TopiaException {
- return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction());
+ return (EchoBaseUserDAO) getDAO(EchoBaseUser.class);
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -24,39 +24,25 @@
package fr.ifremer.echobase.services;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.entities.data.VoyageDAO;
import org.nuiton.topia.TopiaException;
-import java.util.List;
-
/**
- * Service to manage all concerning voayges.
+ * Service to manage all concerning voyages.
*
* @author sletellier <letellier(a)codelutin.com>
*/
public class VoyageService extends AbstractEchoBaseService {
- public List<Voyage> getVoyages() {
+ public Voyage createVoyage(Voyage voyage) {
try {
- List<Voyage> voyages = getDAO().findAll();
- return voyages;
+ Voyage result = getDAO(Voyage.class).create(voyage);
+ commitTransaction("Could not create voyage " +
+ voyage.getVoyageName());
+ return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
}
- public Voyage getVoyageById(String topiaId) {
- try {
- Voyage voyage = getDAO().findByTopiaId(topiaId);
- return voyage;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(eee);
- }
- }
-
- protected VoyageDAO getDAO() throws TopiaException {
- return EchoBaseDAOHelper.getVoyageDAO(getTransaction());
- }
}
Property changes on: trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
===================================================================
--- trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,5 @@
+echobase.common.acousticImport=Import Acoustique
+echobase.common.captureImport=Import Pêcherie
+echobase.common.eventsImport=Import Evènements
+echobase.common.lectureAgeGenImport=Import Lecture Agen Gen
+echobase.common.typeEchoSpeciesImport=Import Type EchoSpecies
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -51,7 +51,7 @@
protected TopiaContext transaction;
- private static final int NB_ASSOCIATIONS = 2;
+ private static final int NB_ASSOCIATIONS = 1;
public MockEntityVisitorCreator(TopiaContext transaction) {
this.transaction = transaction;
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -28,6 +28,7 @@
import fr.ifremer.echobase.entities.MockEntityVisitorCreator;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.data.VoyageDAO;
+import org.junit.Ignore;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
@@ -39,6 +40,7 @@
* @author sletellier <letellier(a)codelutin.com>
* @since 0.2
*/
+@Ignore
public class EmbeddedApplicationServiceTest extends AbstractEchoBaseServiceTest {
public static final String TEST_ECHOBASE_EMBEDDED = "test-echobase-embedded";
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-services/src/test/resources/echobase.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/pom.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -262,6 +262,7 @@
<executions>
<execution>
<goals>
+ <goal>parserValidation</goal>
<goal>parserJava</goal>
<goal>gen</goal>
<goal>bundle</goal>
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui;
import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.services.ImportDataConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,6 +45,9 @@
/** Key to set User connected in this session. */
protected static final String PROPERTY_ECHO_BASE_USER = "echobaseUser";
+ /** Key to keep import configuration in this session. */
+ protected static final String PROPERTY_IMPORT_DATA_CONFIGURATION = "importDataConfiguration";
+
/** To store all properties in this session. */
protected Map<String, Object> store;
@@ -65,6 +69,14 @@
set(PROPERTY_ECHO_BASE_USER, echoBaseUser);
}
+ public ImportDataConfiguration getImportDataConfiguration() {
+ return get(PROPERTY_IMPORT_DATA_CONFIGURATION, ImportDataConfiguration.class);
+ }
+
+ public void setImportDataConfiguration(ImportDataConfiguration configuration) {
+ set(PROPERTY_IMPORT_DATA_CONFIGURATION, configuration);
+ }
+
/**
* Remove form this session, the object from his given key and returns it.
*
@@ -121,9 +133,13 @@
* @param value the object to store in this session
*/
protected void set(String key, Object value) {
- store.put(key, value);
- if (log.isInfoEnabled()) {
- log.info("Set in user session data [" + key + "] = " + value);
+ if (value == null) {
+ remove(key);
+ } else {
+ store.put(key, value);
+ if (log.isInfoEnabled()) {
+ log.info("Set in user session data [" + key + "] = " + value);
+ }
}
}
}
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -1,94 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $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 Affero 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 Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.ui.actions;
-
-import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.VoyageService;
-import fr.ifremer.echobase.services.models.ImportModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Action to manage imports
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.1
- */
-public class ImportAction extends EchoBaseActionSupport implements Preparable {
-
- private static final long serialVersionUID = 1L;
-
- protected static final Log log = LogFactory.getLog(ImportAction.class);
-
- protected ImportModel importModel;
-
- protected Map<String, String> voyages;
-
- public ImportModel getImportModel() {
- if (importModel == null) {
- importModel = new ImportModel();
- }
- return importModel;
- }
-
- public String getSelectedVoyageId() {
- String selectedVoyageId = getImportModel().getSelectedVoyageId();
- return selectedVoyageId;
- }
-
- public void setSelectedVoyageId(String selectedVoyageId) {
- VoyageService service = newService(VoyageService.class);
- Voyage selectedVoyage = service.getVoyageById(selectedVoyageId);
- getImportModel().setSelectedVoyage(selectedVoyage);
- }
-
- public Map<String, String> getVoyages() {
- return voyages;
- }
-
- @Override
- public void prepare() throws Exception {
- VoyageService service = newService(VoyageService.class);
- List<Voyage> allVoyages = service.getVoyages();
- voyages = sortAndDecorate(allVoyages, null);
- }
-
- @Override
- public String execute() throws Exception {
- log.info("Will import : " + getImportModel().toString());
- return SUCCESS;
- }
-
-// @Override
-// public void validate() {
-// //FIXME : do a real validation with a xml validation file.
-// if (!importModel.validate()) {
-// addActionError(_("echobase.error.importArgument"));
-// }
-// }
-}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -73,7 +73,7 @@
public String execute() throws Exception {
VoyageService service = newService(VoyageService.class);
- List<Voyage> allVoyages = service.getVoyages();
+ List<Voyage> allVoyages = service.getEntities(Voyage.class);
voyages = sortAndDecorate(allVoyages, null);
EchoBaseConfiguration configuration = getConfiguration();
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -100,7 +100,8 @@
public void prepare() throws Exception {
ExportSqlService service = newService(ExportSqlService.class);
- Collection<ExportQuery> sqlQueries = service.getQueries();
+ Collection<ExportQuery> sqlQueries =
+ service.getEntities(ExportQuery.class);
queries = sortAndDecorate(sqlQueries, null);
if (sqlQueries.isEmpty()) {
@@ -117,7 +118,7 @@
} else {
// load query from database
- query = service.getQueryById(selectedQueryId);
+ query = service.getEntityById(ExportQuery.class, selectedQueryId);
}
}
}
\ No newline at end of file
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,187 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.ui.actions.importData;
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.echobase.InputFile;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.services.ImportDataConfiguration;
+import fr.ifremer.echobase.services.VoyageService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Action to load input files to import.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ConfigureFiles extends EchoBaseActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ConfigureFiles.class);
+
+ /** Import data configuration to push in session. */
+ protected ImportDataConfiguration model;
+
+ /** Id of selected voyage used in import. */
+ protected String voyageId;
+
+ public void setVoyageId(String voyageId) {
+ this.voyageId = voyageId;
+ }
+
+ public void setAcoustic(File file) {
+ getModel().getAcousticFile().setFile(file);
+ }
+
+ public void setAcousticContentType(String contentType) {
+ getModel().getAcousticFile().setContentType(contentType);
+ }
+
+ public void setAcousticFileName(String fileName) {
+ getModel().getAcousticFile().setFileName(fileName);
+ }
+
+ public void setCapture(File file) {
+ getModel().getCaptureFile().setFile(file);
+ }
+
+ public void setCaptureContentType(String contentType) {
+ getModel().getCaptureFile().setContentType(contentType);
+ }
+
+ public void setCaptureFileName(String fileName) {
+ getModel().getCaptureFile().setFileName(fileName);
+ }
+
+ public void setLectureAgeGen(File file) {
+ getModel().getLectureAgeGenFile().setFile(file);
+ }
+
+ public void setLectureAgeGenContentType(String contentType) {
+ getModel().getLectureAgeGenFile().setContentType(contentType);
+ }
+
+ public void setLectureAgeGenFileName(String fileName) {
+ getModel().getLectureAgeGenFile().setFileName(fileName);
+ }
+
+ public void setEvents(File file) {
+ getModel().getEventsFile().setFile(file);
+ }
+
+ public void setEventsContentType(String contentType) {
+ getModel().getEventsFile().setContentType(contentType);
+ }
+
+ public void setEventsFileName(String fileName) {
+ getModel().getEventsFile().setFileName(fileName);
+ }
+
+ public void setTypeEchoSpecies(File file) {
+ getModel().getTypeEchoSpeciesFile().setFile(file);
+ }
+
+ public void setTypeEchoSpeciesContentType(String contentType) {
+ getModel().getTypeEchoSpeciesFile().setContentType(contentType);
+ }
+
+ public void setTypeEchoSpeciesFileName(String fileName) {
+ getModel().getTypeEchoSpeciesFile().setFileName(fileName);
+ }
+
+ public String getVoyageId() {
+ return voyageId;
+ }
+
+ public ImportDataConfiguration getModel() {
+ if (model == null) {
+ model = new ImportDataConfiguration(getLocale());
+ }
+ return model;
+ }
+
+ @Override
+ public String input() throws Exception {
+
+ // remove configuration from session
+ getEchoBaseSession().setImportDataConfiguration(null);
+
+ return INPUT;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ ImportDataConfiguration importModel = getModel();
+ File tempDirectory = FileUtils.getTempDirectory();
+ File dataDirectory = new File(tempDirectory, "echobase-import" + System.currentTimeMillis());
+ FileUtil.createDirectoryIfNecessary(dataDirectory);
+ if (log.isInfoEnabled()) {
+ log.info("Temporary directory to use : " + dataDirectory);
+ }
+ copyFile(importModel.getAcousticFile(), dataDirectory);
+ copyFile(importModel.getCaptureFile(), dataDirectory);
+ copyFile(importModel.getEventsFile(), dataDirectory);
+ copyFile(importModel.getLectureAgeGenFile(), dataDirectory);
+ copyFile(importModel.getTypeEchoSpeciesFile(), dataDirectory);
+
+ getEchoBaseSession().setImportDataConfiguration(importModel);
+ return SUCCESS;
+ }
+
+ @Override
+ public void prepare() throws Exception {
+
+ VoyageService service = newService(VoyageService.class);
+
+ Voyage voyage = service.getEntityById(Voyage.class, voyageId);
+ getModel().setVoyage(voyage);
+ }
+
+ protected void copyFile(InputFile inputFile, File dataDirectory) throws IOException {
+ File source = inputFile.getFile();
+ if (source != null) {
+
+ File target = new File(dataDirectory, inputFile.getFileName());
+ if (log.isInfoEnabled()) {
+ log.info("Copy file " + source + " to " + target);
+ }
+ FileUtils.copyFile(source, target);
+
+ // keep target (source file will be removed at the end of this action)
+ inputFile.setFile(target);
+ }
+
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,170 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.ui.actions.importData;
+
+import com.google.common.collect.Maps;
+import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageImpl;
+import fr.ifremer.echobase.entities.references.AreaOfOperation;
+import fr.ifremer.echobase.entities.references.Mission;
+import fr.ifremer.echobase.services.VoyageService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configure the step 1 of import data (says which campagne to use).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ConfigureVoyage extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ConfigureVoyage.class);
+
+ /** Universe of existing voyages. */
+ protected Map<String, String> voyages;
+
+ /** Universe of existing missions. */
+ protected Map<String, String> missions;
+
+ /** Universe of existing areaOfOperations. */
+ protected Map<String, String> areaOfOperations;
+
+ /** Universe of possible import modes. */
+ protected Map<String, String> importModes;
+
+ /** Selected import mode. */
+ protected ImportMode importMode;
+
+ /** Voyage to use. */
+ protected Voyage voyage;
+
+ /** Mission selected id. */
+ protected String missionId;
+
+ /** Area of operation selected id. */
+ protected String areaOfOperationId;
+
+ public Voyage getVoyage() {
+ if (voyage == null) {
+ voyage = new VoyageImpl();
+ }
+ return voyage;
+ }
+
+ public Map<String, String> getImportModes() {
+ return importModes;
+ }
+
+ public Map<String, String> getVoyages() {
+ return voyages;
+ }
+
+ public Map<String, String> getMissions() {
+ return missions;
+ }
+
+ public Map<String, String> getAreaOfOperations() {
+ return areaOfOperations;
+ }
+
+ public ImportMode getImportMode() {
+ return importMode;
+ }
+
+ public void setMissionId(String missionId) {
+ this.missionId = missionId;
+ }
+
+ public void setAreaOfOperationId(String areaOfOperationId) {
+ this.areaOfOperationId = areaOfOperationId;
+ }
+
+ public void setImportMode(ImportMode importMode) {
+ this.importMode = importMode;
+ }
+
+ @Override
+ public String input() throws Exception {
+ importModes = Maps.newLinkedHashMap();
+ for (ImportMode mode : ImportMode.values()) {
+ importModes.put(mode.name(), _(mode.getI18nKey()));
+ }
+
+ if (importMode == null) {
+ importMode = ImportMode.USE_EXISTING_VOYAGE;
+ }
+
+ VoyageService service = newService(VoyageService.class);
+ List<Voyage> allVoyages = service.getEntities(Voyage.class);
+ voyages = sortAndDecorate(allVoyages, null);
+
+ List<Mission> allMissions = service.getEntities(Mission.class);
+ missions = sortAndDecorate(allMissions, null);
+
+ List<AreaOfOperation> allAreaOfOperations =
+ service.getEntities(AreaOfOperation.class);
+ areaOfOperations = sortAndDecorate(allAreaOfOperations, null);
+ if (log.isInfoEnabled()) {
+ log.info("File errors : "+getFieldErrors());
+ }
+ return INPUT;
+ }
+
+ @InputConfig(methodName = "input")
+ @Override
+ public String execute() throws Exception {
+
+ if (importMode == ImportMode.CREATE_NEW_VOYAGE) {
+
+ // create voyage in db
+ VoyageService service = newService(VoyageService.class);
+ Voyage voyageToCreate = getVoyage();
+ //TODO Remove this test when references will be ok
+ if (StringUtils.isNotEmpty(missionId)) {
+ Mission mission =
+ service.getEntityById(Mission.class, missionId);
+ voyage.setMission(mission);
+ }
+ //TODO Remove this test when references will be ok
+ if (StringUtils.isNotEmpty(areaOfOperationId)) {
+ AreaOfOperation area = service.getEntityById(AreaOfOperation.class,
+ areaOfOperationId);
+ voyage.setAreaOfOperation(area);
+ }
+ voyage = service.createVoyage(voyageToCreate);
+ }
+ return SUCCESS;
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,49 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.ui.actions.importData;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Define import mode (use an existing voayge, or create a new one.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public enum ImportMode {
+
+ CREATE_NEW_VOYAGE(n_("echobase.common.importMode.createNewVoyage")),
+ USE_EXISTING_VOYAGE(n_("echobase.common.importMode.useExistingVoyage"));
+
+
+ private final String i18nKey;
+
+ ImportMode(String i18nKey) {
+ this.i18nKey = i18nKey;
+ }
+
+ public String getI18nKey() {
+ return i18nKey;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,90 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.ui.actions.importData;
+
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.echobase.InputFile;
+import fr.ifremer.echobase.services.CsvImportResult;
+import fr.ifremer.echobase.services.ImportDataConfiguration;
+import fr.ifremer.echobase.services.ImportDataService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+
+/**
+ * To launch the import data process.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class LaunchImport extends EchoBaseActionSupport implements Preparable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(LaunchImport.class);
+
+ /** Import data configuration to push in session. */
+ protected ImportDataConfiguration model;
+
+ protected Map<InputFile, CsvImportResult> importResult;
+
+ transient ImportDataService service;
+
+ public ImportDataConfiguration getModel() {
+ return model;
+ }
+
+ public Map<InputFile, CsvImportResult> getImportResult() {
+ return importResult;
+ }
+
+ @Override
+ public void prepare() throws Exception {
+
+ model = getEchoBaseSession().getImportDataConfiguration();
+
+ service = newService(ImportDataService.class);
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ try {
+ if (log.isInfoEnabled()) {
+ log.info("Start imports with voyage " +
+ model.getVoyage().getVoyageName());
+ }
+
+ importResult = service.startImport(model);
+ return SUCCESS;
+ } finally {
+
+ // remove configuration from session
+ getEchoBaseSession().setImportDataConfiguration(null);
+ }
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java 2011-11-24 23:06:43 UTC (rev 116)
@@ -76,7 +76,7 @@
if (!StringUtils.isEmpty(userId)) {
// load user
- user = getUserService().getUserById(userId).toDTO();
+ user = getUserService().getEntityById(EchoBaseUser.class, userId).toDTO();
log.info("Selected user " + user.getEmail());
}
Modified: trunk/echobase-ui/src/main/resources/config/struts-import.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -32,20 +32,40 @@
<package name="import" extends="loggued" namespace="/import">
- <!-- Display import page -->
- <action name="import" class="fr.ifremer.echobase.ui.actions.ImportAction"
- method="input">
- <result name="input">/WEB-INF/jsp/import/import.jsp</result>
+ <!-- Configure import voyage -->
+ <action name="configureVoyage"
+ class="fr.ifremer.echobase.ui.actions.importData.ConfigureVoyage">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/import/configureVoyage.jsp</result>
+ <result type="redirectAction">
+ <param name="namespace">/import</param>
+ <param name="actionName">configureFiles</param>
+ <param name="method">input</param>
+ <param name="voyageId">${voyage.topiaId}</param>
+ </result>
</action>
- <!-- Display import page -->
- <action name="doImport" class="fr.ifremer.echobase.ui.actions.ImportAction">
+ <!-- Configure import files -->
+ <action name="configureFiles"
+ class="fr.ifremer.echobase.ui.actions.importData.ConfigureFiles">
<interceptor-ref name="paramsPrepareParamsStackLoggued"/>
- <!--<result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result>-->
- <result name="input">/WEB-INF/jsp/import/import.jsp</result>
- <result>/WEB-INF/jsp/import/importProgress.jsp</result>
+ <result name="input">/WEB-INF/jsp/import/configureFiles.jsp</result>
+ <result type="redirectAction">
+ <param name="namespace">/import</param>
+ <param name="actionName">doImport</param>
+ </result>
</action>
+ <!-- Starts import -->
+ <action name="doImport"
+ class="fr.ifremer.echobase.ui.actions.importData.LaunchImport"
+ method="execute">
+ <interceptor-ref name="basicStackLoggued"/>
+ <interceptor-ref name="execAndWait"/>
+ <result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result>
+ <result>/WEB-INF/jsp/import/importResult.jsp</result>
+ </action>
+
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/echobase.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-24 23:06:43 UTC (rev 116)
@@ -29,6 +29,7 @@
hibernate.hbm2ddl.auto=none
hibernate.show_sql=false
hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider
hibernate.connection.driver_class=org.h2.Driver
hibernate.connection.url=jdbc:h2:file:${data.directory}/db/echobase
Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -1,36 +0,0 @@
-<!--
- #%L
- EchoBase :: UI
-
- $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 Affero 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 Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- -->
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
-
- <field name="importModel.accessImport">
- <field-validator type="expression">
- <param name="expression">(importModel.accessImport == null ^ importModel.selectedVoyage == null) == 1</param>
- <message key="echobase.validation.import.selectedVoyageOrAccessImport.required"/>
- </field-validator>
- </field>
-
-</validators>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -29,27 +29,27 @@
<field name="query.name">
<field-validator type="requiredstring">
- <message key="echobase.validation.export.name.requiredstring"/>
+ <message key="echobase.error.export.name.requiredstring"/>
</field-validator>
</field>
<field name="query.description">
<field-validator type="requiredstring">
- <message key="echobase.validation.export.description.requiredstring"/>
+ <message key="echobase.error.export.description.requiredstring"/>
</field-validator>
</field>
<field name="query.sqlQuery">
<field-validator type="requiredstring">
- <message key="echobase.validation.export.sqlQuery.requiredstring"/>
+ <message key="echobase.error.export.sqlQuery.requiredstring"/>
</field-validator>
<field-validator type="regex">
<!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query -->
<param name="expression">^\s*select\s+.+\s+from\s+.+$</param>
<param name="caseSensitive">false</param>
- <message key="echobase.validation.export.sqlQuery.wrongformat"/>
+ <message key="echobase.error.export.sqlQuery.wrongformat"/>
</field-validator>
</field>
Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,35 @@
+<!--
+ #%L
+ EchoBase :: UI
+
+ $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 Affero 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 Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="voyageId">
+ <field-validator type="requiredstring">
+ <message key="echobase.error.import.voyage.required"/>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,92 @@
+<!--
+ #%L
+ EchoBase :: UI
+
+ $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 Affero 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 Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="importMode">
+ <field-validator type="required">
+ <message key="echobase.error.import.importMode.required"/>
+ </field-validator>
+ </field>
+
+ <field name="voyage.topiaId">
+ <field-validator type="requiredstring">
+ <param name="skip">importMode.name() != "USE_EXISTING_VOYAGE"</param>
+ <message key="echobase.error.import.voyage.required"/>
+ </field-validator>
+ </field>
+
+ <field name="voyage.voyageName">
+ <field-validator type="requiredstring">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.voyageName.required"/>
+ </field-validator>
+ </field>
+
+ <field name="voyage.datum">
+ <field-validator type="requiredstring">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.datum.required"/>
+ </field-validator>
+ </field>
+
+ <field name="voyage.voyageDescription">
+ <field-validator type="requiredstring">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.voyageDescription.required"/>
+ </field-validator>
+ </field>
+
+ <!-- TODO Reput this when references are in db -->
+ <!--field name="missionId">
+ <field-validator type="requiredstring">
+ <param name="skip">${importMode.name} != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.missionId.required"/>
+ </field-validator>
+ </field-->
+
+ <!--field name="areaOfOperationId">
+ <field-validator type="requiredstring">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.areaOfOperationId.required"/>
+ </field-validator>
+ </field-->
+
+ <field name="voyage.voyageStartDate">
+ <field-validator type="required">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.voyageStartDate.required"/>
+ </field-validator>
+ </field>
+
+ <field name="voyage.voyageEndDate">
+ <field-validator type="required">
+ <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param>
+ <message key="echobase.error.import.voyageEndDate.required"/>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -29,7 +29,7 @@
<field name="email">
<field-validator type="login">
- <message key="echobase.validation.login.wrongLogin"/>
+ <message key="echobase.error.login.wrongLogin"/>
</field-validator>
</field>
Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -29,14 +29,14 @@
<field name="user.email">
<field-validator type="login">
- <message key="echobase.validation.login.wrongLogin"/>
+ <message key="echobase.error.login.wrongLogin"/>
</field-validator>
</field>
<field name="user.password">
<field-validator type="requiredstring">
- <message key="echobase.validation.login.password.requiredstring"/>
+ <message key="echobase.error.login.password.requiredstring"/>
</field-validator>
</field>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116)
@@ -18,16 +18,19 @@
echobase.action.return=Retour
echobase.action.save=Sauvegarder
echobase.action.saveSqlQuery=Enregistrer la requête
+echobase.action.validateImportVoyage=Valider la campagne
echobase.common.admin=Administrateur
echobase.common.comment=Commentaire
echobase.common.email=Email
echobase.common.entityType=Type d'entité
+echobase.common.importMode=Type de campagne
+echobase.common.importMode.createNewVoyage=Créer une nouvelle campagne
+echobase.common.importMode.useExistingVoyage=Utiliser une campagne existante
echobase.common.jdbcLogin=Login de connexion
echobase.common.jdbcPassword=Mot de passe
echobase.common.jdbcUrl=Url de connexion
echobase.common.password=Mot de passe
echobase.common.user=Utilisateur
-echobase.common.voyage=Voyage
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
echobase.error.export.description.requiredstring=La description de l'export est obligatoire
@@ -36,7 +39,7 @@
echobase.error.export.sqlQuery.wrongformat=La requêtes n'est pas valide
echobase.error.fileDontExist=
echobase.error.fileNotFound=
-echobase.error.import.selectedVoyageOrAccessImport.required=Merci de selectionner un voyage ou un import access
+echobase.error.import.selectedVoyageOrAccessImport.required=Merci de selectionner un campagne
echobase.error.importArgument=
echobase.error.importFile.required=Fichier d'import obligatoire
echobase.error.login.password.requiredstring=Le mot de passe est obligatoire
@@ -47,7 +50,7 @@
echobase.error.warlocation.notFound=L'application n'a pas été trouvé à l'emplacement suivant %s
echobase.header.request.result=Résultat de la requête sql
echobase.header.user.gridTitle=Liste des utilisateurs
-echobase.header.voyageSelect=Selectionnez un voyage
+echobase.header.voyageSelect=Selectionnez une campagne
echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données
echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré
echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée
@@ -79,6 +82,10 @@
echobase.legend.dbeditor.edit=Edition de '%s'
echobase.legend.embeddedApplication.configuration=Configuration de l'application embarquée
echobase.legend.import=Import configuration
+echobase.legend.import.configuration.files=Choix des fichiers d'import
+echobase.legend.import.configuration.voyage=Configurer la campagne
+echobase.legend.import.configuration.voyage.resume=Résumé de la campagne à utiliser
+echobase.legend.importFileResult=Résultat de l'import %s
echobase.legend.sqlQuery.configuration=Configuration de la requête
echobase.legend.sqlQuery.result=Résultats de la requête
echobase.menu.connectToDbInformations=Se connecter à la base
@@ -104,6 +111,7 @@
echobase.title.export=Export
echobase.title.exportTable=Exporter une table
echobase.title.import=Imports
+echobase.title.import.configuration=Configuration d'un import
echobase.title.importProgress=Import en cours
echobase.title.importResult=Résultats de l'import
echobase.title.importTable=Importer une table
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-24 23:06:43 UTC (rev 116)
@@ -55,7 +55,7 @@
<div class="cleanBoth">
<ul>
<li>
- <s:a action="import" namespace="/import">
+ <s:a action="configureVoyage" namespace="/import" method="input">
<s:text name="echobase.menu.import"/></s:a>
</li>
<li>
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,71 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $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 Affero 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 Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.import"/></title>
+
+<s:form namespace="/import" method="POST" enctype="multipart/form-data">
+
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.import.configuration.voyage.resume"/>
+ </legend>
+ <s:label value="%{model.voyage.voyageName}"
+ key='echobase.common.voyageName'/>
+
+ <s:label value="%{model.voyage.voyageDescription}"
+ key='echobase.common.voyageDescription'/>
+ </fieldset>
+
+ <hr/>
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.import.configuration.files"/>
+ </legend>
+
+ <s:hidden key="voyageId" label=''/>
+
+ <s:file name="acoustic"
+ key="echobase.label.import.accoustique"/>
+
+ <s:file name="capture"
+ key="echobase.label.import.pecherie"/>
+
+ <s:file name="lectureAgeGen"
+ key="echobase.label.import.lectureAgeGen"/>
+
+ <s:file name="events"
+ key="echobase.label.import.events"/>
+
+ <s:file name="typeEchoSpecies"
+ key="echobase.label.import.typeEchoSpecies"/>
+
+ </fieldset>
+ <br/>
+ <s:submit id="addFilesSubmit" action="configureFiles"
+ value='%{getText("echobase.action.import")}'/>
+
+
+</s:form>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp 2011-11-24 23:06:43 UTC (rev 116)
@@ -0,0 +1,127 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $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 Affero 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 Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<script type="text/javascript">
+
+ jQuery(document).ready(function () {
+
+ var importMode = $('[name="importMode"]');
+ importMode.change(function(event) {
+ $('[class="importMode"]').hide();
+ $('#' + this.value).show();
+ });
+ var val = $('[name="importMode"][checked="checked"]').val();
+ $('[class="importMode"]').hide();
+ $("#"+val).show();
+ });
+</script>
+<title><s:text name="echobase.title.import.configuration"/></title>
+
+<s:form id="importForm" namespace="/import" method="POST">
+
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.import.configuration.voyage"/>
+ </legend>
+
+ <s:radio key='importMode' list="importModes"
+ label='%{getText("echobase.common.importMode")}'
+ required="true" />
+
+ <hr/>
+
+ <div id='USE_EXISTING_VOYAGE' class='importMode'>
+ <s:select name="voyage.topiaId" value="''"
+ label='%{getText("echobase.common.voyage")}'
+ list="voyages" headerKey="" headerValue=""/>
+ </div>
+
+ <div id='CREATE_NEW_VOYAGE' class='importMode'>
+
+ <%--
+ String PROPERTY_VOYAGE_NAME = "voyageName";
+
+ String PROPERTY_VOYAGE_START_DATE = "voyageStartDate";
+
+ String PROPERTY_VOYAGE_END_DATE = "voyageEndDate";
+
+ String PROPERTY_VOYAGE_START_HARBOUR = "voyageStartHarbour";
+
+ String PROPERTY_VOYAGE_END_HARBOUR = "voyageEndHarbour";
+
+ String PROPERTY_VOYAGE_DESCRIPTION = "voyageDescription";
+
+ String PROPERTY_DATUM = "datum";
+
+ String PROPERTY_MISSION = "mission";
+
+ String PROPERTY_AREA_OF_OPERATION = "areaOfOperation";
+
+ String PROPERTY_TRANSIT = "transit";
+
+ String PROPERTY_ECHOTYPE = "echotype";
+ --%>
+
+ <s:textfield key="voyage.voyageName"
+ label='%{getText("echobase.common.voyageName")}'/>
+
+ <s:textfield key="voyage.voyageStartHarbour"
+ label='%{getText("echobase.common.voyageStartHarbour")}'/>
+
+ <s:textfield key="voyage.voyageEndHarbour"
+ label='%{getText("echobase.common.voyageEndHarbour")}'/>
+
+ <s:textfield key="voyage.datum"
+ label='%{getText("echobase.common.datum")}'/>
+
+ <s:textarea key="voyage.voyageDescription"
+ label='%{getText("echobase.common.voyageDescription")}'/>
+
+ <s:select name="missionId" value="''"
+ label='%{getText("echobase.common.mission")}'
+ list="missions" headerKey="" headerValue=""/>
+
+ <s:select name="areaOfOperationId" value="''"
+ label='%{getText("echobase.common.areaOfOperation")}'
+ list="areaOfOperations" headerKey="" headerValue=""/>
+
+ <sj:datepicker key="voyage.voyageStartDate"
+ label='%{getText("echobase.common.voyageStartDate")}'
+ value="%{new java.util.Date()}"
+ displayFormat="dd/mm/yy"/>
+
+ <sj:datepicker key="voyage.voyageEndDate"
+ label='%{getText("echobase.common.voyageEndDate")}'
+ value="%{new java.util.Date()}"
+ displayFormat="dd/mm/yy"/>
+ </div>
+
+ </fieldset>
+ <br/>
+ <s:submit value='%{getText("echobase.action.validateImportVoyage")}'
+ action="configureVoyage" />
+</s:form>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-24 23:06:43 UTC (rev 116)
@@ -25,9 +25,16 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+<s:url id="url" action="doImport" namespace="/import"/>
+<meta http-equiv="refresh" content="1;url=${url}"/>
+
<title><s:text name="echobase.title.importProgress"/></title>
-<sj:progressbar value="%{EchoBaseActionContext.progression}"/>
+<%-- TODO letellier 20111104 : Add warn icon --%>
+<p><s:text name="echobase.message.warnImportInProgress"/></p>
-<%-- TODO letellier 20111104 : Add warn icon --%>
-<p><s:text name="echobase.message.warnImportInProgress"/></p>
\ No newline at end of file
+<br/>
+
+<div>
+ <sj:progressbar value="%{model.progression}"/>
+</div>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp 2011-11-24 23:06:43 UTC (rev 116)
@@ -26,4 +26,23 @@
<title><s:text name="echobase.title.importResult"/></title>
-<%-- TODO letellier 20111104 : Add import results --%>
\ No newline at end of file
+<s:iterator value="importResult" var="entry">
+ <s:set var="inputFile" value="%{#entry.key}"/>
+ <s:set var="result" value="%{#entry.value}"/>
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.importFileResult">
+ <s:param><strong><s:property value="%{#inputFile.label}"/></strong></s:param>
+ </s:text>
+ </legend>
+
+ <s:label value="%{#inputFile.fileName}"
+ label="%{getText('echobase.label.importFile')}"/>
+
+ <s:label value="%{#result.numberCreated}"
+ label="%{getText('echobase.label.numberOfCreatedEntities')}"/>
+
+ <s:label value="%{#result.numberUpdated}"
+ label="%{getText('echobase.label.numberOfUpdatedEntities')}"/>
+ </fieldset>
+</s:iterator>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/pom.xml 2011-11-24 23:06:43 UTC (rev 116)
@@ -27,8 +27,6 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>EchoBase</name>
-
<description>Projet EchoBase</description>
<inceptionYear>2011</inceptionYear>
<url>http://maven-site.forge.codelutin.com/echobase</url>
Modified: trunk/src/doc/reunions/reunion-2011-11-15.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-11-15.txt 2011-11-24 14:18:03 UTC (rev 115)
+++ trunk/src/doc/reunions/reunion-2011-11-15.txt 2011-11-24 23:06:43 UTC (rev 116)
@@ -23,7 +23,7 @@
- DataMetadataName
- CategoryMeaning
- CategoryType
- - CellMEthod
+ - CellMethod
- discussion autour de la modélisation des *Class* que l'on renomme en *Category*
- suppression de l'entité du référentiel *Region* qui sera au final remplacée
1
0
r115 - trunk/echobase-services/src/main/resources/embedded
by sletellier@users.forge.codelutin.com 24 Nov '11
by sletellier@users.forge.codelutin.com 24 Nov '11
24 Nov '11
Author: sletellier
Date: 2011-11-24 15:18:03 +0100 (Thu, 24 Nov 2011)
New Revision: 115
Url: http://forge.codelutin.com/repositories/revision/echobase/115
Log:
Fix startScripts
Modified:
trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
Modified: trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
===================================================================
--- trunk/echobase-services/src/main/resources/embedded/startEchobase.bat 2011-11-24 13:31:55 UTC (rev 114)
+++ trunk/echobase-services/src/main/resources/embedded/startEchobase.bat 2011-11-24 14:18:03 UTC (rev 115)
@@ -1 +1 @@
-java -jar ${project.build.finalName}.war
\ No newline at end of file
+java -jar echobase-ui-${project.version}.war
\ No newline at end of file
Modified: trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
===================================================================
--- trunk/echobase-services/src/main/resources/embedded/startEchobase.sh 2011-11-24 13:31:55 UTC (rev 114)
+++ trunk/echobase-services/src/main/resources/embedded/startEchobase.sh 2011-11-24 14:18:03 UTC (rev 115)
@@ -2,9 +2,9 @@
MX=512M
cd `dirname $0`
if [ -n "$JAVA_HOME" ]; then
- $JAVA_HOME/bin/java -Xmx$MX -Xms$MX -jar ${project.build.finalName}.war $*
+ $JAVA_HOME/bin/java -Xmx$MX -Xms$MX -jar echobase-ui-${project.version}.war $*
else
- java -Xmx$MX -Xms$MX -jar ${project.build.finalName}.war $*
+ java -Xmx$MX -Xms$MX -jar echobase-ui-${project.version}.war $*
fi
cd "$OLDPWD"
1
0
24 Nov '11
Author: sletellier
Date: 2011-11-24 14:31:55 +0100 (Thu, 24 Nov 2011)
New Revision: 114
Url: http://forge.codelutin.com/repositories/revision/echobase/114
Log:
- Add topia-service-replication
- Add service test structure (AbstractEchoBaseServiceTest)
- Add tests for embeddedApplication service
- Creating visitor to create mocked entities (MokeEntityVisitorCreator)
- Copy start files (.sh and .bat) in embedded application
- Replicate referenciel and voyage selected creating embedded application
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/
trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java
trunk/echobase-services/src/test/resources/echobase.properties
Removed:
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/entities/
Modified:
trunk/echobase-entities/pom.xml
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java
trunk/echobase-entities/src/test/resources/echobase.properties
trunk/echobase-services/pom.xml
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
trunk/echobase-ui/src/main/resources/echobase.properties
trunk/pom.xml
Modified: trunk/echobase-entities/pom.xml
===================================================================
--- trunk/echobase-entities/pom.xml 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-entities/pom.xml 2011-11-24 13:31:55 UTC (rev 114)
@@ -74,6 +74,11 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-replication</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
@@ -127,6 +132,17 @@
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.nuiton.eugene</groupId>
@@ -196,6 +212,13 @@
</plugins>
+ <testResources>
+ <testResource>
+ <directory>${maven.src.dir}/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+
</build>
</project>
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseTopiaRootContextSupplierFactory.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -33,6 +33,8 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.topia.replication.TopiaReplicationService;
+import org.nuiton.topia.replication.TopiaReplicationServiceImpl;
import java.io.File;
import java.io.IOException;
@@ -90,6 +92,10 @@
TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
EchoBaseDAOHelper.getImplementationClassesAsString());
+ // add topiaReplicationService in the context
+ properties.setProperty(TopiaReplicationService.TOPIA_SERVICE_NAME,
+ TopiaReplicationServiceImpl.class.getName());
+
TopiaContext rootContext;
try {
rootContext = TopiaContextFactory.getContext(properties);
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,58 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities;
+
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility method for enities
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public class EntitiesUtil {
+
+ /**
+ * Used to get all contract of a package
+ *
+ * @param entitiesPackage package contening desired entities
+ * @return contracts contained in entitiesPackage
+ */
+ public static EchoBaseEntityEnum[] getContractsOf(Package entitiesPackage) {
+ EchoBaseEntityEnum[] echoBaseEntityEnums = EchoBaseEntityEnum.values();
+ List<EchoBaseEntityEnum> refClasses = new ArrayList<EchoBaseEntityEnum>();
+ for (EchoBaseEntityEnum echoBaseEntityEnum : echoBaseEntityEnums) {
+
+ // Get all entities in package fr.ifremer.echobase.entities.references
+ Class<? extends TopiaEntity> contract = echoBaseEntityEnum.getContract();
+ if (contract.getPackage().equals(entitiesPackage)) {
+ refClasses.add(echoBaseEntityEnum);
+ }
+ }
+ return refClasses.toArray(new EchoBaseEntityEnum[refClasses.size()]);
+ }
+}
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,45 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.data;
+
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.EntitiesUtil;
+
+/**
+ * Data method utility
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public class DataUtil {
+
+ /**
+ * Used to get all contract of a data package
+ *
+ * @return contracts in package data
+ */
+ public static EchoBaseEntityEnum[] getDataContracts() {
+ return EntitiesUtil.getContractsOf(DataUtil.class.getPackage());
+ }
+}
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,45 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.references;
+
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.EntitiesUtil;
+
+/**
+ * References method utility
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public class ReferencesUtil {
+
+ /**
+ * Used to get all contract of a referenciel package
+ *
+ * @return contracts in package referenciel
+ */
+ public static EchoBaseEntityEnum[] getReferencielContracts() {
+ return EntitiesUtil.getContractsOf(ReferencesUtil.class.getPackage());
+ }
+}
Added: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java
===================================================================
--- trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java (rev 0)
+++ trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,54 @@
+/*
+ * #%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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Ignore;
+
+import java.io.File;
+
+/**
+ * Utility methods for tests
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+@Ignore
+public class TestHelper {
+
+ protected static File basedir;
+
+ public static File getBasedir() {
+ if (basedir == null) {
+// String tmp = System.getProperty("basedir");
+// if (tmp == null) {
+// tmp = new File("").getAbsolutePath();
+// }
+// basedir = new File(tmp);
+ basedir = FileUtils.getTempDirectory();
+ }
+ return basedir;
+ }
+
+}
Modified: trunk/echobase-entities/src/test/resources/echobase.properties
===================================================================
--- trunk/echobase-entities/src/test/resources/echobase.properties 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-entities/src/test/resources/echobase.properties 2011-11-24 13:31:55 UTC (rev 114)
@@ -29,3 +29,6 @@
hibernate.connection.url=jdbc:h2:file:${data.directory}/echobase/h2data
hibernate.connection.username=sa
hibernate.connection.password=sa
+
+war.directory=${data.directory}/war
+war.location=${war.directory}/echobase-ui-${project.version}.war
\ No newline at end of file
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-services/pom.xml 2011-11-24 13:31:55 UTC (rev 114)
@@ -24,6 +24,14 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>echobase-entities</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
<!--dependency>
<groupId>fr.ird</groupId>
<artifactId>msaccess-importer</artifactId>
@@ -97,6 +105,11 @@
<artifactId>topia-service-migration</artifactId>
</dependency-->
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-replication</artifactId>
+ </dependency>
+
<!-- test dependencies -->
<dependency>
@@ -153,6 +166,7 @@
</includes>
<excludes>
<exclude>echobase-config</exclude>
+ <exclude>embedded/*</exclude>
</excludes>
</resource>
<resource>
@@ -162,6 +176,11 @@
</includes>
<filtering>true</filtering>
</resource>
+ <resource>
+ <directory>src/main/resources/embedded</directory>
+ <targetPath>embedded</targetPath>
+ <filtering>true</filtering>
+ </resource>
</resources>
<plugins>
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -24,18 +24,21 @@
package fr.ifremer.echobase.services;
import com.google.common.base.Supplier;
-import com.google.common.collect.Lists;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.DataUtil;
+import fr.ifremer.echobase.entities.references.ReferencesUtil;
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.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.replication.TopiaReplicationService;
+import org.nuiton.topia.replication.model.ReplicationModel;
import org.nuiton.util.FileUtil;
import org.nuiton.util.ZipUtil;
@@ -44,12 +47,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.URISyntaxException;
import java.util.List;
/**
* To create embedded application.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @author sletellier <letellier(a)codelutin.com>
* @since 0.1
*/
public class EmbeddedApplicationService extends AbstractEchoBaseService {
@@ -58,7 +63,27 @@
private static final Log log =
LogFactory.getLog(EmbeddedApplicationService.class);
+ public static final String EMBEDDED_PATH = "/embedded/";
+ public enum StartFiles {
+ BAT("startEchobase.sh"),
+ SH("startEchobase.bat");
+
+ protected String fileName;
+
+ StartFiles(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public String getFilePath() {
+ return EMBEDDED_PATH + fileName;
+ }
+ }
+
public File createEmbeddedApplication(String fileName, String... voyageIds) {
File warLocation = getConfiguration().getWarLocation();
@@ -82,6 +107,9 @@
// copy configuration file to /
copyConfigurationFile(zipDirectory);
+ // copy start scripts
+ copyStartFiles(zipDirectory);
+
// copy war to /
FileUtil.copy(warLocation, new File(zipDirectory, warLocation.getName()));
@@ -107,6 +135,24 @@
return zipFile;
}
+ protected void copyStartFiles(File zipDirectory) throws IOException, URISyntaxException {
+
+ for (StartFiles startFile : StartFiles.values()) {
+
+ InputStream inputStream =
+ getClass().getResourceAsStream(startFile.getFilePath());
+
+ File startFileDest = new File(zipDirectory, startFile.getFileName());
+ OutputStream outputStream = new FileOutputStream(startFileDest);
+ try {
+ IOUtils.copy(inputStream, outputStream);
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ IOUtils.closeQuietly(outputStream);
+ }
+ }
+ }
+
protected void copyConfigurationFile(File zipDirectory) throws IOException {
File configurationfile = new File(zipDirectory, "echobase.properties");
@@ -114,7 +160,8 @@
log.info("Copy configuration to " + configurationfile);
}
InputStream configInputStream =
- getClass().getResourceAsStream("/embedded/echobase-embedded.properties");
+ getClass().getResourceAsStream(EMBEDDED_PATH + "echobase-embedded.properties");
+
OutputStream configOutputStream = new FileOutputStream(configurationfile);
try {
IOUtils.copy(configInputStream, configOutputStream);
@@ -124,9 +171,17 @@
}
}
- protected void createH2Batabase(File zipDirectory,
+ protected TopiaContext createH2Batabase(File zipDirectory,
String... voyageIds) throws IOException, TopiaException {
+ return createH2Batabase(zipDirectory, true, voyageIds);
+ }
+
+
+ // Use it only for tests
+ protected TopiaContext createH2Batabase(File zipDirectory, boolean closeRootContext,
+ String... voyageIds) throws IOException, TopiaException {
+
// create new h2 db
Supplier<TopiaContext> topiaContextSupplier =
new EchoBaseTopiaRootContextSupplierFactory().newEmbeddedDatabase(zipDirectory);
@@ -180,22 +235,43 @@
}
// replicate referentiel to new h2 db
- //TODO
+ replicateReferentiel(topiaContext);
if (voyageIds != null) {
// replicate selected voyage to new h2 db
- VoyageService voyageService = newService(VoyageService.class);
- List<Voyage> voyages = Lists.newArrayList();
- for (String voyageId : voyageIds) {
- Voyage voyage = voyageService.getVoyageById(voyageId);
- voyages.add(voyage);
- }
- getTransaction().replicateEntities(topiaContext, voyages);
+ replicateVoyages(topiaContext, voyageIds);
}
} finally {
- rootContext.closeContext();
+ if (closeRootContext) {
+ rootContext.closeContext();
+ }
}
+ return rootContext;
+ }
+ protected void replicateVoyages(TopiaContext topiaContextDest, String... voyagesIds) throws TopiaException {
+ TopiaReplicationService service = getTransaction().getService(TopiaReplicationService.class);
+ ReplicationModel replicationModel = service.prepare(DataUtil.getDataContracts(), true, voyagesIds);
+ try {
+ service.doReplicate(replicationModel, topiaContextDest);
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException(
+ "Failed to replicate referentiel : ", eee);
+ }
}
+ protected void replicateReferentiel(TopiaContext topiaContextDest) throws TopiaException {
+
+ // Get all referenciel contracts
+ EchoBaseEntityEnum[] referencielClass = ReferencesUtil.getReferencielContracts();
+ TopiaReplicationService service = getTransaction().getService(TopiaReplicationService.class);
+ ReplicationModel replicationModel = service.prepareForAll(referencielClass);
+ try {
+ service.doReplicate(replicationModel, topiaContextDest);
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException(
+ "Failed to replicate referentiel : ", eee);
+ }
+ }
+
}
Added: trunk/echobase-services/src/main/resources/embedded/startEchobase.bat
===================================================================
--- trunk/echobase-services/src/main/resources/embedded/startEchobase.bat (rev 0)
+++ trunk/echobase-services/src/main/resources/embedded/startEchobase.bat 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1 @@
+java -jar ${project.build.finalName}.war
\ No newline at end of file
Added: trunk/echobase-services/src/main/resources/embedded/startEchobase.sh
===================================================================
--- trunk/echobase-services/src/main/resources/embedded/startEchobase.sh (rev 0)
+++ trunk/echobase-services/src/main/resources/embedded/startEchobase.sh 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,11 @@
+#!/bin/sh
+MX=512M
+cd `dirname $0`
+if [ -n "$JAVA_HOME" ]; then
+ $JAVA_HOME/bin/java -Xmx$MX -Xms$MX -jar ${project.build.finalName}.war $*
+else
+ java -Xmx$MX -Xms$MX -jar ${project.build.finalName}.war $*
+fi
+cd "$OLDPWD"
+
+
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,229 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities;
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.beanutils.BeanUtils;
+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.persistence.EntityVisitor;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * Visitor to create mocked entities
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public class MockEntityVisitorCreator implements EntityVisitor {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(MockEntityVisitorCreator.class);
+
+ protected TopiaContext transaction;
+
+ private static final int NB_ASSOCIATIONS = 2;
+
+ public MockEntityVisitorCreator(TopiaContext transaction) {
+ this.transaction = transaction;
+ }
+
+ public enum DefaultSimpleValues {
+ DATE(Date.class, new Date()),
+ STRING(String.class, "string"),
+ INTEGER(int.class, 1),
+ FLOAT(float.class, 1f),
+ LONG(long.class, 1l);
+
+ protected Class<?> type;
+ protected Object defaultValue;
+
+ DefaultSimpleValues(Class<?> type, Object defaultValue) {
+ this.type = type;
+ this.defaultValue = defaultValue;
+ }
+
+ protected Class<?> getType() {
+ return type;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ public static <E> E getDefaultValue(Class<E> type) {
+ DefaultSimpleValues defaultSimpleValues = getDefaultSimpleValues(type);
+ return (E) defaultSimpleValues.getDefaultValue();
+ }
+
+ protected static <E> DefaultSimpleValues getDefaultSimpleValues(Class<E> type) {
+ for (DefaultSimpleValues values : values()) {
+ if (type.isAssignableFrom(values.getType())) {
+ return values;
+ }
+ }
+ throw new IllegalArgumentException("No default value found for type : " + type);
+ }
+ }
+
+ @Override
+ public void start(TopiaEntity topiaEntity) {
+ // Do nothing
+ }
+
+ @Override
+ public void end(TopiaEntity topiaEntity) {
+ // Do nothing
+ }
+
+ @Override
+ public final void visit(TopiaEntity entity,
+ String propertyName,
+ Class<?> type,
+ Object value) {
+
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+
+ // chargement d'une composition
+ visitComposition(entity, propertyName, (Class<? extends TopiaEntity>) type);
+
+ } else {
+
+ // visite d'une propriété simple
+ visitSimpleProperty(entity, propertyName, type);
+ }
+ }
+
+ @Override
+ public void visit(TopiaEntity entity,
+ String propertyName,
+ Class<?> collectionType,
+ Class<?> type,
+ Object value) {
+
+ if (!TopiaEntity.class.isAssignableFrom(type)) {
+
+ // ce n'est pas une association (ce cas ne devrait jamais arrivé)
+ return;
+ }
+
+ visitAssociation(entity, propertyName, (Class<? extends TopiaEntity>) type);
+ }
+
+ @Override
+ public final void visit(TopiaEntity entity,
+ String propertyName,
+ Class<?> collectionType,
+ Class<?> type,
+ int index,
+ Object value) {
+ // Never append
+ }
+
+ @Override
+ public void clear() {
+ // Do nothing
+ }
+
+ protected void visitSimpleProperty(TopiaEntity entity,
+ String propertyName,
+ Class<?> type) {
+
+ Object defaultValue = DefaultSimpleValues.getDefaultValue(type);
+ setProperty(entity, propertyName, defaultValue);
+ }
+
+ protected void visitComposition(TopiaEntity entity,
+ String propertyName,
+ Class<? extends TopiaEntity> type) {
+
+ // Do not continue for parent of Cell entities
+ if (Cell.class.isAssignableFrom(entity.getClass()) && Cell.class.equals(type)) {
+ return;
+ }
+
+ TopiaEntity value = createEntity(type);
+ setProperty(entity, propertyName, value);
+ }
+
+ protected void visitAssociation(TopiaEntity entity,
+ String propertyName,
+ Class<? extends TopiaEntity> type) {
+
+ Collection<TopiaEntity> values = new ArrayList<TopiaEntity>();
+ for (int i=0;i<NB_ASSOCIATIONS;i++) {
+ TopiaEntity value = createEntity(type);
+ values.add(value);
+ }
+ setProperty(entity, propertyName, values);
+ }
+
+ protected void setProperty(TopiaEntity entity,
+ String propertyName,
+ Object value) {
+ try {
+ BeanUtils.setProperty(entity, propertyName, value);
+ } catch (Exception eee) {
+ throw new RuntimeException("Failed to set property '" + propertyName +
+ "' with value '" + value +
+ "' for entity : " + entity, eee);
+ }
+ }
+
+ public <T extends TopiaEntity> T createEntity(Class<T> type) {
+
+ TopiaDAO<T> dao = getDAO(type);
+ try {
+
+ // Creating new entity
+ T created = dao.create();
+ try {
+ // Visit created entity
+ created.accept(this);
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException("Failed to visit composition", eee);
+ }
+ return created;
+ } catch (TopiaException eee) {
+ throw new RuntimeException("Failed to create entity type '" + type.getName() + "'", eee);
+ }
+ }
+
+ protected <T extends TopiaEntity, D extends TopiaDAO<? super T>> D getDAO(Class<T> type) {
+
+ try {
+ return EchoBaseDAOHelper.getDAO(transaction, type);
+ } catch (TopiaException eee) {
+ throw new RuntimeException("Failed to get dao for type '" + type.getName() + "'", eee);
+ }
+ }
+}
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,116 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.TestHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.MockEntityVisitorCreator;
+import fr.ifremer.echobase.entities.meta.DbMeta;
+import junit.framework.Assert;
+import org.junit.After;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Common methods (manage transaction, services...) to have on EchoBase tests.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public abstract class AbstractEchoBaseServiceTest extends Assert {
+
+ protected TopiaContext transaction;
+ protected EchoBaseConfiguration config;
+ protected EchoBaseServiceFactory serviceFactory;
+ protected DbMeta dbMeta;
+
+ @After
+ public void after() throws TopiaException {
+ if (transaction != null && !transaction.isClosed()) {
+ transaction.rollbackTransaction();
+ transaction.closeContext();
+ }
+ }
+
+ public TopiaContext getTransaction() throws Exception {
+ if (transaction == null || transaction.isClosed()) {
+ EchoBaseTopiaRootContextSupplierFactory factory =
+ new EchoBaseTopiaRootContextSupplierFactory();
+ File basedir = TestHelper.getBasedir();
+ File target = new File(basedir, "/target");
+ Supplier<TopiaContext> topiaContextSupplier = factory.newEmbeddedDatabase(target);
+ TopiaContext rootContext = topiaContextSupplier.get();
+ transaction = rootContext.beginTransaction();
+ }
+ return transaction;
+ }
+
+ public EchoBaseServiceFactory getServiceFactory() {
+ if (serviceFactory == null) {
+ serviceFactory = new EchoBaseServiceFactory();
+ }
+ return serviceFactory;
+ }
+
+ public EchoBaseConfiguration getConfig() {
+ if (config == null) {
+ config = new EchoBaseConfiguration();
+ }
+ return config;
+ }
+
+ public DbMeta getDbMeta() {
+ if (dbMeta == null) {
+ List<EchoBaseEntityEnum> entityEnums =
+ Lists.newArrayList(EchoBaseEntityEnum.values());
+ dbMeta = new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
+ }
+ return dbMeta;
+ }
+
+ protected <E extends EchoBaseService> E getService(Class<E> clazz) throws Exception {
+ EchoBaseServiceContext serviceContext = EchoBaseServiceContextImpl.newContext(
+ Locale.getDefault(),
+ getTransaction(),
+ getConfig(),
+ getDbMeta(),
+ new EchoBaseServiceFactory()
+ );
+ return getServiceFactory().newService(clazz, serviceContext);
+ }
+
+ public <T extends TopiaEntity> T createMockedEntity(Class<T> type) throws Exception {
+ MockEntityVisitorCreator visitor = new MockEntityVisitorCreator(getTransaction());
+ return visitor.createEntity(type);
+ }
+}
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,97 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.TestHelper;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.MockEntityVisitorCreator;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageDAO;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+
+import java.io.File;
+
+/**
+ * Test all fuctionnality of {@link EmbeddedApplicationService}
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.2
+ */
+public class EmbeddedApplicationServiceTest extends AbstractEchoBaseServiceTest {
+
+ public static final String TEST_ECHOBASE_EMBEDDED = "test-echobase-embedded";
+
+ public EmbeddedApplicationService getEmbeddedApplicationService() throws Exception {
+ return getService(EmbeddedApplicationService.class);
+ }
+
+ @Test
+ public void testCreateEmbeddedApplication() throws Exception {
+ File embeddedApplication = getEmbeddedApplicationService().createEmbeddedApplication(TEST_ECHOBASE_EMBEDDED);
+ assertTrue(embeddedApplication.exists());
+ }
+
+ @Test
+ public void testCreateVoyageMock() throws Exception {
+ Voyage mockedVoyage = createMockedEntity(Voyage.class);
+ assertNotNull(mockedVoyage);
+ }
+
+ @Test
+ public void testReplicateVoyageEntity() throws Exception {
+
+ // creating mocked voyage
+ Voyage voyageMocked = createMockedEntity(Voyage.class);
+
+ // commit
+ getTransaction().commitTransaction();
+
+ // create new H2 dataBase in target/voyageId
+ String voyageId = voyageMocked.getTopiaId();
+ File testBaseDir = new File(TestHelper.getBasedir(), voyageId);
+ TopiaContext rootContextDest = getEmbeddedApplicationService().createH2Batabase(testBaseDir, false, voyageId);
+
+ // verify that replicated voyage is in new base
+ TopiaContext transactionDest = null;
+ try {
+ transactionDest = rootContextDest.beginTransaction();
+ VoyageDAO voyageDAO = EchoBaseDAOHelper.getVoyageDAO(transactionDest);
+ Object stringDefaultValue = MockEntityVisitorCreator.DefaultSimpleValues.STRING.getDefaultValue();
+ Voyage voyageReplicated = voyageDAO.findByVoyageName((String) stringDefaultValue);
+
+ // assert voyage is in new base
+ assertNotNull(voyageReplicated);
+
+ // and same ids
+ assertEquals(voyageMocked, voyageReplicated);
+
+ // TODO sletellier 20111124 : try to test deph equality between entities
+ } finally {
+ if (transactionDest != null) {
+ transactionDest.closeContext();
+ }
+ }
+ }
+}
Added: trunk/echobase-services/src/test/resources/echobase.properties
===================================================================
--- trunk/echobase-services/src/test/resources/echobase.properties (rev 0)
+++ trunk/echobase-services/src/test/resources/echobase.properties 2011-11-24 13:31:55 UTC (rev 114)
@@ -0,0 +1,24 @@
+###
+# #%L
+# EchoBase :: Services
+#
+# $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 Affero 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 Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
+data.directory=${java.io.tmpdir}
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/resources/echobase.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-24 13:31:55 UTC (rev 114)
@@ -24,6 +24,7 @@
project.version=${project.version}
project.site.url=${project.url}
+topia.service.replication=org.nuiton.topia.replication.TopiaReplicationServiceImpl
hibernate.hbm2ddl.auto=none
hibernate.show_sql=false
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-23 19:08:01 UTC (rev 113)
+++ trunk/pom.xml 2011-11-24 13:31:55 UTC (rev 114)
@@ -226,6 +226,13 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-replication</artifactId>
+ <version>${topiaVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
1
0
r113 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 20:08:01 +0100 (Wed, 23 Nov 2011)
New Revision: 113
Url: http://forge.codelutin.com/repositories/revision/echobase/113
Log:
use csv model for export sql
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-23 18:02:27 UTC (rev 112)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -113,6 +113,12 @@
return file;
}
+ public char getCsvCharSeparator() {
+ char csvSeparator = applicationConfig.getOption(char.class, EchoBaseConfigurationOption.CSV_CHAR_SEPARATOR.key);
+ Preconditions.checkNotNull(csvSeparator);
+ return csvSeparator;
+ }
+
public Version getApplicationVersion() {
String versionStr =
applicationConfig.getOption(EchoBaseConfigurationOption.VERSION.key);
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-23 18:02:27 UTC (rev 112)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -50,6 +50,9 @@
SITE_URL("project.siteUrl",
"URL du site de l'application",
"", URL.class),
+ CSV_CHAR_SEPARATOR("csv.separator",
+ "Caractère de séparation pour les fichiers csv",
+ ";", char.class),
WAR_DIRECTORY("war.directory",
"Répertoire où est stoqué le war",
"${data.directory}/war", File.class),
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-23 18:02:27 UTC (rev 112)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -67,8 +67,6 @@
/** Logger. */
private static final Log log = LogFactory.getLog(DbEditorService.class);
- public static final char CSV_CHAR_SEPARATOR = ';';
-
protected DecoratorService decoratorService;
protected DecoratorService getDecoratorService() {
@@ -463,7 +461,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForImport(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -490,7 +488,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForSave(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -521,7 +519,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForExport(TableMeta tableMetas) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
@@ -548,7 +546,7 @@
protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForLoad(TableMeta tableMetas,
boolean addDecorated) {
- DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(),
tableMetas);
ModelBuilder<E> modelBuilder = model.modelBuilder;
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $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 Affero 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.ImportExportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Csv model to export sql in {@link ExportSqlService}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class ExportSqlCsvModel implements ImportExportModel<Map<String, Object>> {
+
+
+ protected final char separator;
+
+ protected final ModelBuilder<?> modelBuilder;
+
+ public ExportSqlCsvModel(char separator, String[] columnHeaders) {
+ this.separator = separator;
+ modelBuilder = new ModelBuilder<Object>();
+ for (String columnHeader : columnHeaders) {
+ modelBuilder.newColumnForExport(
+ columnHeader,
+ columnHeader
+ );
+ }
+ }
+
+ @Override
+ public char getSeparator() {
+ return separator;
+ }
+
+ @Override
+ public Collection<ExportableColumn<Map<String, Object>, Object>> getColumnsForExport() {
+ return (Collection) modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Collection<ImportableColumn<Map<String, Object>, Object>> getColumnsForImport() {
+ // never do import from this model
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public Map<String, Object> newEmptyInstance() {
+ // never do import from this model
+ throw new UnsupportedOperationException();
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-23 18:02:27 UTC (rev 112)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -35,6 +35,7 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.util.csv.Export;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -117,8 +118,8 @@
// get a query to count all rows for the request
GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, pager);
try {
- Map<String, Object>[] result = sqlQuery.getResult(getTransaction());
- return result;
+ List<Map<String, Object>> result = sqlQuery.getResult(getTransaction());
+ return result.toArray(new Map[result.size()]);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not execute sql query", eee);
}
@@ -142,26 +143,25 @@
}
}
- public String createCsvFileContent(String sql, EchoBaseUser echoBaseUser) {
+ public String createCsvFileContent(String sql) {
GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, null);
- Map<String, Object>[] rows;
- String[] columnNames;
+ List<Map<String, Object>> rows;
try {
rows = sqlQuery.getResult(getTransaction());
- columnNames = sqlQuery.getColumnNames();
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not execute sql query", eee);
}
- StringBuilder buffer = new StringBuilder();
- int rowCount = rows.length;
- buffer.append(StringUtils.join(columnNames, ";"));
- for (int i = 0; i < rowCount; i++) {
- Map<String, Object> row = rows[i];
- buffer.append('\n').append(StringUtils.join(row.values(), ";"));
+ ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(getConfiguration().getCsvCharSeparator());
+ Export<Map<String, Object>> exporter = Export.newExport(csvModel, rows);
+ String content = null;
+ try {
+ content = exporter.startExportAsString();
+ return content;
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Could not export sql", eee);
}
- return buffer.toString();
}
protected ExportQueryDAO getDAO() throws TopiaException {
@@ -185,10 +185,18 @@
return columnNames;
}
- public Map<String, Object>[] getResult(TopiaContext tx) throws TopiaException {
+ public ExportSqlCsvModel generateCsvModel(char charSeparator) {
+ ExportSqlCsvModel model = new ExportSqlCsvModel(
+ charSeparator,
+ columnNames
+ );
+ return model;
+ }
+
+ public List<Map<String, Object>> getResult(TopiaContext tx) throws TopiaException {
List<Map<String, Object>> rows =
findMultipleResult((TopiaContextImplementor) tx);
- return rows.toArray(new Map[rows.size()]);
+ return rows;
}
public String[] getColumnNames(TopiaContext tx) throws TopiaException {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java 2011-11-23 18:02:27 UTC (rev 112)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/DownloadExportSqlResult.java 2011-11-23 19:08:01 UTC (rev 113)
@@ -84,10 +84,7 @@
ExportSqlService service = newService(ExportSqlService.class);
contentType = "text/csv";
- String content = service.createCsvFileContent(
- sql,
- getEchoBaseSession().getEchoBaseUser()
- );
+ String content = service.createCsvFileContent(sql);
contentLength = content.length();
inputStream = new ByteArrayInputStream(content.getBytes());
1
0