Skip to content

Commit

Permalink
Merge pull request #313 from ncats/removeEndpointsProduct
Browse files Browse the repository at this point in the history
Updated product api export removed productsall endpoint
  • Loading branch information
blueSwordfish authored Jan 10, 2024
2 parents cda287d + ab363e4 commit be9966f
Show file tree
Hide file tree
Showing 14 changed files with 709 additions and 431 deletions.
Binary file removed extraJars/products-api-3.1-SNAPSHOT.jar
Binary file not shown.
Binary file added extraJars/products-api-3.1.1-SNAPSHOT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gsrs-fda-substance-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<dependency>
<groupId>gov.nih.ncats</groupId>
<artifactId>products-api</artifactId>
<version>3.1-SNAPSHOT</version>
<version>3.1.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package fda.gsrs.substance.exporters;

import gsrs.api.AbstractLegacySearchGsrsEntityRestTemplate;
import gsrs.api.AbstractLegacySearchGsrsEntityRestTemplate.SearchRequest;
import gsrs.api.AbstractLegacySearchGsrsEntityRestTemplate.SearchResult;
import ix.ginas.exporters.DefaultParameters;
import ix.ginas.exporters.ExporterFactory;
import ix.ginas.exporters.OutputFormat;
import ix.ginas.exporters.Exporter;
import ix.ginas.models.v1.Substance;

import gov.hhs.gsrs.products.api.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
Expand All @@ -21,7 +17,7 @@
public class ExcelSubstanceRelatedProductsExporter implements Exporter<Substance> {
private OutputStream os;
private ProductsApi productsApi;
private ProductAllDTOExporter prodExporter;
private ProductDTOExporter prodExporter;

public ExcelSubstanceRelatedProductsExporter(OutputStream os, ProductsApi productsApi){
this.os = os; //probably use a buffer instead
Expand All @@ -31,17 +27,17 @@ public ExcelSubstanceRelatedProductsExporter(OutputStream os, ProductsApi produc
//Export Application Factory
OutputFormat format = new OutputFormat("xlsx", "SRS Product Data");
ExporterFactory.Parameters params = new ExportParameters(format, true);
ProductAllDTOExporterFactory factory = new ProductAllDTOExporterFactory();
ProductDTOExporterFactory factory = new ProductDTOExporterFactory();
this.prodExporter = factory.createNewExporter(os, params);

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

private void exportProduct(ProductMainAllDTO app){
private void exportProduct(ProductDTO prod){
try {
this.prodExporter.export(app);
this.prodExporter.export(prod);
}catch (Exception ex) {
ex.printStackTrace();
}
Expand All @@ -50,15 +46,15 @@ private void exportProduct(ProductMainAllDTO app){
@Override
public void export(Substance s) throws IOException{

SearchResult<ProductMainAllDTO> result = getAllProductsRelatedToSubstance(s);
List<ProductMainAllDTO> appList = result.getContent();
SearchResult<ProductDTO> result = getAllProductsRelatedToSubstance(s);
List<ProductDTO> prodList = result.getContent();

for (ProductMainAllDTO app: appList) {
for (ProductDTO app: prodList) {
exportProduct(app);
}
}

public SearchResult<ProductMainAllDTO> getAllProductsRelatedToSubstance(Substance s) {
public SearchResult<ProductDTO> getAllProductsRelatedToSubstance(Substance s) {
try {
SearchRequest searchRequest = SearchRequest.builder().q("entity_link_substances:\"" + s.uuid + "\"").top(1000000).simpleSearchOnly(true).build();
return productsApi.search(searchRequest);
Expand Down
Loading

0 comments on commit be9966f

Please sign in to comment.