OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 21... Line 21...
21
import org.openconcerto.sql.model.SQLTable;
21
import org.openconcerto.sql.model.SQLTable;
22
import org.openconcerto.sql.model.Where;
22
import org.openconcerto.sql.model.Where;
23
 
23
 
24
import java.util.List;
24
import java.util.List;
25
 
25
 
-
 
26
import net.jcip.annotations.GuardedBy;
26
import net.jcip.annotations.ThreadSafe;
27
import net.jcip.annotations.ThreadSafe;
27
 
28
 
28
@ThreadSafe
29
@ThreadSafe
29
public class ListSQLRequest extends FilteredFillSQLRequest {
30
public class ListSQLRequest extends FilteredFillSQLRequest {
30
 
31
 
-
 
32
    static private final boolean FETCH_METADATA = Boolean.getBoolean("listRequest.fetchMD");
-
 
33
 
31
    private static final FieldExpander getExpander(final FieldExpander showAs) {
34
    private static final FieldExpander getExpander(final FieldExpander showAs) {
32
        final FieldExpander res;
35
        final FieldExpander res;
33
        if (showAs != null) {
36
        if (showAs != null) {
34
            res = showAs;
37
            res = showAs;
35
        } else {
38
        } else {
Line 41... Line 44...
41
            }
44
            }
42
        }
45
        }
43
        return res;
46
        return res;
44
    }
47
    }
45
 
48
 
-
 
49
    @GuardedBy("this")
-
 
50
    private boolean fetchMD = FETCH_METADATA;
-
 
51
 
46
    public ListSQLRequest(SQLTable table, List<String> fieldss) {
52
    public ListSQLRequest(SQLTable table, List<String> fieldss) {
47
        this(table, fieldss, null);
53
        this(table, fieldss, null);
48
    }
54
    }
49
 
55
 
50
    public ListSQLRequest(SQLTable table, List<String> fieldss, Where where) {
56
    public ListSQLRequest(SQLTable table, List<String> fieldss, Where where) {
Line 78... Line 84...
78
    @Override
84
    @Override
79
    protected ListSQLRequest clone(boolean forFreeze) {
85
    protected ListSQLRequest clone(boolean forFreeze) {
80
        return new ListSQLRequest(this, forFreeze);
86
        return new ListSQLRequest(this, forFreeze);
81
    }
87
    }
82
 
88
 
-
 
89
    public synchronized final void setMetadataFetched(boolean fetchMD) {
-
 
90
        this.fetchMD = fetchMD;
-
 
91
    }
-
 
92
 
-
 
93
    public synchronized final boolean isMetadataFetched() {
-
 
94
        return this.fetchMD;
-
 
95
    }
-
 
96
 
83
    // MAYBE use changeGraphToFetch()
97
    // MAYBE use changeGraphToFetch()
84
    @Override
98
    @Override
85
    protected final void customizeToFetch(SQLRowValues graphToFetch) {
99
    protected final void customizeToFetch(SQLRowValues graphToFetch) {
86
        super.customizeToFetch(graphToFetch);
100
        super.customizeToFetch(graphToFetch);
-
 
101
        if (this.isMetadataFetched()) {
87
        addField(graphToFetch, getPrimaryTable().getCreationDateField());
102
            addField(graphToFetch, getPrimaryTable().getCreationDateField());
88
        addField(graphToFetch, getPrimaryTable().getCreationUserField());
103
            addField(graphToFetch, getPrimaryTable().getCreationUserField());
89
        addField(graphToFetch, getPrimaryTable().getModifDateField());
104
            addField(graphToFetch, getPrimaryTable().getModifDateField());
90
        addField(graphToFetch, getPrimaryTable().getModifUserField());
105
            addField(graphToFetch, getPrimaryTable().getModifUserField());
-
 
106
        }
91
        addField(graphToFetch, getPrimaryTable().getFieldRaw(SQLComponent.READ_ONLY_FIELD));
107
        addField(graphToFetch, getPrimaryTable().getFieldRaw(SQLComponent.READ_ONLY_FIELD));
92
        addField(graphToFetch, getPrimaryTable().getFieldRaw(SQLComponent.READ_ONLY_USER_FIELD));
108
        addField(graphToFetch, getPrimaryTable().getFieldRaw(SQLComponent.READ_ONLY_USER_FIELD));
93
    }
109
    }
94
 
110
 
95
    private void addField(SQLRowValues graphToFetch, final SQLField f) {
111
    private void addField(SQLRowValues graphToFetch, final SQLField f) {