Merge branch 'master' of github.com:jamesagnew/hapi-fhir
Conflicts: src/changes/changes.xml
This commit is contained in:
commit
81f9e492f3
|
@ -283,7 +283,8 @@ public class IdDt implements IPrimitiveDatatype<String> {
|
||||||
b.append('/');
|
b.append('/');
|
||||||
b.append(myUnqualifiedVersionId);
|
b.append(myUnqualifiedVersionId);
|
||||||
}
|
}
|
||||||
myValue = b.toString();
|
String value = b.toString();
|
||||||
|
myValue = value;
|
||||||
}
|
}
|
||||||
return myValue;
|
return myValue;
|
||||||
}
|
}
|
||||||
|
@ -384,10 +385,17 @@ public class IdDt implements IPrimitiveDatatype<String> {
|
||||||
myValue = theValue;
|
myValue = theValue;
|
||||||
myHaveComponentParts = false;
|
myHaveComponentParts = false;
|
||||||
if (StringUtils.isBlank(theValue)) {
|
if (StringUtils.isBlank(theValue)) {
|
||||||
|
myBaseUrl = null;
|
||||||
myValue = null;
|
myValue = null;
|
||||||
myUnqualifiedId = null;
|
myUnqualifiedId = null;
|
||||||
myUnqualifiedVersionId = null;
|
myUnqualifiedVersionId = null;
|
||||||
myResourceType = null;
|
myResourceType = null;
|
||||||
|
} else if (theValue.charAt(0)== '#') {
|
||||||
|
myValue = theValue;
|
||||||
|
myUnqualifiedId = theValue;
|
||||||
|
myUnqualifiedVersionId=null;
|
||||||
|
myResourceType = null;
|
||||||
|
myHaveComponentParts = true;
|
||||||
} else {
|
} else {
|
||||||
int vidIndex = theValue.indexOf("/_history/");
|
int vidIndex = theValue.indexOf("/_history/");
|
||||||
int idIndex;
|
int idIndex;
|
||||||
|
@ -452,13 +460,7 @@ public class IdDt implements IPrimitiveDatatype<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdDt toVersionless() {
|
public IdDt toVersionless() {
|
||||||
String value = getValue();
|
return new IdDt(getBaseUrl(), getResourceType(), getIdPart(), null);
|
||||||
int i = value.indexOf(Constants.PARAM_HISTORY);
|
|
||||||
if (i > 1) {
|
|
||||||
return new IdDt(value.substring(0, i - 1));
|
|
||||||
} else {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IdDt withResourceType(String theResourceName) {
|
public IdDt withResourceType(String theResourceName) {
|
||||||
|
|
|
@ -26,6 +26,43 @@ public class IdDtTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #67
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testComplicatedLocal() {
|
||||||
|
IdDt id = new IdDt("#Patient/cid:Patient-72/_history/1");
|
||||||
|
assertTrue(id.isLocal());
|
||||||
|
assertNull(id.getBaseUrl());
|
||||||
|
assertNull(id.getResourceType());
|
||||||
|
assertNull(id.getVersionIdPart());
|
||||||
|
assertEquals("#Patient/cid:Patient-72/_history/1", id.getIdPart());
|
||||||
|
|
||||||
|
IdDt id2 = new IdDt("#Patient/cid:Patient-72/_history/1");
|
||||||
|
assertEquals(id, id2);
|
||||||
|
|
||||||
|
id2 = id2.toUnqualified();
|
||||||
|
assertTrue(id2.isLocal());
|
||||||
|
assertNull(id2.getBaseUrl());
|
||||||
|
assertNull(id2.getResourceType());
|
||||||
|
assertNull(id2.getVersionIdPart());
|
||||||
|
assertEquals("#Patient/cid:Patient-72/_history/1", id2.getIdPart());
|
||||||
|
|
||||||
|
id2 = id2.toVersionless();
|
||||||
|
assertTrue(id2.isLocal());
|
||||||
|
assertNull(id2.getBaseUrl());
|
||||||
|
assertNull(id2.getResourceType());
|
||||||
|
assertNull(id2.getVersionIdPart());
|
||||||
|
assertEquals("#Patient/cid:Patient-72/_history/1", id2.getIdPart());
|
||||||
|
|
||||||
|
id2 = id2.toUnqualifiedVersionless();
|
||||||
|
assertTrue(id2.isLocal());
|
||||||
|
assertNull(id2.getBaseUrl());
|
||||||
|
assertNull(id2.getResourceType());
|
||||||
|
assertNull(id2.getVersionIdPart());
|
||||||
|
assertEquals("#Patient/cid:Patient-72/_history/1", id2.getIdPart());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetermineBase() {
|
public void testDetermineBase() {
|
||||||
|
|
||||||
|
@ -80,6 +117,15 @@ public class IdDtTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testViewMethods() {
|
||||||
|
IdDt i = new IdDt("http://foo/fhir/Organization/123/_history/999");
|
||||||
|
assertEquals("Organization/123/_history/999", i.toUnqualified().getValue());
|
||||||
|
assertEquals("http://foo/fhir/Organization/123", i.toVersionless().getValue());
|
||||||
|
assertEquals("Organization/123", i.toUnqualifiedVersionless().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseValueWithVersion() {
|
public void testParseValueWithVersion() {
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
</ul>
|
</ul>
|
||||||
]]>
|
]]>
|
||||||
</action>
|
</action>
|
||||||
|
<action type="fix" issue="67">
|
||||||
|
IdDt failed to recognize local identifiers containing fragments that look like
|
||||||
|
real identifiers as being local identifiers even though they started with '#'.
|
||||||
|
For example, a local resource reference of "#aa/_history/aa" would be incorrectly
|
||||||
|
parsed as a non-local reference.
|
||||||
|
Thanks to Mohammad Jafari for reporting!
|
||||||
|
</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="0.8" date="2014-Dec-17">
|
<release version="0.8" date="2014-Dec-17">
|
||||||
<action type="add">
|
<action type="add">
|
||||||
|
|
Loading…
Reference in New Issue