-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luke Sikina
committed
Dec 28, 2023
1 parent
6bf6c60
commit 572f66c
Showing
4 changed files
with
68 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/QueryDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.service.util; | ||
|
||
import edu.harvard.dbmi.avillach.util.UUIDv5; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.VariantUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
@Component | ||
public class QueryDecorator { | ||
private static final Logger LOG = LoggerFactory.getLogger(QueryDecorator.class); | ||
|
||
public void setId(Query query) { | ||
query.setId(""); // the id is included in the toString | ||
// I clear it here to keep the ID setting stable for any query | ||
// of identical structure and content | ||
|
||
// Some places where we call toString, we call mergeFilterFieldsIntoSelectedFields | ||
// first. This can mutate the query, resulting in shifting UUIDs | ||
// To stabilize things, we're always going to call that, and shift the logic here | ||
mergeFilterFieldsIntoSelectedFields(query); | ||
|
||
String id = UUIDv5.UUIDFromString(query.toString()).toString(); | ||
query.setId(id); | ||
} | ||
|
||
public void mergeFilterFieldsIntoSelectedFields(Query query) { | ||
LinkedHashSet<String> fields = new LinkedHashSet<>(query.getFields()); | ||
|
||
if(!query.getCategoryFilters().isEmpty()) { | ||
Set<String> categoryFilters = new TreeSet<>(query.getCategoryFilters().keySet()); | ||
Set<String> toBeRemoved = new TreeSet<>(); | ||
for(String categoryFilter : categoryFilters) { | ||
LOG.debug("In : {}", categoryFilter); | ||
if(VariantUtils.pathIsVariantSpec(categoryFilter)) { | ||
toBeRemoved.add(categoryFilter); | ||
} | ||
} | ||
categoryFilters.removeAll(toBeRemoved); | ||
for(String categoryFilter : categoryFilters) { | ||
LOG.debug("Out : {}", categoryFilter); | ||
} | ||
fields.addAll(categoryFilters); | ||
} | ||
fields.addAll(query.getAnyRecordOf()); | ||
fields.addAll(query.getRequiredFields()); | ||
fields.addAll(query.getNumericFilters().keySet()); | ||
query.setFields(fields); | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/QueryUUIDGen.java
This file was deleted.
Oops, something went wrong.