-
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.
- Loading branch information
1 parent
acf7ce0
commit 2896e73
Showing
8 changed files
with
279 additions
and
5 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
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
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; | ||
} | ||
} |
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; | ||
} |
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.