-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avniproject/avni-webapp#1304 - moved category and status to database
- Loading branch information
1 parent
27e62ff
commit 943f204
Showing
18 changed files
with
258 additions
and
76 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
avni-server-api/src/main/java/org/avni/server/dao/OrganisationCategoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.avni.server.dao; | ||
|
||
import org.avni.server.domain.organisation.OrganisationCategory; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
import org.springframework.data.rest.core.annotation.RestResource; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RepositoryRestResource(collectionResourceRel = "organisationCategory", path = "organisationCategory") | ||
public interface OrganisationCategoryRepository extends AvniJpaRepository<OrganisationCategory, Long>, CHSRepository<OrganisationCategory> { | ||
@RestResource(path = "findAllById", rel = "findAllById") | ||
List<OrganisationCategory> findByIdIn(@Param("ids") Long[] ids); | ||
} |
16 changes: 16 additions & 0 deletions
16
avni-server-api/src/main/java/org/avni/server/dao/OrganisationStatusRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.avni.server.dao; | ||
|
||
import org.avni.server.domain.organisation.OrganisationStatus; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
import org.springframework.data.rest.core.annotation.RestResource; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RepositoryRestResource(collectionResourceRel = "organisationStatus", path = "organisationStatus") | ||
public interface OrganisationStatusRepository extends AvniJpaRepository<OrganisationStatus, Long>, CHSRepository<OrganisationStatus> { | ||
@RestResource(path = "findAllById", rel = "findAllById") | ||
List<OrganisationStatus> findByIdIn(@Param("ids") Long[] ids); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
avni-server-api/src/main/java/org/avni/server/domain/organisation/OrganisationCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
package org.avni.server.domain.organisation; | ||
|
||
public enum OrganisationCategory { | ||
Production, UAT, Prototype, Temporary, Trial | ||
import org.avni.server.domain.CHSEntity; | ||
|
||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
public class OrganisationCategory extends CHSEntity { | ||
public static final String Production = "Production"; | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
17 changes: 15 additions & 2 deletions
17
avni-server-api/src/main/java/org/avni/server/domain/organisation/OrganisationStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
package org.avni.server.domain.organisation; | ||
|
||
public enum OrganisationStatus { | ||
Archived, Live | ||
import org.avni.server.domain.CHSEntity; | ||
|
||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
public class OrganisationStatus extends CHSEntity { | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
avni-server-api/src/main/resources/db/migration/V1_339_3__OrgCategoryTable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
create table if not exists organisation_category | ||
( | ||
id serial primary key, | ||
uuid varchar(255) not null, | ||
is_voided boolean NOT NULL DEFAULT FALSE, | ||
name varchar(255) not null, | ||
created_date_time timestamp(3) with time zone not null, | ||
last_modified_date_time timestamp(3) with time zone not null, | ||
created_by_id int not null, | ||
last_modified_by_id int not null | ||
); | ||
|
||
insert into organisation_category (uuid, name, created_date_time, last_modified_date_time, created_by_id, last_modified_by_id) | ||
values ('71e1bf3b-48fb-4d4f-90f3-71c39e15fbf0', 'Production', now(), now(), 1, 1), | ||
('95e89458-c152-4557-9929-85f1a275d6a3', 'UAT', now(), now(), 1, 1), | ||
('283af4ea-0024-4440-857f-c8a82328a61d', 'Prototype', now(), now(), 1, 1), | ||
('f0b0a48d-8d4b-4d13-8956-c1bc577b4971', 'Temporary', now(), now(), 1, 1), | ||
('470ecdab-f7be-4336-a52a-1fa280080168', 'Trial', now(), now(), 1, 1), | ||
('d75e667e-b7ea-40dd-8d85-1328943d3b65', 'Training', now(), now(), 1, 1), | ||
('27eeb3e7-2396-45ac-ba50-b1b50690bcfc', 'Dev', now(), now(), 1, 1); | ||
|
||
alter table organisation add column if not exists category_id int null; | ||
|
||
update organisation set category_id = organisation_category.id | ||
from organisation_category | ||
where organisation.category = organisation_category.name; | ||
|
||
alter table organisation drop column category; | ||
|
||
alter table organisation alter column category_id set not null; |
25 changes: 25 additions & 0 deletions
25
avni-server-api/src/main/resources/db/migration/V1_339_4__OrgStatusTable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
create table if not exists organisation_status | ||
( | ||
id serial primary key, | ||
uuid varchar(255) not null, | ||
is_voided boolean NOT NULL DEFAULT FALSE, | ||
name varchar(255) not null, | ||
created_date_time timestamp(3) with time zone not null, | ||
last_modified_date_time timestamp(3) with time zone not null, | ||
created_by_id int not null, | ||
last_modified_by_id int not null | ||
); | ||
|
||
insert into organisation_status (uuid, name, created_date_time, last_modified_date_time, created_by_id, last_modified_by_id) | ||
values ('338be2e2-d0e5-4186-b113-b8197ce879c5', 'Live', now(), now(), 1, 1), | ||
('7e609db3-ff79-472c-8f28-5b12933faaf5', 'Archived', now(), now(), 1, 1); | ||
|
||
alter table organisation add column if not exists status_id int null; | ||
|
||
update organisation set status_id = organisation_status.id | ||
from organisation_status | ||
where organisation.status = organisation_status.name; | ||
|
||
alter table organisation drop column status; | ||
|
||
alter table organisation alter column status_id set not null; |
2 changes: 2 additions & 0 deletions
2
avni-server-api/src/main/resources/db/migration/V1_339_5__AddVersions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table organisation_category add column if not exists version int not null default 1; | ||
alter table organisation_status add column if not exists version int not null default 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.