Add some logging

This commit is contained in:
James Agnew 2015-05-04 11:08:01 -07:00
parent 0af3518772
commit 7585256037
4 changed files with 19 additions and 8 deletions

View File

@ -106,6 +106,9 @@ public class StringParam extends BaseParam implements IQueryParameterType {
if (myExact) {
builder.append("exact", myExact);
}
if (getMissing() != null) {
builder.append("missing", getMissing().booleanValue());
}
return builder.toString();
}

View File

@ -425,11 +425,9 @@ public abstract class BaseFhirDao implements IDao {
// Get list of IDs
searchHistoryCurrentVersion(theResourceName, theId, theSince, end.getValue(), limit, tuples);
assert tuples.size() < 2 || !tuples.get(tuples.size() - 2).getUpdated().before(tuples.get(tuples.size() - 1).getUpdated()) : tuples.toString();
ourLog.info("Retrieved {} history IDs from current versions in {} ms", tuples.size(), timer.getMillisAndRestart());
searchHistoryHistory(theResourceName, theId, theSince, end.getValue(), limit, tuples);
assert tuples.size() < 2 || !tuples.get(tuples.size() - 2).getUpdated().before(tuples.get(tuples.size() - 1).getUpdated()) : tuples.toString();
ourLog.info("Retrieved {} history IDs from previous versions in {} ms", tuples.size(), timer.getMillisAndRestart());
// Sort merged list
@ -1042,6 +1040,9 @@ public abstract class BaseFhirDao implements IDao {
quantityParams = extractSearchParamQuantity(entity, theResource);
dateParams = extractSearchParamDates(entity, theResource);
ourLog.info("Indexing resource: {}", entity.getId());
ourLog.info("Storing string indexes: {}", stringParams);
tokenParams = new ArrayList<ResourceIndexedSearchParamToken>();
for (BaseResourceIndexedSearchParam next : extractSearchParamTokens(entity, theResource)) {
if (next instanceof ResourceIndexedSearchParamToken) {

View File

@ -366,6 +366,8 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
}
private Set<Long> addPredicateParamMissing(Set<Long> thePids, String joinName, String theParamName, Class<? extends BaseResourceIndexedSearchParam> theParamTable) {
String resourceType = getContext().getResourceDefinition(getResourceType()).getName();
CriteriaBuilder builder = myEntityManager.getCriteriaBuilder();
CriteriaQuery<Long> cq = builder.createQuery(Long.class);
Root<ResourceTable> from = cq.from(ResourceTable.class);
@ -374,17 +376,22 @@ public abstract class BaseFhirResourceDao<T extends IResource> extends BaseFhirD
Subquery<Long> subQ = cq.subquery(Long.class);
Root<? extends BaseResourceIndexedSearchParam> subQfrom = subQ.from(theParamTable);
subQ.select(subQfrom.get("myResourcePid").as(Long.class));
subQ.where(builder.equal(subQfrom.get("myParamName"), theParamName));
Predicate subQname = builder.equal(subQfrom.get("myParamName"), theParamName);
Predicate subQtype = builder.equal(subQfrom.get("myResourceType"), resourceType);
subQ.where(builder.and(subQtype, subQname));
Predicate joinPredicate = builder.not(builder.in(from.get("myId")).value(subQ));
Predicate typePredicate = builder.equal(from.get("myResourceType"), resourceType);
if (thePids.size() > 0) {
Predicate inPids = (from.get("myId").in(thePids));
cq.where(builder.and(inPids, joinPredicate));
cq.where(builder.and(inPids, typePredicate, joinPredicate));
} else {
cq.where(joinPredicate);
cq.where(builder.and(typePredicate, joinPredicate));
}
ourLog.info("Adding :missing qualifier for parameter '{}'", theParamName);
TypedQuery<Long> q = myEntityManager.createQuery(cq);
List<Long> resultList = q.getResultList();
HashSet<Long> retVal = new HashSet<Long>(resultList);

View File

@ -359,7 +359,7 @@ public class ResourceProviderDstu2Test {
List<IdDt> list = toIdListUnqualifiedVersionless(found);
ourLog.info(methodName + ": " + list.toString());
assertThat(list, not(containsInRelativeOrder(orgNotMissing)));
assertThat(list, containsInRelativeOrder(orgMissing));
assertThat("Wanted " + orgMissing + " but found: " + list, list, containsInRelativeOrder(orgMissing));
}
}