Skip to content

Commit

Permalink
support including or excluding ivms
Browse files Browse the repository at this point in the history
  • Loading branch information
Hu committed Mar 28, 2024
1 parent 48099c0 commit 0522d46
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
import ix.core.search.text.IndexValueMaker;
import ix.core.search.text.IndexableValue;
import ix.ginas.models.v1.Substance;

import ix.utils.Util;
import gov.hhs.gsrs.applications.api.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand All @@ -33,9 +35,14 @@ public Class<Substance> getIndexedEntityClass() {
}

@Override
public boolean isExternal() {
return true;
public Set<String> getTags(){
return Util.toSet("external","applications");
}

@Override
public Set<String> getFieldNames(){
return Util.toSet("Application Status","Application Center","Application Type");
}

@Override
public void createIndexableValues(Substance substance, Consumer<IndexableValue> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import ix.core.search.text.IndexValueMaker;
import ix.core.search.text.IndexableValue;
import ix.ginas.models.v1.Substance;
import ix.utils.Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
@Slf4j
public class SubstanceClinicalEuropeTrialIndexValueMaker implements IndexValueMaker<Substance> {
Expand All @@ -28,9 +30,14 @@ public Class<Substance> getIndexedEntityClass() {
}

@Override
public boolean isExternal() {
return true;
public Set<String> getTags(){
return Util.toSet("external","clinicalEuropeTrial");
}

@Override
public Set<String> getFieldNames(){
return Util.toSet("Clinical Trial Europe Status","Clinical Trial Europe Count");
}

private static final long[] countBuckets = new long[]{1,2,3,4,5,10,15,20,25,30,40,50,75,100,250,500,1000,2000,3000,5000};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import ix.core.search.text.IndexValueMaker;
import ix.core.search.text.IndexableValue;
import ix.ginas.models.v1.Substance;
import ix.utils.Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.util.List;
import java.util.Set;
import java.util.function.Consumer;

@Slf4j
Expand All @@ -29,9 +31,14 @@ public Class<Substance> getIndexedEntityClass() {
}

@Override
public boolean isExternal() {
return true;
public Set<String> getTags(){
return Util.toSet("external","clinicalUSTrial");
}

@Override
public Set<String> getFieldNames(){
return Util.toSet("Clinical Trial US Status","Clinical Trial US Count");
}

private static final long[] countBuckets = new long[]{1,2,3,4,5,10,15,20,25,30,40,50,75,100,250,500,1000,2000,3000,5000};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ix.core.search.text.IndexValueMaker;
import ix.core.search.text.IndexableValue;
import ix.ginas.models.v1.Substance;

import ix.utils.Util;
import gov.hhs.gsrs.products.api.*;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -16,6 +16,7 @@

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand All @@ -33,9 +34,14 @@ public Class<Substance> getIndexedEntityClass() {
}

@Override
public boolean isExternal() {
return true;
public Set<String> getTags(){
return Util.toSet("external","product");
}

@Override
public Set<String> getFieldNames(){
return Util.toSet("Product Type","Product Ingredient Type","Product Dosage Form");
}

@Override
public void createIndexableValues(Substance substance, Consumer<IndexableValue> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ix.core.search.text.IndexableValue;
import ix.core.util.EntityUtils.EntityWrapper;
import ix.ginas.models.v1.Substance;
import ix.utils.Util;
import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand All @@ -36,15 +37,13 @@ public Class<Substance> getIndexedEntityClass() {

@Override
public Set<String> getFieldNames(){
return Stream.of("User List").collect(Collectors.toSet());
return Util.toSet("User List");
}

//Todo for Lihui: Remove after testing

@Override
public boolean isExternal() {
return true;
public Set<String> getTags(){
return Util.toSet("user_list");
}
//Todo for Lihui: Remove after testing

@Override
public void createIndexableValues(Substance substance, Consumer<IndexableValue> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void execute(Object id, SchedulerPlugin.TaskListener l) throws IOExceptio
// however, you could argue there SHOULD be a controller for them
if (seen.add(keyString)) {
//is this a good idea ?
ReindexEntityEvent event = new ReindexEntityEvent(reindexId, key,Optional.of(wrapped), false, false);
ReindexEntityEvent event = new ReindexEntityEvent(reindexId, key,Optional.of(wrapped), false);
eventConsumer.accept(event);
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void IndexEntity(TextIndexer indexer, Object object) {
EntityUtils.EntityWrapper<Substance> wrapper = EntityUtils.EntityWrapper.of(substance);
log.trace("create wrapper with kind {} - id field {}", wrapper.getKind(), wrapper.getEntityInfo().getIDFieldInfo().get());
UUID reindexUuid = UUID.randomUUID();
ReindexEntityEvent event = new ReindexEntityEvent(reindexUuid, wrapper.getKey(), Optional.of(wrapper),true);
ReindexEntityEvent event = new ReindexEntityEvent(reindexUuid, wrapper.getKey(), Optional.of(wrapper));
applicationEventPublisher.publishEvent(event);
log.info("submitted object for indexing");
}
Expand Down

0 comments on commit 0522d46

Please sign in to comment.