Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#255 Remove GenericDAO #266

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence</artifactId>
<version>3.7-SNAPSHOT</version>
<version>3.8-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
Expand All @@ -19,9 +19,8 @@
used in GeoFence -->
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<geofence-version>3.7-SNAPSHOT</geofence-version>
<geofence-version>3.8-SNAPSHOT</geofence-version>
<hibernate-version>3.6.9.Final</hibernate-version>
<hibernate-generic-dao-version>1.1.0</hibernate-generic-dao-version>
<hibernate-spatial-version>1.1.3.2</hibernate-spatial-version>
<postgresql.jdbc.version>42.2.18</postgresql.jdbc.version>
<postgis.jdbc.version>1.3.3</postgis.jdbc.version>
Expand Down
2 changes: 1 addition & 1 deletion src/samples/csv2geofence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>org.geoserver.geofence.sample</groupId>
<artifactId>csv2geofence</artifactId>
<version>3.7-SNAPSHOT</version>
<version>3.8-SNAPSHOT</version>
<packaging>jar</packaging>

<name>csv2geofence</name>
Expand Down
48 changes: 37 additions & 11 deletions src/services/core/model-external/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/


-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

Expand All @@ -14,7 +12,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.7-SNAPSHOT</version>
<version>3.8-SNAPSHOT</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand All @@ -26,17 +24,38 @@
<dependencies>

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

<dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<!-- <dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency> -->

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
</dependency>

<dependency>
Expand All @@ -51,7 +70,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<version>3.1.1</version>

<executions>
<execution>
Expand Down Expand Up @@ -84,7 +103,7 @@

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<version>3.1.0</version>

<executions>
<execution>
Expand Down Expand Up @@ -112,6 +131,13 @@
<include name="**/*.java"/>
</fileset>
</replaceregexp>

<replaceregexp byline="true" replace="">
<regexp pattern="(@ElementCollection).*"/>
<fileset dir="${project.build.directory}/generated-sources/original">
<include name="**/*.java"/>
</fileset>
</replaceregexp>

<replaceregexp byline="true" replace="">
<regexp pattern="(@Id|@GeneratedValue|@Enumerated|@Column|@Type|@Temporal|@OneToOne|@ManyToOne|@ManyToMany|@ForeignKey|@UniqueConstraint|@AttributeOverride|@JoinTable).*"/>
Expand All @@ -133,7 +159,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<version>3.5.0</version>

<executions>
<execution>
Expand All @@ -155,7 +181,7 @@
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.3</version>
<version>3.1.0</version>
<configuration>
<attach>true</attach>
</configuration>
Expand Down
44 changes: 33 additions & 11 deletions src/services/core/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.7-SNAPSHOT</version>
<version>3.8-SNAPSHOT</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand All @@ -24,7 +24,34 @@
<description>Model with JPA annotation used internally</description>

<dependencies>


<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>

<!-- <dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency> -->

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand All @@ -43,14 +70,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
Expand Down Expand Up @@ -87,7 +106,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -97,6 +116,9 @@
</goals>
</execution>
</executions>
<!-- <configuration>
<release>11</release>
</configuration>-->
</plugin>

</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
Expand Down Expand Up @@ -49,7 +50,7 @@
@Table(name = "gf_layer_details")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "LayerDetails")
@XmlRootElement(name = "LayerDetails")
public class LayerDetails implements Serializable {
public class LayerDetails implements Identifiable, Serializable {

private static final long serialVersionUID = -4150963895550551513L;

Expand All @@ -72,7 +73,7 @@ public class LayerDetails implements Serializable {
@Column(length=4000)
private String cqlFilterWrite;

@Type(type = "org.hibernatespatial.GeometryUserType")
// @Type(type = "org.hibernate.spatial.JTSGeometryType")
@Column(name = "area")
private MultiPolygon area;

Expand All @@ -90,23 +91,23 @@ public class LayerDetails implements Serializable {
private Rule rule;

/** Styles allowed for this layer */
@org.hibernate.annotations.CollectionOfElements(fetch=FetchType.EAGER)
@ElementCollection(fetch=FetchType.EAGER)
@JoinTable( name = "gf_layer_styles", joinColumns = @JoinColumn(name = "details_id"))
@ForeignKey(name="fk_styles_layer")
@Column(name="styleName")
private Set<String> allowedStyles = new HashSet<String>();
private Set<String> allowedStyles = new HashSet<>();

/** Feature Attributes associated to the Layer
* <P>We'll use the pair <TT>(details_id, name)</TT> as PK for the associated table.
* To do so, we have to perform some trick on the <TT>{@link LayerAttribute#access}</TT> field.
*/
@org.hibernate.annotations.CollectionOfElements(fetch=FetchType.EAGER)
@ElementCollection(fetch=FetchType.EAGER)
@JoinTable( name = "gf_layer_attributes", joinColumns = @JoinColumn(name = "details_id"), uniqueConstraints = @UniqueConstraint(columnNames={"details_id", "name"}))
// override is used to set the pk as {"details_id", "name"}
// @AttributeOverride( name="access", column=@Column(name="access", nullable=false) )
@ForeignKey(name="fk_attribute_layer")
@Fetch(FetchMode.SELECT) // without this, hibernate will duplicate results(!)
private Set<LayerAttribute> attributes = new HashSet<LayerAttribute>();
private Set<LayerAttribute> attributes = new HashSet<>();

@XmlJavaTypeAdapter(MultiPolygonAdapter.class)
public MultiPolygon getArea() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Table(name = "gf_rule_limits", uniqueConstraints = @UniqueConstraint(columnNames = "rule_id"))
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "RuleLimits")
@XmlRootElement(name = "RuleLimits")
public class RuleLimits implements Serializable {
public class RuleLimits implements Identifiable, Serializable {

private static final long serialVersionUID = 2829839552804345725L;

Expand All @@ -56,7 +56,7 @@ public class RuleLimits implements Serializable {
@ForeignKey(name = "fk_limits_rule")
private Rule rule;

@Type(type = "org.hibernatespatial.GeometryUserType")
//@Type(type = "org.hibernate.spatial.JTSGeometryType")
@Column(name = "area")
private MultiPolygon allowedArea;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* (c) 2024 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.geofence.core.model.util;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

/**
*
* @author etj
*/
public class EWKTParser {

static public Geometry parse(String wkt) throws ParseException {
if (wkt == null) {
return null;
}

WKTReader reader = new WKTReader();
Geometry result;
if (wkt.startsWith("SRID=")) {
String[] areaAr = wkt.split(";");
String srid = areaAr[0].split("=")[1];
result = reader.read(areaAr[1]);
result.setSRID(Integer.valueOf(srid));
} else {
result = reader.read(wkt);
result.setSRID(4326);
}
return result;
}
}
2 changes: 1 addition & 1 deletion src/services/core/persistence-pg-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.geoserver.geofence</groupId>
<artifactId>geofence-core</artifactId>
<version>3.7-SNAPSHOT</version>
<version>3.8-SNAPSHOT</version>
</parent>

<groupId>org.geoserver.geofence</groupId>
Expand Down
Loading