Skip to content

Commit

Permalink
handle case when a column is missing from the json file in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dkapoor committed Dec 10, 2014
1 parent c831272 commit 09db0dc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ else if(o instanceof ParentRowColumnAffinity)
@Override
public boolean isValidFor(HNodePath a, HNodePath b) {
HNodePath commonPath = HNodePath.findCommon(a, b);
if(commonPath == null || a == null || b == null)
return false;

if(commonPath.length() == a.length() && b.length() > a.length())
{
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public int compareTo(ColumnAffinity o) {
@Override
public boolean isValidFor(HNodePath a, HNodePath b) {
HNodePath commonPath = HNodePath.findCommon(a, b);
if(commonPath == null)
if(commonPath == null || a == null || b == null)
return false;
int commonPathLength = commonPath.length();
return commonPathLength +1 == a.length() && commonPathLength +1 == b.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ else if(generateContext && objectTemplateTermSetPopulator.getTerms().isSingleCol
}

protected String getColumnContextUri (String hNodeId) {

if (hNodeToContextUriMap.containsKey(hNodeId))
return hNodeToContextUriMap.get(hNodeId);
else {
String randomId = UUID.randomUUID().toString();
String uri = Namespaces.KARMA_DEV + randomId + "_" + hNodeId;
hNodeToContextUriMap.put(hNodeId, uri);
return uri;
if(hNodeId != null) {
if (hNodeToContextUriMap.containsKey(hNodeId))
return hNodeToContextUriMap.get(hNodeId);
else {
String randomId = UUID.randomUUID().toString();
String uri = Namespaces.KARMA_DEV + randomId + "_" + hNodeId;
hNodeToContextUriMap.put(hNodeId, uri);
return uri;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ protected void populateTermsToPathForSubject(
throws HNodeNotFoundKarmaException {
for(ColumnTemplateTerm term : subjMapTemplate.getAllColumnNameTermElements())
{
HNodePath path = factory.getHNode(translator.getHNodeIdForColumnName(term.getTemplateTermValue())).getHNodePath(factory);
subjectTermsToPaths.put(term, path);
String hNodeId = translator.getHNodeIdForColumnName(term.getTemplateTermValue());
if(hNodeId != null) {
HNodePath path = factory.getHNode(hNodeId).getHNodePath(factory);
subjectTermsToPaths.put(term, path);
}
}
}
protected TemplateTermSet generateSubjectMapTemplateForBlankNode(SubjectMap subjectMap,
Expand Down

0 comments on commit 09db0dc

Please sign in to comment.