OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 177
Line 23... Line 23...
23
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
23
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
24
import org.openconcerto.utils.StringUtils;
24
import org.openconcerto.utils.StringUtils;
25
import org.openconcerto.utils.cc.ITransformer;
25
import org.openconcerto.utils.cc.ITransformer;
26
 
26
 
27
import java.sql.SQLException;
27
import java.sql.SQLException;
-
 
28
import java.text.DateFormat;
-
 
29
import java.text.SimpleDateFormat;
28
import java.util.ArrayList;
30
import java.util.ArrayList;
29
import java.util.Arrays;
31
import java.util.Arrays;
30
import java.util.HashMap;
32
import java.util.HashMap;
-
 
33
import java.util.HashSet;
31
import java.util.List;
34
import java.util.List;
32
import java.util.Map;
35
import java.util.Map;
33
import java.util.Set;
36
import java.util.Set;
34
 
37
 
35
public class SQLInjector {
38
public class SQLInjector {
Line 184... Line 187...
184
            rowValsHeader.put(refField, rowVals);
187
            rowValsHeader.put(refField, rowVals);
185
        }
188
        }
186
 
189
 
187
    }
190
    }
188
 
191
 
-
 
192
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
-
 
193
 
189
    protected void transfertNumberReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField) {
194
    protected void transfertNumberReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField) {
190
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
195
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
191
 
196
 
192
        if (prefs.getBoolean("TransfertRef", true)) {
197
        if (prefs.getBoolean("TransfertRef", true)) {
193
            String label = rowVals.getString("NOM");
198
            String label = rowVals.getString("NOM");
194
            if (label != null && label.trim().length() > 0) {
199
            if (label != null && label.trim().length() > 0) {
195
                rowVals.put("NOM", label + ", " + srcRow.getString("NUMERO"));
200
                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);
196
            } else {
212
            } else {
197
                rowVals.put("NOM", srcRow.getString("NUMERO"));
213
                rowVals.put("NOM", srcRow.getString("NUMERO"));
198
            }
214
            }
199
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
215
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
200
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
216
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
-
 
217
            // FIXME Style forcé en titre 1 via l'ID
-
 
218
            rowValsHeader.put("ID_STYLE", 3);
201
            String elementName = StringUtils.firstUp(Configuration.getInstance().getDirectory().getElement(getSource()).getName().getVariant(org.openconcerto.utils.i18n.Grammar.SINGULAR));
219
            String elementName = StringUtils.firstUp(Configuration.getInstance().getDirectory().getElement(getSource()).getName().getVariant(org.openconcerto.utils.i18n.Grammar.SINGULAR));
202
            rowValsHeader.put("NOM", elementName + " N° " + srcRow.getString("NUMERO"));
220
            rowValsHeader.put("NOM", elementName + "\n N° " + srcRow.getString("NUMERO") + " du " + dateFormat.format(srcRow.getDate("DATE").getTime()));
203
            rowValsHeader.put(refField, rowVals);
221
            rowValsHeader.put(refField, rowVals);
204
        }
222
        }
205
    }
223
    }
206
 
224
 
207
    public synchronized SQLRow insertFrom(final SQLRowAccessor srcRow) throws SQLException {
225
    public synchronized SQLRow insertFrom(final SQLRowAccessor srcRow) throws SQLException {