Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new fields and facets #29

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
Expand Down Expand Up @@ -76,6 +78,32 @@ public void createIndexableValues(Product product, Consumer<IndexableValue> cons
} // for productLots
} // for productManufactureItems


// Facet: Application Type Number - Create a facet by combining Application Type and Application Number
for (ProductProvenance prodProv : product.productProvenances) {
if (prodProv != null) {
if ((prodProv.applicationType != null) && (prodProv.applicationNumber != null)) {
consumer.accept(IndexableValue.simpleFacetStringValue("Application Type Number", prodProv.applicationType + " " + prodProv.applicationNumber).suggestable().setSortable());
}
}

// The Product Code is stored as String in the database, and need this IVM so can
// sort by numeric values on the frontend.
for (ProductCode prodCode : prodProv.productCodes) {
if (prodCode != null) {
if (prodCode.productCode != null) {
// Remove hypen - from Product Code. Change 13334-155 to 13334155
String codeRemovedHypen = prodCode.productCode.replaceAll("-", "");
// Check if code has numeric values or not. If has number values, create IVM
if (StringUtils.isNumeric(codeRemovedHypen) == true) {
Long codeLong = Long.parseLong(codeRemovedHypen);
consumer.accept(IndexableValue.simpleLongValue("Product Code", codeLong).suggestable().setSortable());
}
}
}
}
} // for ProductProvenance

} catch (Exception e) {
log.warn("Error indexing ProductSubstanceIndexValueMaker:" + product.fetchKey(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public class Product extends ProductCommonData {
@Column(name="MANUFACTURER_CODE_TYPE")
public String manufacturerCodeType;

@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="MM/dd/yyyy")
@Column(name="EFFECTIVE_DATE")
public Date effectiveDate;

@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="MM/dd/yyyy")
@Column(name="END_DATE")
public Date endDate;

@JsonIgnore
@Indexable(facet=true, name="Deprecated")
public String getDeprecated(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public class ProductIngredient extends ProductCommonData {
@Column(name = "INGREDIENT_LOCATION")
public String ingredientLocation;

@Column(name = "INGRED_LOCATION_TEXT")
public String ingredientLocationText;

@Column(name = "CONFIDENTIALITY_CODE")
public String confidentialityCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,18 @@ public Optional<Substance> getEntityManagerSubstanceBySubstanceKeyResolver(Strin
Optional<Substance> substance = null;

try {
// CALL to Substance Module, EntityManagerSubstanceKeyResolver
// Get ENTITY MANAGER Substance Key resolver by Substance Key and substanceKeyType (UUID, APPROVAL_ID, BDNUM)
substance = entityManagerSubstanceKeyResolver.resolveEMSubstance(substanceKey, substanceKeyType);

} catch (Exception e) {
e.printStackTrace();
}

if (substance == null || !substance.isPresent()) {
return null;
}

if (substance.get().uuid != null) {
return substance;
} else {
Expand All @@ -122,6 +127,7 @@ public Optional<SubstanceDTO> getSubstanceBySubstanceKeyResolver(String substanc
try {
// Substance API resolver by Substance Key and substanceKeyType (UUID, APPROVAL_ID, BDNUM)
substanceDTO = substanceRestApi.resolveSubstance(substanceKey, substanceKeyType);

} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -167,7 +173,7 @@ public Optional<List<NameDTO>> getNamesOfSubstance(String anyKindOfSubstanceId)
return null;
}

// Substance API, get the Names for the Substance
// Substance API, get the Codes for the Substance
public Optional<List<CodeDTO>> getCodesOfSubstance(String anyKindOfSubstanceId) {
if (anyKindOfSubstanceId == null) {
return null;
Expand Down
Loading