1 |
|
|
2 |
1 |
package org.gvsig.postgresql.dal;
|
3 |
2 |
|
|
3 |
import java.util.Arrays;
|
|
4 |
import java.util.Collections;
|
|
5 |
import java.util.HashSet;
|
|
6 |
import java.util.Set;
|
|
7 |
import java.util.function.Function;
|
4 |
8 |
import org.gvsig.fmap.dal.DataParameters;
|
|
9 |
import static org.gvsig.fmap.dal.DataStoreProviderFactory.NO;
|
|
10 |
import static org.gvsig.fmap.dal.DataStoreProviderFactory.UNKNOWN;
|
|
11 |
import static org.gvsig.fmap.dal.DataStoreProviderFactory.YES;
|
5 |
12 |
import org.gvsig.fmap.dal.exception.InitializeException;
|
6 |
13 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
|
7 |
14 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters;
|
... | ... | |
10 |
17 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProvider;
|
11 |
18 |
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory;
|
12 |
19 |
|
|
20 |
public class PostgreSQLStoreProviderFactory extends JDBCStoreProviderFactory {
|
13 |
21 |
|
14 |
|
public class PostgreSQLStoreProviderFactory extends JDBCStoreProviderFactory {
|
15 |
|
|
|
22 |
private static final Set<String> ALLOWED_FUNCTIONS = new HashSet<>(
|
|
23 |
Arrays.asList(new String[]{
|
|
24 |
"COUNT",
|
|
25 |
"SUM",
|
|
26 |
"MIN",
|
|
27 |
"MAX"
|
|
28 |
}
|
|
29 |
)
|
|
30 |
);
|
|
31 |
private static final Set<String> DENIED_FUNCTIONS = Collections.EMPTY_SET;
|
|
32 |
|
16 |
33 |
public PostgreSQLStoreProviderFactory() {
|
17 |
34 |
super(
|
18 |
|
PostgreSQLLibrary.NAME,
|
|
35 |
PostgreSQLLibrary.NAME,
|
19 |
36 |
"PostgreSQL store"
|
20 |
37 |
);
|
21 |
38 |
}
|
... | ... | |
27 |
44 |
) throws InitializeException {
|
28 |
45 |
JDBCHelper helper = new PostgreSQLHelper((JDBCConnectionParameters) parameters);
|
29 |
46 |
JDBCStoreProvider provider = helper.createProvider(
|
30 |
|
(JDBCStoreParameters) parameters,
|
|
47 |
(JDBCStoreParameters) parameters,
|
31 |
48 |
providerServices
|
32 |
49 |
);
|
33 |
50 |
return provider;
|
... | ... | |
38 |
55 |
JDBCStoreParameters params = new PostgreSQLStoreParameters();
|
39 |
56 |
return params;
|
40 |
57 |
}
|
41 |
|
|
|
58 |
|
|
59 |
@Override
|
|
60 |
public Function<String, Integer> allowFunction() {
|
|
61 |
return (Function<String, Integer>) (String name) -> {
|
|
62 |
if (ALLOWED_FUNCTIONS.contains(name)) {
|
|
63 |
return YES;
|
|
64 |
}
|
|
65 |
if (DENIED_FUNCTIONS.contains(name)) {
|
|
66 |
return NO;
|
|
67 |
}
|
|
68 |
return UNKNOWN;
|
|
69 |
};
|
|
70 |
}
|
|
71 |
|
|
72 |
@Override
|
|
73 |
public int allowGroupBy() {
|
|
74 |
return YES;
|
|
75 |
}
|
|
76 |
|
|
77 |
@Override
|
|
78 |
public int hasVectorialSupport() {
|
|
79 |
return YES;
|
|
80 |
}
|
|
81 |
|
|
82 |
@Override
|
|
83 |
public int hasRasterSupport() {
|
|
84 |
return NO;
|
|
85 |
}
|
|
86 |
|
|
87 |
@Override
|
|
88 |
public int hasTabularSupport() {
|
|
89 |
return YES;
|
|
90 |
}
|
|
91 |
|
|
92 |
@Override
|
|
93 |
public int hasSQLSupport() {
|
|
94 |
return YES;
|
|
95 |
}
|
42 |
96 |
}
|