From 71d0a93902c08aa29749585ccabc43c2963211ad Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 5 Dec 2023 11:23:23 +0100 Subject: [PATCH 1/9] =?UTF-8?q?Ajouter=20et=20modifier=20les=20classes=20n?= =?UTF-8?q?=C3=A9cessaires=20[APPS-01X0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kopi/galite/visual/domain/CodeDomain.kt | 76 +++++++++++------ .../org/kopi/galite/visual/domain/Domain.kt | 39 ++++----- .../visual/pivottable/VBooleanCodeColumn.kt | 19 +++++ .../visual/pivottable/VBooleanColumn.kt | 15 ++++ .../galite/visual/pivottable/VCodeColumn.kt | 84 +++++++++++++++++++ .../visual/pivottable/VDecimalCodeColumn.kt | 20 +++++ .../visual/pivottable/VDecimalColumn.kt | 15 ++++ .../visual/pivottable/VIntegerCodeColumn.kt | 19 +++++ .../visual/pivottable/VIntegerColumn.kt | 11 +++ .../visual/pivottable/VPivotTableColumn.kt | 4 +- .../visual/pivottable/VStringCodeColumn.kt | 19 +++++ .../galite/visual/pivottable/VStringColumn.kt | 15 ++++ 12 files changed, 291 insertions(+), 45 deletions(-) create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt index ed97f9c7b..b9bdbdca2 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt @@ -17,36 +17,20 @@ package org.kopi.galite.visual.domain -import java.math.BigDecimal - -import org.kopi.galite.visual.chart.VBooleanCodeDimension -import org.kopi.galite.visual.chart.VColumnFormat -import org.kopi.galite.visual.chart.VDimension -import org.kopi.galite.visual.chart.VDecimalCodeDimension -import org.kopi.galite.visual.chart.VDecimalCodeMeasure -import org.kopi.galite.visual.chart.VIntegerCodeDimension -import org.kopi.galite.visual.chart.VIntegerCodeMeasure -import org.kopi.galite.visual.chart.VMeasure -import org.kopi.galite.visual.chart.VStringCodeDimension +import org.kopi.galite.visual.VColor +import org.kopi.galite.visual.chart.* import org.kopi.galite.visual.dsl.chart.ChartDimension import org.kopi.galite.visual.dsl.chart.ChartMeasure import org.kopi.galite.visual.dsl.common.CodeDescription import org.kopi.galite.visual.dsl.common.LocalizationWriter import org.kopi.galite.visual.dsl.form.FormField +import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.dsl.pivottable.PivotTableField import org.kopi.galite.visual.dsl.report.ReportField -import org.kopi.galite.visual.form.VBooleanCodeField -import org.kopi.galite.visual.form.VField -import org.kopi.galite.visual.form.VDecimalCodeField -import org.kopi.galite.visual.form.VIntegerCodeField -import org.kopi.galite.visual.form.VStringCodeField -import org.kopi.galite.visual.report.VBooleanCodeColumn -import org.kopi.galite.visual.report.VCalculateColumn -import org.kopi.galite.visual.report.VCellFormat -import org.kopi.galite.visual.report.VDecimalCodeColumn -import org.kopi.galite.visual.report.VIntegerCodeColumn -import org.kopi.galite.visual.report.VReportColumn -import org.kopi.galite.visual.report.VStringCodeColumn -import org.kopi.galite.visual.VColor +import org.kopi.galite.visual.form.* +import org.kopi.galite.visual.pivottable.VPivotTableColumn +import org.kopi.galite.visual.report.* +import java.math.BigDecimal /** * Represents a code domain. @@ -224,6 +208,50 @@ open class CodeDomain?> : Domain() { } } + /** + * Builds the pivot table column model + */ + override fun buildPivotTableFieldModel( + field: PivotTableField<*>, + position: Dimension.Position? + ): VPivotTableColumn { + return with(field) { + when (kClass) { + Boolean::class -> org.kopi.galite.visual.pivottable.VBooleanCodeColumn( + ident, + position, + this@CodeDomain.ident.ifEmpty { ident }, + field.source, + codes.map { it.ident }.toTypedArray() + ) + BigDecimal::class -> org.kopi.galite.visual.pivottable.VDecimalCodeColumn( + ident, + position, + this@CodeDomain.ident.ifEmpty { ident }, + field.source, + codes.map { it.ident }.toTypedArray() + ) + Int::class, Long::class -> org.kopi.galite.visual.pivottable.VIntegerCodeColumn( + ident, + position, + this@CodeDomain.ident.ifEmpty { ident }, + field.source!!, + codes.map { it.ident }.toTypedArray() + ) + String::class -> org.kopi.galite.visual.pivottable.VStringCodeColumn( + ident, + position, + this@CodeDomain.ident.ifEmpty { ident }, + field.source, + codes.map { it.ident }.toTypedArray() + ) + else -> throw RuntimeException("Type ${kClass!!.qualifiedName} is not supported") + }.also { + it.initLabels(codes.map { it.label }.toTypedArray()) + } + } + } + /** * Sets a mapping between the values that the domain can take * and a corresponding text to be displayed in a field. diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt index c12200c2e..39890099b 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt @@ -17,15 +17,6 @@ package org.kopi.galite.visual.domain -import java.io.File -import java.math.BigDecimal -import java.time.Instant -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.LocalTime - -import kotlin.reflect.KClass - import org.joda.time.DateTime import org.kopi.galite.type.Image import org.kopi.galite.type.Month @@ -36,12 +27,19 @@ import org.kopi.galite.visual.dsl.chart.ChartDimension import org.kopi.galite.visual.dsl.chart.ChartMeasure import org.kopi.galite.visual.dsl.common.LocalizationWriter import org.kopi.galite.visual.dsl.form.FormField -import org.kopi.galite.visual.dsl.report.ReportField -import org.kopi.galite.visual.form.* -import org.kopi.galite.visual.report.* import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.dsl.pivottable.PivotTableField +import org.kopi.galite.visual.dsl.report.ReportField +import org.kopi.galite.visual.form.* import org.kopi.galite.visual.pivottable.VPivotTableColumn +import org.kopi.galite.visual.report.* +import java.io.File +import java.math.BigDecimal +import java.time.Instant +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.LocalTime +import kotlin.reflect.KClass /** * A domain is a data type with predefined list of allowed values. @@ -182,8 +180,8 @@ open class Domain(val width: Int? = null, BigDecimal::class -> VDecimalDimension(ident, format, height ?: 6, true) String::class -> VStringDimension(ident, format) Boolean::class -> VBooleanDimension(ident, format) - org.joda.time.LocalDate::class, LocalDate::class, java.sql.Date::class, java.util.Date::class -> - VDateDimension(ident, format) + org.joda.time.LocalDate::class, LocalDate::class, java.sql.Date::class, java.util.Date::class + -> VDateDimension(ident, format) Month::class -> VMonthDimension(ident, format) Week::class -> VWeekDimension(ident, format) org.joda.time.LocalTime::class, LocalTime::class -> VTimeDimension(ident, format) @@ -247,11 +245,14 @@ open class Domain(val width: Int? = null, open fun buildPivotTableFieldModel(field: PivotTableField<*>, position: Dimension.Position?): VPivotTableColumn { return with(field) { when (kClass) { - Int::class, Long::class, String::class, BigDecimal::class, Boolean::class, org.joda.time.LocalDate::class, - LocalDate::class, java.sql.Date::class, java.util.Date::class, Month::class, Week::class, org.joda.time.LocalTime::class, - LocalTime::class, Instant::class, LocalDateTime::class, DateTime::class -> - VPivotTableColumn(ident, position) - + Int::class, Long::class-> + org.kopi.galite.visual.pivottable.VIntegerColumn(ident, position) + String::class-> + org.kopi.galite.visual.pivottable.VStringColumn(ident, position) + BigDecimal::class-> + org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position) + Boolean::class -> + org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position) else -> throw java.lang.RuntimeException("Type ${kClass!!.qualifiedName} is not supported") } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt new file mode 100644 index 000000000..ee5d7c7d3 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt @@ -0,0 +1,19 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +class VBooleanCodeColumn (ident: String?, + position: Dimension.Position?, + type: String?, + source: String?, + name: Array ) + : VCodeColumn(ident, + position, + type, + source, + name) { + + override fun getIndex(value: Any): Int { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt new file mode 100644 index 000000000..62cf8a845 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt @@ -0,0 +1,15 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VBooleanColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt new file mode 100644 index 000000000..624c3cade --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.l10n.PivotTableLocalizer +import org.kopi.galite.visual.l10n.TypeLocalizer + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +abstract class VCodeColumn(ident: String?, + position : Dimension.Position?, + private val type: String?, + private val source: String?, + private val idents: Array) + : VPivotTableColumn(ident, + position) { + + protected var names: Array? = null // array of external representations + + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + //abstract override fun compareTo(object1: Any, object2: Any): Int + + /** + * Return a string representation. + */ +// override fun format(o: Any?): String { +// return format?.format(o) ?: if (names != null) names!![getIndex(o)]!! else idents[getIndex(o)] +// } + + /** + * Get the index of the value. + */ + abstract fun getIndex(value: Any): Int + + // ---------------------------------------------------------------------- + // LOCALIZATION + // ---------------------------------------------------------------------- + /** + * Localizes this field + * + * @param parent the caller localizer + */ + override fun localize(parent: PivotTableLocalizer) { + val loc: TypeLocalizer = parent.manager.getTypeLocalizer(source, type) + names = Array(idents.size) { i -> + val label = loc.getCodeLabel(idents[i]) + label + } + } + + fun initLabels(labels: Array) { + names = labels.map { + it + }.toTypedArray() + } +} diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt new file mode 100644 index 000000000..8102b209a --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt @@ -0,0 +1,20 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +class VDecimalCodeColumn (ident: String?, + position: Dimension.Position?, + type: String?, + source: String?, + name: Array ) + : VCodeColumn(ident, + position, + type, + source, + name) { + + override fun getIndex(value: Any): Int { + TODO("Not yet implemented") + } + +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt new file mode 100644 index 000000000..e0eb94da6 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt @@ -0,0 +1,15 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VDecimalColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt new file mode 100644 index 000000000..832b63637 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt @@ -0,0 +1,19 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +class VIntegerCodeColumn (ident: String?, + position: Dimension.Position?, + type: String?, + source: String?, + name: Array ) + : VCodeColumn(ident, + position, + type, + source, + name) { + + override fun getIndex(value: Any): Int { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt new file mode 100644 index 000000000..e5d7f1eec --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt @@ -0,0 +1,11 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +class VIntegerColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + + } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt index 27e826d9d..dee5d7cf9 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt @@ -27,7 +27,7 @@ import org.kopi.galite.visual.l10n.PivotTableLocalizer * @param ident The identifier of the field * @param position The position of the dimension field */ -class VPivotTableColumn(val ident: String?, val position: Dimension.Position?) { +abstract class VPivotTableColumn(val ident: String?, val position: Dimension.Position?) { // ---------------------------------------------------------------------- // DATA MEMBERS @@ -43,7 +43,7 @@ class VPivotTableColumn(val ident: String?, val position: Dimension.Position?) { * * @param parent the caller localizer */ - fun localize(parent: PivotTableLocalizer) { + open fun localize(parent: PivotTableLocalizer) { if (ident != "") { val loc: FieldLocalizer = parent.getFieldLocalizer(ident!!) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt new file mode 100644 index 000000000..81505c388 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt @@ -0,0 +1,19 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +class VStringCodeColumn (ident: String?, + position: Dimension.Position?, + type: String?, + source: String?, + name: Array ) + : VCodeColumn(ident, + position, + type, + source, + name) { + + override fun getIndex(value: Any): Int { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt new file mode 100644 index 000000000..0e0840945 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt @@ -0,0 +1,15 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VStringColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + +} \ No newline at end of file From 20675e29069fa20746146fa7d68d9bf36ea9f03c Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Wed, 6 Dec 2023 09:52:37 +0100 Subject: [PATCH 2/9] Ajouter l'attribut 'format' de type 'VCellFormat'aux nouvelles classes de PivotTable [APPS-01X0] --- .../kopi/galite/visual/domain/CodeDomain.kt | 20 ++++++--- .../org/kopi/galite/visual/domain/Domain.kt | 10 ++--- .../galite/visual/dsl/pivottable/Dimension.kt | 12 ++++- .../galite/visual/dsl/pivottable/Measure.kt | 13 +++++- .../visual/pivottable/VBooleanCodeColumn.kt | 16 +++++-- .../visual/pivottable/VBooleanColumn.kt | 7 ++- .../galite/visual/pivottable/VCodeColumn.kt | 13 +++--- .../visual/pivottable/VDecimalCodeColumn.kt | 25 ++++++++--- .../visual/pivottable/VDecimalColumn.kt | 7 ++- .../visual/pivottable/VIntegerCodeColumn.kt | 33 ++++++++++++-- .../visual/pivottable/VIntegerColumn.kt | 7 ++- .../visual/pivottable/VPivotTableColumn.kt | 17 ++++++- .../visual/pivottable/VStringCodeColumn.kt | 16 +++++-- .../galite/visual/pivottable/VStringColumn.kt | 7 ++- .../org/kopi/galite/demo/product/ProductP.kt | 45 +++---------------- 15 files changed, 168 insertions(+), 80 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt index b9bdbdca2..6a6776082 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt @@ -213,8 +213,10 @@ open class CodeDomain?> : Domain() { */ override fun buildPivotTableFieldModel( field: PivotTableField<*>, - position: Dimension.Position? + position: Dimension.Position?, + format: VCellFormat? ): VPivotTableColumn { + println(codes.map { it.value}) return with(field) { when (kClass) { Boolean::class -> org.kopi.galite.visual.pivottable.VBooleanCodeColumn( @@ -222,28 +224,36 @@ open class CodeDomain?> : Domain() { position, this@CodeDomain.ident.ifEmpty { ident }, field.source, - codes.map { it.ident }.toTypedArray() + codes.map { it.ident }.toTypedArray(), + format, + codes.map { it.value as Boolean }.toBooleanArray() ) BigDecimal::class -> org.kopi.galite.visual.pivottable.VDecimalCodeColumn( ident, position, this@CodeDomain.ident.ifEmpty { ident }, field.source, - codes.map { it.ident }.toTypedArray() + codes.map { it.ident }.toTypedArray(), + format, + codes.map { it.value as? BigDecimal }.toTypedArray() ) Int::class, Long::class -> org.kopi.galite.visual.pivottable.VIntegerCodeColumn( ident, position, this@CodeDomain.ident.ifEmpty { ident }, field.source!!, - codes.map { it.ident }.toTypedArray() + codes.map { it.ident }.toTypedArray(), + format, + codes.map { it.value as Int }.toIntArray() ) String::class -> org.kopi.galite.visual.pivottable.VStringCodeColumn( ident, position, this@CodeDomain.ident.ifEmpty { ident }, field.source, - codes.map { it.ident }.toTypedArray() + codes.map { it.ident }.toTypedArray(), + format, + codes.map { it.value as? String }.toTypedArray() ) else -> throw RuntimeException("Type ${kClass!!.qualifiedName} is not supported") }.also { diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt index 39890099b..d81187d35 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt @@ -242,17 +242,17 @@ open class Domain(val width: Int? = null, /** * Builds the pivot table column model */ - open fun buildPivotTableFieldModel(field: PivotTableField<*>, position: Dimension.Position?): VPivotTableColumn { + open fun buildPivotTableFieldModel(field: PivotTableField<*>, position: Dimension.Position?, format: VCellFormat?): VPivotTableColumn { return with(field) { when (kClass) { Int::class, Long::class-> - org.kopi.galite.visual.pivottable.VIntegerColumn(ident, position) + org.kopi.galite.visual.pivottable.VIntegerColumn(ident, position, format) String::class-> - org.kopi.galite.visual.pivottable.VStringColumn(ident, position) + org.kopi.galite.visual.pivottable.VStringColumn(ident, position, format) BigDecimal::class-> - org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position) + org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position, format) Boolean::class -> - org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position) + org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position, format) else -> throw java.lang.RuntimeException("Type ${kClass!!.qualifiedName} is not supported") } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt index 6dce53bfc..d3177e45a 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt @@ -19,8 +19,10 @@ package org.kopi.galite.visual.dsl.pivottable import org.kopi.galite.visual.domain.Domain import org.kopi.galite.visual.dsl.common.LocalizationWriter +import org.kopi.galite.visual.dsl.common.Trigger import org.kopi.galite.visual.pivottable.Constants import org.kopi.galite.visual.pivottable.VPivotTableColumn +import org.kopi.galite.visual.report.VCellFormat class Dimension(override val domain: Domain, val init: Dimension.() -> Unit, @@ -32,10 +34,18 @@ class Dimension(override val domain: Domain, init() } + /** format trigger */ + internal var formatTrigger: Trigger? = null + lateinit var model: VPivotTableColumn fun buildPivotTableColumn(): VPivotTableColumn { - model = domain.buildPivotTableFieldModel(this, position).also { column -> + val format: VCellFormat? = if (formatTrigger != null) { + formatTrigger!!.action.method() as VCellFormat + } else { + null + } + model = domain.buildPivotTableFieldModel(this, position,format).also { column -> column.label = label ?: "" column.help = help } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt index fa1971ab1..43947e90d 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt @@ -19,7 +19,9 @@ package org.kopi.galite.visual.dsl.pivottable import org.kopi.galite.visual.domain.Domain import org.kopi.galite.visual.dsl.common.LocalizationWriter +import org.kopi.galite.visual.dsl.common.Trigger import org.kopi.galite.visual.pivottable.VPivotTableColumn +import org.kopi.galite.visual.report.VCellFormat class Measure(override val domain: Domain, val init: Measure.() -> Unit, @@ -30,10 +32,19 @@ class Measure(override val domain: Domain, init() } + /** format trigger */ + internal var formatTrigger: Trigger? = null + lateinit var model: VPivotTableColumn fun buildPivotTableColumn(): VPivotTableColumn { - model = domain.buildPivotTableFieldModel(this, Dimension.Position.NONE).also { column -> + val format: VCellFormat? = if (formatTrigger != null) { + formatTrigger!!.action.method() as VCellFormat + } else { + null + } + + model = domain.buildPivotTableFieldModel(this, Dimension.Position.NONE, format).also { column -> column.label = label ?: "" column.help = help } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt index ee5d7c7d3..906dc6729 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt @@ -1,19 +1,29 @@ package org.kopi.galite.visual.pivottable +import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat class VBooleanCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, - name: Array ) + name: Array, + format: VCellFormat?, + private val codes: BooleanArray) : VCodeColumn(ident, position, type, source, + format, name) { - override fun getIndex(value: Any): Int { - TODO("Not yet implemented") + init { + if (codes.size > 2) { + throw InconsistencyException("Can't define more than two codes for a boolean column") + } + } + override fun getIndex(value: Any?): Int { + return if ((value as Boolean) == codes[0]) 0 else 1 } } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt index 62cf8a845..6dd69b659 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt @@ -1,6 +1,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -8,8 +9,10 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension * @param position The position of the dimension field */ class VBooleanColumn(ident: String?, - position: Dimension.Position?) + position: Dimension.Position?, + format: VCellFormat?) : VPivotTableColumn(ident, - position) { + position, + format) { } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt index 624c3cade..83d54f632 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -21,6 +21,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.l10n.PivotTableLocalizer import org.kopi.galite.visual.l10n.TypeLocalizer +import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -31,9 +32,11 @@ abstract class VCodeColumn(ident: String?, position : Dimension.Position?, private val type: String?, private val source: String?, + format: VCellFormat?, private val idents: Array) : VPivotTableColumn(ident, - position) { + position, + format) { protected var names: Array? = null // array of external representations @@ -51,14 +54,14 @@ abstract class VCodeColumn(ident: String?, /** * Return a string representation. */ -// override fun format(o: Any?): String { -// return format?.format(o) ?: if (names != null) names!![getIndex(o)]!! else idents[getIndex(o)] -// } + override fun format(o: Any?): String { + return format?.format(o) ?: if (names != null) names!![getIndex(o)]!! else idents[getIndex(o)] + } /** * Get the index of the value. */ - abstract fun getIndex(value: Any): Int + abstract fun getIndex(value: Any?): Int // ---------------------------------------------------------------------- // LOCALIZATION diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt index 8102b209a..ea780190c 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt @@ -1,20 +1,33 @@ package org.kopi.galite.visual.pivottable +import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat +import java.math.BigDecimal class VDecimalCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, - name: Array ) + name: Array, + format: VCellFormat?, + private val codes: Array) : VCodeColumn(ident, position, type, source, + format, name) { - override fun getIndex(value: Any): Int { - TODO("Not yet implemented") - } - -} \ No newline at end of file + /** + * Get the index of the value. + */ + override fun getIndex(value: Any?): Int { + for (i in codes.indices) { + if (value == codes[i]) { + return i + } + } + throw InconsistencyException(">>>>$value") + } + } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt index e0eb94da6..e8b7124da 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt @@ -1,6 +1,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -8,8 +9,10 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension * @param position The position of the dimension field */ class VDecimalColumn(ident: String?, - position: Dimension.Position?) + position: Dimension.Position?, + format: VCellFormat?) : VPivotTableColumn(ident, - position) { + position, + format) { } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt index 832b63637..f6bac10e8 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt @@ -1,19 +1,46 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat class VIntegerCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, - name: Array ) + name: Array, + format: VCellFormat?, + private val codes: IntArray) : VCodeColumn(ident, position, type, source, + format, name) { - override fun getIndex(value: Any): Int { - TODO("Not yet implemented") + private var fastIndex = -1 // if array = {fastIndex, fastIndex + 1, ...} + + init { + fastIndex = codes[0] + for (i in 1 until codes.size) { + if (codes[i] != fastIndex + i) { + fastIndex = -1 + break + } + } + } + + /** + * Get the index of the value. + */ + override fun getIndex(value: Any?): Int { + if (fastIndex != -1) { + return (value as Int) - fastIndex + } + for (i in codes.indices) { + if ((value as Int) == codes[i]) { + return i + } + } + return -1 } } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt index e5d7f1eec..094fd0030 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt @@ -1,11 +1,14 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat class VIntegerColumn(ident: String?, - position: Dimension.Position?) + position: Dimension.Position?, + format: VCellFormat?) : VPivotTableColumn(ident, - position) { + position, + format) { } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt index dee5d7cf9..1dfd006b0 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt @@ -21,19 +21,34 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.l10n.FieldLocalizer import org.kopi.galite.visual.l10n.PivotTableLocalizer +import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description * @param ident The identifier of the field * @param position The position of the dimension field + * @param format format of the cells */ -abstract class VPivotTableColumn(val ident: String?, val position: Dimension.Position?) { +abstract class VPivotTableColumn(val ident: String?, + val position: Dimension.Position?, + protected var format: VCellFormat?) { // ---------------------------------------------------------------------- // DATA MEMBERS // ---------------------------------------------------------------------- var label: String = "" var help: String? = null + open var isFolded: Boolean = false + + open fun format(o: Any?): String { + return if (isFolded || o == null) { + "" + } else if (format != null) { + format!!.format(o) + } else { + o.toString() + } + } // ---------------------------------------------------------------------- // LOCALIZATION diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt index 81505c388..11b83ed4a 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt @@ -1,19 +1,29 @@ package org.kopi.galite.visual.pivottable +import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat class VStringCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, - name: Array ) + name: Array, + format: VCellFormat?, + private val codes: Array) : VCodeColumn(ident, position, type, source, + format, name) { - override fun getIndex(value: Any): Int { - TODO("Not yet implemented") + override fun getIndex(value: Any?): Int { + codes.forEachIndexed { index, code -> + if (value == code) { + return index + } + } + throw InconsistencyException(">>>>$value") } } \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt index 0e0840945..2e7b9dbe4 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt @@ -1,6 +1,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -8,8 +9,10 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension * @param position The position of the dimension field */ class VStringColumn(ident: String?, - position: Dimension.Position?) + position: Dimension.Position?, + format: VCellFormat?) : VPivotTableColumn(ident, - position) { + position, + format) { } \ No newline at end of file diff --git a/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt b/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt index 10a48ea4c..71039b0b3 100644 --- a/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt +++ b/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt @@ -16,18 +16,16 @@ */ package org.kopi.galite.demo.product -import java.util.Locale - import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction - import org.kopi.galite.demo.database.Product import org.kopi.galite.visual.domain.DECIMAL import org.kopi.galite.visual.domain.STRING import org.kopi.galite.visual.dsl.common.Icon import org.kopi.galite.visual.dsl.form.Key -import org.kopi.galite.visual.dsl.pivottable.PivotTable import org.kopi.galite.visual.dsl.pivottable.Dimension.Position +import org.kopi.galite.visual.dsl.pivottable.PivotTable +import java.util.* /** * Product Report @@ -54,11 +52,11 @@ class ProductP : PivotTable(title = "Products", locale = Locale.UK) { label = "Supplier" help = "The supplier" } - val tax = dimension(STRING(10), Position.ROW) { + val tax = dimension(Tax, Position.ROW) { label = "Tax" help = "The product tax name" } - val category = dimension(STRING(10), Position.ROW) { + val category = dimension(Category, Position.ROW) { label = "Category" help = "The product category" } @@ -76,42 +74,11 @@ class ProductP : PivotTable(title = "Products", locale = Locale.UK) { this[product] = result[Product.description] this[department] = result[Product.department].orEmpty() this[supplier] = result[Product.supplier].orEmpty() - this[category] = decodeCategory(result[Product.category]) - this[tax] = decodeTax(result[Product.taxName]) + this[category] = result[Product.category] + this[tax] = result[Product.taxName] this[price] = result[Product.price] } } } } - - /** - * Decode category code - * !!! FIXME : Fix pivot table to accept CodeDomain type and automatically convert a code to its value - */ - fun decodeCategory(category: Int) : String { - return when (category) { - 1 -> "shoes" - 2 -> "shirts" - 3 -> "glasses" - 4 -> "pullovers" - 5 -> "jeans" - else -> "UNKNOWN" - } - } - - /** - * Decode Tax code - * !!! FIXME : Fix pivot table to accept CodeDomain type and automatically convert a code to its value - */ - fun decodeTax(taxe: String) : String { - return when (taxe) { - "tax 0" -> "0%" - "tax 1" -> "19%" - "tax 2" -> "9%" - "tax 3" -> "13%" - "tax 4" -> "22%" - "tax 5" -> "11%" - else -> "UNKNOWN" - } - } } From 3208975775df957961c42fd4637514710ea0bbcb Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Fri, 8 Dec 2023 17:26:54 +0100 Subject: [PATCH 3/9] Ajouter methode 'getValueAt()' dans class 'DPivotTable' [APPS-01X0] --- .../kopi/galite/visual/domain/CodeDomain.kt | 1 - .../galite/visual/pivottable/MPivotTable.kt | 26 +++++++++++++++++++ .../ui/vaadin/pivottable/DPivotTable.kt | 15 ++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt index 6a6776082..3dc395c05 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt @@ -216,7 +216,6 @@ open class CodeDomain?> : Domain() { position: Dimension.Position?, format: VCellFormat? ): VPivotTableColumn { - println(codes.map { it.value}) return with(field) { when (kClass) { Boolean::class -> org.kopi.galite.visual.pivottable.VBooleanCodeColumn( diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt index 6b4393173..4e4974e7b 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt @@ -21,6 +21,7 @@ package org.kopi.galite.visual.pivottable import java.io.Serializable import org.kopi.galite.visual.MessageCode +import org.kopi.galite.visual.report.VReportColumn import org.kopi.galite.visual.report.VReportRow class MPivotTable : Serializable { @@ -30,9 +31,16 @@ class MPivotTable : Serializable { // -------------------------------------------------------------------- // Columns contains all columns defined by the user var columns = mutableListOf() // array of column definitions + var accessibleColumns: Array = arrayOf() // array of visible or hide columns + private set // Baserows contains data give by the request of the user internal var userRows: ArrayList? = ArrayList() + private var visibleRows: Array? = null // array of visible rows + + private lateinit var displayLevels: IntArray // column levels in display order + + private lateinit var reverseOrder: IntArray // column mapping from model to display /** * Add a row to the list of rows defined by the user @@ -81,4 +89,22 @@ class MPivotTable : Serializable { * @return the desired row */ fun getRow(row: Int): VPivotTableRow? = userRows!![row] + + /** + * Returns an attribute value for a cell. + * + * @param row the index of the row whose value is to be looked up + * @param column the index of the column whose value is to be looked up (column of the model) + * @return the value Object at the specified cell + */ + fun getValueAt(row: Int, column: Int): Any? { + var x: Any? = null + + try { + x = visibleRows!![row]!!.getValueAt(column) + } catch (e: Exception) { + e.printStackTrace() + } + return if (visibleRows!![row]!!.level < displayLevels[reverseOrder[column]]) null else x + } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt index 96c924ca1..e64a5f108 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt @@ -19,11 +19,18 @@ package org.kopi.galite.visual.ui.vaadin.pivottable import org.vaadin.addons.componentfactory.PivotTable import com.vaadin.flow.component.dependency.CssImport +import com.vaadin.flow.component.grid.ColumnTextAlign +import com.vaadin.flow.component.grid.Grid +import com.vaadin.flow.function.ValueProvider import org.kopi.galite.visual.dsl.pivottable.Dimension.Position import org.kopi.galite.visual.pivottable.MPivotTable import org.kopi.galite.visual.pivottable.UPivotTable import org.kopi.galite.visual.pivottable.VPivotTable +import org.kopi.galite.visual.report.Constants +import org.kopi.galite.visual.report.VReportColumn +import org.kopi.galite.visual.report.VReportRow +import org.kopi.galite.visual.ui.vaadin.report.DReport import org.kopi.galite.visual.ui.vaadin.visual.DWindow @CssImport("./styles/galite/pivottable.css") @@ -64,7 +71,7 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP model.userRows ?.flatMap { it.data.asIterable() } ?.chunked(model.columns.count()) { rows -> - pivotData.addRow(*rows.map { it ?: "" }.toTypedArray())} + pivotData.addRow(*rows.map{ it }.toTypedArray())} // Pivot table dimension pivotOptions.setRows(*rows.toTypedArray()) @@ -93,4 +100,10 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP add(pivot) } + + fun getValueAt(columnIndex: Int, rowIndex: Int): String { + println("entree") + println(model.accessibleColumns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex))) + return model.accessibleColumns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex)) + } } From 6cb0b90d4f5730fcac4777f417a57c16b779694d Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 19 Dec 2023 17:30:47 +0100 Subject: [PATCH 4/9] Corrige l'ordre des importations [APPS-01X0] --- .../kopi/galite/visual/domain/CodeDomain.kt | 31 +++++++++++++++---- .../org/kopi/galite/visual/domain/Domain.kt | 17 +++++----- .../galite/visual/pivottable/MPivotTable.kt | 8 ++--- .../visual/pivottable/VPivotTableColumn.kt | 5 +-- .../ui/vaadin/pivottable/DPivotTable.kt | 22 ++++++------- .../org/kopi/galite/demo/product/ProductP.kt | 4 ++- 6 files changed, 51 insertions(+), 36 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt index 3dc395c05..9b687725d 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt @@ -17,20 +17,39 @@ package org.kopi.galite.visual.domain -import org.kopi.galite.visual.VColor -import org.kopi.galite.visual.chart.* +import java.math.BigDecimal + +import org.kopi.galite.visual.chart.VBooleanCodeDimension +import org.kopi.galite.visual.chart.VColumnFormat +import org.kopi.galite.visual.chart.VDimension +import org.kopi.galite.visual.chart.VDecimalCodeDimension +import org.kopi.galite.visual.chart.VDecimalCodeMeasure +import org.kopi.galite.visual.chart.VIntegerCodeDimension +import org.kopi.galite.visual.chart.VIntegerCodeMeasure +import org.kopi.galite.visual.chart.VMeasure +import org.kopi.galite.visual.chart.VStringCodeDimension import org.kopi.galite.visual.dsl.chart.ChartDimension import org.kopi.galite.visual.dsl.chart.ChartMeasure import org.kopi.galite.visual.dsl.common.CodeDescription import org.kopi.galite.visual.dsl.common.LocalizationWriter import org.kopi.galite.visual.dsl.form.FormField -import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.dsl.pivottable.PivotTableField import org.kopi.galite.visual.dsl.report.ReportField -import org.kopi.galite.visual.form.* +import org.kopi.galite.visual.dsl.pivottable.Dimension +import org.kopi.galite.visual.form.VBooleanCodeField +import org.kopi.galite.visual.form.VField +import org.kopi.galite.visual.form.VDecimalCodeField +import org.kopi.galite.visual.form.VIntegerCodeField +import org.kopi.galite.visual.form.VStringCodeField import org.kopi.galite.visual.pivottable.VPivotTableColumn -import org.kopi.galite.visual.report.* -import java.math.BigDecimal +import org.kopi.galite.visual.report.VBooleanCodeColumn +import org.kopi.galite.visual.report.VCalculateColumn +import org.kopi.galite.visual.report.VCellFormat +import org.kopi.galite.visual.report.VDecimalCodeColumn +import org.kopi.galite.visual.report.VIntegerCodeColumn +import org.kopi.galite.visual.report.VReportColumn +import org.kopi.galite.visual.report.VStringCodeColumn +import org.kopi.galite.visual.VColor /** * Represents a code domain. diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt index d81187d35..089df0b6d 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt @@ -17,6 +17,15 @@ package org.kopi.galite.visual.domain +import java.io.File +import java.math.BigDecimal +import java.time.Instant +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.LocalTime + +import kotlin.reflect.KClass + import org.joda.time.DateTime import org.kopi.galite.type.Image import org.kopi.galite.type.Month @@ -33,13 +42,7 @@ import org.kopi.galite.visual.dsl.report.ReportField import org.kopi.galite.visual.form.* import org.kopi.galite.visual.pivottable.VPivotTableColumn import org.kopi.galite.visual.report.* -import java.io.File -import java.math.BigDecimal -import java.time.Instant -import java.time.LocalDate -import java.time.LocalDateTime -import java.time.LocalTime -import kotlin.reflect.KClass + /** * A domain is a data type with predefined list of allowed values. diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt index 4e4974e7b..1dde327c2 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt @@ -21,8 +21,6 @@ package org.kopi.galite.visual.pivottable import java.io.Serializable import org.kopi.galite.visual.MessageCode -import org.kopi.galite.visual.report.VReportColumn -import org.kopi.galite.visual.report.VReportRow class MPivotTable : Serializable { @@ -35,7 +33,7 @@ class MPivotTable : Serializable { private set // Baserows contains data give by the request of the user - internal var userRows: ArrayList? = ArrayList() + var userRows = mutableListOf() private var visibleRows: Array? = null // array of visible rows private lateinit var displayLevels: IntArray // column levels in display order @@ -101,10 +99,10 @@ class MPivotTable : Serializable { var x: Any? = null try { - x = visibleRows!![row]!!.getValueAt(column) + x = userRows!![row]!!.getValueAt(column) } catch (e: Exception) { e.printStackTrace() } - return if (visibleRows!![row]!!.level < displayLevels[reverseOrder[column]]) null else x + return x } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt index 1dfd006b0..7d67330c5 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt @@ -38,12 +38,9 @@ abstract class VPivotTableColumn(val ident: String?, // ---------------------------------------------------------------------- var label: String = "" var help: String? = null - open var isFolded: Boolean = false open fun format(o: Any?): String { - return if (isFolded || o == null) { - "" - } else if (format != null) { + return if (format != null) { format!!.format(o) } else { o.toString() diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt index e64a5f108..519cb763d 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt @@ -19,18 +19,11 @@ package org.kopi.galite.visual.ui.vaadin.pivottable import org.vaadin.addons.componentfactory.PivotTable import com.vaadin.flow.component.dependency.CssImport -import com.vaadin.flow.component.grid.ColumnTextAlign -import com.vaadin.flow.component.grid.Grid -import com.vaadin.flow.function.ValueProvider import org.kopi.galite.visual.dsl.pivottable.Dimension.Position import org.kopi.galite.visual.pivottable.MPivotTable import org.kopi.galite.visual.pivottable.UPivotTable import org.kopi.galite.visual.pivottable.VPivotTable -import org.kopi.galite.visual.report.Constants -import org.kopi.galite.visual.report.VReportColumn -import org.kopi.galite.visual.report.VReportRow -import org.kopi.galite.visual.ui.vaadin.report.DReport import org.kopi.galite.visual.ui.vaadin.visual.DWindow @CssImport("./styles/galite/pivottable.css") @@ -42,6 +35,7 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP private val model: MPivotTable = pivotTable.model // pivot table model private val pivotData = PivotTable.PivotData() private val pivotOptions = PivotTable.PivotOptions() + private val baseRows = mutableListOf() private val rows = mutableListOf() private val columns = mutableListOf() @@ -58,6 +52,11 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP } override fun build() { + for(j in 0..model.userRows!!.count() - 1) { + for(i in 0..model.columns.count() - 1) { + baseRows.add(getValueAt(i,j)) + } + } model.columns.forEach { pivotData.addColumn(it?.label, it?.javaClass) if (it?.position == Position.ROW) { @@ -68,10 +67,9 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP } } - model.userRows - ?.flatMap { it.data.asIterable() } - ?.chunked(model.columns.count()) { rows -> - pivotData.addRow(*rows.map{ it }.toTypedArray())} + baseRows + .chunked(model.columns.count()) { rows -> + pivotData.addRow(*rows.map{ it ?: "" }.toTypedArray())} // Pivot table dimension pivotOptions.setRows(*rows.toTypedArray()) @@ -102,8 +100,6 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP } fun getValueAt(columnIndex: Int, rowIndex: Int): String { - println("entree") - println(model.accessibleColumns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex))) return model.accessibleColumns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex)) } } diff --git a/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt b/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt index 71039b0b3..a07260abf 100644 --- a/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt +++ b/galite-demo/galite-vaadin/src/main/kotlin/org/kopi/galite/demo/product/ProductP.kt @@ -16,8 +16,11 @@ */ package org.kopi.galite.demo.product +import java.util.Locale + import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction + import org.kopi.galite.demo.database.Product import org.kopi.galite.visual.domain.DECIMAL import org.kopi.galite.visual.domain.STRING @@ -25,7 +28,6 @@ import org.kopi.galite.visual.dsl.common.Icon import org.kopi.galite.visual.dsl.form.Key import org.kopi.galite.visual.dsl.pivottable.Dimension.Position import org.kopi.galite.visual.dsl.pivottable.PivotTable -import java.util.* /** * Product Report From ccf05d6ca786a7c811a3cf87fe3ea89e69dcca27 Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Wed, 20 Dec 2023 10:28:18 +0100 Subject: [PATCH 5/9] Ajoute methode changeValue() a la class DPivotTable [APPS-01X0] --- .../galite/visual/pivottable/MPivotTable.kt | 9 +-------- .../ui/vaadin/pivottable/DPivotTable.kt | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt index 1dde327c2..e5483f65d 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt @@ -29,16 +29,9 @@ class MPivotTable : Serializable { // -------------------------------------------------------------------- // Columns contains all columns defined by the user var columns = mutableListOf() // array of column definitions - var accessibleColumns: Array = arrayOf() // array of visible or hide columns - private set // Baserows contains data give by the request of the user var userRows = mutableListOf() - private var visibleRows: Array? = null // array of visible rows - - private lateinit var displayLevels: IntArray // column levels in display order - - private lateinit var reverseOrder: IntArray // column mapping from model to display /** * Add a row to the list of rows defined by the user @@ -99,7 +92,7 @@ class MPivotTable : Serializable { var x: Any? = null try { - x = userRows!![row]!!.getValueAt(column) + x = userRows[row]!!.getValueAt(column) } catch (e: Exception) { e.printStackTrace() } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt index 519cb763d..a4887fcf9 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt @@ -52,11 +52,6 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP } override fun build() { - for(j in 0..model.userRows!!.count() - 1) { - for(i in 0..model.columns.count() - 1) { - baseRows.add(getValueAt(i,j)) - } - } model.columns.forEach { pivotData.addColumn(it?.label, it?.javaClass) if (it?.position == Position.ROW) { @@ -66,10 +61,10 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP columns.add(it.label) } } - + changeValue() baseRows .chunked(model.columns.count()) { rows -> - pivotData.addRow(*rows.map{ it ?: "" }.toTypedArray())} + pivotData.addRow(*rows.map{ it }.toTypedArray())} // Pivot table dimension pivotOptions.setRows(*rows.toTypedArray()) @@ -99,7 +94,15 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP add(pivot) } + private fun changeValue(){ + for (j in 0 until model.userRows.count()) { + for (i in 0 until model.columns.count()) { + baseRows.add(getValueAt(i, j)) + } + } + } + fun getValueAt(columnIndex: Int, rowIndex: Int): String { - return model.accessibleColumns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex)) + return model.columns[columnIndex]!!.format(model.getValueAt(rowIndex, columnIndex)) } } From 978fe9474c73235f688675d52f153983e6cd4052 Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 26 Dec 2023 11:36:25 +0100 Subject: [PATCH 6/9] Nettoyer le code [APPS-01X0] --- .../org/kopi/galite/visual/domain/CodeDomain.kt | 7 +------ .../org/kopi/galite/visual/domain/Domain.kt | 10 +++++----- .../galite/visual/dsl/pivottable/Dimension.kt | 12 +----------- .../kopi/galite/visual/dsl/pivottable/Measure.kt | 13 +------------ .../kopi/galite/visual/pivottable/MPivotTable.kt | 4 ++-- .../visual/pivottable/VBooleanCodeColumn.kt | 3 --- .../galite/visual/pivottable/VBooleanColumn.kt | 9 ++------- .../kopi/galite/visual/pivottable/VCodeColumn.kt | 7 ++----- .../visual/pivottable/VDecimalCodeColumn.kt | 6 ++---- .../galite/visual/pivottable/VDecimalColumn.kt | 9 ++------- .../visual/pivottable/VIntegerCodeColumn.kt | 3 --- .../galite/visual/pivottable/VIntegerColumn.kt | 10 ++-------- .../galite/visual/pivottable/VPivotTableColumn.kt | 11 ++--------- .../galite/visual/pivottable/VStringCodeColumn.kt | 3 --- .../galite/visual/pivottable/VStringColumn.kt | 9 ++------- .../visual/ui/vaadin/pivottable/DPivotTable.kt | 15 ++++++++------- 16 files changed, 32 insertions(+), 99 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt index 9b687725d..d38f7a359 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/CodeDomain.kt @@ -33,9 +33,9 @@ import org.kopi.galite.visual.dsl.chart.ChartMeasure import org.kopi.galite.visual.dsl.common.CodeDescription import org.kopi.galite.visual.dsl.common.LocalizationWriter import org.kopi.galite.visual.dsl.form.FormField +import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.dsl.pivottable.PivotTableField import org.kopi.galite.visual.dsl.report.ReportField -import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.form.VBooleanCodeField import org.kopi.galite.visual.form.VField import org.kopi.galite.visual.form.VDecimalCodeField @@ -233,7 +233,6 @@ open class CodeDomain?> : Domain() { override fun buildPivotTableFieldModel( field: PivotTableField<*>, position: Dimension.Position?, - format: VCellFormat? ): VPivotTableColumn { return with(field) { when (kClass) { @@ -243,7 +242,6 @@ open class CodeDomain?> : Domain() { this@CodeDomain.ident.ifEmpty { ident }, field.source, codes.map { it.ident }.toTypedArray(), - format, codes.map { it.value as Boolean }.toBooleanArray() ) BigDecimal::class -> org.kopi.galite.visual.pivottable.VDecimalCodeColumn( @@ -252,7 +250,6 @@ open class CodeDomain?> : Domain() { this@CodeDomain.ident.ifEmpty { ident }, field.source, codes.map { it.ident }.toTypedArray(), - format, codes.map { it.value as? BigDecimal }.toTypedArray() ) Int::class, Long::class -> org.kopi.galite.visual.pivottable.VIntegerCodeColumn( @@ -261,7 +258,6 @@ open class CodeDomain?> : Domain() { this@CodeDomain.ident.ifEmpty { ident }, field.source!!, codes.map { it.ident }.toTypedArray(), - format, codes.map { it.value as Int }.toIntArray() ) String::class -> org.kopi.galite.visual.pivottable.VStringCodeColumn( @@ -270,7 +266,6 @@ open class CodeDomain?> : Domain() { this@CodeDomain.ident.ifEmpty { ident }, field.source, codes.map { it.ident }.toTypedArray(), - format, codes.map { it.value as? String }.toTypedArray() ) else -> throw RuntimeException("Type ${kClass!!.qualifiedName} is not supported") diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt index 089df0b6d..0608102f7 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt @@ -245,17 +245,17 @@ open class Domain(val width: Int? = null, /** * Builds the pivot table column model */ - open fun buildPivotTableFieldModel(field: PivotTableField<*>, position: Dimension.Position?, format: VCellFormat?): VPivotTableColumn { + open fun buildPivotTableFieldModel(field: PivotTableField<*>, position: Dimension.Position?): VPivotTableColumn { return with(field) { when (kClass) { Int::class, Long::class-> - org.kopi.galite.visual.pivottable.VIntegerColumn(ident, position, format) + org.kopi.galite.visual.pivottable.VIntegerColumn(ident, position) String::class-> - org.kopi.galite.visual.pivottable.VStringColumn(ident, position, format) + org.kopi.galite.visual.pivottable.VStringColumn(ident, position) BigDecimal::class-> - org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position, format) + org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position) Boolean::class -> - org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position, format) + org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position) else -> throw java.lang.RuntimeException("Type ${kClass!!.qualifiedName} is not supported") } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt index d3177e45a..6dce53bfc 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Dimension.kt @@ -19,10 +19,8 @@ package org.kopi.galite.visual.dsl.pivottable import org.kopi.galite.visual.domain.Domain import org.kopi.galite.visual.dsl.common.LocalizationWriter -import org.kopi.galite.visual.dsl.common.Trigger import org.kopi.galite.visual.pivottable.Constants import org.kopi.galite.visual.pivottable.VPivotTableColumn -import org.kopi.galite.visual.report.VCellFormat class Dimension(override val domain: Domain, val init: Dimension.() -> Unit, @@ -34,18 +32,10 @@ class Dimension(override val domain: Domain, init() } - /** format trigger */ - internal var formatTrigger: Trigger? = null - lateinit var model: VPivotTableColumn fun buildPivotTableColumn(): VPivotTableColumn { - val format: VCellFormat? = if (formatTrigger != null) { - formatTrigger!!.action.method() as VCellFormat - } else { - null - } - model = domain.buildPivotTableFieldModel(this, position,format).also { column -> + model = domain.buildPivotTableFieldModel(this, position).also { column -> column.label = label ?: "" column.help = help } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt index 43947e90d..fa1971ab1 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/dsl/pivottable/Measure.kt @@ -19,9 +19,7 @@ package org.kopi.galite.visual.dsl.pivottable import org.kopi.galite.visual.domain.Domain import org.kopi.galite.visual.dsl.common.LocalizationWriter -import org.kopi.galite.visual.dsl.common.Trigger import org.kopi.galite.visual.pivottable.VPivotTableColumn -import org.kopi.galite.visual.report.VCellFormat class Measure(override val domain: Domain, val init: Measure.() -> Unit, @@ -32,19 +30,10 @@ class Measure(override val domain: Domain, init() } - /** format trigger */ - internal var formatTrigger: Trigger? = null - lateinit var model: VPivotTableColumn fun buildPivotTableColumn(): VPivotTableColumn { - val format: VCellFormat? = if (formatTrigger != null) { - formatTrigger!!.action.method() as VCellFormat - } else { - null - } - - model = domain.buildPivotTableFieldModel(this, Dimension.Position.NONE, format).also { column -> + model = domain.buildPivotTableFieldModel(this, Dimension.Position.NONE).also { column -> column.label = label ?: "" column.help = help } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt index e5483f65d..4bde74bb1 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/MPivotTable.kt @@ -31,7 +31,7 @@ class MPivotTable : Serializable { var columns = mutableListOf() // array of column definitions // Baserows contains data give by the request of the user - var userRows = mutableListOf() + internal var userRows: ArrayList? = ArrayList() /** * Add a row to the list of rows defined by the user @@ -92,7 +92,7 @@ class MPivotTable : Serializable { var x: Any? = null try { - x = userRows[row]!!.getValueAt(column) + x = userRows?.get(row)!!.getValueAt(column) } catch (e: Exception) { e.printStackTrace() } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt index 906dc6729..e2f4dbea4 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt @@ -2,20 +2,17 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat class VBooleanCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, name: Array, - format: VCellFormat?, private val codes: BooleanArray) : VCodeColumn(ident, position, type, source, - format, name) { init { diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt index 6dd69b659..23d1aa97e 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt @@ -1,7 +1,6 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -9,10 +8,6 @@ import org.kopi.galite.visual.report.VCellFormat * @param position The position of the dimension field */ class VBooleanColumn(ident: String?, - position: Dimension.Position?, - format: VCellFormat?) + position: Dimension.Position?) : VPivotTableColumn(ident, - position, - format) { - - } \ No newline at end of file + position) {} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt index 83d54f632..fea56d1de 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -21,7 +21,6 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.l10n.PivotTableLocalizer import org.kopi.galite.visual.l10n.TypeLocalizer -import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -32,11 +31,9 @@ abstract class VCodeColumn(ident: String?, position : Dimension.Position?, private val type: String?, private val source: String?, - format: VCellFormat?, private val idents: Array) : VPivotTableColumn(ident, - position, - format) { + position) { protected var names: Array? = null // array of external representations @@ -55,7 +52,7 @@ abstract class VCodeColumn(ident: String?, * Return a string representation. */ override fun format(o: Any?): String { - return format?.format(o) ?: if (names != null) names!![getIndex(o)]!! else idents[getIndex(o)] + return if (names != null) names!![getIndex(o)]!! else idents[getIndex(o)] } /** diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt index ea780190c..ff4135c9e 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt @@ -1,22 +1,20 @@ package org.kopi.galite.visual.pivottable +import java.math.BigDecimal + import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat -import java.math.BigDecimal class VDecimalCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, name: Array, - format: VCellFormat?, private val codes: Array) : VCodeColumn(ident, position, type, source, - format, name) { /** diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt index e8b7124da..6f38b4630 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt @@ -1,7 +1,6 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -9,10 +8,6 @@ import org.kopi.galite.visual.report.VCellFormat * @param position The position of the dimension field */ class VDecimalColumn(ident: String?, - position: Dimension.Position?, - format: VCellFormat?) + position: Dimension.Position?) : VPivotTableColumn(ident, - position, - format) { - - } + position) {} diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt index f6bac10e8..84a98926f 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt @@ -1,20 +1,17 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat class VIntegerCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, name: Array, - format: VCellFormat?, private val codes: IntArray) : VCodeColumn(ident, position, type, source, - format, name) { private var fastIndex = -1 // if array = {fastIndex, fastIndex + 1, ...} diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt index 094fd0030..4af78a827 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt @@ -1,14 +1,8 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat class VIntegerColumn(ident: String?, - position: Dimension.Position?, - format: VCellFormat?) + position: Dimension.Position?) : VPivotTableColumn(ident, - position, - format) { - - - } \ No newline at end of file + position) {} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt index 7d67330c5..4f3f1d041 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt @@ -21,17 +21,14 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension import org.kopi.galite.visual.l10n.FieldLocalizer import org.kopi.galite.visual.l10n.PivotTableLocalizer -import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description * @param ident The identifier of the field * @param position The position of the dimension field - * @param format format of the cells */ abstract class VPivotTableColumn(val ident: String?, - val position: Dimension.Position?, - protected var format: VCellFormat?) { + val position: Dimension.Position?) { // ---------------------------------------------------------------------- // DATA MEMBERS @@ -40,11 +37,7 @@ abstract class VPivotTableColumn(val ident: String?, var help: String? = null open fun format(o: Any?): String { - return if (format != null) { - format!!.format(o) - } else { - o.toString() - } + return o.toString() } // ---------------------------------------------------------------------- diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt index 11b83ed4a..a9a1568b6 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt @@ -2,20 +2,17 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.util.base.InconsistencyException import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat class VStringCodeColumn (ident: String?, position: Dimension.Position?, type: String?, source: String?, name: Array, - format: VCellFormat?, private val codes: Array) : VCodeColumn(ident, position, type, source, - format, name) { override fun getIndex(value: Any?): Int { diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt index 2e7b9dbe4..2aa6bda62 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt @@ -1,7 +1,6 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.report.VCellFormat /** * Represents a pivot table column description @@ -9,10 +8,6 @@ import org.kopi.galite.visual.report.VCellFormat * @param position The position of the dimension field */ class VStringColumn(ident: String?, - position: Dimension.Position?, - format: VCellFormat?) + position: Dimension.Position?) : VPivotTableColumn(ident, - position, - format) { - -} \ No newline at end of file + position) {} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt index a4887fcf9..5d3584a49 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt @@ -35,7 +35,7 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP private val model: MPivotTable = pivotTable.model // pivot table model private val pivotData = PivotTable.PivotData() private val pivotOptions = PivotTable.PivotOptions() - private val baseRows = mutableListOf() + private val rowsValues = mutableListOf() private val rows = mutableListOf() private val columns = mutableListOf() @@ -43,6 +43,7 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP getModel()!!.setDisplay(this) } + //--------------------------------------------------- // IMPLEMENTATIONS //--------------------------------------------------- @@ -61,8 +62,8 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP columns.add(it.label) } } - changeValue() - baseRows + buildRows() + rowsValues .chunked(model.columns.count()) { rows -> pivotData.addRow(*rows.map{ it }.toTypedArray())} @@ -94,10 +95,10 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP add(pivot) } - private fun changeValue(){ - for (j in 0 until model.userRows.count()) { - for (i in 0 until model.columns.count()) { - baseRows.add(getValueAt(i, j)) + private fun buildRows(){ + for (i in 0 until model.userRows!!.count()) { + for (j in 0 until model.columns.count()) { + rowsValues.add(getValueAt(j, i)) } } } From afef8a5a241aeabaf5e5c1015204784c93ac2e75 Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 26 Dec 2023 12:30:16 +0100 Subject: [PATCH 7/9] Ajouter les class VDateColumn, VMonthColumn, VWeekColumn, VTimeColumn et VTimestampColumn [APPS-01X0] --- .../org/kopi/galite/visual/domain/Domain.kt | 10 +++++++ .../visual/pivottable/VBooleanColumn.kt | 16 ++++++++++- .../galite/visual/pivottable/VCodeColumn.kt | 8 +++--- .../galite/visual/pivottable/VDateColumn.kt | 26 +++++++++++++++++ .../visual/pivottable/VDecimalColumn.kt | 18 ++++++++++-- .../visual/pivottable/VIntegerColumn.kt | 19 ++++++++++++- .../galite/visual/pivottable/VMonthColumn.kt | 28 +++++++++++++++++++ .../visual/pivottable/VPivotTableColumn.kt | 21 +++++++++++++- .../galite/visual/pivottable/VStringColumn.kt | 16 +++++++++-- .../galite/visual/pivottable/VTimeColumn.kt | 28 +++++++++++++++++++ .../visual/pivottable/VTimestampColumn.kt | 28 +++++++++++++++++++ .../galite/visual/pivottable/VWeekColumn.kt | 26 +++++++++++++++++ 12 files changed, 233 insertions(+), 11 deletions(-) create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt create mode 100644 galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt index 0608102f7..ea63a7415 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/domain/Domain.kt @@ -256,6 +256,16 @@ open class Domain(val width: Int? = null, org.kopi.galite.visual.pivottable.VDecimalColumn(ident, position) Boolean::class -> org.kopi.galite.visual.pivottable.VBooleanColumn(ident, position) + org.joda.time.LocalDate::class, LocalDate::class, java.sql.Date::class, java.util.Date::class -> + org.kopi.galite.visual.pivottable.VDateColumn(ident, position) + Month::class -> + org.kopi.galite.visual.pivottable.VMonthColumn(ident, position) + Week::class -> + org.kopi.galite.visual.pivottable.VWeekColumn(ident, position) + org.joda.time.LocalTime::class, LocalTime::class -> + org.kopi.galite.visual.pivottable.VTimeColumn(ident, position) + Instant::class, LocalDateTime::class, DateTime::class -> + org.kopi.galite.visual.pivottable.VTimestampColumn(ident, position) else -> throw java.lang.RuntimeException("Type ${kClass!!.qualifiedName} is not supported") } } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt index 23d1aa97e..22b8e142a 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt @@ -10,4 +10,18 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension class VBooleanColumn(ident: String?, position: Dimension.Position?) : VPivotTableColumn(ident, - position) {} \ No newline at end of file + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + return if (object1 == object2) 0 else if (true == object1) 1 else -1 + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt index fea56d1de..f34a1aea8 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -19,7 +19,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension -import org.kopi.galite.visual.l10n.PivotTableLocalizer +import org.kopi.galite.visual.l10n.FieldLocalizer import org.kopi.galite.visual.l10n.TypeLocalizer /** @@ -66,10 +66,10 @@ abstract class VCodeColumn(ident: String?, /** * Localizes this field * - * @param parent the caller localizer + * @param parentLocalizer the caller localizer */ - override fun localize(parent: PivotTableLocalizer) { - val loc: TypeLocalizer = parent.manager.getTypeLocalizer(source, type) + override fun localize(parentLocalizer: FieldLocalizer) { + val loc: TypeLocalizer = parentLocalizer.manager.getTypeLocalizer(source, type) names = Array(idents.size) { i -> val label = loc.getCodeLabel(idents[i]) label diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt new file mode 100644 index 000000000..0703e66ed --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt @@ -0,0 +1,26 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension +import java.time.LocalDate + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VDateColumn (ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int = (object1 as LocalDate).compareTo(object2 as LocalDate) +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt index 6f38b4630..640bf634c 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt @@ -1,6 +1,7 @@ package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension +import java.math.BigDecimal /** * Represents a pivot table column description @@ -9,5 +10,18 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension */ class VDecimalColumn(ident: String?, position: Dimension.Position?) - : VPivotTableColumn(ident, - position) {} + : VPivotTableColumn(ident, + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int = + (object1 as BigDecimal).compareTo(object2 as BigDecimal) +} diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt index 4af78a827..f20a9d0ce 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt @@ -5,4 +5,21 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension class VIntegerColumn(ident: String?, position: Dimension.Position?) : VPivotTableColumn(ident, - position) {} \ No newline at end of file + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + val v1 = (object1 as Int) + val v2 = (object2 as Int) + + return if (v1 < v2) -1 else if (v1 > v2) 1 else 0 + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt new file mode 100644 index 000000000..84eb13086 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt @@ -0,0 +1,28 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.type.Month +import org.kopi.galite.visual.dsl.pivottable.Dimension + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VMonthColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + return (object1 as Month).compareTo(object2 as Month) + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt index 4f3f1d041..d2bd4e6e1 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VPivotTableColumn.kt @@ -39,6 +39,16 @@ abstract class VPivotTableColumn(val ident: String?, open fun format(o: Any?): String { return o.toString() } + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + abstract fun compareTo(object1: Any, object2: Any): Int // ---------------------------------------------------------------------- // LOCALIZATION @@ -48,7 +58,7 @@ abstract class VPivotTableColumn(val ident: String?, * * @param parent the caller localizer */ - open fun localize(parent: PivotTableLocalizer) { + fun localize(parent: PivotTableLocalizer) { if (ident != "") { val loc: FieldLocalizer = parent.getFieldLocalizer(ident!!) @@ -56,6 +66,15 @@ abstract class VPivotTableColumn(val ident: String?, } } + /** + * Localizes this field + * + * @param parentLocalizer the caller localizer + */ + protected open fun localize(parentLocalizer: FieldLocalizer) { + // by default nothing to do + } + fun helpOnColumn(help: VHelpGenerator) { help.helpOnColumn(label, this.help) } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt index 2aa6bda62..2021905f2 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt @@ -9,5 +9,17 @@ import org.kopi.galite.visual.dsl.pivottable.Dimension */ class VStringColumn(ident: String?, position: Dimension.Position?) - : VPivotTableColumn(ident, - position) {} \ No newline at end of file + : VPivotTableColumn(ident, + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int = (object1 as String).compareTo((object2 as String)) +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt new file mode 100644 index 000000000..b6a2fc35c --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt @@ -0,0 +1,28 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension +import java.time.LocalTime + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VTimeColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + return (object1 as LocalTime).compareTo(object2 as LocalTime) + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt new file mode 100644 index 000000000..ae30aa20a --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt @@ -0,0 +1,28 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.visual.dsl.pivottable.Dimension +import java.time.Instant + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VTimestampColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + return (object1 as Instant).compareTo(object2 as Instant) + } +} \ No newline at end of file diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt new file mode 100644 index 000000000..f25a3cd98 --- /dev/null +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt @@ -0,0 +1,26 @@ +package org.kopi.galite.visual.pivottable + +import org.kopi.galite.type.Week +import org.kopi.galite.visual.dsl.pivottable.Dimension + +/** + * Represents a pivot table column description + * @param ident The identifier of the field + * @param position The position of the dimension field + */ +class VWeekColumn(ident: String?, + position: Dimension.Position?) + : VPivotTableColumn(ident, + position) { + + /** + * Compare two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int = (object1 as Week).compareTo(object2 as Week) +} \ No newline at end of file From 95384ed8da9bbde0519259311c84b01450cf2607 Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 26 Dec 2023 13:14:58 +0100 Subject: [PATCH 8/9] =?UTF-8?q?Ajouter=20m=C3=A9thode=20compareTo=20aux=20?= =?UTF-8?q?class=20VBooleanCodeColumn,VDecimalCodeColumn,VIntegerCodeColum?= =?UTF-8?q?n,VStringCodeColumn=20et=20VCodeColumn=20[APPS-01X0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visual/pivottable/VBooleanCodeColumn.kt | 5 +++++ .../kopi/galite/visual/pivottable/VCodeColumn.kt | 2 +- .../visual/pivottable/VDecimalCodeColumn.kt | 12 ++++++++++++ .../visual/pivottable/VIntegerCodeColumn.kt | 16 ++++++++++++++++ .../visual/pivottable/VStringCodeColumn.kt | 13 +++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt index e2f4dbea4..fac2d52ba 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt @@ -20,6 +20,11 @@ class VBooleanCodeColumn (ident: String?, throw InconsistencyException("Can't define more than two codes for a boolean column") } } + + override fun compareTo(object1: Any, object2: Any): Int { + return if (object1 == object2) 0 else if (true == object1) 1 else -1 + } + override fun getIndex(value: Any?): Int { return if ((value as Boolean) == codes[0]) 0 else 1 } diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt index f34a1aea8..a517592c8 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -46,7 +46,7 @@ abstract class VCodeColumn(ident: String?, * 1 if the second operand if smaller than the first * 0 if the two operands are equal */ - //abstract override fun compareTo(object1: Any, object2: Any): Int + abstract override fun compareTo(object1: Any, object2: Any): Int /** * Return a string representation. diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt index ff4135c9e..5f19cb299 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt @@ -17,6 +17,18 @@ class VDecimalCodeColumn (ident: String?, source, name) { + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int = (object1 as BigDecimal) + .compareTo(object2 as BigDecimal) + /** * Get the index of the value. */ diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt index 84a98926f..9dc43213a 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt @@ -26,6 +26,22 @@ class VIntegerCodeColumn (ident: String?, } } + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + val v1 = (object1 as Int) + val v2 = (object2 as Int) + + return if (v1 < v2) -1 else if (v1 > v2) 1 else 0 + } + /** * Get the index of the value. */ diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt index a9a1568b6..153128098 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt @@ -15,6 +15,19 @@ class VStringCodeColumn (ident: String?, source, name) { + /** + * Compares two objects. + * + * @param object1 the first operand of the comparison + * @param object2 the second operand of the comparison + * @return -1 if the first operand is smaller than the second + * 1 if the second operand if smaller than the first + * 0 if the two operands are equal + */ + override fun compareTo(object1: Any, object2: Any): Int { + return (object1 as String).compareTo((object2 as String)) + } + override fun getIndex(value: Any?): Int { codes.forEachIndexed { index, code -> if (value == code) { From 72623fb0c5eb9a36775e32c62e7a1ed88834f832 Mon Sep 17 00:00:00 2001 From: Iyed Chaabane Date: Tue, 26 Dec 2023 17:37:07 +0100 Subject: [PATCH 9/9] Ajouter une description aux nouveaux classes [APPS-01X0] --- .../visual/pivottable/VBooleanCodeColumn.kt | 28 +++++++++++++++---- .../visual/pivottable/VBooleanColumn.kt | 18 ++++++++++++ .../galite/visual/pivottable/VCodeColumn.kt | 4 +-- .../galite/visual/pivottable/VDateColumn.kt | 18 ++++++++++++ .../visual/pivottable/VDecimalCodeColumn.kt | 18 ++++++++++++ .../visual/pivottable/VDecimalColumn.kt | 18 ++++++++++++ .../visual/pivottable/VIntegerCodeColumn.kt | 28 +++++++++++++++---- .../visual/pivottable/VIntegerColumn.kt | 18 ++++++++++++ .../galite/visual/pivottable/VMonthColumn.kt | 18 ++++++++++++ .../visual/pivottable/VStringCodeColumn.kt | 18 ++++++++++++ .../galite/visual/pivottable/VStringColumn.kt | 18 ++++++++++++ .../galite/visual/pivottable/VTimeColumn.kt | 18 ++++++++++++ .../visual/pivottable/VTimestampColumn.kt | 18 ++++++++++++ .../galite/visual/pivottable/VWeekColumn.kt | 18 ++++++++++++ .../ui/vaadin/pivottable/DPivotTable.kt | 1 - 15 files changed, 246 insertions(+), 13 deletions(-) diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt index fac2d52ba..aaa5aad8f 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanCodeColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.util.base.InconsistencyException @@ -9,11 +27,11 @@ class VBooleanCodeColumn (ident: String?, source: String?, name: Array, private val codes: BooleanArray) - : VCodeColumn(ident, - position, - type, - source, - name) { + : VCodeColumn(ident, + position, + type, + source, + name) { init { if (codes.size > 2) { diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt index 22b8e142a..7ea673a13 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VBooleanColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt index a517592c8..1b4bd5d2f 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VCodeColumn.kt @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN - * Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt index 0703e66ed..471d7f221 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDateColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt index 5f19cb299..30932f38b 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalCodeColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import java.math.BigDecimal diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt index 640bf634c..5f84bc77f 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VDecimalColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt index 9dc43213a..3bd63d2b6 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerCodeColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension @@ -8,11 +26,11 @@ class VIntegerCodeColumn (ident: String?, source: String?, name: Array, private val codes: IntArray) - : VCodeColumn(ident, - position, - type, - source, - name) { + : VCodeColumn(ident, + position, + type, + source, + name) { private var fastIndex = -1 // if array = {fastIndex, fastIndex + 1, ...} diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt index f20a9d0ce..8643d11bf 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VIntegerColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt index 84eb13086..346ef333e 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VMonthColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.type.Month diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt index 153128098..3497d1e90 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringCodeColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.util.base.InconsistencyException diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt index 2021905f2..504f53be3 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VStringColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt index b6a2fc35c..53dcec4e5 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimeColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt index ae30aa20a..4a7abf1a4 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VTimestampColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.visual.dsl.pivottable.Dimension diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt index f25a3cd98..a7ba2410c 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/pivottable/VWeekColumn.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2013-2023 kopiLeft Services SARL, Tunis TN + * Copyright (c) 1990-2023 kopiRight Managed Solutions GmbH, Wien AT + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package org.kopi.galite.visual.pivottable import org.kopi.galite.type.Week diff --git a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt index 5d3584a49..ae4e8eb85 100644 --- a/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt +++ b/galite-core/src/main/kotlin/org/kopi/galite/visual/ui/vaadin/pivottable/DPivotTable.kt @@ -43,7 +43,6 @@ class DPivotTable(private val pivotTable: VPivotTable) : DWindow(pivotTable), UP getModel()!!.setDisplay(this) } - //--------------------------------------------------- // IMPLEMENTATIONS //---------------------------------------------------