OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 93 Rev 174
Line 164... Line 164...
164
 
164
 
165
    protected void merge(SQLField field, Object value, SQLRowValues rowVals) {
165
    protected void merge(SQLField field, Object value, SQLRowValues rowVals) {
166
        rowVals.put(field.getName(), value);
166
        rowVals.put(field.getName(), value);
167
    }
167
    }
168
 
168
 
169
    protected void transfertReference(SQLRowAccessor srcRow, SQLRowValues rowVals, String from, String to) {
169
    protected void transfertReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField, String from, String to) {
170
 
170
 
171
        String label = rowVals.getString(to);
171
        String label = rowVals.getString(to);
-
 
172
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
-
 
173
 
-
 
174
        if (prefs.getBoolean("TransfertRef", true) || !to.equals("NOM")) {
172
        if (label != null && label.trim().length() > 0) {
175
            if (label != null && label.trim().length() > 0) {
173
            rowVals.put(to, label + ", " + srcRow.getString(from));
176
                rowVals.put(to, label + ", " + srcRow.getString(from));
174
        } else {
177
            } else {
175
            rowVals.put(to, srcRow.getString(from));
178
                rowVals.put(to, srcRow.getString(from));
176
        }
179
            }
-
 
180
        } else if (prefs.getBoolean("TransfertMultiRef", false)) {
-
 
181
            SQLRowValues rowValsHeader = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(tableElementDestination));
-
 
182
            // TODO taxe may be undefined set it to default
-
 
183
            rowValsHeader.put("NOM", srcRow.getString(from));
-
 
184
            rowValsHeader.put(refField, rowVals);
-
 
185
        }
-
 
186
 
177
    }
187
    }
178
 
188
 
179
    protected void transfertNumberReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField) {
189
    protected void transfertNumberReference(SQLRowAccessor srcRow, SQLRowValues rowVals, final SQLTable tableElementDestination, String refField) {
180
        SQLPreferences prefs = new SQLPreferences(srcRow.getTable().getDBRoot());
190
        SQLPreferences prefs = SQLPreferences.getMemCached(srcRow.getTable().getDBRoot());
181
 
191
 
182
        if (prefs.getBoolean("TransfertRef", true)) {
192
        if (prefs.getBoolean("TransfertRef", true)) {
183
            String label = rowVals.getString("NOM");
193
            String label = rowVals.getString("NOM");
184
            if (label != null && label.trim().length() > 0) {
194
            if (label != null && label.trim().length() > 0) {
185
                rowVals.put("NOM", label + ", " + srcRow.getString("NUMERO"));
195
                rowVals.put("NOM", label + ", " + srcRow.getString("NUMERO"));
Line 410... Line 420...
410
 
420
 
411
    /**
421
    /**
412
     * register manually a transfer, use with caution
422
     * register manually a transfer, use with caution
413
     * 
423
     * 
414
     * @throws SQLException
424
     * @throws SQLException
415
     * */
425
     */
416
    public void addTransfert(int idFrom, int idTo) throws SQLException {
426
    public void addTransfert(int idFrom, int idTo) throws SQLException {
417
        final SQLTable tableTransfert = getSource().getTable(getTableTranferName());
427
        final SQLTable tableTransfert = getSource().getTable(getTableTranferName());
418
        final SQLRowValues rowTransfer = new SQLRowValues(tableTransfert);
428
        final SQLRowValues rowTransfer = new SQLRowValues(tableTransfert);
419
        final Set<SQLField> foreignKeysSrc = tableTransfert.getForeignKeys(getSource());
429
        final Set<SQLField> foreignKeysSrc = tableTransfert.getForeignKeys(getSource());
420
        final Set<SQLField> foreignKeysDest = tableTransfert.getForeignKeys(getDestination());
430
        final Set<SQLField> foreignKeysDest = tableTransfert.getForeignKeys(getDestination());