OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Rev 182 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
Line 167... Line 167...
167
 
167
 
168
    protected void merge(SQLField field, Object value, SQLRowValues rowVals) {
168
    protected void merge(SQLField field, Object value, SQLRowValues rowVals) {
169
        rowVals.put(field.getName(), value);
169
        rowVals.put(field.getName(), value);
170
    }
170
    }
171
 
171
 
-
 
172
    private String cleanRef(String value) {
-
 
173
        List<String> l = StringUtils.fastSplit(value, ',');
-
 
174
        Set<String> s = new HashSet<>(l);
-
 
175
        String nom = "";
-
 
176
        if (s.size() > 1) {
-
 
177
            Set<String> refAdded = new HashSet<>();
-
 
178
            for (String string : s) {
-
 
179
                if (string.trim().length() > 0 && !refAdded.contains(string.trim())) {
-
 
180
                    nom += string + ",";
-
 
181
                    refAdded.add(string.trim());
-
 
182
                }
-
 
183
            }
-
 
184
        } else if (s.size() == 1) {
-
 
185
            nom = s.iterator().next();
-
 
186
        }
-
 
187
        return nom;
-
 
188
    }
-
 
189
 
172
    protected void transfertReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField, String from, String to) {
190
    protected void transfertReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField, String from, String to) {
173
 
191
 
174
        String label = rowVals.getString(to);
192
        String label = rowVals.getString(to);
175
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
193
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
176
 
194
 
177
        if (prefs.getBoolean("TransfertRef", true) || !to.equals("NOM")) {
195
        if (prefs.getBoolean("TransfertRef", true) || !to.equals("NOM")) {
178
            if (label != null && label.trim().length() > 0) {
196
            if (label != null && label.trim().length() > 0) {
179
                rowVals.put(to, label + ", " + srcRow.getString(from));
197
                rowVals.put(to, cleanRef(label + ", " + srcRow.getString(from)));
180
            } else {
198
            } else {
181
                rowVals.put(to, srcRow.getString(from));
199
                rowVals.put(to, srcRow.getString(from));
182
            }
200
            }
183
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
201
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
184
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
202
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
Line 196... Line 214...
196
 
214
 
197
        if (prefs.getBoolean("TransfertRef", true)) {
215
        if (prefs.getBoolean("TransfertRef", true)) {
198
            String label = rowVals.getString("NOM");
216
            String label = rowVals.getString("NOM");
199
            if (label != null && label.trim().length() > 0) {
217
            if (label != null && label.trim().length() > 0) {
200
                final String value = label + ", " + srcRow.getString("NUMERO");
218
                final String value = label + ", " + srcRow.getString("NUMERO");
201
                List<String> l = StringUtils.fastSplit(value, ',');
-
 
202
                Set<String> s = new HashSet<>(l);
-
 
203
                String nom = "";
-
 
204
                if (s.size() > 1) {
-
 
205
                    for (String string : s) {
-
 
206
                        nom += string + ",";
-
 
207
                    }
-
 
208
                } else if (s.size() == 1) {
-
 
209
                    nom = s.iterator().next();
-
 
210
                }
-
 
211
                rowVals.put("NOM", nom);
219
                rowVals.put("NOM", cleanRef(value));
212
            } else {
220
            } else {
213
                rowVals.put("NOM", srcRow.getString("NUMERO"));
221
                rowVals.put("NOM", srcRow.getString("NUMERO"));
214
            }
222
            }
215
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
223
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
216
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
224
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));