Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/Modules/Module OLAP/module.properties |
---|
1,5 → 1,5 |
# [\p{Alnum}_.]{3,} |
id=org.openconcerto.modules.reports.olap |
# \p{Digit}(\.\p{Digit}+)? |
version=1.2 |
version=1.0 |
contact=ILM Informatique |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPSQLPanel.java |
---|
File deleted |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPPanel.java |
---|
20,8 → 20,6 |
import org.openconcerto.utils.FileUtils; |
public class OLAPPanel extends JPanel { |
private String loadInfo = ""; |
public OLAPPanel() { |
this.setOpaque(false); |
this.setLayout(new GridLayout(1, 1)); |
40,12 → 38,10 |
if (f.exists()) { |
System.out.println("OLAP: using catalog " + f.getAbsolutePath()); |
catalog = FileUtils.read(f, "UTF8"); |
loadInfo = f.getAbsolutePath() + " ok"; |
} else { |
System.out.println("OLAP: using embedded catalog (" + f.getAbsolutePath() + " missing)"); |
final InputStream in = this.getClass().getResourceAsStream("openconcerto_catalog.xml"); |
catalog = FileUtils.readUTF8(in); |
loadInfo = f.getAbsolutePath() + " missing"; |
} |
final String url = getOlapURL(ComptaPropsConfiguration.getInstanceCompta(), catalog); |
final Connection rConnection = DriverManager.getConnection(url); |
94,8 → 90,4 |
} |
return url; |
} |
public String getLoadInfo() { |
return this.loadInfo; |
} |
} |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPMainPanel.java |
---|
1,8 → 1,6 |
package org.openconcerto.modules.reports.olap; |
import java.awt.BorderLayout; |
import java.awt.Dimension; |
import java.awt.FlowLayout; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.Insets; |
10,12 → 8,7 |
import java.awt.event.ActionListener; |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseEvent; |
import java.io.File; |
import java.io.FileWriter; |
import java.io.IOException; |
import javax.swing.JButton; |
import javax.swing.JFileChooser; |
import javax.swing.JLabel; |
import javax.swing.JMenuItem; |
import javax.swing.JPanel; |
24,13 → 17,9 |
import javax.swing.JSplitPane; |
import javax.swing.JTabbedPane; |
import org.jopendocument.panel.Messages; |
import org.olap4j.OlapConnection; |
import org.olap4j.metadata.Schema; |
import org.openconcerto.modules.reports.olap.renderer.Matrix; |
import org.openconcerto.ui.JLabelBold; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.text.CSVWriter; |
public class OLAPMainPanel extends JPanel { |
OLAPMainPanel(OlapConnection oConnection, Schema schema, final OLAPPanel olapPanel) { |
43,7 → 32,6 |
c.gridy = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
final JLabelBold title = new JLabelBold("Analyse multidimensionnelle des données"); |
title.setToolTipText(olapPanel.getLoadInfo()); |
this.addMouseListener(new MouseAdapter() { |
@Override |
public void mouseReleased(MouseEvent e) { |
76,10 → 64,8 |
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); |
split.setBorder(null); |
final OLAPParametersPanel parameters = new OLAPParametersPanel(schema); |
parameters.setMinimumSize(new Dimension(200, 200)); |
parameters.setOpaque(false); |
split.setLeftComponent(parameters); |
split.setDividerLocation(200); |
split.setOpaque(true); |
JPanel rightPanel = new JPanel(); |
89,65 → 75,16 |
final OLAPRenderer renderer = new OLAPRenderer(); |
final OLAPMDXPanel mdxPanel = new OLAPMDXPanel(parameters, oConnection, renderer); |
final OLAPSQLPanel sqlPanel = new OLAPSQLPanel(renderer); |
final OLAPConfigurationPanel confPanel = new OLAPConfigurationPanel(parameters, oConnection, renderer, mdxPanel); |
parameters.setConfigurationPanel(confPanel); |
JTabbedPane t = new JTabbedPane(); |
t.add("Mode simplifié", confPanel); |
t.add("Requête MDX", mdxPanel); |
t.add("Requête SQL", sqlPanel); |
renderer.setOpaque(false); |
t.setOpaque(false); |
// Bottom panel |
JPanel p = new JPanel(); |
p.setLayout(new FlowLayout(FlowLayout.LEFT)); |
JButton bExport = new JButton("Exporter"); |
bExport.addActionListener(new ActionListener() { |
@Override |
public void actionPerformed(ActionEvent e) { |
Matrix m = renderer.getMatrix(); |
if (m == null) { |
return; |
} |
JFileChooser fileChooser = new JFileChooser(); |
fileChooser.setSelectedFile(new File("export_olap.csv")); |
fileChooser.setDialogTitle(Messages.getString("ODSViewerPanel.saveAs")); |
int userSelection = fileChooser.showSaveDialog(OLAPMainPanel.this); |
if (userSelection == JFileChooser.APPROVE_OPTION) { |
File file = fileChooser.getSelectedFile(); |
try { |
int witdth = m.getWidth(); |
final FileWriter writer = new FileWriter(file); |
CSVWriter w = new CSVWriter(writer); |
for (int y = 0; y < m.getHeight(); y++) { |
String[] a = new String[witdth]; |
for (int x = 0; x < witdth; x++) { |
a[x] = m.get(x, y).getValue(); |
} |
w.writeNext(a); |
w.flush(); |
} |
w.close(); |
writer.close(); |
} catch (IOException e1) { |
ExceptionHandler.handle("Erreur lors de l'export", e1); |
} |
} |
} |
}); |
p.add(bExport); |
// |
rightPanel.add(t, BorderLayout.NORTH); |
rightPanel.add(renderer, BorderLayout.CENTER); |
rightPanel.add(p, BorderLayout.SOUTH); |
split.setRightComponent(rightPanel); |
c.weightx = 1; |
c.weighty = 1; |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPRenderer.java |
---|
1,5 → 1,4 |
package org.openconcerto.modules.reports.olap; |
import java.awt.Color; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
11,10 → 10,10 |
import org.olap4j.CellSet; |
import org.openconcerto.modules.reports.olap.renderer.CellSetRenderer; |
import org.openconcerto.modules.reports.olap.renderer.Matrix; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.ReloadPanel; |
public class OLAPRenderer extends JPanel { |
final CellSetRenderer cellSetRenderer; |
final ReloadPanel reload; |
54,13 → 53,4 |
} |
} |
public Matrix getMatrix() { |
return this.cellSetRenderer.getMatrix(); |
} |
public void setMatrix(Matrix matrix) { |
setWaitState(false); |
cellSetRenderer.setMatrix(matrix); |
} |
} |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/Module.java |
---|
78,4 → 78,21 |
protected void stop() { |
} |
public static void main(String[] args) throws IOException { |
System.setProperty(ConnexionPanel.QUICK_LOGIN, "true"); |
final File propsFile = new File("module.properties"); |
final File distDir = new File("dist"); |
FileUtils.mkdir_p(distDir); |
final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/")); |
modulePackager.setSkipDuplicateFiles(true); |
modulePackager.addJarsFromDir(new File("lib")); |
modulePackager.writeToDir(distDir); |
modulePackager.writeToDir(new File("../OpenConcerto/Modules")); |
SQLRequestLog.setEnabled(true); |
SQLRequestLog.showFrame(); |
ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules")); |
Gestion.main(args); |
} |
} |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/renderer/Matrix.java |
---|
26,7 → 26,7 |
* @param y Y coordinate |
* @param value Value |
*/ |
public void set(int x, int y, String value) { |
void set(int x, int y, String value) { |
set(x, y, value, false, false); |
} |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/renderer/MatrixCell.java |
---|
18,8 → 18,4 |
this.right = right; |
this.sameAsPrev = sameAsPrev; |
} |
public String getValue() { |
return value; |
} |
} |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/renderer/CellSetRenderer.java |
---|
22,6 → 22,7 |
import org.olap4j.Position; |
import org.olap4j.impl.CoordinateIterator; |
import org.olap4j.impl.Olap4jUtil; |
import org.olap4j.metadata.Member; |
public class CellSetRenderer extends JComponent implements Scrollable { |
33,16 → 34,11 |
private AxisInfo rowsAxisInfo; |
private int w; |
private int h; |
private Matrix matrix; |
public CellSetRenderer() { |
} |
public Matrix getMatrix() { |
return matrix; |
} |
public CellSetRenderer(CellSet set) { |
this.cellSet = set; |
computeCells(); |
49,7 → 45,7 |
} |
public void setCellSet(CellSet set) { |
this.matrix = null; |
this.cellSet = set; |
computeCells(); |
repaint(); |
56,17 → 52,6 |
this.setSize(new Dimension(w, h)); |
} |
public void setMatrix(Matrix matrix2) { |
this.matrix = matrix2; |
this.cellSet = null; |
this.rowsAxis = null; |
this.rowsAxisInfo = null; |
this.columnsAxis = null; |
this.columnsAxisInfo = null; |
repaint(); |
this.setSize(new Dimension(w, h)); |
} |
private void computeCells() { |
if (cellSet == null) { |
return; |
95,16 → 80,10 |
} |
boolean isOuside(int x, int y) { |
if (rowsAxisInfo == null) { |
return false; |
} |
return x < rowsAxisInfo.getWidth() && y < columnsAxisInfo.getWidth(); |
} |
boolean isValue(int x, int y) { |
if (rowsAxisInfo == null) { |
return true; |
} |
return x >= rowsAxisInfo.getWidth() && y >= columnsAxisInfo.getWidth(); |
} |
119,12 → 98,11 |
g.setColor(Color.WHITE); |
g.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height); |
if (cellSet == null && matrix == null) { |
if (cellSet == null) { |
return; |
} |
if (cellSet != null && cellSet.getAxes().size() > 2) { |
if (cellSet.getAxes().size() > 2) { |
int[] dimensions = new int[cellSet.getAxes().size() - 2]; |
for (int i = 2; i < cellSet.getAxes().size(); i++) { |
CellSetAxis cellSetAxis = cellSet.getAxes().get(i); |
158,14 → 136,11 |
} |
// Figure out the dimensions of the blank rectangle in the top left |
// corner. |
int yOffset = 0; |
int xOffsset = 0; |
final int yOffset = columnsAxisInfo.getWidth(); |
final int xOffsset = rowsAxisInfo.getWidth(); |
// Populate a string matrix |
if (matrix == null) { |
yOffset = columnsAxisInfo.getWidth(); |
xOffsset = rowsAxisInfo.getWidth(); |
this.matrix = new Matrix(xOffsset + (columnsAxis == null ? 1 : columnsAxis.getPositions().size()), yOffset + (rowsAxis == null ? 1 : rowsAxis.getPositions().size())); |
Matrix matrix = new Matrix(xOffsset + (columnsAxis == null ? 1 : columnsAxis.getPositions().size()), yOffset + (rowsAxis == null ? 1 : rowsAxis.getPositions().size())); |
// Populate corner |
for (int x = 0; x < xOffsset; x++) { |
192,7 → 167,7 |
} |
matrix.set(x, y, cell.getFormattedValue(), true, false); |
} |
} |
final int matrixWidth = matrix.getWidth(); |
final int matrixHeight = matrix.getHeight(); |
int[] columnWidths = new int[matrixWidth]; |
262,7 → 237,7 |
g.drawString(value, xString, y * lineHeight + (int) (spaceH * 1.4f)); |
} |
if (columnsAxisInfo != null) { |
// Top |
if (!isOuside(x, y) |
&& (value.length() > 0 || y == columnsAxisInfo.getWidth() || isValue(x, y) || (!isValue(x, y) && (leftNotEmpty(matrix, x, y - 1)) || leftNotEmpty(matrix, x, y)))) { |
270,8 → 245,6 |
g.drawLine(offsetX, y * lineHeight, offsetX + columnWidth, y * lineHeight); |
} |
if (rowsAxisInfo != null) { |
if ((y < columnsAxisInfo.getWidth() && x >= rowsAxisInfo.getWidth()) || isValue(x, y) || (!isOuside(x, y) && (!leftNotEmpty(matrix, x, y) || !isValue(x, y)))) { |
g.setColor(BORDER_COLOR); |
// Left |
279,20 → 252,12 |
} |
} |
} else { |
g.setColor(BORDER_COLOR); |
g.drawLine(offsetX, y * lineHeight, offsetX + columnWidth, y * lineHeight); |
g.drawLine(offsetX, y * lineHeight, offsetX, (y + 1) * lineHeight); |
} |
} |
} |
offsetX += columnWidth; |
widestWidth = Math.max(columnWidth, widestWidth); |
} |
// Right |
g.setColor(BORDER_COLOR); |
final int bottomRightX = offsetX; |
final int bottomRightY = matrixHeight * lineHeight; |
g.drawLine(offsetX, 0, offsetX, bottomRightY); |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPConfigurationPanel.java |
---|
64,7 → 64,7 |
c.gridy++; |
c.weightx = 0; |
c.gridwidth = 1; |
JLabel filtersLabel = new JLabel("Mesure", SwingConstants.RIGHT); |
JLabel filtersLabel = new JLabel("Filtre", SwingConstants.RIGHT); |
this.add(filtersLabel, c); |
filters = new ParameterHolder(false); |
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/openconcerto_catalog.xml |
---|
3,51 → 3,9 |
<Cube name="Ventes"> |
<Table name="SAISIE_VENTE_FACTURE_ELEMENT" schema="_SCHEMA_" /> |
<Dimension name="Commercial" foreignKey="ID_SAISIE_VENTE_FACTURE"> |
<Hierarchy hasAll="true" allMemberName="Tous" primaryKey="ID" primaryKeyTable="SAISIE_VENTE_FACTURE"> |
<Join leftKey="ID_COMMERCIAL" rightKey="ID_COMMERCIAL"> |
<Table name="SAISIE_VENTE_FACTURE" schema="_SCHEMA_" /> |
<Table name="COMMERCIAL" schema="_SCHEMA_" /> |
</Join> |
<Level name="Nom du commercial" table="COMMERCIAL" column="NOM" schema="_SCHEMA_"> |
</Level> |
</Hierarchy> |
</Dimension> |
<Dimension name="Localisation du client" foreignKey="ID_SAISIE_VENTE_FACTURE"> |
<Hierarchy hasAll="true" allMemberName="Tous" primaryKey="ID" primaryKeyTable="SAISIE_VENTE_FACTURE"> |
<Join leftKey="ID_CLIENT" rightKey="ID"> |
<Table name="SAISIE_VENTE_FACTURE" schema="_SCHEMA_" /> |
<Join leftKey="ID_PAYS" rightKey="ID"> |
<Table name="CLIENT" schema="_SCHEMA_" /> |
<Table name="PAYS" schema="_SCHEMA_" /> |
</Join> |
</Join> |
<Level name="Pays" table="PAYS" column="NOM" schema="_SCHEMA_" uniqueMembers="true"> |
</Level> |
<Level name="Nom du client" table="CLIENT" column="NOM" schema="_SCHEMA_"> |
</Level> |
</Hierarchy> |
</Dimension> |
<Dimension name="Client" foreignKey="ID_SAISIE_VENTE_FACTURE"> |
<Hierarchy hasAll="true" allMemberName="Tous" primaryKey="ID" primaryKeyTable="SAISIE_VENTE_FACTURE"> |
<Join leftKey="ID_CLIENT" rightKey="ID"> |
<Table name="SAISIE_VENTE_FACTURE" schema="_SCHEMA_" /> |
<Table name="CLIENT" schema="_SCHEMA_" /> |
</Join> |
<Level name="Nom du client" table="CLIENT" column="NOM" schema="_SCHEMA_"> |
</Level> |
</Hierarchy> |
</Dimension> |
<Dimension name="Articles" foreignKey="ID_ARTICLE"> |
<Hierarchy hasAll="true" allMemberName="Tous les articles" primaryKey="ID"> |
<View alias="articles"> |
<View alias="ARTICLE"> |
<SQL dialect="generic"> <![CDATA[select * from "_SCHEMA_"."ARTICLE" where "ARCHIVE" = '0']]> |
</SQL> |
</View> |
57,7 → 15,7 |
</Dimension> |
<Dimension name="Mode de vente" foreignKey="ID_MODE_VENTE_ARTICLE"> |
<Hierarchy hasAll="true" allMemberName="Tous les modes de vente" primaryKey="ID"> |
<View alias="mode"> |
<View alias="MODE_VENTE_ARTICLE"> |
<SQL dialect="generic"> <![CDATA[select * from "_SCHEMA_"."MODE_VENTE_ARTICLE" where "ARCHIVE" = '0']]> |
</SQL> |
</View> |
68,7 → 26,7 |
<Dimension name="Date de facturation" foreignKey="ID_SAISIE_VENTE_FACTURE" type="TimeDimension"> |
<Hierarchy hasAll="true" allMemberName="Toutes les dates" primaryKey="ID"> |
<View alias="factures"> |
<View alias="SAISIE_VENTE_FACTURE"> |
<SQL dialect="generic"> <![CDATA[select * from "_SCHEMA_"."SAISIE_VENTE_FACTURE" where "ARCHIVE" = '0']]> |
</SQL> |
</View> |
75,7 → 33,7 |
<Level name="Annee" column="DATE" uniqueMembers="true" levelType="TimeYears" type="Numeric"> |
<KeyExpression> |
<SQL dialect="generic"> |
<![CDATA[EXTRACT(YEAR FROM "factures"."DATE")]]> |
<![CDATA[EXTRACT(YEAR FROM "SAISIE_VENTE_FACTURE"."DATE")]]> |
</SQL> |
</KeyExpression> |
</Level> |
84,7 → 42,7 |
formatter="org.openconcerto.modules.reports.olap.formatter.MonthMemberFormatter"> |
<KeyExpression> |
<SQL dialect="generic"> |
<![CDATA[EXTRACT(MONTH FROM "factures"."DATE")]]> |
<![CDATA[EXTRACT(MONTH FROM "SAISIE_VENTE_FACTURE"."DATE")]]> |
</SQL> |
</KeyExpression> |
</Level> |
100,13 → 58,12 |
</Hierarchy> |
</Dimension> |
<Measure name="Quantite" column="QTE" aggregator="sum" formatString="Standard" /> |
<Measure name="Nombre vendu" column="ID_ARTICLE" aggregator="count" formatString="Standard" /> |
<Measure name="Quantite" column="QTE" aggregator="count" formatString="Standard" /> |
<Measure name="Prix de vente HT" column="T_PV_HT" aggregator="sum" |
formatter="org.openconcerto.modules.reports.olap.formatter.CentsCellFormatter" /> |
<Measure name="Prix d'achat HT" column="T_PA_HT" aggregator="sum" |
formatter="org.openconcerto.modules.reports.olap.formatter.CentsCellFormatter" /> |
<Measure name="Nombre de lignes" column="ID_ARTICLE" aggregator="count" formatString="Standard" /> |
<CalculatedMember name="Marge" dimension="Measures"> |
<Formula>[Measures].[Prix de vente HT] - [Measures].[Prix d'achat HT] |
</Formula> |