OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 142 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 25... Line 25...
25
import org.openconcerto.sql.utils.SQLCreateRoot;
25
import org.openconcerto.sql.utils.SQLCreateRoot;
26
import org.openconcerto.sql.utils.SQLCreateTableBase;
26
import org.openconcerto.sql.utils.SQLCreateTableBase;
27
import org.openconcerto.sql.utils.SQLUtils;
27
import org.openconcerto.sql.utils.SQLUtils;
28
import org.openconcerto.sql.utils.SQL_URL;
28
import org.openconcerto.sql.utils.SQL_URL;
29
import org.openconcerto.utils.CollectionUtils;
29
import org.openconcerto.utils.CollectionUtils;
-
 
30
import org.openconcerto.utils.Tuple2.List2;
30
 
31
 
31
import java.net.URISyntaxException;
32
import java.net.URISyntaxException;
32
import java.sql.SQLException;
33
import java.sql.SQLException;
33
import java.util.Arrays;
34
import java.util.Arrays;
34
import java.util.Collection;
35
import java.util.Collection;
Line 333... Line 334...
333
 
334
 
334
    public final String equalsDesc(final DBRoot o) {
335
    public final String equalsDesc(final DBRoot o) {
335
        return this.equalsDesc(o, null);
336
        return this.equalsDesc(o, null);
336
    }
337
    }
337
 
338
 
338
    public final String equalsDesc(final DBRoot o, final SQLSystem otherSystem) {
339
    public final String equalsDesc(final DBRoot o, final SQLSyntax otherSystem) {
339
        if (this == o)
340
        if (this == o)
340
            return null;
341
            return null;
341
        if (null == o)
342
        if (null == o)
342
            return "other is null";
343
            return "other is null";
343
 
344
 
Line 362... Line 363...
362
     * 
363
     * 
363
     * @return the url or <code>null</code> if this cannot be represented as an {@link SQL_URL} (eg
364
     * @return the url or <code>null</code> if this cannot be represented as an {@link SQL_URL} (eg
364
     *         jdbc:h2:file:/a/b/c).
365
     *         jdbc:h2:file:/a/b/c).
365
     */
366
     */
366
    public final SQL_URL getURL() {
367
    public final SQL_URL getURL() {
-
 
368
        // check that our name doesn't contain a path, otherwise we would lose it
-
 
369
        // e.g. dbserv:8084/~/sample
367
        final String hostname = this.getServer().getHostname();
370
        final List2<String> hostAndPath = this.getServer().getHostnameAndPath();
-
 
371
        final String hostname = hostAndPath.get0();
368
        if (hostname == null)
372
        // TODO return JDBCUrl
-
 
373
        if (hostname == null || hostAndPath.get1() != null)
369
            return null;
374
            return null;
370
        final SQLSystem system = this.getServer().getSQLSystem();
375
        final SQLSystem system = this.getServer().getSQLSystem();
371
        String url = system.name().toLowerCase() + "://" + this.getDBSystemRoot().getDataSource().getUsername() + "@" + hostname + "/";
376
        String url = system.name().toLowerCase() + "://" + this.getDBSystemRoot().getDataSource().getUsername() + "@" + hostname + "/";
372
        // handle systems w/o systemRoot
377
        // handle systems w/o systemRoot
373
        if (system.getDBLevel(DBSystemRoot.class) != HierarchyLevel.SQLSERVER) {
378
        if (system.getDBLevel(DBSystemRoot.class) != HierarchyLevel.SQLSERVER) {