OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 144 Rev 180
Line 14... Line 14...
14
 package org.openconcerto.sql.sqlobject;
14
 package org.openconcerto.sql.sqlobject;
15
 
15
 
16
import org.openconcerto.sql.model.SQLField;
16
import org.openconcerto.sql.model.SQLField;
17
import org.openconcerto.sql.model.SQLRow;
17
import org.openconcerto.sql.model.SQLRow;
18
import org.openconcerto.sql.model.SQLRowAccessor;
18
import org.openconcerto.sql.model.SQLRowAccessor;
-
 
19
import org.openconcerto.sql.model.SQLRowValues;
-
 
20
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
19
import org.openconcerto.sql.model.SQLSelect;
21
import org.openconcerto.sql.model.SQLSelect;
20
import org.openconcerto.sql.model.SQLTable;
22
import org.openconcerto.sql.model.SQLTable;
21
import org.openconcerto.sql.model.Where;
23
import org.openconcerto.sql.model.Where;
22
import org.openconcerto.sql.request.MultipleSQLSelectExecutor;
24
import org.openconcerto.sql.request.MultipleSQLSelectExecutor;
23
import org.openconcerto.ui.component.text.TextComponent;
25
import org.openconcerto.ui.component.text.TextComponent;
Line 355... Line 357...
355
 
357
 
356
            listSel.add(selContainsCodeF);
358
            listSel.add(selContainsCodeF);
357
 
359
 
358
            MultipleSQLSelectExecutor mult = new MultipleSQLSelectExecutor(this.tableArticle.getDBSystemRoot(), listSel);
360
            MultipleSQLSelectExecutor mult = new MultipleSQLSelectExecutor(this.tableArticle.getDBSystemRoot(), listSel);
359
 
361
 
360
            List<List<SQLRow>> resultList = mult.execute();
362
            List<List<? extends SQLRowAccessor>> resultList = new ArrayList<>();
-
 
363
            resultList.addAll(mult.execute());
361
 
364
 
-
 
365
            // Recherche dans les codes fournisseurs
-
 
366
            SQLTable tableCodeArt = this.tableArticle.getDBRoot().getTable("CODE_FOURNISSEUR");
-
 
367
            SQLRowValues rowValsCodeF = new SQLRowValues(tableCodeArt);
-
 
368
            rowValsCodeF.putNulls("CODE");
-
 
369
            rowValsCodeF.putRowValues("ID_ARTICLE").putNulls(this.tableArticle.getFieldsName());
-
 
370
 
-
 
371
            final String codeText = aText;
-
 
372
            SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowValsCodeF);
-
 
373
            fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
-
 
374
                @Override
-
 
375
                public SQLSelect transformChecked(SQLSelect input) {
-
 
376
 
-
 
377
                    Where wCodeFContains = new Where(tableCodeArt.getField("CODE"), "LIKE", "%" + codeText + "%");
-
 
378
                    input.setWhere(wCodeFContains);
-
 
379
                    input.setLimit(SQL_RESULT_LIMIT);
-
 
380
                    return input;
-
 
381
                }
-
 
382
            });
-
 
383
            List<SQLRowValues> resultCodeF = fetcher.fetch();
-
 
384
            resultList.add(2, resultCodeF);
-
 
385
 
362
            for (List<SQLRow> list : resultList) {
386
            for (List<? extends SQLRowAccessor> list : resultList) {
363
 
387
 
364
                for (SQLRow sqlRow : list) {
388
                for (SQLRowAccessor sqlRow : list) {
365
 
389
 
366
                    StringBuffer buf = new StringBuffer();
390
                    StringBuffer buf = new StringBuffer();
-
 
391
                    if (sqlRow.getTable().getName().equals("CODE_FOURNISSEUR")) {
-
 
392
                        SQLRowAccessor rArt = sqlRow.getForeign("ID_ARTICLE");
-
 
393
                        buf.append(sqlRow.getString("CODE") + " -- ");
-
 
394
                        buf.append(rArt.getString("CODE") + " -- ");
-
 
395
                        buf.append(rArt.getString("NOM"));
-
 
396
                        result.add(new IComboSelectionItem(rArt, buf.toString()));
-
 
397
                    } else {
367
                    if (sqlRow.getString("CODE_BARRE") != null && sqlRow.getString("CODE_BARRE").trim().length() > 0) {
398
                        if (sqlRow.getString("CODE_BARRE") != null && sqlRow.getString("CODE_BARRE").trim().length() > 0) {
368
                        buf.append(sqlRow.getString("CODE_BARRE") + " -- ");
399
                            buf.append(sqlRow.getString("CODE_BARRE") + " -- ");
-
 
400
                        }
-
 
401
                        buf.append(sqlRow.getString("CODE") + " -- ");
-
 
402
                        buf.append(sqlRow.getString("NOM"));
-
 
403
                        result.add(new IComboSelectionItem(sqlRow, buf.toString()));
369
                    }
404
                    }
370
                    buf.append(sqlRow.getString("CODE") + " -- ");
-
 
371
                    buf.append(sqlRow.getString("NOM"));
-
 
372
                    result.add(new IComboSelectionItem(sqlRow, buf.toString()));
-
 
373
                }
405
                }
374
            }
406
            }
375
 
407
 
376
        }
408
        }
377
 
409