[Libreoffice-commits] core.git: Branch 'aoo/trunk' - connectivity/java
Damjan Jovanovic
damjan at apache.org
Thu Oct 26 02:10:07 UTC 2017
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java | 22 +++--
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java | 39 +++-------
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java | 10 ++
3 files changed, 39 insertions(+), 32 deletions(-)
New commits:
commit 35810eb91bd3514c1b5234a5ae4ae0d04fcb3b46
Author: Damjan Jovanovic <damjan at apache.org>
Date: Thu Oct 26 00:42:42 2017 +0000
Base expects the containers returned by X(Tables/Views/Groups/Users)Supplier
to be the same throughout the lifetime of the catalog!!
Patch by: me
diff --git a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
index 1845ec849033..f67d95606a8c 100644
--- a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
+++ b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
@@ -40,7 +40,7 @@ public class PostgresqlCatalog extends OCatalog {
}
@Override
- public OContainer refreshTables() {
+ public void refreshTables() {
XResultSet results = null;
try {
// Using { "VIEW", "TABLE", "%" } shows INFORMATION_SCHEMA and others, but it also shows indexes :-(
@@ -52,7 +52,11 @@ public class PostgresqlCatalog extends OCatalog {
System.out.println("Table " + name);
names.add(name);
}
- return new PostgresqlTables(this, metadata, this, names);
+ if (tables == null) {
+ tables = new PostgresqlTables(this, metadata, this, names);
+ } else {
+ tables.refill(names);
+ }
} catch (ElementExistException | SQLException exception) {
throw new com.sun.star.uno.RuntimeException("Error", exception);
} finally {
@@ -61,7 +65,7 @@ public class PostgresqlCatalog extends OCatalog {
}
@Override
- public OContainer refreshViews() {
+ public void refreshViews() {
XResultSet results = null;
try {
results = metadata.getTables(Any.VOID, "%", "%", new String[] { "VIEW" });
@@ -71,7 +75,11 @@ public class PostgresqlCatalog extends OCatalog {
String name = buildName(row);
names.add(name);
}
- return new PostgresqlViews(this, metadata, this, names);
+ if (views == null) {
+ views = new PostgresqlViews(this, metadata, this, names);
+ } else {
+ views.refill(names);
+ }
} catch (ElementExistException | SQLException exception) {
throw new com.sun.star.uno.RuntimeException("Error", exception);
} finally {
@@ -80,13 +88,11 @@ public class PostgresqlCatalog extends OCatalog {
}
@Override
- public OContainer refreshGroups() {
- return null;
+ public void refreshGroups() {
}
@Override
- public OContainer refreshUsers() {
- return null;
+ public void refreshUsers() {
}
synchronized OContainer getTablesInternal() {
diff --git a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
index f6c4026bdbb2..e91cac8f2772 100644
--- a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
+++ b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
@@ -34,6 +34,9 @@ import com.sun.star.sdbcx.XViewsSupplier;
import com.sun.star.sdbcx.comp.postgresql.util.ComposeRule;
import com.sun.star.sdbcx.comp.postgresql.util.DbTools;
+/** Base expects the containers returned by X(Tables/Views/Groups/Users)Supplier
+ * to be the same throughout the lifetime of the catalog!!
+ */
public abstract class OCatalog extends ComponentBase
implements XTablesSupplier, XViewsSupplier, XUsersSupplier, XGroupsSupplier, XServiceInfo {
@@ -96,7 +99,7 @@ public abstract class OCatalog extends ComponentBase
public synchronized XNameAccess getTables() {
checkDisposed();
if (tables == null) {
- tables = refreshTables();
+ refreshTables();
}
return tables;
}
@@ -105,7 +108,7 @@ public abstract class OCatalog extends ComponentBase
public synchronized XNameAccess getViews() {
checkDisposed();
if (views == null) {
- views = refreshViews();
+ refreshViews();
}
return views;
}
@@ -114,7 +117,7 @@ public abstract class OCatalog extends ComponentBase
public synchronized XNameAccess getGroups() {
checkDisposed();
if (groups == null) {
- groups = refreshGroups();
+ refreshGroups();
}
return groups;
}
@@ -123,29 +126,17 @@ public abstract class OCatalog extends ComponentBase
public synchronized XNameAccess getUsers() {
checkDisposed();
if (users == null) {
- users = refreshUsers();
+ refreshUsers();
}
return users;
}
public synchronized void refreshObjects() {
checkDisposed();
- if (tables != null) {
- tables.dispose();
- tables = null;
- }
- if (views != null) {
- views.dispose();
- views = null;
- }
- if (groups != null) {
- groups.dispose();
- groups = null;
- }
- if (users != null) {
- users.dispose();
- users = null;
- }
+ refreshTables();
+ refreshViews();
+ refreshGroups();
+ refreshUsers();
}
/**
@@ -169,8 +160,8 @@ public abstract class OCatalog extends ComponentBase
return DbTools.composeTableName(metadata, catalog, schema, table, false, ComposeRule.InDataManipulation);
}
- public abstract OContainer refreshTables();
- public abstract OContainer refreshViews();
- public abstract OContainer refreshGroups();
- public abstract OContainer refreshUsers();
+ public abstract void refreshTables();
+ public abstract void refreshViews();
+ public abstract void refreshGroups();
+ public abstract void refreshUsers();
}
diff --git a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
index 3be4e5fe9b3f..27df7ab69915 100644
--- a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
+++ b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
@@ -109,6 +109,16 @@ public abstract class OContainer extends WeakBase implements
}
}
+ public void refill(List<String> names) {
+ // We only add new elements, as per the C++ implementation.
+ for (String name : names) {
+ if (!entriesByName.containsKey(name)) {
+ entriesByName.put(name, null);
+ namesByIndex.add(name);
+ }
+ }
+ }
+
// Would be from XComponent ;)
public void dispose() {
More information about the Libreoffice-commits
mailing list