Skip to content

Commit

Permalink
added fixed ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Newatia authored and Newatia committed Nov 24, 2021
1 parent 067974c commit 9f8a9df
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import javax.persistence.EntityManager;

@ExposesResourceFor(AdverseEventCvm.class)
@GsrsRestApiController(context = AdverseEventCvmEntityService.CONTEXT, idHelper = IdHelpers.NUMBER)
public class AdverseEventCvmController extends EtagLegacySearchEntityController<AdverseEventCvmController, AdverseEventCvm, Long> {
@GsrsRestApiController(context = AdverseEventCvmEntityService.CONTEXT, idHelper = IdHelpers.STRING_NO_WHITESPACE)
public class AdverseEventCvmController extends EtagLegacySearchEntityController<AdverseEventCvmController, AdverseEventCvm, String> {

@Autowired
private ETagRepository eTagRepository;
Expand Down Expand Up @@ -89,7 +89,7 @@ public class AdverseEventCvmController extends EtagLegacySearchEntityController<


@Override
public GsrsEntityService<AdverseEventCvm, Long> getEntityService() {
public GsrsEntityService<AdverseEventCvm, String> getEntityService() {
return adverseEventEntityService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
public class AdverseEventCvm extends AbstractGsrsEntity implements SubstanceAdverseEvent {

@Id
@Column(name="ID")
public Long id;
@Column(name = "AE_ID")
public String id;

@Column(name = "ID")
public Long id2;

@Column(name="SUBSTANCE_ID")
public String substanceId;
Expand Down Expand Up @@ -77,7 +80,7 @@ public String getDeprecated(){
return "Not Deprecated";
}

public Long getId() {
public String getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.hhs.gsrs.adverseevents.adverseeventcvm.repository;

import gov.hhs.gsrs.adverseevents.adverseeventcvm.models.*;
import gov.hhs.gsrs.adverseevents.adverseeventcvm.models.AdverseEventCvm;
import gov.hhs.gsrs.adverseevents.adverseeventcvm.models.AdverseEventCvm;

import gsrs.repository.GsrsRepository;
import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -9,7 +10,7 @@
import java.util.Optional;

@Service
public interface AdverseEventCvmRepository extends GsrsRepository<AdverseEventCvm, Long> {
public interface AdverseEventCvmRepository extends GsrsRepository<AdverseEventCvm, String> {

Optional<AdverseEventCvm> findById(Long id);
Optional<AdverseEventCvm> findById(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Optional;

@Service
public class AdverseEventCvmEntityService extends AbstractGsrsEntityService<AdverseEventCvm, Long> {
public class AdverseEventCvmEntityService extends AbstractGsrsEntityService<AdverseEventCvm, String> {
public static final String CONTEXT = "adverseeventcvm";

public AdverseEventCvmEntityService() {
Expand All @@ -54,8 +54,8 @@ public Class<AdverseEventCvm> getEntityClass() {
}

@Override
public Long parseIdFromString(String idAsString) {
return Long.parseLong(idAsString);
public String parseIdFromString(String idAsString) {
return idAsString;
}

@Override
Expand All @@ -80,12 +80,12 @@ protected AdverseEventCvm create(AdverseEventCvm adverse) {

@Override
@Transactional
protected AdverseEventCvm update(AdverseEventCvm product) {
return repository.saveAndFlush(product);
protected AdverseEventCvm update(AdverseEventCvm adverse) {
return repository.saveAndFlush(adverse);
}

@Override
public void delete(Long id) {
public void delete(String id) {
repository.deleteById(id);
}

Expand All @@ -100,7 +100,7 @@ protected AbstractEntityCreatedEvent<AdverseEventCvm> newCreationEvent(AdverseEv
}

@Override
public Long getIdFrom(AdverseEventCvm entity) {
public String getIdFrom(AdverseEventCvm entity) {
return entity.id;
}

Expand Down Expand Up @@ -136,8 +136,8 @@ protected List<AdverseEventCvm> fromUpdatedJsonList(JsonNode list) throws IOExce
}

@Override
protected JsonNode toJson(AdverseEventCvm product) throws IOException {
return objectMapper.valueToTree(product);
protected JsonNode toJson(AdverseEventCvm adverse) throws IOException {
return objectMapper.valueToTree(adverse);
}

@Override
Expand All @@ -146,7 +146,7 @@ public long count() {
}

@Override
public Optional<AdverseEventCvm> get(Long id) {
public Optional<AdverseEventCvm> get(String id) {
return repository.findById(id);
}

Expand All @@ -155,11 +155,11 @@ public Optional<AdverseEventCvm> flexLookup(String someKindOfId) {
if (someKindOfId == null){
return Optional.empty();
}
return repository.findById(Long.parseLong(someKindOfId));
return repository.findById(someKindOfId);
}

@Override
protected Optional<Long> flexLookupIdOnly(String someKindOfId) {
protected Optional<String> flexLookupIdOnly(String someKindOfId) {
//easiest way to avoid deduping data is to just do a full flex lookup and then return id
Optional<AdverseEventCvm> found = flexLookup(someKindOfId);
if(found.isPresent()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import javax.persistence.EntityManager;

@ExposesResourceFor(AdverseEventDme.class)
@GsrsRestApiController(context = AdverseEventDmeEntityService.CONTEXT, idHelper = IdHelpers.NUMBER)
public class AdverseEventDmeController extends EtagLegacySearchEntityController<AdverseEventDmeController, AdverseEventDme, Long> {
@GsrsRestApiController(context = AdverseEventDmeEntityService.CONTEXT, idHelper = IdHelpers.STRING_NO_WHITESPACE)
public class AdverseEventDmeController extends EtagLegacySearchEntityController<AdverseEventDmeController, AdverseEventDme, String> {


@Autowired
Expand Down Expand Up @@ -90,7 +90,7 @@ public class AdverseEventDmeController extends EtagLegacySearchEntityController<


@Override
public GsrsEntityService<AdverseEventDme, Long> getEntityService() {
public GsrsEntityService<AdverseEventDme, String> getEntityService() {
return adverseEventEntityService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
public class AdverseEventDme extends AbstractGsrsEntity implements SubstanceAdverseEvent {

@Id
@Column(name="ID")
public Long id;
@Column(name = "AE_ID")
public String id;

@Column(name = "ID")
public Long id2;

@Column(name="SUBSTANCE_ID")
public String substanceId;
Expand Down Expand Up @@ -83,7 +86,7 @@ public String getDeprecated(){
return "Not Deprecated";
}

public Long getId() {
public String getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Optional;

@Service
public interface AdverseEventDmeRepository extends GsrsRepository<AdverseEventDme, Long> {
public interface AdverseEventDmeRepository extends GsrsRepository<AdverseEventDme, String> {

Optional<AdverseEventDme> findById(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Optional;

@Service
public class AdverseEventDmeEntityService extends AbstractGsrsEntityService<AdverseEventDme, Long> {
public class AdverseEventDmeEntityService extends AbstractGsrsEntityService<AdverseEventDme, String> {
public static final String CONTEXT = "adverseeventdme";

public AdverseEventDmeEntityService() {
Expand All @@ -60,8 +60,8 @@ public Class<AdverseEventDme> getEntityClass() {
}

@Override
public Long parseIdFromString(String idAsString) {
return Long.parseLong(idAsString);
public String parseIdFromString(String idAsString) {
return idAsString;
}

@Override
Expand Down Expand Up @@ -91,7 +91,7 @@ protected AdverseEventDme update(AdverseEventDme adverse) {
}

@Override
public void delete(Long id) {
public void delete(String id) {
repository.deleteById(id);
}

Expand All @@ -106,7 +106,7 @@ protected AbstractEntityCreatedEvent<AdverseEventDme> newCreationEvent(AdverseEv
}

@Override
public Long getIdFrom(AdverseEventDme entity) {
public String getIdFrom(AdverseEventDme entity) {
return entity.id;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public long count() {
}

@Override
public Optional<AdverseEventDme> get(Long id) {
public Optional<AdverseEventDme> get(String id) {
return repository.findById(id);
}

Expand All @@ -161,11 +161,11 @@ public Optional<AdverseEventDme> flexLookup(String someKindOfId) {
if (someKindOfId == null){
return Optional.empty();
}
return repository.findById(Long.parseLong(someKindOfId));
return repository.findById(someKindOfId);
}

@Override
protected Optional<Long> flexLookupIdOnly(String someKindOfId) {
protected Optional<String> flexLookupIdOnly(String someKindOfId) {
//easiest way to avoid deduping data is to just do a full flex lookup and then return id
Optional<AdverseEventDme> found = flexLookup(someKindOfId);
if(found.isPresent()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import javax.persistence.EntityManager;

@ExposesResourceFor(AdverseEventPt.class)
@GsrsRestApiController(context = AdverseEventPtEntityService.CONTEXT, idHelper = IdHelpers.NUMBER)
public class AdverseEventPtController extends EtagLegacySearchEntityController<AdverseEventPtController, AdverseEventPt, Long> {
@GsrsRestApiController(context = AdverseEventPtEntityService.CONTEXT, idHelper = IdHelpers.STRING_NO_WHITESPACE)
public class AdverseEventPtController extends EtagLegacySearchEntityController<AdverseEventPtController, AdverseEventPt, String> {

@Autowired
private ETagRepository eTagRepository;
Expand Down Expand Up @@ -89,7 +89,7 @@ public class AdverseEventPtController extends EtagLegacySearchEntityController<A


@Override
public GsrsEntityService<AdverseEventPt, Long> getEntityService() {
public GsrsEntityService<AdverseEventPt, String> getEntityService() {
return adverseEventEntityService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void close() throws IOException {
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.SUBSTANCE_NAME, SingleColumnValueRecipe.create(PtDefaultColumns.SUBSTANCE_NAME, (s, cell) -> cell.writeString(s.name)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.APPROVAL_ID, SingleColumnValueRecipe.create(PtDefaultColumns.APPROVAL_ID, (s, cell) -> cell.writeString(s.unii)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.SUBSTANCE_KEY, SingleColumnValueRecipe.create(PtDefaultColumns.SUBSTANCE_KEY, (s, cell) -> cell.writeString(s.substanceKey)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.PT_TERM, SingleColumnValueRecipe.create(PtDefaultColumns.PT_TERM, (s, cell) -> cell.writeString(s.adverseEvent)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.PT_TERM, SingleColumnValueRecipe.create(PtDefaultColumns.PT_TERM, (s, cell) -> cell.writeString(s.ptTerm)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.PRIM_SOC, SingleColumnValueRecipe.create(PtDefaultColumns.PRIM_SOC, (s, cell) -> cell.writeString(s.primSoc)));
DEFAULT_RECIPE_MAP.put(PtDefaultColumns.CASE_COUNT, SingleColumnValueRecipe.create(PtDefaultColumns.CASE_COUNT, (s, cell) -> {
String count = (s.caseCount != null) ? Integer.toString(s.caseCount) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
public class AdverseEventPt extends AbstractGsrsEntity implements SubstanceAdverseEvent {

@Id
@Column(name = "AE_ID")
public String id;

@Column(name = "ID")
public Long id;
public Long id2;

@Column(name="SUBSTANCE_ID")
public String substanceId;
Expand All @@ -62,9 +65,9 @@ public class AdverseEventPt extends AbstractGsrsEntity implements SubstanceAdver
@Column(name = "NAME")
public String name;

@Indexable(suggest = true, facet = true, name = "Adverse Event")
@Indexable(suggest = true, facet = true, name = "PT Term")
@Column(name = "PT_TERM")
public String adverseEvent;
public String ptTerm;

@Indexable(suggest = true, facet = true, name = "Prim SOC")
@Column(name = "PRIM_SOC")
Expand All @@ -91,7 +94,7 @@ public class AdverseEventPt extends AbstractGsrsEntity implements SubstanceAdver
@Column(name = "PRR")
public Double prr;

public Long getId() {
public String getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.Optional;

@Service
public interface AdverseEventPtRepository extends GsrsRepository<AdverseEventPt, Long> {
public interface AdverseEventPtRepository extends GsrsRepository<AdverseEventPt, String> {

Optional<AdverseEventPt> findById(Long id);
Optional<AdverseEventPt> findById(String id);

@Query("SELECT a FROM AdverseEventFAERSDashboard a where lower(a.nameTruncateGP) = lower(?1)")
AdverseEventFAERSDashboard findFaersDashboardRecordByName(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Optional;

@Service
public class AdverseEventPtEntityService extends AbstractGsrsEntityService<AdverseEventPt, Long> {
public class AdverseEventPtEntityService extends AbstractGsrsEntityService<AdverseEventPt, String> {
public static final String CONTEXT = "adverseeventpt";

public AdverseEventPtEntityService() {
Expand All @@ -54,8 +54,8 @@ public Class<AdverseEventPt> getEntityClass() {
}

@Override
public Long parseIdFromString(String idAsString) {
return Long.parseLong(idAsString);
public String parseIdFromString(String idAsString) {
return idAsString;
}

@Override
Expand Down Expand Up @@ -85,7 +85,7 @@ protected AdverseEventPt update(AdverseEventPt adverse) {
}

@Override
public void delete(Long id) {
public void delete(String id) {
repository.deleteById(id);
}

Expand All @@ -100,7 +100,7 @@ protected AbstractEntityCreatedEvent<AdverseEventPt> newCreationEvent(AdverseEve
}

@Override
public Long getIdFrom(AdverseEventPt entity) {
public String getIdFrom(AdverseEventPt entity) {
return entity.id;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public long count() {
}

@Override
public Optional<AdverseEventPt> get(Long id) {
public Optional<AdverseEventPt> get(String id) {
return repository.findById(id);
}

Expand All @@ -155,11 +155,11 @@ public Optional<AdverseEventPt> flexLookup(String someKindOfId) {
if (someKindOfId == null){
return Optional.empty();
}
return repository.findById(Long.parseLong(someKindOfId));
return repository.findById(someKindOfId);
}

@Override
protected Optional<Long> flexLookupIdOnly(String someKindOfId) {
protected Optional<String> flexLookupIdOnly(String someKindOfId) {
//easiest way to avoid deduping data is to just do a full flex lookup and then return id
Optional<AdverseEventPt> found = flexLookup(someKindOfId);
if(found.isPresent()){
Expand Down

0 comments on commit 9f8a9df

Please sign in to comment.