branch develop updated (ded52c0 -> 59ca87b)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See http://git.codelutin.com/observe.git from ded52c0 Merge branch 'feature/7676' into develop new 59ca87b migration de l'écran des tableaux de synthèse (refs #7678) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 59ca87b2260fa7b61654579bd5090538f6ca84d9 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Nov 5 08:27:26 2015 +0100 migration de l'écran des tableaux de synthèse (refs #7678) Summary of changes: .../ird/observe/business/report/ReportBuilder.java | 490 --------------------- .../observe/business/report/model/DataMatrix.java | 259 ----------- .../ird/observe/business/report/model/Report.java | 144 ------ .../business/report/model/ReportExecute.java | 289 ------------ .../business/report/model/ReportOperation.java | 109 ----- .../business/report/model/ReportRequest.java | 369 ---------------- .../business/report/model/ReportVariable.java | 59 --- .../report/model/operations/ExecuteRequests.java | 126 ------ .../ird/observe/business/report/package-info.java | 30 -- .../java/fr/ird/observe/ui/admin/AdminStep.java | 3 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 2 +- .../ird/observe/ui/admin/report/ReportModel.java | 16 +- .../fr/ird/observe/ui/admin/report/ReportUI.jaxx | 6 +- .../observe/ui/admin/report/ReportUIHandler.java | 290 ++++++------ .../observe/ui/admin/report/ResultTableModel.java | 2 +- .../services/dto/actions/report/Report.java | 39 ++ .../service/actions/report/ReportServiceTopia.java | 21 +- 17 files changed, 191 insertions(+), 2063 deletions(-) delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/ReportBuilder.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/DataMatrix.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/Report.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportExecute.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportOperation.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportRequest.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportVariable.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/model/operations/ExecuteRequests.java delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/business/report/package-info.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 59ca87b2260fa7b61654579bd5090538f6ca84d9 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Thu Nov 5 08:27:26 2015 +0100 migration de l'écran des tableaux de synthèse (refs #7678) --- .../ird/observe/business/report/ReportBuilder.java | 490 --------------------- .../observe/business/report/model/DataMatrix.java | 259 ----------- .../ird/observe/business/report/model/Report.java | 144 ------ .../business/report/model/ReportExecute.java | 289 ------------ .../business/report/model/ReportOperation.java | 109 ----- .../business/report/model/ReportRequest.java | 369 ---------------- .../business/report/model/ReportVariable.java | 59 --- .../report/model/operations/ExecuteRequests.java | 126 ------ .../ird/observe/business/report/package-info.java | 30 -- .../java/fr/ird/observe/ui/admin/AdminStep.java | 3 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 2 +- .../ird/observe/ui/admin/report/ReportModel.java | 16 +- .../fr/ird/observe/ui/admin/report/ReportUI.jaxx | 6 +- .../observe/ui/admin/report/ReportUIHandler.java | 290 ++++++------ .../observe/ui/admin/report/ResultTableModel.java | 2 +- .../services/dto/actions/report/Report.java | 39 ++ .../service/actions/report/ReportServiceTopia.java | 21 +- 17 files changed, 191 insertions(+), 2063 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/ReportBuilder.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/ReportBuilder.java deleted file mode 100644 index f038fa4..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/ReportBuilder.java +++ /dev/null @@ -1,490 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report; - - -import fr.ird.observe.business.report.model.Report; -import fr.ird.observe.business.report.model.ReportExecute; -import fr.ird.observe.business.report.model.ReportOperation; -import fr.ird.observe.business.report.model.ReportRequest; -import fr.ird.observe.business.report.model.ReportVariable; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.SortedProperties; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.ServiceLoader; -import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Classe responsable de la construction d'un report à partir de sa définition - * lue dans un fichier de propriétés. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public class ReportBuilder { - - public static final Pattern REPORT_DEFINITION_PATTERN = Pattern.compile("report.(\\w+).name"); - - public static final String REQUEST_PREFIX = "request."; - - public static final String OPERATION_PREFIX = "operations."; - - public static final String VARIABLE_PREFIX = "variable."; - - public static final String REPEAT_VARIABLE_PREFIX = "repeatVariable."; - - /** Logger */ - private static final Log log = LogFactory.getLog(ReportBuilder.class); - - /** les propriétés chargées par le builder pour construire les reports */ - protected Properties properties; - - /** la liste des lastName sde reports connus par le système */ - protected List<String> reportNames; - - /** les operations connues par le système */ - protected static Map<String, Class<?>> operations; - - public static Map<String, Class<?>> getOperations() { - if (operations == null) { - operations = new TreeMap<String, Class<?>>(); - ServiceLoader<ReportOperation> loader = - ServiceLoader.load(ReportOperation.class); - for (ReportOperation op : loader) { - if (log.isInfoEnabled()) { - log.info("Detected operations : " + op.getOperationName()); - } - operations.put(op.getOperationName(), op.getClass()); - } - } - return operations; - } - - public static ReportOperation newOperation(String operationsName) { - Class<?> operationsType = getOperations().get(operationsName); - if (operationsType == null) { - throw new IllegalArgumentException("No such operations [" + operationsName + "], available operationss : " + getOperations().keySet()); - } - try { - Object result = operationsType.newInstance(); - return (ReportOperation) result; - } catch (Exception e) { - throw new IllegalStateException("Could not instanciate operations [" + operationsType + "]", e); - } - } - - public List<String> getReportNames() { - return reportNames; - } - - public List<Report> load(URL definition) throws IOException { - properties = new SortedProperties(); - InputStream in = definition.openStream(); - try { - properties.load(in); - } finally { - in.close(); - } - - reportNames = detectReportNames(); - if (log.isInfoEnabled()) { - log.info("Detected report names : " + reportNames); - } - - List<Report> reports = new ArrayList<Report>(); - for (String reportName : reportNames) { - Report report = build(reportName); - reports.add(report); - } - - return reports; - } - - - protected List<String> detectReportNames() { - List<String> reportNames = new ArrayList<String>(); - Enumeration<Object> keys = properties.keys(); - while (keys.hasMoreElements()) { - String key = (String) keys.nextElement(); - Matcher matcher = REPORT_DEFINITION_PATTERN.matcher(key); - if (!matcher.matches()) { - - // pas de match - continue; - } - String reportName = matcher.group(1); - if (log.isInfoEnabled()) { - log.info("Discover a new report : " + reportName); - } - reportNames.add(reportName); - } - return reportNames; - } - - protected Report build(String reportName) { - - Map<String, String> dico = detectReportProperties(reportName); - - if (log.isDebugEnabled()) { - log.debug("Will build report [" + reportName + "] with " + dico.size() + " properties (" + dico + ")."); - } - - String name = getValue(dico, "name").trim(); - String description = getValue(dico, "description").trim(); - String rows = getValue(dico, "rows"); - String columns = getValue(dico, "columns"); - String[] rowHeaders = rows == null ? null : rows.split(","); - if (rowHeaders != null) { - for (int i = 0; i < rowHeaders.length; i++) { - String rowHeader = rowHeaders[i]; - rowHeaders[i] = rowHeader.trim(); - } - } - String[] columnHeaders = columns == null ? null : columns.split(","); - if (columnHeaders != null) { - for (int i = 0; i < columnHeaders.length; i++) { - String columnHeader = columnHeaders[i]; - columnHeaders[i] = columnHeader.trim(); - } - } - ReportRequest[] requests = getRequests(reportName, dico); - ReportOperation[] operationss = getOperations(reportName, dico); - ReportVariable[] variables = getVariables(reportName, dico); - ReportVariable[] repeatVariables = getRepeatVariables(reportName, dico); - - // a la fin il ne devrait plus y avoir de propriétés pour le report - if (!dico.isEmpty()) { - if (log.isWarnEnabled()) { - log.warn("Il reste des propriétés non utilisées pour le report [" + reportName + "] : " + dico); - } - } - - Report report = new Report(reportName, - name, - description, - rowHeaders, - columnHeaders, - operationss, - variables, - repeatVariables, - requests - ); - - return report; - } - - protected Map<String, String> detectReportProperties(String reportName) { - - Map<String, String> dico = new TreeMap<String, String>(); - - // pour chaque report, on récupère ses informations - String reportKeyPrefix = "report." + reportName + "."; - int reportKeyPrefixLength = reportKeyPrefix.length(); - - Enumeration<Object> keys = properties.keys(); - while (keys.hasMoreElements()) { - String key = (String) keys.nextElement(); - if (!key.startsWith(reportKeyPrefix)) { - // pas de match - continue; - } - String realKey = key.substring(reportKeyPrefixLength); - dico.put(realKey, (String) properties.get(key)); - } - - return dico; - } - - protected ReportRequest[] getRequests(String reportName, Map<String, String> dico) { - - Map<Integer, String> requestDico = new TreeMap<Integer, String>(); - Map<Integer, String> requestRepeatDico = new TreeMap<Integer, String>(); - Iterator<Map.Entry<String, String>> itr = dico.entrySet().iterator(); - while (itr.hasNext()) { - Map.Entry<String, String> entry = itr.next(); - String key = entry.getKey(); - if (!key.startsWith(REQUEST_PREFIX)) { - - continue; - } - String REQUEST_REPEAT_SUFFIX = ".repeat"; - if (key.endsWith(REQUEST_REPEAT_SUFFIX)) { - - // definition d'un repeat - String request = entry.getValue(); - String requestId = key.substring(REQUEST_PREFIX.length()); - requestId = requestId.substring(0, requestId.length() - REQUEST_REPEAT_SUFFIX.length()); - Integer id = Integer.valueOf(requestId); - if (log.isInfoEnabled()) { - log.info("Detects a request repeat [" + reportName + ":" + id + "] = " + request); - } - requestRepeatDico.put(id, request); - itr.remove(); - continue; - } - String request = entry.getValue(); - String requestId = key.substring(REQUEST_PREFIX.length()); - Integer id = Integer.valueOf(requestId); - if (log.isDebugEnabled()) { - log.debug("Detects a request [" + reportName + ":" + id + "] = " + request); - } - requestDico.put(id, request); - itr.remove(); - - } - - // On trie les request - List<Integer> ids = new ArrayList<Integer>(requestDico.keySet()); - Collections.sort(ids); - - // on construit (dans le bon ordre la liste des requetes) - List<ReportRequest> result = new ArrayList<ReportRequest>(); - for (Integer id : ids) { - - String requestDef = requestDico.get(id); - String requestRepeatDef = requestRepeatDico.get(id); - - ReportRequest def = getRequest(requestDef, requestRepeatDef); - if (log.isInfoEnabled()) { - log.info("Detects a request : " + def); - } - result.add(def); - - } - return result.toArray(new ReportRequest[result.size()]); - } - - protected ReportRequest getRequest(String requestDef, - String requestRepeatDef) { - - String[] parts = requestDef.split("\\|"); - if (parts.length != 3) { - throw new IllegalArgumentException("La définition de la requete doit etre de type 'X,Y|layout|hql' mais est : " + requestDef); - } - String[] coords = parts[0].split(","); - String layout = parts[1]; - String hql = parts[2]; - - if (coords.length != 2) { - throw new IllegalArgumentException("La définition des coordonées doit etre de type 'X,Y' mais est : " + parts[0]); - } - - int x = Integer.valueOf(coords[0]); - int y = Integer.valueOf(coords[1]); - ReportRequest.RequestLayout realLayout = ReportRequest.RequestLayout.valueOf(layout); - - ReportRequest.RequestRepeat repeat = null; - if (requestRepeatDef != null) { - - // il y a un repeat - String[] repeatParts = requestRepeatDef.split("\\|"); - if (repeatParts.length != 2) { - throw new IllegalArgumentException("La définition d'un repéteur de requete doit etre de type 'repeatName|layout' mais est : " + requestRepeatDef); - } - String repeatName = repeatParts[0].trim(); - String repeatLayout = repeatParts[1].trim(); - ReportRequest.RequestLayout realRepeatLayout = - ReportRequest.RequestLayout.valueOf(repeatLayout); - repeat = new ReportRequest.RequestRepeat(repeatName, realRepeatLayout); - - } - ReportRequest def = new ReportRequest(realLayout, x, y, hql, repeat); - return def; - } - - protected ReportOperation[] getOperations(String reportName, Map<String, String> dico) { - - Map<Integer, String> requestDico = new TreeMap<Integer, String>(); - Iterator<Map.Entry<String, String>> itr = dico.entrySet().iterator(); - while (itr.hasNext()) { - Map.Entry<String, String> entry = itr.next(); - String key = entry.getKey(); - if (!key.startsWith(OPERATION_PREFIX)) { - - continue; - } - String operations = entry.getValue(); - String requestId = key.substring(OPERATION_PREFIX.length()); - Integer id = Integer.valueOf(requestId); - if (log.isDebugEnabled()) { - log.debug("Detects a operations [" + reportName + ":" + id + "] = " + operations); - } - requestDico.put(id, operations); - itr.remove(); - } - - // On trie les request - List<Integer> ids = new ArrayList<Integer>(requestDico.keySet()); - Collections.sort(ids); - - // on construit (dans le bon ordre la liste des requetes) - List<ReportOperation> result = new ArrayList<ReportOperation>(); - for (Integer id : ids) { - - String operationsDef = requestDico.get(id); - - ReportOperation def = getOperation(operationsDef); - if (log.isInfoEnabled()) { - log.info("Detects a operations : " + def); - } - result.add(def); - } - return result.toArray(new ReportOperation[result.size()]); - } - - protected ReportVariable[] getVariables(String reportName, Map<String, String> dico) { - List<ReportVariable> result = new ArrayList<ReportVariable>(); - Iterator<Map.Entry<String, String>> itr = dico.entrySet().iterator(); - List<String> ids = new ArrayList<String>(); - while (itr.hasNext()) { - Map.Entry<String, String> entry = itr.next(); - String key = entry.getKey(); - if (!key.startsWith(VARIABLE_PREFIX)) { - - continue; - } - String operations = entry.getValue(); - String id = key.substring(VARIABLE_PREFIX.length()); - - // on interdit la surcharge d'une variable déjà trouvée pour le report - if (ids.contains(id)) { - throw new IllegalArgumentException("La variable " + id + " est déjà définie pour le report " + reportName); - } - - // on interdit l'utilisation de la variable tripId - if (ReportExecute.TRIP_ID_VARIABLE.equals(id)) { - throw new IllegalArgumentException("La variable tripId n'est pas utilisable (c'est uen variable réservée) pour le report " + reportName); - } - ids.add(id); - String[] parts = operations.split("\\|"); - - if (parts.length != 2) { - throw new IllegalArgumentException("La définition d'une variable doit etre de la forme 'type|hql' mais est : " + operations); - } - String typeStr = parts[0].trim(); - String request = parts[1].trim(); - Class<?> type = null; - try { - type = Class.forName(typeStr); - } catch (ClassNotFoundException eee) { - throw new IllegalArgumentException("Le type " + type + " n'est pas connu", eee); - } - ReportVariable variable = new ReportVariable(id, type, request); - if (log.isInfoEnabled()) { - log.info("Detects a variable : [" + reportName + ":" + variable.getName() + "] = " + variable.getRequest() + " (type = " + variable.getType().getName() + ")"); - } - result.add(variable); - itr.remove(); - } - return result.toArray(new ReportVariable[result.size()]); - } - - protected ReportVariable[] getRepeatVariables(String reportName, Map<String, String> dico) { - List<ReportVariable> result = new ArrayList<ReportVariable>(); - Iterator<Map.Entry<String, String>> itr = dico.entrySet().iterator(); - List<String> ids = new ArrayList<String>(); - while (itr.hasNext()) { - Map.Entry<String, String> entry = itr.next(); - String key = entry.getKey(); - if (!key.startsWith(REPEAT_VARIABLE_PREFIX)) { - - continue; - } - String operations = entry.getValue(); - String id = key.substring(REPEAT_VARIABLE_PREFIX.length()); - - // on interdit la surcharge d'une variable déjà trouvée pour le report - if (ids.contains(id)) { - throw new IllegalArgumentException("La variable de répétition " + id + " est déjà définie pour le report " + reportName); - } - - // on interdit l'utilisation de la variable tripId - if (ReportExecute.TRIP_ID_VARIABLE.equals(id)) { - throw new IllegalArgumentException("La variable de répétition tripId n'est pas utilisable (c'est uen variable réservée) pour le report " + reportName); - } - ids.add(id); - String[] parts = operations.split("\\|"); - - if (parts.length != 2) { - throw new IllegalArgumentException("La définition d'une variable de répétition doit etre de la forme 'type|hql' mais est : " + operations); - } - String typeStr = parts[0].trim(); - String request = parts[1].trim(); - Class<?> type = null; - try { - type = Class.forName(typeStr); - } catch (ClassNotFoundException eee) { - throw new IllegalArgumentException("Le type " + type + " n'est pas connu", eee); - } - ReportVariable variable = new ReportVariable(id, type, request); - if (log.isInfoEnabled()) { - log.info("Detects a variable : [" + reportName + ":" + variable.getName() + "] = " + variable.getRequest() + " (type = " + variable.getType().getName() + ")"); - } - result.add(variable); - itr.remove(); - } - return result.toArray(new ReportVariable[result.size()]); - } - - protected ReportOperation getOperation(String operationsDef) { - - // pour le moment, une operations n'a qu'une seule valeur : celle - // du lastName de l'opération - String operationsName = operationsDef; - - ReportOperation def = newOperation(operationsName); - return def; - } - - protected String getValue(Map<String, String> dico, String key) { - - String value = dico.get(key); - if (value != null) { - dico.remove(key); - } - return value; - } - - public void clear() { - if (reportNames != null) { - reportNames.clear(); - reportNames = null; - } - if (properties != null) { - properties.clear(); - properties = null; - } - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/DataMatrix.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/DataMatrix.java deleted file mode 100644 index 54fb09a..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/DataMatrix.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.awt.Dimension; -import java.awt.Point; -import java.io.Serializable; - -/** - * Une matrice de données - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public class DataMatrix { - - /** Logger */ - private static final Log log = LogFactory.getLog(DataMatrix.class); - - protected Object[][] data; - - protected int width; - - protected int height; - - protected int x; - - protected int y; - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public Object[][] getData() { - return data; - } - - public void setWidth(int width) { - this.width = width; - } - - public void setHeight(int height) { - this.height = height; - } - - public void setX(int x) { - this.x = x; - } - - public void setY(int y) { - this.y = y; - } - - public void createData() { - data = new Object[height][width]; - } - - public void setData(Object[][] data) { - this.data = data; - } - - public void copyData(DataMatrix incoming) { - - int x = incoming.getX(); - int y = incoming.getY(); - - Integer height = incoming.getHeight(); - Integer width = incoming.getWidth(); - - if (log.isDebugEnabled()) { - log.debug("copying incoming matrix (dim: " + - incoming.getDimension() + ", location: " + - incoming.getLocation() + ")"); - } - - for (int i = 0; i < width; i++) { - - for (int j = 0; j < height; j++) { - - Serializable value = incoming.getValue(i, j); - setValue(x + i, y + j, value); - } - } - } - - public Dimension getDimension() { - return new Dimension(width, height); - } - - public void setDimension(Dimension dim) { - height = (int) dim.getHeight(); - width = (int) dim.getWidth(); - } - - public Point getLocation() { - return new Point(x, y); - } - - public void setLocation(Point location) { - x = (int) location.getX(); - y = (int) location.getY(); - } - - public Serializable getValue(int x, int y) { - return data == null ? null : (Serializable) data[y][x]; - } - - public void setValue(int x, int y, Object data) { - - String cellData = data == null ? null : String.valueOf(data); - if (log.isDebugEnabled()) { - log.debug("Put data [" + x + "," + y + "] = " + cellData); - } - this.data[y][x] = cellData; - } - - public static Dimension getDimension(DataMatrix... datas) { - int width = 0; - int height = 0; - - for (DataMatrix request : datas) { - - int nWidth = request.getX() + request.getWidth(); - int nHeight = request.getY() + request.getHeight(); - if (nWidth > width) { - width = nWidth; - } - if (nHeight > height) { - height = nHeight; - } - } - return new Dimension(width, height); - } - - public static DataMatrix merge(DataMatrix... incomings) { - DataMatrix result = merge(-1, -1, incomings); - return result; - } - - public static DataMatrix merge(int rows, - int columns, - DataMatrix... incomings) { - Dimension dimension = getDimension(incomings); - - if (log.isDebugEnabled()) { - log.debug("Merge dimension : " + dimension); - } - - if (rows != -1) { - int height = (int) dimension.getHeight(); - // on verifie que récupère bien le bon count de lignes - if (rows != height) { - if (log.isWarnEnabled()) { - log.warn("No matching rows number : should have " + rows + - ", but was " + height); - } - } - } - - if (columns != -1) { - int width = (int) dimension.getWidth(); - // on verifie que récupère bien le bon count de colonnes - if (columns != width) { - if (log.isWarnEnabled()) { - log.warn("No matching columns number : should have " + - columns + ", but was " + width); - } - } - } - - DataMatrix result = new DataMatrix(); - result.setDimension(dimension); - result.createData(); - for (DataMatrix incoming : incomings) { - result.copyData(incoming); - } - return result; - } - - @Override - public String toString() { - ToStringBuilder builder = new ToStringBuilder(this); - builder.append("dimension", getDimension()); - builder.append("location", getLocation()); - return builder.toString(); - } - - public String getClipbordContent(boolean copyRowHeaders, - boolean copyColumnHeaders) { - - if (getWidth() <= 0 || getHeight() <= 0) { - return ""; - } - - StringBuilder buffer = new StringBuilder(); - - char sep = '\t'; - char eol = '\n'; - - for (int y = copyColumnHeaders ? 0 : 1, rows = getHeight(); y < rows; y++) { - - Serializable value; - - // nouvell ligne - - int x = copyRowHeaders ? 0 : 1; - - for (int columns = getWidth() - 1; x < columns; x++) { - - // sur chaque cellule (sauf la dernière) - value = getValue(x, y); - buffer.append(value).append(sep); - } - - // dernière cellule - value = getValue(x, y); - buffer.append(value); - - // fin de ligne - buffer.append(eol); - } - return buffer.toString(); - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/Report.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/Report.java deleted file mode 100644 index 752efd1..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/Report.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.Serializable; - -import static org.nuiton.i18n.I18n.t; - -public class Report implements Serializable { - - /** Logger. */ - private static final Log log = LogFactory.getLog(Report.class); - - /** l'id du report. */ - protected final String id; - - /** le libellé court du report. */ - protected final String name; - - /** la description du report. */ - protected final String description; - - /** les libellés des colonnes du report. */ - protected final String[] columnHeaders; - - /** les libellés des lignes du report. */ - protected final String[] rowHeaders; - - /** la liste des requêtes à jouer. */ - protected final ReportRequest[] requests; - - /** la liste des opérations à jouer. */ - protected final ReportOperation[] operations; - - /** la liste des variables du report. */ - protected final ReportVariable[] variables; - - /** la liste des variables de type repeat du report */ - protected final ReportVariable[] repeatVariables; - - private static final long serialVersionUID = 1L; - - public Report(String id, - String name, - String description, - String[] rowHeaders, - String[] columnHeaders, - ReportOperation[] operations, - ReportVariable[] variables, - ReportVariable[] repeatVariables, - ReportRequest... requests) { - this.id = id; - this.name = name; - this.description = description; - this.rowHeaders = rowHeaders; - this.columnHeaders = columnHeaders; - this.requests = requests; - this.operations = operations; - this.variables = variables; - this.repeatVariables = repeatVariables; - if (log.isDebugEnabled()) { - log.debug("New report [" + id + ":" + name + "], nb requests : " + - requests.length + ", nb objectOperations : " + - operations.length + ", nb variables : " + - variables.length + ", nb repeat variables : " + - repeatVariables.length); - } - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public int getRows() { - return rowHeaders == null ? -1 : rowHeaders.length; - } - - public int getColumns() { - return columnHeaders == null ? -1 : columnHeaders.length; - } - - public String[] getColumnHeaders() { - return columnHeaders; - } - - public String[] getRowHeaders() { - return rowHeaders; - } - - public ReportRequest[] getRequests() { - return requests; - } - - public ReportOperation[] getOperations() { - return operations; - } - - public ReportVariable[] getVariables() { - return variables; - } - - public ReportVariable[] getRepeatVariables() { - return repeatVariables; - } - - public boolean isVariableRequired() { - return variables.length > 0; - } - - @Override - public String toString() { - return t(name); - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportExecute.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportExecute.java deleted file mode 100644 index 8538cbe..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportExecute.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import fr.ird.observe.db.ObserveSwingDataSource; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * Objet contenant l'execution d'un report. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.7 - */ -public class ReportExecute { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ReportExecute.class); - - /** le report a executer. */ - protected Report report; - - /** l'univers des valeurs possibles pour les variables que l'utilisateur doit sélectionner. */ - protected final Map<String, List<?>> variablesUniverse; - - /** l'univers des valeurs possibles pour les variables des requêtes en mode repeat. */ - protected final Map<String, List<?>> repeatVariablesUniverse; - - /** la source de données qui permet d'exécuter les requêtes hql. */ - protected ObserveSwingDataSource source; - - public static final String TRIP_ID_VARIABLE = "tripId"; - - public ReportExecute() { - variablesUniverse = new TreeMap<String, List<?>>(); - repeatVariablesUniverse = new TreeMap<String, List<?>>(); - } - - public Report getReport() { - return report; - } - - public List<?> getVariableUniverse(String key) { - return variablesUniverse.get(key); - } - - public List<?> getRepeatVariableUniverse(String key) { - return repeatVariablesUniverse.get(key); - } - - public ObserveSwingDataSource getSource() { - return source; - } - - public void setSource(ObserveSwingDataSource source) { - this.source = source; - } - - public void populate(Report report, - String tripId) { - if (!checkDataSource(source)) { - - // source de donnee fermée - return; - } - this.report = report; - - // populate variables universe - doPopulateVariables(tripId); - } - - public DataMatrix execute(Map<String, Object> variables) { - - if (report == null) { - - // pas de report selectionne, donc pas de résultat - return null; - } - if (!checkDataSource(source)) { - - // source de donnee fermée - return null; - } - - if (!canExecute(variables)) { - - // la requete n'est pas exécutable - return null; - } - - // remplissage des variables de répétition si nécessaire - doPopulateRepeatVariables(variables); - - if (log.isDebugEnabled()) { - log.debug("Build result for report [" + report.getName() + - "] on " + variables.get(TRIP_ID_VARIABLE)); - } - - int rows = report.getRows(); - int columns = report.getColumns(); - - if (log.isDebugEnabled()) { - log.debug("Dimension : [" + rows + "," + columns + "]"); - } - - // execution des opérations sur le report - String txName = "execute"; - //FIXME -// TopiaContext tx = source.beginTransaction(txName); -// try { -// -// // creation de la première opération qui exécute les requètes -// ExecuteRequests firstRequest = (ExecuteRequests) -// ReportBuilder.newOperation(ExecuteRequests.OPERATION_NAME); -// -// // lancement de la première opération et la matrice de resultat -// DataMatrix result = firstRequest.execute(tx, -// report, -// new DataMatrix(), -// variables, -// repeatVariablesUniverse -// ); -// -// // lancement des opérations supplémentaires -// for (ReportOperation objectOperation : report.getOperations()) { -// -// DataMatrix tmp = result; -// if (log.isDebugEnabled()) { -// log.debug("Apply objectOperation " + objectOperation + " to " + tmp); -// } -// result = objectOperation.execute(tx, -// report, -// tmp, -// variables, -// repeatVariablesUniverse -// ); -// } -// if (log.isDebugEnabled()) { -// log.debug("Final result : " + result); -// } -// return result; -// } finally { -// source.closeTransaction(tx, txName); -// } - return null; - } - - public boolean canExecute(Map<String, Object> variables) { - - // il faut un report non null - if (report == null) { - - if (log.isInfoEnabled()) { - log.info("report is null"); - } - return false; - } - - for (ReportVariable request : report.getVariables()) { - - // on verifie qu'on a bien cette variable - String name = request.getName(); - if (!variables.containsKey(name)) { - - if (log.isInfoEnabled()) { - log.info("variable " + name + " is missing"); - } - return false; - } - - // et que sa valeur n'est pas null (ou vide) - Object variableValue = variables.get(name); - if (variableValue==null || StringUtils.isEmpty(variableValue.toString())) { - - if (log.isInfoEnabled()) { - log.info("variable " + name + " is empty or null"); - } - return false; - } - } - - // le report peut-être executé - return true; - } - - protected void doPopulateVariables(String tripId) { - - // on nettoye les univers de variables avant tout - variablesUniverse.clear(); - - if (report == null) { - - // pas de report, donc rien a faire - return; - } - - if (report.getVariables().length == 0) { - - // pas de variable utilise pour ce report - return; - } - - if (!checkDataSource(source)) { - - // source de donnee fermée - return; - } - String txName = "populateVariableUniverse"; - //FIXME -// TopiaContext tx = source.beginTransaction(txName); -// try { -// -// Map<String, Object> vars = new TreeMap<String, Object>(); -// vars.put(TRIP_ID_VARIABLE, tripId); -// for (ReportVariable variable : report.getVariables()) { -// String hql = variable.getRequest(); -// Object[] objects = ReportRequest.getParams(hql, vars); -// List<?> universe = tx.findAll(hql, objects); -// variablesUniverse.put(variable.getName(), universe); -// } -// } finally { -// source.closeTransaction(tx, txName); -// } - } - - protected void doPopulateRepeatVariables(Map<String, Object> variables) { - - // on nettoye les univers de variables de répétition avant tout - repeatVariablesUniverse.clear(); - - if (report.getRepeatVariables().length == 0) { - - // pas de variable de répétition - return; - } - if (!checkDataSource(source)) { - - // source de donnee fermée - return; - } - - String txName = "populateRepeatVariableUniverse"; - //FIXME -// TopiaContext tx = source.beginTransaction(txName); -// try { -// for (ReportVariable variable : report.getRepeatVariables()) { -// String hql = variable.getRequest(); -// Object[] objects = ReportRequest.getParams(hql, variables); -// List<?> universe = Lists.newArrayList(Sets.newLinkedHashSet(tx.findAll(hql, objects))); -// repeatVariablesUniverse.put(variable.getName(), universe); -// } -// } finally { -// source.closeTransaction(tx, txName); -// } - } - - protected boolean checkDataSource(ObserveSwingDataSource source) throws IllegalStateException { - - if (!source.isOpen()) { - throw new IllegalStateException("data source is not opened."); - } - return true; - } -} - diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportOperation.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportOperation.java deleted file mode 100644 index 60655f6..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportOperation.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.awt.*; -import java.io.Serializable; - -/** - * Pour caractériser une opération à lancer dans un report. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public abstract class ReportOperation implements Serializable { - - private static final long serialVersionUID = 1L; - - /** Logger */ - private static final Log log = LogFactory.getLog(ReportOperation.class); - - public abstract String getOperationName(); - - /** - * Calcule la position où positionner le rsultat dans la matrice sortante. - * - * @param model le report - * @param incoming la matrice entrante - * @return la position de la première cellule - */ - protected abstract Point computeLocation(Report model, - DataMatrix incoming); - - /** - * Calcule la dimension du résultat de l'opération. - * - * @param model le report - * @param incoming la matrice entrante - * @return la dimension des données de l'opération - */ - protected abstract Dimension computeDimension(Report model, - DataMatrix incoming); - - /** - * Pour executer l'opération. - * -// * @param tx la transaction courante -// * @param model le modèle -// * @param incoming la matrice entrante -// * @param variables le dictionnaire de variables utilisées dans le report -// * @param repeatVariablesUniverse le dictionnaire des variables de répétition - * @return la matrice sortante - * @pour toute erreur de manipulation de base - */ - - //FIXME -// public abstract DataMatrix execute(TopiaContext tx, -// Report model, -// DataMatrix incoming, -// Map<String, Object> variables, -// Map<String, List<?>> repeatVariablesUniverse -// ) throws TopiaException; - - protected ReportOperation() { - } - - protected DataMatrix createTmpMatrix(Report model, DataMatrix incoming) { - - DataMatrix result = new DataMatrix(); - - // calcul de la position des résultats de l'opération - Point location = computeLocation(model, incoming); - result.setLocation(location); - - // calcul de la taille des résultats de l'opération - Dimension dim = computeDimension(model, incoming); - result.setDimension(dim); - - // creation de la matrice - result.createData(); - - if (log.isDebugEnabled()) { - log.debug("Operation [" + getOperationName() + "] tmp matrix : " + result); - } - return result; - } - -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportRequest.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportRequest.java deleted file mode 100644 index 1239f23..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportRequest.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.awt.*; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Pour caractériser une requète à lancer dans un report. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public class ReportRequest implements Serializable { - - private static final long serialVersionUID = 1L; - - /** Logger. */ - private static final Log log = LogFactory.getLog(ReportRequest.class); - - /** le layout de la requete. */ - public enum RequestLayout { - /** lorsque les résultats de la requète sont les lignes du résultat. */ - row, - /** lorsque les résultats de la requète sont les colonnes du résultat. */ - column - } - - /** Un repeater optionnel sur la requête. */ - public static class RequestRepeat implements Serializable { - - protected final String variableName; - - protected final RequestLayout layout; - - private static final long serialVersionUID = 1L; - - public RequestRepeat(String variableName, RequestLayout layout) { - this.variableName = variableName; - this.layout = layout; - } - - public String getVariableName() { - return variableName; - } - - public RequestLayout getLayout() { - return layout; - } - - @Override - public String toString() { - ToStringBuilder builder = new ToStringBuilder(this); - builder.append("variableName", getVariableName()); - builder.append("layout", getLayout()); - return builder.toString(); - } - } - - /** layout de la requète. */ - protected final RequestLayout layout; - - /** la requète à exécuter. */ - protected final String request; - - /** la position de la requète. */ - protected final Point location; - - /** le repeater optionel. */ - protected final RequestRepeat repeat; - - public ReportRequest(RequestLayout layout, - int x, - int y, - String request, - RequestRepeat repeat) { - this.layout = layout; - this.request = request; - this.repeat = repeat; - location = new Point(x, y); - } - - public RequestLayout getLayout() { - return layout; - } - - public int getX() { - return (int) location.getX(); - } - - public int getY() { - return (int) location.getY(); - } - - public Point getLocation() { - return location; - } - - public String getRequest() { - return request; - } - - public RequestRepeat getRepeat() { - return repeat; - } - - //FIXME -// public DataMatrix execute(TopiaContext tx, -// Map<String, Object> params, -// List<?> repeatValues) { -// -// DataMatrix result = new DataMatrix(); -// for (Object repeatValue : repeatValues) { -// params.put(repeat.getVariableName(), repeatValue); -// DataMatrix tmp = execute(tx, params); -// if (result == null) { -// -// // premiere requete executee -// result = tmp; -// result.setX(0); -// result.setY(0); -// } else { -// switch (repeat.getLayout()) { -// -// case row: -// -// // on ajoute le resultat a droite de celui deja present -// tmp.setX(result.getX() + result.getWidth()); -// tmp.setY(result.getY()); -// break; -// -// case column: -// -// // on ajoute le resultat en dessous de celui deja present -// tmp.setX(result.getX()); -// tmp.setY(result.getY() + result.getHeight()); -// break; -// } -// result = DataMatrix.merge(result, tmp); -// } -// } -// result.setX(getX()); -// result.setY(getY()); -// if (log.isDebugEnabled()) { -// log.debug("Result location : " + result.getLocation()); -// log.debug("Result data :\n" + result.getClipbordContent(true, true)); -// } -// return result; -// } - - //FIXME -// public DataMatrix execute(TopiaContext tx, -// Map<String, Object> params) { -// -// // création des paramètres : couples (key, value) -// Object[] datas = getParams(request, params); -// if (log.isDebugEnabled()) { -// log.debug("Request : " + request); -// log.debug("Available params : " + params.keySet()); -// log.debug("Params to use : " + Arrays.toString(datas)); -// } -// -// // lancement de la requête -// List<?> list = tx.findAll(request, datas); -// if (log.isDebugEnabled()) { -// log.debug("Result size : " + list.size()); -// } -// -// // determination des dimensions du résultat -// Dimension dimension = computeDimension(list); -// if (log.isDebugEnabled()) { -// log.debug("Result dimension : " + dimension); -// } -// -// // construction du resultat -// DataMatrix result = computeResult(dimension, list); -// if (log.isDebugEnabled()) { -// log.debug("Result location : " + result.getLocation()); -// log.debug("Result data :\n" + result.getClipbordContent(true, true)); -// } -// return result; -// } - - protected DataMatrix computeResult(Dimension dimension, List<?> list) { - - DataMatrix result = new DataMatrix(); - result.setDimension(dimension); - result.createData(); - - // le seul cas différent est le n-* (une ligne correspond à une colonne) - - int y = 0; - int x = 0; - - switch (layout) { - - case row: - - boolean uniqueColumn = result.getWidth() == 1; - - // les lignes du résultat sont les lignes du tableau - - for (Object row : list) { - - if (uniqueColumn) { - - // une seule colonne - result.setValue(0, y, row); - } else { - - x = 0; - Object[] cells = (Object[]) row; - for (Object cell : cells) { - result.setValue(x++, y, cell); - } - } - - // on passage a la ligne suivante - y++; - } - break; - case column: - - // les lignes du résultat sont les colonnes du tableau - - boolean uniqueRow = result.getHeight() == 1; - - for (Object col : list) { - - if (uniqueRow) { - - // une seule ligne - result.setValue(x, 0, col); - } else { - - y = 0; - Object[] cells = (Object[]) col; - for (Object cell : cells) { - result.setValue(x, y++, cell); - } - } - - // on passage a la colonne suivante - x++; - } - break; - } - - // on pousse la position du résultat - result.setX(getX()); - result.setY(getY()); - return result; - } - - protected Dimension computeDimension(List<?> list) { - - int height = 0; - int width = 0; - - switch (layout) { - - case row: - - // le count de result est le lastNamebre de lignes - height = list.size(); - - if (list.isEmpty()) { - - // vu qu'il n'y a pas de résultat, on ne peut rien dire - width = 0; - } else { - - Object o = list.get(0); - - if (o == null || !o.getClass().isArray()) { - - // une seule colonne - width = 1; - } else { - width = ((Object[]) o).length; - } - } - - break; - case column: - - // le count de result est le lastNamebre de colonnes - width = list.size(); - - if (list.isEmpty()) { - - // vu qu'il n'y a pas de résultat, on ne peut rien dire - height = 0; - } else { - - Object o = list.get(0); - - if (o == null || !o.getClass().isArray()) { - - // une seule ligne - height = 1; - } else { - height = ((Object[]) o).length; - } - } - - break; - } - return new Dimension(width, height); - } - - public static Object[] getParams(String request, Map<String, Object> params) { - - // on parcourt la liste de tous les paramètres pour savoir si on doit - // les inclure pour la requête donnée : - List<String> namesToUsed = new ArrayList<String>(); - for (String paramName : params.keySet()) { - if (request.contains(":" + paramName)) { - namesToUsed.add(paramName); - } - } - Object[] datas = new Object[namesToUsed.size() * 2]; - int index = 0; - for (String name : namesToUsed) { - Object value = params.get(name); - datas[index * 2] = name; - datas[index * 2 + 1] = value; - index++; - } - namesToUsed.clear(); - return datas; - } - - @Override - public String toString() { - ToStringBuilder builder = new ToStringBuilder(this); - builder.append("request", getRequest()); - builder.append("layout", getLayout()); - builder.append("location", getLocation()); - builder.append("repeatVariable", getRepeat()); - return builder.toString(); - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportVariable.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportVariable.java deleted file mode 100644 index 868eb18..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/ReportVariable.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model; - -import java.io.Serializable; - -/** - * La définition d'une variable utilisable dans un report. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.7 - */ -public class ReportVariable implements Serializable { - - private static final long serialVersionUID = 1L; - - protected String name; - - protected Class<?> type; - - protected String request; - - public ReportVariable(String name, Class<?> type, String request) { - this.name = name; - this.type = type; - this.request = request; - } - - public String getName() { - return name; - } - - public Class<?> getType() { - return type; - } - - public String getRequest() { - return request; - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/operations/ExecuteRequests.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/operations/ExecuteRequests.java deleted file mode 100644 index 4fae51c..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/model/operations/ExecuteRequests.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.business.report.model.operations; - -import fr.ird.observe.business.report.model.DataMatrix; -import fr.ird.observe.business.report.model.Report; -import fr.ird.observe.business.report.model.ReportOperation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.awt.*; - -/** - * Opération pour lancer les requètes d'un report. - * <p/> - * Cette opération est toujours exécuter en premier lors de la construction - * du résultat d'un report. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public class ExecuteRequests extends ReportOperation { - - /** Logger */ - private static final Log log = LogFactory.getLog(ExecuteRequests.class); - - private static final long serialVersionUID = 1L; - - public static final String OPERATION_NAME = "ExecuteRequests"; - - public ExecuteRequests() { - } - - public String getOperationName() { - return OPERATION_NAME; - } - - //FIXME -// @Override -// public DataMatrix execute(TopiaContext tx, -// Report report, -// DataMatrix incoming, -// Map<String, Object> variables, -// Map<String, List<?>> repeatVariablesUniverse) { -// -// if (log.isDebugEnabled()) { -// log.debug("Launch " + this); -// } -// -// ReportRequest[] requests = report.getRequests(); -// -// DataMatrix[] requestResults = new DataMatrix[requests.length]; -// -// int i = 0; -// for (ReportRequest request : requests) { -// -// ReportRequest.RequestRepeat repeatVariable = request.getRepeat(); -// -// DataMatrix result; -// -// if (repeatVariable == null) { -// -// // requete simple sans repetition -// result = request.execute(tx, variables); -// } else { -// -// // on a une requete avec repetition -// String repeatVariableName = repeatVariable.getVariableName(); -// List<?> repeatValues = repeatVariablesUniverse.get(repeatVariableName); -// -// try { -// result = request.execute(tx, -// variables, -// repeatValues -// ); -// } finally { -// //FIXME rendre etanche l'utilisation des variables -// // la variable a ete ajoutee pendant l'execution -// // il faut la retirer -// variables.remove(repeatVariable.getVariableName()); -// } -// -// } -// -// requestResults[i++] = result; -// } -// -// int rows = report.getRows(); -// int columns = report.getColumns(); -// -// DataMatrix result = DataMatrix.merge(rows, columns, requestResults); -// return result; -// } - - @Override - protected Point computeLocation(Report model, DataMatrix incoming) { - Point result = new Point(0, 0); - return result; - } - - @Override - protected Dimension computeDimension(Report model, DataMatrix incoming) { - - Dimension result = new Dimension(0, 0); - return result; - } -} diff --git a/observe-application-swing/src/main/java/fr/ird/observe/business/report/package-info.java b/observe-application-swing/src/main/java/fr/ird/observe/business/report/package-info.java deleted file mode 100644 index 1eab678..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/business/report/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -/** - * Ce paquetage définit l'api des reports d'observe : - * {@link Report}. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.7 - */ -package fr.ird.observe.business.report; - diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java index 5c233bf..04d5726 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java @@ -156,7 +156,8 @@ public enum AdminStep implements WizardExtStep { false, false, DbMode.USE_LOCAL, - DbMode.USE_REMOTE + DbMode.USE_REMOTE, + DbMode.USE_SERVER ), /** pour l'import GPS */ diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index a53212f..1943e55 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.admin; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.business.report.model.Report; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constantes.DbMode; @@ -33,6 +32,7 @@ import fr.ird.observe.services.configuration.ObserveDataSourceInformation; import fr.ird.observe.services.dto.IdDtos; import fr.ird.observe.services.dto.ReferenceDto; import fr.ird.observe.services.dto.ReferenceSetDto; +import fr.ird.observe.services.dto.actions.report.Report; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.BabModelVersionException; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java index 0e5d458..5408802 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java @@ -21,9 +21,8 @@ */ package fr.ird.observe.ui.admin.report; -import fr.ird.observe.business.report.ReportBuilder; -import fr.ird.observe.business.report.model.Report; -import fr.ird.observe.business.report.model.ReportExecute; +import fr.ird.observe.services.dto.actions.report.Report; +import fr.ird.observe.services.service.actions.report.ReportBuilder; import fr.ird.observe.ui.admin.AdminActionModel; import fr.ird.observe.ui.admin.AdminStep; import org.apache.commons.logging.Log; @@ -98,20 +97,11 @@ public class ReportModel extends AdminActionModel { /** Pour copier les entêtes de colonnes */ protected boolean copyColumnHeaders = true; - protected ReportExecute reportExecute; - public ReportModel() { super(AdminStep.REPORT); variables = new TreeMap<String, Object>(); } - public ReportExecute getReportExecute() { - if (reportExecute == null) { - reportExecute = new ReportExecute(); - } - return reportExecute; - } - public List<Report> loadReports(URL resource) throws IOException { ReportBuilder builder = new ReportBuilder(); @@ -242,7 +232,7 @@ public class ReportModel extends AdminActionModel { firePropertyChange(VALID_PROPERTY_NAME, old, valid); } - public void addVariable(String name, String value) { + public void addVariable(String name, Object value) { variables.put(name, value); // invalidation du modèle (sans déclanchement d'évènement) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUI.jaxx index edd7726..5289faa 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUI.jaxx @@ -30,7 +30,7 @@ fr.ird.observe.ui.admin.AdminStep fr.ird.observe.ui.admin.AdminTabUI fr.ird.observe.ui.admin.AdminUI - fr.ird.observe.business.report.model.Report + fr.ird.observe.services.dto.actions.report.Report java.awt.Dimension @@ -54,6 +54,10 @@ public ReportUI(AdminUI parentContext) { public void initUI(AdminUI ui) { getHandler().initTabUI(ui, this); } + +public void destroy() { + getHandler().destroy(); +} ]]> </script> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java index ae42d5e..ce401f2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java @@ -21,15 +21,15 @@ */ package fr.ird.observe.ui.admin.report; -import fr.ird.observe.business.report.model.DataMatrix; -import fr.ird.observe.business.report.model.Report; -import fr.ird.observe.business.report.model.ReportExecute; -import fr.ird.observe.business.report.model.ReportVariable; +import com.google.common.collect.Lists; +import fr.ird.observe.ObserveSwingTechnicalException; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.IdDto; -import fr.ird.observe.services.service.BabModelVersionException; -import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; -import fr.ird.observe.services.service.DatabaseNotFoundException; +import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.actions.report.DataMatrix; +import fr.ird.observe.services.dto.actions.report.Report; +import fr.ird.observe.services.dto.actions.report.ReportVariable; +import fr.ird.observe.services.service.actions.report.ReportService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.admin.AdminStep; import fr.ird.observe.ui.admin.AdminTabUI; @@ -38,6 +38,7 @@ import fr.ird.observe.ui.admin.AdminUI; import fr.ird.observe.ui.admin.AdminUIModel; import fr.ird.observe.ui.admin.config.ConfigUI; import fr.ird.observe.ui.admin.config.SelectDataUI; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import jaxx.runtime.context.JAXXInitialContext; import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.bean.BeanComboBox; @@ -64,6 +65,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.util.List; import java.util.Map; +import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -221,12 +223,12 @@ public class ReportUIHandler extends AdminTabUIHandler { // avoid multi-cast return; } - //FIXME -// DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); -// if (log.isDebugEnabled()) { -// log.debug("selection model changed to " + value.getDatas()); -// log.debug("IS USE DATA ? : " + value.isUseData()); -// } + + DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("selection model changed to " + value.getDatas()); + log.debug("IS USE DATA ? : " + value.isUseData()); + } updateSelectionModel(selectTabUI); } }); @@ -258,15 +260,10 @@ public class ReportUIHandler extends AdminTabUIHandler { throw new IllegalStateException( "No 'variableName' clientProperty on " + combo); } - IdDto entity = (IdDto) value; - String id = null; - if (entity != null) { - id = entity.getId(); - } if (log.isInfoEnabled()) { - log.info("Set variable [" + variableName + "] to value " + id); + log.info("Set variable [" + variableName + "] to value " + value); } - getStepModel().addVariable(variableName, id); + getStepModel().addVariable(variableName, value); } public void chooseReportFile() { @@ -318,90 +315,99 @@ public class ReportUIHandler extends AdminTabUIHandler { ReportModel model, Report report) { - if (log.isInfoEnabled()) { - log.info("New selected report [" + report + "]"); - } + if (report != null) { - ReportExecute execute = getReportExecute(model); - if (execute == null) { + if (log.isInfoEnabled()) { + log.info("New selected report [" + report + "]"); + } - // l'executeur n'est plus disponible, on ne fait rien - return; - } - //FIXME -// try { -// execute.populate(report, getModel().getSelectedTrip()); -// } catch (RuntimeException eee) { -// throw eee; -// } catch (Exception eee) { -// throw new IllegalStateException( -// "Could not populate report " + report + " in executor", eee); -// } - - // on regénère l'ui de configuration des variables - JPanel variablesPanel = tabUI.getReportVariableSelectorPanel(); - variablesPanel.removeAll(); - - // on utilise les variables uniquement si nécessaire - boolean useVariables = report != null && report.getVariables().length > 0; - tabUI.getReportVariableSelectorPane().setVisible(useVariables); - - if (useVariables) { - - // on construit les ui pour chaqsue variable - for (ReportVariable variable : report.getVariables()) { - String variableName = variable.getName(); -// String value = variables.get(variableName); - List<Object> universe = (List<Object>) execute.getVariableUniverse(variableName); - BeanComboBox<Object> combo = new BeanComboBox<Object>(); - - combo.setShowReset(true); - variablesPanel.add(combo); - Decorator<Object> decorator = getDecoratorService().getDecoratorByType((Class<Object>) variable.getType()); - combo.init((JXPathDecorator<Object>) decorator, universe); - JComboBox jComboBox = combo.getCombobox(); - jComboBox.putClientProperty(VARIABLE_NAME, variableName); - jComboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - - JComboBox comboBox = (JComboBox) e.getSource(); - - if (e.getStateChange() == ItemEvent.DESELECTED) { - - // ne rien faire de l'évènement de déselection - // sauf si le modèle devient vide - - if (comboBox.getSelectedItem() == null) { - updateVariable(comboBox, null); - } - return; - } + ObserveSwingDataSource dataSource = getSource(); + + try { + + if (!dataSource.isOpen()) { + + dataSource.open(); - Object o = e.getItem(); - updateVariable(comboBox, o); + } + + ReportService reportService = dataSource.newService(ReportService.class); + + report = reportService.populateVariables(report, getModel().getSelectedTrip().getId()); + + } catch (Exception e) { + throw new ObserveSwingTechnicalException("unable to populate report : " + report.getName(), e); + } + + // on regénère l'ui de configuration des variables + JPanel variablesPanel = tabUI.getReportVariableSelectorPanel(); + variablesPanel.removeAll(); + + // on utilise les variables uniquement si nécessaire + boolean useVariables = report != null && report.isVariableRequired(); + tabUI.getReportVariableSelectorPane().setVisible(useVariables); + + if (useVariables) { + + // on construit les ui pour chaqsue variable + for (ReportVariable variable : report.getVariables()) { + String variableName = variable.getName(); + // String value = variables.get(variableName); + Set values = variable.getValues(); + List<Object> universe = Lists.newArrayList(values); + BeanComboBox<Object> combo = new BeanComboBox<Object>(); + + combo.setShowReset(true); + variablesPanel.add(combo); + Decorator decorator; + if (IdDto.class.isAssignableFrom(variable.getType()) && !universe.isEmpty()) { + decorator = getDecoratorService().getDecoratorByType(ReferenceDto.class, variable.getType().getSimpleName()); + } else { + decorator = getDecoratorService().getDecoratorByType(variable.getType()); } - }); + combo.init((JXPathDecorator<Object>) decorator, universe); + JComboBox jComboBox = combo.getCombobox(); + jComboBox.putClientProperty(VARIABLE_NAME, variableName); + jComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + + JComboBox comboBox = (JComboBox) e.getSource(); + + if (e.getStateChange() == ItemEvent.DESELECTED) { + + // ne rien faire de l'évènement de déselection + // sauf si le modèle devient vide + + if (comboBox.getSelectedItem() == null) { + updateVariable(comboBox, null); + } + return; + } + + Object o = e.getItem(); + updateVariable(comboBox, o); + } + }); + } } - } - // on revalide la disposition de l'onglet - SwingUtilities.invokeLater(revalidateTabUI); + // on revalide la disposition de l'onglet + SwingUtilities.invokeLater(revalidateTabUI); - Map<String, Object> variables = model.getVariables(); - updateValidState(execute, variables); + Map<String, Object> variables = model.getVariables(); + updateValidState(report, variables); + } } protected void onVariablesChanges(ReportModel model, Map<String, Object> variables) { - ReportExecute execute = getReportExecute(model); - if (execute == null) { + Report report = model.getSelectedReport(); + if (report != null) { - // l'executeur n'est plus disponible, on ne fait rien - return; + updateValidState(report, variables); } - updateValidState(execute, variables); } protected void onValidChanged(ReportModel model, boolean valid) { @@ -412,57 +418,49 @@ public class ReportUIHandler extends AdminTabUIHandler { if (!valid) { // calcul des données et contruction du tableau - model.getResultModel().populate(null, null); + model.getResultModel().clear(); return; } + getModel().setBusy(true); try { - ReportExecute execute = getReportExecute(model); - if (execute == null) { + Report report = model.getSelectedReport();; + + ReferenceDto trip = getModel().getSelectedTrip(); - // l'executeur n'est plus disponible, on ne fait rien - return; + if (log.isDebugEnabled()) { + log.debug("Build result for report [" + report.getName() + + "] on " + trip); } - Report report = null; - // nettoyage - DataMatrix data; - try { + Map<String, Object> variables = model.getVariables(); - IdDto mareeId = getModel().getSelectedTrip(); + for (ReportVariable variable : report.getVariables()) { + Object value = variables.get(variable.getName()); + variable.setSelectedValue(value); + } - //FIXME -// report = execute.getReport(); - if (log.isDebugEnabled()) { - log.debug("Build result for report [" + report.getName() + - "] on " + mareeId); - } + long startTime = TimeLog.getTime(); - Map<String, Object> variables = model.getVariables(); + ObserveSwingDataSource dataSource = getSource(); + if (!dataSource.isOpen()) { + dataSource.open(); + } - variables.put(ReportExecute.TRIP_ID_VARIABLE, mareeId); - long startTime = TimeLog.getTime(); - //FIXME -// data = execute.execute(variables); - timeLog.log(startTime, "execute", report.getName()); - //FIXME -// if (log.isInfoEnabled()) { -// log.info("Result to dispaly:\n" + data.getClipbordContent(true, true)); -// } + ReportService reportService = dataSource.newService(ReportService.class); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not obtain report data", e); - } - ErrorDialogUI.showError(e); - data = null; + DataMatrix data = reportService.executeReport(report, trip.getId()); + + timeLog.log(startTime, "execute", report.getName()); + + if (log.isInfoEnabled()) { + log.info("Result to dispaly:\n" + data.getClipbordContent(true, true)); } // calcul des données et contruction du tableau - //FIXME -// model.getResultModel().populate(report, data); + model.getResultModel().populate(report, data); // mise a jour du clipboard automatique si requis if (model.isAutoCopyToClipboard()) { @@ -472,8 +470,19 @@ public class ReportUIHandler extends AdminTabUIHandler { model.isCopyColumnHeaders() ); } + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Could not obtain report data", e); + } + ErrorDialogUI.showError(e); + + model.getResultModel().clear(); + } finally { + getModel().setBusy(false); + } } @@ -481,39 +490,18 @@ public class ReportUIHandler extends AdminTabUIHandler { return model.getReportModel(); } - protected void updateValidState(ReportExecute execute, + protected void updateValidState(Report report, Map<String, Object> variables) { - boolean canExecute = execute.canExecute(variables); + boolean canExecute = report != null && report.canExecute(variables); getStepModel().setValid(canExecute); } - protected ReportExecute getReportExecute(ReportModel stepModel) { - if (getModel().getModelState() == WizardState.CANCELED) { + public void destroy() { + ObserveSwingDataSource dataSource = getSource(); - // action annulée, l'executeur n'est plus disponible - return null; + if (dataSource.isOpen()) { + dataSource.close(); } - - ObserveSwingDataSource source = getModel().getSafeLocalSource(false); - if (!source.isOpen()) { - - // source de donnée fermée, l'executeur n'est plus disponible - return null; - } - try { - openSource(source); - } catch (DatabaseConnexionNotAuthorizedException | DatabaseNotFoundException | BabModelVersionException eee) { - throw new IllegalStateException( - "Could not open data source " + source.getLabel(), eee); - } - - ReportExecute execute = stepModel.getReportExecute(); - - // on attache la source de donnée plutot que d'écouter si elle a changée - // cela est moins compliqué et nous garanti d'avoir toujours la bonne - // source - execute.setSource(source); - return execute; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ResultTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ResultTableModel.java index ebbdcf9..d3ffaf2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ResultTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ResultTableModel.java @@ -21,7 +21,7 @@ */ package fr.ird.observe.ui.admin.report; -import fr.ird.observe.business.report.model.DataMatrix; +import fr.ird.observe.services.dto.actions.report.DataMatrix; import fr.ird.observe.services.dto.actions.report.Report; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java index 5e76144..cf53d6f 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.Serializable; +import java.util.Map; import static org.nuiton.i18n.I18n.t; @@ -155,4 +156,42 @@ public class Report implements Serializable, ObserveDto { }); } + public boolean canExecute() { + + for (ReportVariable variable : getVariables()) { + + // on verifie qu'on a bien cette variable + String name = variable.getName(); + if (variable.getSelectedValue() == null) { + + if (log.isInfoEnabled()) { + log.info("variable " + name + " is missing"); + } + return false; + } + } + + // le report peut-être executé + return true; + } + + public boolean canExecute(Map<String, Object> variables) { + + for (ReportVariable variable : getVariables()) { + + // on verifie qu'on a bien cette variable + String name = variable.getName(); + if (variables.get(name) == null) { + + if (log.isInfoEnabled()) { + log.info("variable " + name + " is missing"); + } + return false; + } + } + + // le report peut-être executé + return true; + } + } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java index c5ca287..594a8af 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java @@ -109,7 +109,7 @@ public class ReportServiceTopia extends ObserveServiceTopia implements ReportSer return null; } - if (!canExecute(report)) { + if (!report.canExecute()) { // la requete n'est pas exécutable return null; @@ -596,25 +596,6 @@ public class ReportServiceTopia extends ObserveServiceTopia implements ReportSer return result; } - public boolean canExecute(Report report) { - - for (ReportVariable variable : report.getVariables()) { - - // on verifie qu'on a bien cette variable - String name = variable.getName(); - if (variable.getSelectedValue() == null) { - - if (log.isInfoEnabled()) { - log.info("variable " + name + " is missing"); - } - return false; - } - } - - // le report peut-être executé - return true; - } - protected void doPopulateRepeatVariables(Report report, String tripId) { Map<String, Object> vars = ReportRequest.extractParams(report, tripId); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm