-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFPREV-145 - Added bc parks code tables (#367)
- Loading branch information
1 parent
dd77c7c
commit f08bee8
Showing
12 changed files
with
771 additions
and
50 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
...rc/main/java/ca/bc/gov/nrs/wfprev/data/assemblers/BCParksRegionCodeResourceAssembler.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,40 @@ | ||
package ca.bc.gov.nrs.wfprev.data.assemblers; | ||
|
||
import ca.bc.gov.nrs.wfprev.common.enums.CodeTables; | ||
import ca.bc.gov.nrs.wfprev.controllers.CodesController; | ||
import ca.bc.gov.nrs.wfprev.data.entities.BCParksOrgUnitEntity; | ||
import ca.bc.gov.nrs.wfprev.data.models.BCParksRegionCodeModel; | ||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; | ||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; | ||
|
||
@Component | ||
public class BCParksRegionCodeResourceAssembler extends RepresentationModelAssemblerSupport<BCParksOrgUnitEntity, BCParksRegionCodeModel> { | ||
|
||
public BCParksRegionCodeResourceAssembler() { | ||
super(CodesController.class, BCParksRegionCodeModel.class); | ||
} | ||
|
||
|
||
@Override | ||
public BCParksRegionCodeModel toModel(BCParksOrgUnitEntity entity) { | ||
BCParksRegionCodeModel resource = instantiateModel(entity); | ||
resource.add(linkTo( | ||
methodOn(CodesController.class) | ||
.getCodeById(CodeTables.BC_PARKS_REGION_CODE, entity.getOrgUnitIdentifier().toString())) | ||
.withSelfRel()); | ||
resource.setOrgUnitId(entity.getOrgUnitIdentifier()); | ||
resource.setEffectiveDate(entity.getEffectiveDate()); | ||
resource.setExpiryDate(entity.getExpiryDate()); | ||
resource.setBcParksOrgUnitTypeCode(entity.getBcParksOrgUnitTypeCode()); | ||
if (entity.getParentOrgUnitIdentifier() != null) { | ||
resource.setParentOrgUnitId(entity.getParentOrgUnitIdentifier().toString()); | ||
} | ||
resource.setOrgUnitName(entity.getOrgUnitName()); | ||
resource.setIntegerAlias(entity.getIntegerAlias()); | ||
resource.setCharacterAlias(entity.getCharacterAlias()); | ||
return resource; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...c/main/java/ca/bc/gov/nrs/wfprev/data/assemblers/BCParksSectionCodeResourceAssembler.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,39 @@ | ||
package ca.bc.gov.nrs.wfprev.data.assemblers; | ||
|
||
import ca.bc.gov.nrs.wfprev.common.enums.CodeTables; | ||
import ca.bc.gov.nrs.wfprev.controllers.CodesController; | ||
import ca.bc.gov.nrs.wfprev.data.entities.BCParksOrgUnitEntity; | ||
import ca.bc.gov.nrs.wfprev.data.models.BCParksRegionCodeModel; | ||
import ca.bc.gov.nrs.wfprev.data.models.BCParksSectionCodeModel; | ||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; | ||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; | ||
|
||
@Component | ||
public class BCParksSectionCodeResourceAssembler extends RepresentationModelAssemblerSupport<BCParksOrgUnitEntity, BCParksSectionCodeModel> { | ||
|
||
public BCParksSectionCodeResourceAssembler() { | ||
super(CodesController.class, BCParksSectionCodeModel.class); | ||
} | ||
@Override | ||
public BCParksSectionCodeModel toModel(BCParksOrgUnitEntity entity) { | ||
BCParksSectionCodeModel resource = instantiateModel(entity); | ||
resource.add(linkTo( | ||
methodOn(CodesController.class) | ||
.getCodeById(CodeTables.BC_PARKS_SECTION_CODE, entity.getOrgUnitIdentifier().toString())) | ||
.withSelfRel()); | ||
resource.setOrgUnitId(entity.getOrgUnitIdentifier()); | ||
resource.setEffectiveDate(entity.getEffectiveDate()); | ||
resource.setExpiryDate(entity.getExpiryDate()); | ||
resource.setBcParksOrgUnitTypeCode(entity.getBcParksOrgUnitTypeCode()); | ||
if (entity.getParentOrgUnitIdentifier() != null) { | ||
resource.setParentOrgUnitId(entity.getParentOrgUnitIdentifier().toString()); | ||
} | ||
resource.setOrgUnitName(entity.getOrgUnitName()); | ||
resource.setIntegerAlias(entity.getIntegerAlias()); | ||
resource.setCharacterAlias(entity.getCharacterAlias()); | ||
return resource; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
server/wfprev-api/src/main/java/ca/bc/gov/nrs/wfprev/data/entities/BCParksOrgUnitEntity.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,84 @@ | ||
package ca.bc.gov.nrs.wfprev.data.entities; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.CreatedBy; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedBy; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Table(name = "bc_parks_org_unit") | ||
@JsonIgnoreProperties(ignoreUnknown = false) | ||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BCParksOrgUnitEntity implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Id | ||
@Column(name = "org_unit_identifier") | ||
@NotNull | ||
private Integer orgUnitIdentifier; | ||
|
||
@NotNull | ||
@Column(name = "effective_date") | ||
private Date effectiveDate; | ||
|
||
@NotNull | ||
@Column(name = "expiry_date") | ||
private Date expiryDate; | ||
|
||
@NotNull | ||
@Column(name = "bc_parks_org_unit_type_code") | ||
private String bcParksOrgUnitTypeCode; | ||
|
||
@Column(name = "parent_org_unit_identifier") | ||
private Integer parentOrgUnitIdentifier; | ||
|
||
@NotNull | ||
@Column(name = "org_unit_name") | ||
private String orgUnitName; | ||
|
||
@Column(name = "integer_alias") | ||
private Integer integerAlias; | ||
|
||
@Column(name = "character_alias") | ||
private String characterAlias; | ||
|
||
@CreatedBy | ||
@NotNull | ||
@Column(name = "create_user", length = 64) | ||
private String createUser; | ||
|
||
@CreatedDate | ||
@NotNull | ||
@Column(name = "create_date") | ||
private Date createDate; | ||
|
||
@LastModifiedBy | ||
@NotNull | ||
@Column(name = "update_user", length = 64) | ||
private String updateUser; | ||
|
||
@LastModifiedDate | ||
@NotNull | ||
@Column(name = "update_date") | ||
private Date updateDate; | ||
|
||
|
||
} |
32 changes: 32 additions & 0 deletions
32
server/wfprev-api/src/main/java/ca/bc/gov/nrs/wfprev/data/models/BCParksRegionCodeModel.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,32 @@ | ||
package ca.bc.gov.nrs.wfprev.data.models; | ||
|
||
import ca.bc.gov.nrs.wfprev.common.entities.CommonModel; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonRootName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.hateoas.server.core.Relation; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@JsonRootName(value = "bcParksRegionCode") | ||
@Relation(collectionRelation = "bcParksRegionCode") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BCParksRegionCodeModel extends CommonModel<BCParksRegionCodeModel> { | ||
private Integer orgUnitId; | ||
private Date effectiveDate; | ||
private Date expiryDate; | ||
private String bcParksOrgUnitTypeCode; | ||
private String parentOrgUnitId; | ||
private String orgUnitName; | ||
private Integer integerAlias; | ||
private String characterAlias; | ||
} |
32 changes: 32 additions & 0 deletions
32
...er/wfprev-api/src/main/java/ca/bc/gov/nrs/wfprev/data/models/BCParksSectionCodeModel.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,32 @@ | ||
package ca.bc.gov.nrs.wfprev.data.models; | ||
|
||
import ca.bc.gov.nrs.wfprev.common.entities.CommonModel; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonRootName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.hateoas.server.core.Relation; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@JsonRootName(value = "bcParksSectionCode") | ||
@Relation(collectionRelation = "bcParksSectionCode") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BCParksSectionCodeModel extends CommonModel<BCParksSectionCodeModel> { | ||
private Integer orgUnitId; | ||
private Date effectiveDate; | ||
private Date expiryDate; | ||
private String bcParksOrgUnitTypeCode; | ||
private String parentOrgUnitId; | ||
private String orgUnitName; | ||
private Integer integerAlias; | ||
private String characterAlias; | ||
} |
13 changes: 13 additions & 0 deletions
13
...pi/src/main/java/ca/bc/gov/nrs/wfprev/data/repositories/BCParksOrgUnitCodeRepository.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,13 @@ | ||
package ca.bc.gov.nrs.wfprev.data.repositories; | ||
|
||
import ca.bc.gov.nrs.wfprev.common.repository.CommonRepository; | ||
import ca.bc.gov.nrs.wfprev.data.entities.BCParksOrgUnitEntity; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
import java.util.List; | ||
|
||
@RepositoryRestResource(exported = false) | ||
public interface BCParksOrgUnitCodeRepository extends CommonRepository<BCParksOrgUnitEntity, Integer>{ | ||
List<BCParksOrgUnitEntity> findByBcParksOrgUnitTypeCode(String bcParksOrgUnitTypeCode); | ||
|
||
} |
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.