|
From: <de...@us...> - 2016-02-24 22:28:57
|
Revision: 9294
http://sourceforge.net/p/fudaa/svn/9294
Author: deniger
Date: 2016-02-24 22:28:54 +0000 (Wed, 24 Feb 2016)
Log Message:
-----------
CRUE-644
Modified Paths:
--------------
trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/projet/report/export/ReportExportProfilLongitudinal.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/export/ReportLongitudinalExportAction.java
Modified: trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/projet/report/export/ReportExportProfilLongitudinal.java
===================================================================
--- trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/projet/report/export/ReportExportProfilLongitudinal.java 2016-02-24 20:28:54 UTC (rev 9293)
+++ trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/projet/report/export/ReportExportProfilLongitudinal.java 2016-02-24 22:28:54 UTC (rev 9294)
@@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,6 +37,7 @@
import org.fudaa.dodico.crue.projet.report.data.ReportRunKey;
import org.fudaa.dodico.crue.projet.report.data.ReportRunVariableHelper;
import org.fudaa.dodico.crue.projet.report.data.ReportRunVariableKey;
+import org.fudaa.dodico.crue.projet.report.data.ReportVariableKey;
import org.fudaa.dodico.crue.projet.report.data.ReportVariableTypeEnum;
import org.fudaa.dodico.crue.projet.report.excel.ReportExcelFormatData;
import org.fudaa.dodico.crue.projet.report.longitudinal.ReportLongitudinalBrancheCartouche;
@@ -51,14 +53,49 @@
* @author Frederic Deniger
*/
public class ReportExportProfilLongitudinal extends ReportExportAbstract<ReportLongitudinalConfig, ReportRunVariableKey> {
-
+
public ReportExportProfilLongitudinal(ReportLongitudinalConfig config, ReportResultProviderServiceContrat resultService) {
super(config, resultService);
}
-
+
+ private static class RowCreator {
+
+ int rowIdx = 0;
+ int colOffset = 0;
+ int colIdx = 0;
+ int maxCol = 0;
+ final Sheet currentSheet;
+ Row currentRow;
+
+ public RowCreator(Sheet currentSheet) {
+ this.currentSheet = currentSheet;
+ }
+
+ public void getRowAndIncrement() {
+ currentRow = currentSheet.getRow(rowIdx);
+ if (currentRow == null) {
+ currentRow = currentSheet.createRow(rowIdx);
+ }
+ colIdx = colOffset;
+ rowIdx++;
+ }
+
+ public Cell createNextCell() {
+ Cell res = currentRow.createCell(colIdx++);
+ maxCol = Math.max(maxCol, colIdx);
+ return res;
+ }
+
+ public void nextBlock() {
+ rowIdx = 0;
+ colOffset = maxCol;
+ }
+
+ }
+
@Override
protected void writeInBook(Workbook wb, List<ReportRunVariableKey> variablesToExportInit, List<ResultatTimeKey> times) {
-
+
String sheetName = CtuluResource.CTULU.getString("Feuille {0}", CtuluLibString.getString(1));
ReportExcelFormatData formater = new ReportExcelFormatData(wb);
Sheet currentSheet = wb.createSheet(sheetName);
@@ -68,138 +105,142 @@
ReportLongitudinalLimitHelper limitHelper = new ReportLongitudinalLimitHelper(ccm);
final Map<String, String> displayNameById = limitHelper.getDisplayNameById();
final ItemVariable propertyXp = ccm.getProperty(CrueConfigMetierConstants.PROP_XP);
-
- //ecriture des titres
- int rowIdx = 0;
- Row row = currentSheet.createRow(rowIdx++);
- int idx = 0;
- row.createCell(idx++).setCellValue(BusinessMessages.getString("prefix.branches"));
- row.createCell(idx++).setCellValue(BusinessMessages.getString("prefix.sections"));
- String currentRunName = this.resultService.getRunCourant().getRunKey().getDisplayName();
- row.createCell(idx++).setCellValue(propertyXp.getDisplayNom() + BusinessMessages.ENTITY_SEPARATOR + currentRunName);
- final List<ReportRunVariableKey> profilVariables = content.getProfilVariables();
- //les titres des limites de profils
- for (ReportRunVariableKey variable : profilVariables) {
- if (ReportVariableTypeEnum.LIMIT_PROFIL.equals(variable.getVariable().getVariableType())) {
- String displayName = displayNameById.get(variable.getVariableName());
- if (StringUtils.isEmpty(displayName)) {
- displayName = variable.getVariableName();
+ Set<ReportRunKey> runs = new LinkedHashSet<>();
+ for (ReportRunVariableKey reportRunVariableKey : variablesToExportInit) {
+ runs.add(reportRunVariableKey.getReportRunKey());
+ }
+ RowCreator rowCreator = new RowCreator(currentSheet);
+ for (ReportRunKey runKey : runs) {
+ //ecriture des titres
+ rowCreator.getRowAndIncrement();
+ String runName = runKey.getDisplayName();
+ rowCreator.createNextCell().setCellValue(BusinessMessages.getString("prefix.branches") + BusinessMessages.ENTITY_SEPARATOR + runName);
+ rowCreator.createNextCell().setCellValue(BusinessMessages.getString("prefix.sections") + BusinessMessages.ENTITY_SEPARATOR + runName);
+ rowCreator.createNextCell().setCellValue(propertyXp.getDisplayNom() + BusinessMessages.ENTITY_SEPARATOR + runName);
+ final List<ReportRunVariableKey> profilVariables = content.getProfilVariables();
+ //les titres des limites de profils
+ for (ReportRunVariableKey variable : profilVariables) {
+ if (ReportVariableTypeEnum.LIMIT_PROFIL.equals(variable.getVariable().getVariableType())) {
+ String displayName = displayNameById.get(variable.getVariableName());
+ if (StringUtils.isEmpty(displayName)) {
+ displayName = variable.getVariableName();
+ }
+ rowCreator.createNextCell().setCellValue(displayName + BusinessMessages.ENTITY_SEPARATOR + runName);
}
- row.createCell(idx++).setCellValue(displayName + BusinessMessages.ENTITY_SEPARATOR + currentRunName);
}
- }
+
+ List<ReportRunVariableKey> variablesToExport = new ArrayList<>();
+ List<ReportRunVariableKey> variablesRPIToExport = new ArrayList<>();
- List<ReportRunVariableKey> variablesToExport = new ArrayList<>();
- List<ReportRunVariableKey> variablesRPIToExport = new ArrayList<>();
-
- //pour les valeur RPTI, il ne faut exporter qu'une seul fois par run.
- for (ReportRunVariableKey variable : variablesToExportInit) {
- if (variable.isRPTIVariable()) {
- variablesRPIToExport.add(variable);
- } else {
- variablesToExport.add(variable);
+ //pour les valeur RPTI, il ne faut exporter qu'une seul fois par runKey.
+ for (ReportRunVariableKey variable : variablesToExportInit) {
+ if (variable.getRunKey().equals(runKey)) {
+ if (variable.isRPTIVariable()) {
+ variablesRPIToExport.add(variable);
+ } else {
+ variablesToExport.add(variable);
+ }
+ }
}
- }
- for (ReportRunVariableKey variable : variablesRPIToExport) {
- row.createCell(idx++).setCellValue(
- variable.getVariable().getVariableDisplayName() + BusinessMessages.ENTITY_SEPARATOR + variable.getReportRunKey().getDisplayName());
- }
- for (ResultatTimeKey time : times) {
- for (ReportRunVariableKey variable : variablesToExport) {
- row.createCell(idx++).setCellValue(
- variable.getVariable().getVariableDisplayName() + BusinessMessages.ENTITY_SEPARATOR + ResultatTimeKey.timeToString(time) + BusinessMessages.ENTITY_SEPARATOR + variable.
- getReportRunKey().
- getDisplayName());
+ for (ReportRunVariableKey variable : variablesRPIToExport) {
+ rowCreator.createNextCell().setCellValue(variable.getVariable().getVariableDisplayName() + BusinessMessages.ENTITY_SEPARATOR + runName);
}
- }
- final List<ReportLongitudinalBrancheConfig> branchesConfig = content.getBranchesConfig();
- ReportLongitudinalPositionBuilder positionBuilder = new ReportLongitudinalPositionBuilder(this.resultService, ccm);
- final ReportRunKey runCourant = this.resultService.getRunCourant().getRunKey();
- Set<ReportRunKey> keys = Collections.singleton(runCourant);
+ for (ResultatTimeKey time : times) {
+ for (ReportRunVariableKey variable : variablesToExport) {
+ rowCreator.createNextCell().setCellValue(
+ variable.getVariable().getVariableDisplayName() + BusinessMessages.ENTITY_SEPARATOR + ResultatTimeKey.timeToString(time) + BusinessMessages.ENTITY_SEPARATOR + runName);
+ }
+ }
+ final List<ReportLongitudinalBrancheConfig> branchesConfig = content.getBranchesConfig();
+ ReportLongitudinalPositionBuilder positionBuilder = new ReportLongitudinalPositionBuilder(this.resultService, ccm);
+ Set<ReportRunKey> keys = Collections.singleton(runKey);
- //construction des cartouches
- double xpInit = 0;
- ReportLongitudinalPositionBrancheContent result = new ReportLongitudinalPositionBrancheContent();
- for (ReportLongitudinalBrancheConfig brancheConfig : branchesConfig) {
- xpInit = xpInit + brancheConfig.getDecalXp();
- positionBuilder.buildPositions(xpInit, brancheConfig, result, keys);
- xpInit = xpInit + brancheConfig.getLength();
- }
+ //construction des cartouches
+ double xpInit = 0;
+ ReportLongitudinalPositionBrancheContent result = new ReportLongitudinalPositionBrancheContent();
+ for (ReportLongitudinalBrancheConfig brancheConfig : branchesConfig) {
+ xpInit = xpInit + brancheConfig.getDecalXp();
+ positionBuilder.buildPositions(xpInit, brancheConfig, result, keys);
+ xpInit = xpInit + brancheConfig.getLength();
+ }
- //ecritures des valeurs
- final List<ReportLongitudinalBrancheCartouche> cartouches = result.getCartouches();
- //les styles commun
- final CellStyle xpStyle = formater.getStyle(propertyXp.getNature(), DecimalFormatEpsilonEnum.COMPARISON);
- final PropertyNature natureForZ = resultService.getCcm().getProperty(CrueConfigMetierConstants.PROP_Z).getNature();
- final CellStyle zStyle = formater.
- getStyle(natureForZ, DecimalFormatEpsilonEnum.COMPARISON);
- for (ReportLongitudinalBrancheCartouche cartouche : cartouches) {
- final ReportLongitudinalPositionSectionByRun sectionPositions = cartouche.getSectionPositions(runCourant);
- final List<ReportLongitudinalPositionSection> sectionDisplayPositions = sectionPositions.getSectionDisplayPositions();
- for (ReportLongitudinalPositionSection reportLongitudinalPositionSection : sectionDisplayPositions) {
- idx = 0;
- row = currentSheet.createRow(rowIdx++);
- final CatEMHSection section = reportLongitudinalPositionSection.getName();
- row.createCell(idx++).setCellValue(section.getBranche().getNom());
- row.createCell(idx++).setCellValue(section.getNom());
- Cell cell = row.createCell(idx++);
- cell.setCellValue(reportLongitudinalPositionSection.getXpDisplay());
- cell.setCellStyle(xpStyle);
- for (ReportRunVariableKey variable : profilVariables) {
- if (ReportVariableTypeEnum.LIMIT_PROFIL.equals(variable.getVariable().getVariableType())) {
- ItemEnum etiquette = limitHelper.getEtiquette(variable.getVariable().getVariableName());
- LitNommeLimite limite = limitHelper.getLimite(variable.getVariable().getVariableName());
- cell = row.createCell(idx++);
- if (etiquette != null || limite != null) {
- EMHSectionProfil retrieveProfil = ReportProfilHelper.retrieveProfil(section);
- if (retrieveProfil != null) {
- DonPrtGeoProfilSection profil = DonPrtHelper.getProfilSection(retrieveProfil);
- Double z = ReportExportUtils.computeZ(etiquette, limite, profil, ccm);
- if (z != null) {
- cell.setCellValue(z.doubleValue());
- cell.setCellStyle(zStyle);
-
+ //ecritures des valeurs
+ final List<ReportLongitudinalBrancheCartouche> cartouches = result.getCartouches();
+ //les styles commun
+ final CellStyle xpStyle = formater.getStyle(propertyXp.getNature(), DecimalFormatEpsilonEnum.COMPARISON);
+ final PropertyNature natureForZ = resultService.getCcm().getProperty(CrueConfigMetierConstants.PROP_Z).getNature();
+ final CellStyle zStyle = formater.
+ getStyle(natureForZ, DecimalFormatEpsilonEnum.COMPARISON);
+ for (ReportLongitudinalBrancheCartouche cartouche : cartouches) {
+ final ReportLongitudinalPositionSectionByRun sectionPositions = cartouche.getSectionPositions(runKey);
+ final List<ReportLongitudinalPositionSection> sectionDisplayPositions = sectionPositions.getSectionDisplayPositions();
+ for (ReportLongitudinalPositionSection reportLongitudinalPositionSection : sectionDisplayPositions) {
+ rowCreator.getRowAndIncrement();
+ final CatEMHSection section = reportLongitudinalPositionSection.getName();
+ rowCreator.createNextCell().setCellValue(section.getBranche().getNom());
+ rowCreator.createNextCell().setCellValue(section.getNom());
+ Cell cell = rowCreator.createNextCell();
+ cell.setCellValue(reportLongitudinalPositionSection.getXpDisplay());
+ cell.setCellStyle(xpStyle);
+ for (ReportRunVariableKey variable : profilVariables) {
+ if (ReportVariableTypeEnum.LIMIT_PROFIL.equals(variable.getVariable().getVariableType())) {
+ ItemEnum etiquette = limitHelper.getEtiquette(variable.getVariable().getVariableName());
+ LitNommeLimite limite = limitHelper.getLimite(variable.getVariable().getVariableName());
+ cell = rowCreator.createNextCell();
+ if (etiquette != null || limite != null) {
+ EMHSectionProfil retrieveProfil = ReportProfilHelper.retrieveProfil(section);
+ if (retrieveProfil != null) {
+ DonPrtGeoProfilSection profil = DonPrtHelper.getProfilSection(retrieveProfil);
+ Double z = ReportExportUtils.computeZ(etiquette, limite, profil, ccm);
+ if (z != null) {
+ cell.setCellValue(z.doubleValue());
+ cell.setCellStyle(zStyle);
+
+ }
}
}
}
}
- }
-
- for (ReportRunVariableKey variable : variablesRPIToExport) {
- Double value = resultService.getValue(variable, section.getNom());
- cell = row.createCell(idx++);
- if (value != null) {
- cell.setCellValue(value.doubleValue());
- final CellStyle style = formater.getStyle(resultService.getPropertyNature(variable.getVariableName()),
- DecimalFormatEpsilonEnum.COMPARISON);
- cell.setCellStyle(style);
-
- }
- }
- for (ResultatTimeKey time : times) {
- for (ReportRunVariableKey variable : variablesToExport) {
- boolean isDz = ReportRunVariableHelper.isNatDzVar(variable.getVariable(), resultService);
- Double value = resultService.getValue(time, variable, section.getNom());
- if (isDz && value != null) {
- Double valueZf = ReportProfilHelper.getRPTGZf(section);
- if (valueZf == null) {
- value = null;
- } else {
- value = Double.valueOf(value.doubleValue() + valueZf.doubleValue());
- }
- }
- cell = row.createCell(idx++);
+
+ for (ReportRunVariableKey variableInit : variablesRPIToExport) {
+ ReportRunVariableKey variable = new ReportRunVariableKey(runKey, variableInit.getVariable());
+ Double value = resultService.getValue(variable, section.getNom());
+ cell = rowCreator.createNextCell();
if (value != null) {
cell.setCellValue(value.doubleValue());
final CellStyle style = formater.getStyle(resultService.getPropertyNature(variable.getVariableName()),
DecimalFormatEpsilonEnum.COMPARISON);
cell.setCellStyle(style);
-
+
}
}
+ for (ResultatTimeKey time : times) {
+ for (ReportRunVariableKey variableInit : variablesToExport) {
+ ReportRunVariableKey variable = new ReportRunVariableKey(runKey, variableInit.getVariable());
+ boolean isDz = ReportRunVariableHelper.isNatDzVar(variable.getVariable(), resultService);
+ Double value = resultService.getValue(time, variable, section.getNom());
+ if (isDz && value != null) {
+ Double valueZf = ReportProfilHelper.getRPTGZf(section);
+ if (valueZf == null) {
+ value = null;
+ } else {
+ value = Double.valueOf(value.doubleValue() + valueZf.doubleValue());
+ }
+ }
+ cell = rowCreator.createNextCell();
+ if (value != null) {
+ cell.setCellValue(value.doubleValue());
+ final CellStyle style = formater.getStyle(resultService.getPropertyNature(variable.getVariableName()),
+ DecimalFormatEpsilonEnum.COMPARISON);
+ cell.setCellStyle(style);
+
+ }
+ }
+ }
}
}
+ rowCreator.nextBlock();
}
}
-
+
}
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/export/ReportLongitudinalExportAction.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/export/ReportLongitudinalExportAction.java 2016-02-24 20:28:54 UTC (rev 9293)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/export/ReportLongitudinalExportAction.java 2016-02-24 22:28:54 UTC (rev 9294)
@@ -84,7 +84,9 @@
keys.addAll(runKey);
Collections.sort(keys, ObjetNommeByNameComparator.INSTANCE);
final Set<ResultatTimeKey> selectedTimeKeys = new TreeSet<>();
- selectedTimeKeys.add(reportResultProviderService.getReportService().getSelectedTime());
+ if (reportResultProviderService.getReportService().getSelectedTime() != null) {
+ selectedTimeKeys.add(reportResultProviderService.getReportService().getSelectedTime());
+ }
selectedTimeKeys.addAll(topComponent.getReportConfig().getTimes());
final List<ReportRunVariableKey> variablesKeys = variableChooser.getKeysForRuns(reportResultProviderService, toExport, keys);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|