Skip to content

Commit

Permalink
Fix hibernate list implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbodiguel committed Jun 12, 2024
1 parent 07a9c6d commit 13d83e8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.arlas.commons.exceptions.ArlasConfigurationException;
import io.arlas.commons.rest.utils.ServerConstants;
import io.dropwizard.db.DataSourceFactory;

import jakarta.validation.Valid;

import java.util.Arrays;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
import org.apache.commons.lang3.tuple.Pair;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.stream.Collectors;

import static io.arlas.filter.config.TechnicalRoles.GROUP_PUBLIC;

public class HibernatePersistenceServiceImpl extends AbstractDAO<Data> implements PersistenceService {
protected static Logger LOGGER = LoggerFactory.getLogger(HibernatePersistenceServiceImpl.class);

public HibernatePersistenceServiceImpl(SessionFactory factory) {
super(factory);
Expand All @@ -48,10 +51,10 @@ public HibernatePersistenceServiceImpl(SessionFactory factory) {
public Pair<Long, List<Data>> list(String zone, IdentityParam identityParam, Integer size, Integer page, SortOrder order) {
String from = " from Data ud "
+ " where ud." + Data.zoneColumn + "=:zone"
+ " and (ud." + Data.organizationColumn + " in :organization"
+ " and ((ud." + Data.organizationColumn + " in :organization"
+ " and (ud." + Data.ownerColumn + "=:userId"
+ " or " + getGroupsRequest(identityParam.groups) + "))"
+ " or (" + getGroupsRequest(List.of(GROUP_PUBLIC)) + ")";
+ " or (" + getGroupsRequest(List.of(GROUP_PUBLIC)) + "))";

Long totalCount = currentSession().createQuery("SELECT count(ud) " + from, Long.class)
.setParameter("zone", zone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@

import io.dropwizard.jackson.JsonSnakeCase;
import io.hypersistence.utils.hibernate.type.json.JsonBinaryType;
import io.hypersistence.utils.hibernate.type.json.JsonType;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Type;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import io.arlas.persistence.model.Link;
import io.arlas.persistence.server.model.Data;
import io.arlas.persistence.server.utils.SortOrder;
import jakarta.ws.rs.core.UriInfo;
import org.apache.commons.lang3.tuple.Pair;

import jakarta.ws.rs.core.UriInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

@Path("/persist")
Expand Down
6 changes: 4 additions & 2 deletions docker/docker-files/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
db:
image: postgres
image: postgres:16.3
container_name: db
restart: always
environment:
Expand Down Expand Up @@ -29,6 +29,8 @@ services:
container_name: arlas-persistence-server
restart: always
environment:
- ARLAS_PERSISTENCE_LOGGING_LEVEL=${ARLAS_PERSISTENCE_LOGGING_LEVEL:-INFO}
- ARLAS_PERSISTENCE_LOGGING_CONSOLE_LEVEL=${ARLAS_PERSISTENCE_LOGGING_CONSOLE_LEVEL:-TRACE}
- ARLAS_PERSISTENCE_HOST="${ARLAS_PERSISTENCE_HOST:-localhost}"
- ARLAS_PERSISTENCE_PORT="${ARLAS_PERSISTENCE_PORT:-9997}"
- ARLAS_PERSISTENCE_PREFIX="${ARLAS_PERSISTENCE_PREFIX:-/arlas_persistence_server}"
Expand All @@ -48,7 +50,7 @@ services:
- ARLAS_PERSISTENCE_HIBERNATE_PASSWORD="${ARLAS_PERSISTENCE_HIBERNATE_PASSWORD:-iAMs00perSecrEET}"
- ARLAS_PERSISTENCE_HIBERNATE_DRIVER="${ARLAS_PERSISTENCE_HIBERNATE_DRIVER:-org.postgresql.Driver}"
- ARLAS_PERSISTENCE_HIBERNATE_DIALECT="${ARLAS_PERSISTENCE_HIBERNATE_DIALECT:-org.hibernate.dialect.PostgreSQLDialect}"
- ARLAS_PERSISTENCE_HIBERNATE_HBM2DDL="${ARLAS_PERSISTENCE_HIBERNATE_HBM2DDL:-update}"
- ARLAS_PERSISTENCE_HIBERNATE_HBM2DDL="${ARLAS_PERSISTENCE_HIBERNATE_HBM2DDL:-create-only}"
- GOOGLE_APPLICATION_CREDENTIALS=/opt/app/google-registry.json
ports:
- "19997:9997" # !EXPOSE!
Expand Down

0 comments on commit 13d83e8

Please sign in to comment.