Skip to content

Commit bbffbf2

Browse files
authored
[PostGIS] Add PostGIS datastore (#112)
1 parent 11eff03 commit bbffbf2

File tree

79 files changed

+9407
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+9407
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
description = 'OSH Datastore (PostGis)'
2+
ext.details = 'Storage module backed by a PostGis database'
3+
4+
dependencies {
5+
implementation 'org.sensorhub:sensorhub-core:' + oshCoreVersion
6+
implementation 'org.sensorhub:sensorhub-service-consys'
7+
embeddedImpl('org.postgresql:postgresql:42.7.7') {
8+
exclude group: "org.slf4j", module: "slf4j-api"
9+
}
10+
embeddedImpl('net.postgis:postgis-jdbc:2021.1.0'){
11+
exclude group: "org.slf4j", module: "slf4j-api"
12+
}
13+
embeddedImpl('com.zaxxer:HikariCP:5.0.1'){
14+
exclude group: "org.slf4j", module: "slf4j-api"
15+
}
16+
embeddedImpl('com.github.ben-manes.caffeine:caffeine:3.1.7') {
17+
exclude group: 'checker-qual', module: 'org.checkerframework'
18+
}
19+
testImplementation(testFixtures('org.sensorhub:sensorhub-core:' + oshCoreVersion))
20+
}
21+
22+
// add info to OSGi manifest
23+
osgi {
24+
manifest {
25+
attributes('Bundle-Vendor': 'GeoRobotix Inc.')
26+
attributes 'Bundle-Activator': 'org.sensorhub.impl.datastore.postgis.Activator'
27+
}
28+
}
29+
30+
// add info to maven pom
31+
ext.pom >>= {
32+
developers {
33+
developer {
34+
id 'mdhsl'
35+
name 'Mathieu Dhainaut'
36+
organization 'GeoRobotix Inc.'
37+
organizationUrl 'https://georobotix.com'
38+
}
39+
}
40+
}
41+
42+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/***************************** BEGIN LICENSE BLOCK ***************************
2+
3+
The contents of this file are subject to the Mozilla Public License, v. 2.0.
4+
If a copy of the MPL was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
7+
Software distributed under the License is distributed on an "AS IS" basis,
8+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9+
for the specific language governing rights and limitations under the License.
10+
11+
Copyright (C) 2023 Georobotix. All Rights Reserved.
12+
13+
******************************* END LICENSE BLOCK ***************************/
14+
15+
package org.sensorhub.impl.datastore.postgis;
16+
17+
import com.google.common.cache.Cache;
18+
import com.google.common.cache.CacheBuilder;
19+
import org.sensorhub.api.data.IDataStreamInfo;
20+
import org.sensorhub.api.datastore.obs.IDataStreamStore;
21+
import org.sensorhub.api.datastore.system.ISystemDescStore;
22+
import org.sensorhub.impl.datastore.postgis.builder.QueryBuilder;
23+
24+
import java.util.concurrent.TimeUnit;
25+
import java.util.concurrent.locks.Lock;
26+
import java.util.concurrent.locks.ReentrantLock;
27+
28+
public abstract class AbstractStreamStore<T extends QueryBuilder> extends PostgisStore<T> implements IDataStreamStore {
29+
30+
protected volatile Cache<Long, IDataStreamInfo> cache = CacheBuilder.newBuilder()
31+
.maximumSize(150)
32+
.expireAfterAccess(5, TimeUnit.MINUTES)
33+
.build();
34+
35+
protected ISystemDescStore systemStore;
36+
37+
private final Lock lock = new ReentrantLock();
38+
39+
protected AbstractStreamStore(int idScope, IdProviderType dsIdProviderType, T queryBuilder) {
40+
super(idScope, dsIdProviderType, queryBuilder);
41+
}
42+
43+
@Override
44+
public void linkTo(ISystemDescStore systemStore) {
45+
// this.systemStore = Asserts.checkNotNull(systemStore, ISystemDescStore.class);
46+
// queryBuilder.linkTo(this.systemStore);
47+
}
48+
49+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/***************************** BEGIN LICENSE BLOCK ***************************
2+
3+
The contents of this file are subject to the Mozilla Public License, v. 2.0.
4+
If a copy of the MPL was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
7+
Software distributed under the License is distributed on an "AS IS" basis,
8+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9+
for the specific language governing rights and limitations under the License.
10+
11+
Copyright (C) 2023 Georobotix. All Rights Reserved.
12+
13+
******************************* END LICENSE BLOCK ***************************/
14+
15+
package org.sensorhub.impl.datastore.postgis;
16+
17+
import org.osgi.framework.BundleActivator;
18+
import org.sensorhub.utils.OshBundleActivator;
19+
20+
21+
public class Activator extends OshBundleActivator implements BundleActivator
22+
{
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/***************************** BEGIN LICENSE BLOCK ***************************
2+
3+
The contents of this file are subject to the Mozilla Public License, v. 2.0.
4+
If a copy of the MPL was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
7+
Software distributed under the License is distributed on an "AS IS" basis,
8+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9+
for the specific language governing rights and limitations under the License.
10+
11+
Copyright (C) 2023 Georobotix. All Rights Reserved.
12+
13+
******************************* END LICENSE BLOCK ***************************/
14+
15+
package org.sensorhub.impl.datastore.postgis;
16+
17+
public class IPostgisStore {
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/***************************** BEGIN LICENSE BLOCK ***************************
2+
3+
The contents of this file are subject to the Mozilla Public License, v. 2.0.
4+
If a copy of the MPL was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
7+
Software distributed under the License is distributed on an "AS IS" basis,
8+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9+
for the specific language governing rights and limitations under the License.
10+
11+
Copyright (C) 2023 Georobotix. All Rights Reserved.
12+
13+
******************************* END LICENSE BLOCK ***************************/
14+
15+
package org.sensorhub.impl.datastore.postgis;
16+
17+
public enum IdProviderType {
18+
SEQUENTIAL,
19+
UID_HASH
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/***************************** BEGIN LICENSE BLOCK ***************************
2+
3+
The contents of this file are subject to the Mozilla Public License, v. 2.0.
4+
If a copy of the MPL was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
7+
Software distributed under the License is distributed on an "AS IS" basis,
8+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9+
for the specific language governing rights and limitations under the License.
10+
11+
Copyright (C) 2023 Georobotix. All Rights Reserved.
12+
13+
******************************* END LICENSE BLOCK ***************************/
14+
15+
package org.sensorhub.impl.datastore.postgis;
16+
17+
import org.sensorhub.api.database.DatabaseConfig;
18+
19+
20+
/**
21+
* <p>
22+
* Base config class for PostGis based database modules
23+
* </p>
24+
*
25+
* @author Mathieu Dhainaut
26+
* @date Jul 25, 2023
27+
*/
28+
public abstract class PostgisDatabaseConfig extends DatabaseConfig
29+
{
30+
public PostgisDatabaseConfig()
31+
{
32+
this.moduleClass = PostgisObsSystemDatabase.class.getCanonicalName();
33+
}
34+
35+
}

0 commit comments

Comments
 (0)