Skip to content

Commit

Permalink
Merge pull request #303 from ncats/syncTool
Browse files Browse the repository at this point in the history
WIP: please do not merge. Sync tool
  • Loading branch information
narchana authored Apr 23, 2024
2 parents 1c919bf + d9ab1bf commit ce9ff52
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 16 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 @@ -31,6 +33,16 @@ public class SubstanceApplicationIndexValueMaker implements IndexValueMaker<Subs
public Class<Substance> getIndexedEntityClass() {
return Substance.class;
}

@Override
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 @@ -26,6 +28,16 @@ public class SubstanceClinicalEuropeTrialIndexValueMaker implements IndexValueMa
public Class<Substance> getIndexedEntityClass() {
return Substance.class;
}

@Override
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 @@ -27,6 +29,16 @@ public class SubstanceClinicalUSTrialIndexValueMaker implements IndexValueMaker<
public Class<Substance> getIndexedEntityClass() {
return Substance.class;
}

@Override
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 @@ -9,12 +9,14 @@
import ix.core.search.text.IndexValueMaker;
import ix.core.search.text.IndexableValue;
import ix.ginas.models.v1.Substance;
import ix.utils.Util;
import ix.ginas.models.v1.Code;

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

import java.util.Set;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
Expand All @@ -28,10 +30,20 @@ public class SubstanceProductIndexValueMaker implements IndexValueMaker<Substanc
@Autowired
public ProductsApi productsApi;

@Override
public Class<Substance> getIndexedEntityClass() {
return Substance.class;
}
@Override
public Class<Substance> getIndexedEntityClass() {
return Substance.class;
}

@Override
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 @@ -6,6 +6,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

Expand All @@ -25,6 +26,9 @@ public interface SubstanceEntityService extends GsrsEntityService<Substance, UUI

@Override
long count();

@Override
List<UUID> getIDs();

Optional<Substance> get(UUID id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ix.core.models.ForceUpdatableModel;
import ix.core.models.Role;
import ix.core.util.EntityUtils;
import ix.core.util.EntityUtils.Key;
import ix.core.util.LogUtil;
import ix.core.validator.*;
import ix.ginas.models.v1.Substance;
Expand Down Expand Up @@ -473,4 +474,10 @@ public UpdateResult<Substance> updateEntityWithoutValidation(JsonNode updatedEnt
});
}

@Override
public List<UUID> getIDs() {
List<UUID> IDs = repository.getAllIds();
return IDs;
}

}
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,9 +37,13 @@ public Class<Substance> getIndexedEntityClass() {

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

@Override
public Set<String> getTags(){
return Util.toSet("user_list");
}


@Override
public void createIndexableValues(Substance substance, Consumer<IndexableValue> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public interface CodeRepository extends GsrsVersionedRepository<Code, UUID> {
List<Code> findByUuidStartingWith(String partialUUID);

List<Code> findByCodeIgnoreCase(String code);

@Query("select c.uuid from Code c")
List<UUID> getAllIDs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ public interface NameRepository extends GsrsVersionedRepository<Name, UUID> {

@Query("select n.uuid from Name n")
List<String> getAllUuids();

@Query("select n.uuid from Name n")
List<UUID> getAllIDs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ix.core.models.Keyword;
import ix.core.models.ProcessingJob;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -14,4 +15,7 @@
public interface ProcessingJobRepository extends JpaRepository<ProcessingJob, Long> {

List<ProcessingJob> findByKeysIn(Collection<Keyword> keyword);

@Query("select pj.id from ProcessingJob pj")
List<Long> getAllIDs();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ public interface ReferenceRepository extends GsrsVersionedRepository<Reference,
//hibernate query will not convert uuid into a string so we have to concatenate it with empty string for this to work.
@Query("select s from Reference s where CONCAT(s.uuid, '') like ?1%")
List<Reference> findByUuidStartingWith(String partialUUID);

@Query("select r.id from Reference r")
List<UUID> getAllIDs();
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,9 @@ public Code createNewSystemCode(Substance substance, String codeSystem, Function
return c;
}

@Override
public List<UUID> getIDs() {
return repository.getAllIDs();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ protected Optional<UUID> flexLookupIdOnly(String someKindOfId) {
return Optional.empty();
}



@Override
public List<UUID> getIDs() {
List<UUID> IDs = repository.getAllIDs();
return IDs;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ public Class<ProcessingJob> getEntityClass() {
public Page page(Pageable pageable) {
return processingJobRepository.findAll(pageable);
}

@Override
public List<Long> getIDs() {
return processingJobRepository.getAllIDs();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
@Scope(proxyMode = ScopedProxyMode.INTERFACES)
@Service
public class ReferenceEntityService extends AbstractGsrsEntityService<Reference, UUID> {
public static final String CONTEXT = "names";
public static final String CONTEXT = "references";


public ReferenceEntityService() {
super(CONTEXT, IdHelpers.UUID, "gsrs_exchange", "name.created", "name.updated");
super(CONTEXT, IdHelpers.UUID, "gsrs_exchange", "reference.created", "reference.updated");
}

@Autowired
Expand Down Expand Up @@ -233,7 +233,9 @@ protected Optional<UUID> flexLookupIdOnly(String someKindOfId) {
return Optional.empty();
}




@Override
public List<UUID> getIDs() {
// TODO Auto-generated method stub
return new ArrayList<UUID>();
}
}
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));
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 ce9ff52

Please sign in to comment.