OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 174 Rev 177
Line 25... Line 25...
25
 
25
 
26
    public SQLUpdate(Where where) {
26
    public SQLUpdate(Where where) {
27
        this.where = where;
27
        this.where = where;
28
    }
28
    }
29
 
29
 
-
 
30
    public void importValuesFrom(SQLRowAccessor row) {
-
 
31
        SQLField pk = row.getTable().getKey();
-
 
32
        for (String field : row.getFields()) {
-
 
33
            final SQLField sqlField = row.getTable().getField(field);
-
 
34
            if (!pk.equals(sqlField)) {
-
 
35
                if (sqlField.isForeignKey()) {
-
 
36
                    add(sqlField, row.getForeignIDNumber(field));
-
 
37
                } else {
-
 
38
                    add(sqlField, row.getObject(field));
-
 
39
                }
-
 
40
            }
-
 
41
        }
-
 
42
    }
-
 
43
 
30
    public void add(SQLField field, Object value) {
44
    public void add(SQLField field, Object value) {
31
        if (this.table == null) {
45
        if (this.table == null) {
32
            this.table = field.getTable();
46
            this.table = field.getTable();
33
        } else {
47
        } else {
34
            if (!this.table.equals(field.getTable())) {
48
            if (!this.table.equals(field.getTable())) {
Line 82... Line 96...
82
            builder.append("=");
96
            builder.append("=");
83
 
97
 
84
            Object value = this.values.get(i);
98
            Object value = this.values.get(i);
85
            final Class<?> javaType = field.getType().getJavaType();
99
            final Class<?> javaType = field.getType().getJavaType();
86
            Object str = value;
100
            Object str = value;
-
 
101
            if (value != null) {
87
            if (!javaType.isInstance(value)) {
102
                if (!javaType.isInstance(value)) {
88
                str = SQLRowValues.convert(value.getClass(), value, javaType);
103
                    str = SQLRowValues.convert(value.getClass(), value, javaType);
-
 
104
                }
-
 
105
                builder.append(field.getType().toString(str));
-
 
106
            } else {
-
 
107
                builder.append("null");
89
            }
108
            }
90
            builder.append(field.getType().toString(str));
-
 
91
            if (i < stop - 1) {
109
            if (i < stop - 1) {
92
                builder.append(',');
110
                builder.append(',');
93
            }
111
            }
94
        }
112
        }
95
        builder.append(" WHERE ");
113
        builder.append(" WHERE ");