You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2017/10/26 00:42:42 UTC
svn commit: r1813361 - in
/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql:
PostgresqlCatalog.java sdbcx/OCatalog.java sdbcx/OContainer.java
Author: damjan
Date: Thu Oct 26 00:42:42 2017
New Revision: 1813361
URL: http://svn.apache.org/viewvc?rev=1813361&view=rev
Log:
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
Modified:
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java?rev=1813361&r1=1813360&r2=1813361&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java Thu Oct 26 00:42:42 2017
@@ -40,7 +40,7 @@ public class PostgresqlCatalog extends O
}
@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 O
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 O
}
@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 O
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 O
}
@Override
- public OContainer refreshGroups() {
- return null;
+ public void refreshGroups() {
}
@Override
- public OContainer refreshUsers() {
- return null;
+ public void refreshUsers() {
}
synchronized OContainer getTablesInternal() {
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java?rev=1813361&r1=1813360&r2=1813361&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OCatalog.java Thu Oct 26 00:42:42 2017
@@ -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 C
public synchronized XNameAccess getTables() {
checkDisposed();
if (tables == null) {
- tables = refreshTables();
+ refreshTables();
}
return tables;
}
@@ -105,7 +108,7 @@ public abstract class OCatalog extends C
public synchronized XNameAccess getViews() {
checkDisposed();
if (views == null) {
- views = refreshViews();
+ refreshViews();
}
return views;
}
@@ -114,7 +117,7 @@ public abstract class OCatalog extends C
public synchronized XNameAccess getGroups() {
checkDisposed();
if (groups == null) {
- groups = refreshGroups();
+ refreshGroups();
}
return groups;
}
@@ -123,29 +126,17 @@ public abstract class OCatalog extends C
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 C
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();
}
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java?rev=1813361&r1=1813360&r2=1813361&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java Thu Oct 26 00:42:42 2017
@@ -109,6 +109,16 @@ public abstract class OContainer extends
}
}
+ 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() {