Skip to content

Commit

Permalink
add columns to h2 db
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Feb 11, 2025
1 parent 2804d75 commit 2741735
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .run/OkrApplication-E2E.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OkrApplication-E2E" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="integration-test" />
<option name="ALTERNATIVE_JRE_PATH" value="$USER_HOME$/.sdkman/candidates/java/current" />
<option name="ALTERNATIVE_JRE_PATH" value="corretto-21" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="backend" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.puzzle.okr.OkrApplication" />
Expand Down
1 change: 0 additions & 1 deletion backend/src/main/java/ch/puzzle/okr/models/Deletable.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jakarta.persistence.*;
import org.hibernate.annotations.ColumnDefault;


@MappedSuperclass
public abstract class Deletable {
@Column(name = "is_deleted", nullable = false)
Expand Down
1 change: 0 additions & 1 deletion backend/src/main/java/ch/puzzle/okr/models/Objective.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ private Objective(Builder builder) {
setModifiedBy(builder.modifiedBy);
}


public Long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
import ch.puzzle.okr.models.Action;
import java.util.List;

import ch.puzzle.okr.models.Objective;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

public interface ActionRepository extends DeleteRepository<Action, Long> {
// @Query("select Action from Action a where ")
// TODO rename this
// @Query("select Action from Action a where ")
// TODO rename this
List<Action> getActionsByKeyResultIdAndIsDeletedFalseOrderByPriorityAsc(Long keyResultId);
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package ch.puzzle.okr.repository;

import ch.puzzle.okr.models.Deletable;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.query.Param;

import java.util.List;

@NoRepositoryBean
public interface DeleteRepository<E extends Deletable, I> extends CrudRepository<E, I> {
// @Query("select #{#entityName} e set e.isDeleted = true where e.id = :id")
// List<E> isDeleted(boolean isDeleted);
// @Query("select #{#entityName} e set e.isDeleted = true where e.id = :id")
// List<E> isDeleted(boolean isDeleted);

@Query("select e from #{#entityName} e where e.isDeleted = false ")
List<E> findAllVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import ch.puzzle.okr.models.Quarter;
import ch.puzzle.okr.models.Team;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ch.puzzle.okr.models.Unit;
import java.util.List;
import java.util.Optional;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ch.puzzle.okr.models.User;
import java.util.List;
import java.util.Optional;
import org.springframework.data.repository.CrudRepository;

public interface UserRepository extends DeleteRepository<User, Long> {
Optional<User> findByEmailAndIsDeletedFalse(String email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.repository.ActionRepository;
import java.util.List;

import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import ch.puzzle.okr.models.checkin.CheckIn;
import ch.puzzle.okr.repository.CheckInRepository;
import java.util.List;

import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package ch.puzzle.okr.service.persistence;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;

import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.service.persistence.customCrud.DeleteMethod;
import ch.puzzle.okr.service.persistence.customCrud.HardDelete;
import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.repository.CrudRepository;
import org.springframework.http.HttpStatus;

import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.StreamSupport;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;

/**
* @param <T>
* the Type or entity of the repository
Expand Down Expand Up @@ -45,7 +44,7 @@ protected PersistenceBase(R repository) {
}

public R getRepository() {
return repository;
return repository;
}

public T findById(I id) throws OkrResponseStatusException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import ch.puzzle.okr.models.Team;
import ch.puzzle.okr.repository.TeamRepository;
import java.util.List;

import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Unit;
import ch.puzzle.okr.repository.UnitRepository;
import java.util.List;

import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import ch.puzzle.okr.models.User;
import ch.puzzle.okr.repository.UserRepository;
import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import java.util.List;
import java.util.Optional;

import ch.puzzle.okr.service.persistence.customCrud.SoftDelete;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
public abstract class DeleteMethod<T, I, R extends CrudRepository<T, I>> {
protected R repo;
public abstract void deleteById(I id);
public abstract Iterable<T> findAll();
public abstract Iterable<T> findAll();

public void setRepo(R repo){
this.repo = repo;
public void setRepo(R repo) {
this.repo = repo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import org.springframework.data.repository.CrudRepository;

import java.util.List;


public class HardDelete<T, I, R extends CrudRepository<T, I>> extends DeleteMethod<T, I, R>{
public class HardDelete<T, I, R extends CrudRepository<T, I>> extends DeleteMethod<T, I, R> {

@Override
public void deleteById(I id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import ch.puzzle.okr.models.Deletable;
import ch.puzzle.okr.repository.DeleteRepository;


public class SoftDelete <T extends Deletable, I, R extends DeleteRepository<T, I>> extends DeleteMethod<T, I, R> {
public class SoftDelete<T extends Deletable, I, R extends DeleteRepository<T, I>> extends DeleteMethod<T, I, R> {
@Override
public void deleteById(I id) {
repo.markAsDeleted(id);
this.repo.deleteById(id);
// repo.markAsDeleted(id);
}

@Override
public Iterable<T> findAll() {
public Iterable<T> findAll() {
return this.repo.findAllVisible();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.data.repository.CrudRepository;
import org.springframework.http.HttpStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ CREATE TABLE unit
unit_name TEXT NOT NULL,
created_by_id BIGINT,
is_default boolean NOT NULL,
is_deleted boolean default false NOT NULL,

PRIMARY KEY (id)
);

Expand All @@ -30,6 +32,7 @@ create table if not exists person
first_name varchar(50) not null,
last_name varchar(50) not null,
okr_champion BOOLEAN DEFAULT FALSE,
is_deleted boolean default false NOT NULL,
primary key (id),
constraint uk_person_email
unique (email)
Expand All @@ -53,6 +56,7 @@ create table if not exists team
id bigint not null,
version int not null,
name varchar(250) not null,
is_deleted boolean default false NOT NULL,
primary key (id)
);

Expand All @@ -71,6 +75,7 @@ create table if not exists objective
state text not null,
modified_by_id bigint,
created_on timestamp not null,
is_deleted boolean default false NOT NULL,
primary key (id),
constraint fk_objective_created_by_person
foreign key (created_by_id) references person,
Expand Down Expand Up @@ -107,6 +112,7 @@ create table if not exists key_result
commit_zone varchar(1024),
target_zone varchar(1024),
stretch_zone varchar(1024),
is_deleted boolean default false NOT NULL,
primary key (id),
constraint fk4ba6rgbr8mrkc8vvyqd5il4v9
foreign key (created_by_id) references person,
Expand Down Expand Up @@ -139,6 +145,7 @@ create table if not exists check_in
confidence integer,
check_in_type varchar(255),
zone text,
is_deleted boolean default false NOT NULL,
primary key (id),
constraint fk_check_in_key_result
foreign key (key_result_id) references key_result
Expand All @@ -165,6 +172,7 @@ create table action
action_point varchar(4096) not null,
priority integer not null,
checked boolean not null,
is_deleted boolean default false NOT NULL,
key_result_id bigint not null
constraint fk_completed_key_result
references key_result
Expand Down

0 comments on commit 2741735

Please sign in to comment.