Skip to content

Commit

Permalink
feat/backend: Create initial ER model for CLIENT (with new goal). Part
Browse files Browse the repository at this point in the history
…#2. Refs: #61
  • Loading branch information
mamartinezmejia committed Nov 10, 2022
1 parent 38b55d8 commit 1963cd9
Show file tree
Hide file tree
Showing 16 changed files with 435 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
basePackages = "ca.bc.gov.app.m.postgres")
public class PostgresPersistenceConfiguration {

public final static String POSTGRES_ATTRIBUTE_SCHEMA_QUALIFIER = "PUBLIC.";
public final static String POSTGRES_ATTRIBUTE_SCHEMA = "PUBLIC";
public final static String POSTGRES_ATTRIBUTE_SCHEMA_QUALIFIER = "nrfc.";
public final static String POSTGRES_ATTRIBUTE_SCHEMA = "nrfc";
public static final String POSTGRES_API_TAG = "Client";

@Bean(name = "postgresDataSource")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package ca.bc.gov.app.m.om.controller;

import java.util.List;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import ca.bc.gov.app.m.om.service.OpenMapsService;
import ca.bc.gov.app.m.om.vo.FirstNationBandVidationVO;
import io.swagger.annotations.Api;

@Api(tags = "Open Maps")
Expand All @@ -24,10 +20,10 @@ public class OpenMapsController {
@Inject
private OpenMapsService dataValidationService;

@GetMapping("/validateFirstNationBand")
/*@GetMapping("/validateFirstNationBand")
public List<FirstNationBandVidationVO> validateFirstNationBand() {
List<FirstNationBandVidationVO> validationResult = dataValidationService.validateFirstNationBand();
return validationResult;
}
}*/

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package ca.bc.gov.app.m.om.service;

import java.util.List;

import ca.bc.gov.app.m.om.vo.FirstNationBandVidationVO;

public interface OpenMapsService {

String BEAN_NAME = "openMapsService";

List<FirstNationBandVidationVO> validateFirstNationBand();
//List<FirstNationBandVidationVO> validateFirstNationBand();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;

import ca.bc.gov.app.core.util.CoreUtil;
import ca.bc.gov.app.m.om.service.OpenMapsService;
import ca.bc.gov.app.m.om.vo.FirstNationBandVidationVO;
import ca.bc.gov.app.m.om.vo.OpenMapsResponseVO;
import ca.bc.gov.app.m.oracle.legacyclient.entity.ClientLocationEntity;
import ca.bc.gov.app.m.oracle.legacyclient.entity.ForestClientEntity;
import ca.bc.gov.app.m.oracle.legacyclient.repository.ClientLocationRepository;
import ca.bc.gov.app.m.oracle.legacyclient.repository.ForestClientRepository;

Expand Down Expand Up @@ -64,7 +58,7 @@ private OpenMapsResponseVO checkSourceFirstNationId(String firstNationId) {

}

@Override
/*@Override
public List<FirstNationBandVidationVO> validateFirstNationBand() {
List<ForestClientEntity> clients = forestClientRepository.findAllFirstNationBandClients();
Expand Down Expand Up @@ -134,6 +128,6 @@ public List<FirstNationBandVidationVO> validateFirstNationBand() {
return firstNationBands;
}
}*/

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package ca.bc.gov.app.m.oracle.legacyclient.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import ca.bc.gov.app.core.repository.CoreRepository;
import ca.bc.gov.app.m.oracle.legacyclient.entity.ForestClientEntity;
import ca.bc.gov.app.m.postgres.client.entity.ClientStatusCodeEntity;
import ca.bc.gov.app.m.postgres.client.entity.ClientTypeCodeEntity;

@Repository
public interface ForestClientRepository extends CoreRepository<ForestClientEntity> {

@Query("select x from ForestClientEntity x " +
"where x.clientTypeCode = '" + ClientTypeCodeEntity.FIRST_NATION_BAND + "' "+
"and x.clientStatusCode = '" + ClientStatusCodeEntity.ACTIVE + "'")
List<ForestClientEntity> findAllFirstNationBandClients();
//Commented out as it is not needed for now
/*
* @Query("select x from ForestClientEntity x " + "where x.clientTypeCode = '" +
* ClientTypeCodeEntity.FIRST_NATION_BAND + "' "+ "and x.clientStatusCode = '" +
* ClientStatusCodeEntity.ACTIVE + "'") List<ForestClientEntity>
* findAllFirstNationBandClients();
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.web.bind.annotation.RestController;

import ca.bc.gov.app.core.configuration.PostgresPersistenceConfiguration;
import ca.bc.gov.app.m.postgres.client.entity.ClientStatusCodeEntity;
import ca.bc.gov.app.m.postgres.client.entity.ClientTypeCodeEntity;
import ca.bc.gov.app.m.postgres.client.service.ClientService;
import io.swagger.annotations.Api;

Expand All @@ -27,9 +27,9 @@ public class ClientController {
@Inject
private ClientService clientService;

@RequestMapping(value = "/findAllClientStatusCodes", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public List<ClientStatusCodeEntity> findAllClientStatusCodes() {
return clientService.findAllClientStatusCodes();
@RequestMapping(value = "/findActiveClientTypeCodes", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public List<ClientTypeCodeEntity> findActiveClientTypeCodes() {
return clientService.findActiveClientTypeCodes();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package ca.bc.gov.app.m.postgres.client.entity;

import java.util.Date;
import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import ca.bc.gov.app.core.configuration.PostgresPersistenceConfiguration;
import ca.bc.gov.app.core.entity.AbstractEntity;
import ca.bc.gov.app.core.misc.scope.ScopeConstant;

@Entity
@Table(name = "SUBMISSION_DETAIL", schema = PostgresPersistenceConfiguration.POSTGRES_ATTRIBUTE_SCHEMA)
@Component(SubmissionDetailEntity.BEAN_NAME)
@Scope(ScopeConstant.PROTOTYPE)
public class SubmissionDetailEntity implements AbstractEntity {

private static final long serialVersionUID = -8966248654104607818L;

public static final String BEAN_NAME = "submissionEntity";

@Id
@GeneratedValue(generator = "SEQ_SUBMISSION_DETAIL")
@SequenceGenerator(name = "SEQ_SUBMISSION_DETAIL",
sequenceName = PostgresPersistenceConfiguration.POSTGRES_ATTRIBUTE_SCHEMA_QUALIFIER + "SUBMISSION_DETAIL_ID_SEQ",
allocationSize = 1)
@Column(name = "SUBMISSION_DETAIL_ID", nullable = false, precision = 10, scale = 0)
private Long submissionDetailId;

@OneToOne
@JoinColumn(name = "SUBMISSION_ID")
private SubmissionEntity submissionEntity;

@Column(name = "INCORPORATION_NUMBER")
private String incorporationNumber;

@Column(name = "ORGANIZATION_NAME")
private Date organizationName;

@Column(name = "FIRST_NAME")
private String firstName;

@Column(name = "MIDDLE_NAME")
private String middleName;

@Column(name = "LAST_NAME")
private String lastName;

@ManyToOne
@JoinColumn(name = "CLIENT_TYPE_CODE")
private ClientTypeCodeEntity clientTypeCodeEntity;

@Column(name = "DATE_OF_BIRTH")
private Date dateOfBirth;

@Column(name = "CLIENT_COMMENT")
private String clientComment;

public Long getSubmissionDetailId() {
return submissionDetailId;
}

public void setSubmissionDetailId(Long submissionDetailId) {
this.submissionDetailId = submissionDetailId;
}

public SubmissionEntity getSubmissionEntity() {
return submissionEntity;
}

public void setSubmissionEntity(SubmissionEntity submissionEntity) {
this.submissionEntity = submissionEntity;
}

public String getIncorporationNumber() {
return incorporationNumber;
}

public void setIncorporationNumber(String incorporationNumber) {
this.incorporationNumber = incorporationNumber;
}

public Date getOrganizationName() {
return organizationName;
}

public void setOrganizationName(Date organizationName) {
this.organizationName = organizationName;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getMiddleName() {
return middleName;
}

public void setMiddleName(String middleName) {
this.middleName = middleName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public ClientTypeCodeEntity getClientTypeCodeEntity() {
return clientTypeCodeEntity;
}

public void setClientTypeCodeEntity(ClientTypeCodeEntity clientTypeCodeEntity) {
this.clientTypeCodeEntity = clientTypeCodeEntity;
}

public Date getDateOfBirth() {
return dateOfBirth;
}

public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}

public String getClientComment() {
return clientComment;
}

public void setClientComment(String clientComment) {
this.clientComment = clientComment;
}

@Override
public int hashCode() {
return Objects.hash(submissionDetailId);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SubmissionDetailEntity other = (SubmissionDetailEntity) obj;
return Objects.equals(submissionDetailId, other.submissionDetailId);
}

}
Loading

0 comments on commit 1963cd9

Please sign in to comment.