本文整理汇总了Java中ca.uhn.fhir.parser.DataFormatException类的典型用法代码示例。如果您正苦于以下问题:Java DataFormatException类的具体用法?Java DataFormatException怎么用?Java DataFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataFormatException类属于ca.uhn.fhir.parser包,在下文中一共展示了DataFormatException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updatePatient
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
/**
* The "@Update" annotation indicates that this method supports replacing an existing
* resource (by ID) with a new instance of that resource.
*
* @param theId
* This is the ID of the patient to update
* @param thePatient
* This is the actual resource to save
* @return This method returns a "MethodOutcome"
*/
@Update()
public MethodOutcome updatePatient(@IdParam IdType theId, @ResourceParam Patient thePatient) {
validateResource(thePatient);
Long id;
try {
id = theId.getIdPartAsLong();
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid ID " + theId.getValue() + " - Must be numeric");
}
/*
* Throw an exception (HTTP 404) if the ID is not known
*/
if (!myIdToPatientVersions.containsKey(id)) {
throw new ResourceNotFoundException(theId);
}
addNewVersion(thePatient, id);
return new MethodOutcome();
}
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:33,代码来源:PatientResourceProvider.java
示例2: main
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@SuppressWarnings("unused")
public static void main(String[] args) throws DataFormatException, IOException {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
patient.setGender(AdministrativeGenderEnum.MALE);
FhirContext ctx = new FhirContext();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir");
IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135");
List<Patient> clients = client.findPatientsByIdentifier(searchParam);
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:QuickUsage.java
示例3: main
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
public static void main(String[] args) throws DataFormatException, IOException {
//START SNIPPET: example1
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:foo").setValue("7000135");
patient.addName().addFamily("Smith").addGiven("John").addGiven("Edward");
patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").setState("ZZ");
FhirContext ctx = new FhirContext();
// Use the narrative generator
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
// Encode the output, including the narrative
String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient);
System.out.println(output);
//END SNIPPET: example1
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:20,代码来源:Narrative.java
示例4: getResourceDefinition
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
public RuntimeResourceDefinition getResourceDefinition(FhirVersionEnum theVersion, String theResourceName) {
Validate.notNull(theVersion, "theVersion can not be null");
if (theVersion.equals(myVersion.getVersion())) {
return getResourceDefinition(theResourceName);
}
Map<String, Class<? extends IBaseResource>> nameToType = myVersionToNameToResourceType.get(theVersion);
if (nameToType == null) {
nameToType = new HashMap<String, Class<? extends IBaseResource>>();
ModelScanner.scanVersionPropertyFile(null, nameToType, theVersion);
Map<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>> newVersionToNameToResourceType = new HashMap<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>>();
newVersionToNameToResourceType.putAll(myVersionToNameToResourceType);
newVersionToNameToResourceType.put(theVersion, nameToType);
myVersionToNameToResourceType = newVersionToNameToResourceType;
}
Class<? extends IBaseResource> resourceType = nameToType.get(theResourceName.toLowerCase());
if (resourceType == null) {
throw new DataFormatException(createUnknownResourceNameError(theResourceName, theVersion));
}
return getResourceDefinition(resourceType);
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:26,代码来源:FhirContext.java
示例5: invokeClient
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Override
public BaseOperationOutcome invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode, Map<String, List<String>> theHeaders) throws IOException,
BaseServerResponseException {
EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
if (respType == null) {
return null;
}
IParser parser = respType.newParser(myContext);
BaseOperationOutcome retVal;
try {
// TODO: handle if something else than OO comes back
retVal = (BaseOperationOutcome) parser.parseResource(theResponseReader);
} catch (DataFormatException e) {
ourLog.warn("Failed to parse OperationOutcome response", e);
return null;
}
MethodUtil.parseClientRequestResourceHeaders(null, theHeaders, retVal);
return retVal;
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:GenericClient.java
示例6: translateQueryParametersIntoServerArgument
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Override
public Object translateQueryParametersIntoServerArgument(Request theRequest, Object theRequestContents) throws InternalErrorException, InvalidRequestException {
String[] sinceParams = theRequest.getParameters().remove(Constants.PARAM_SINCE);
if (sinceParams != null) {
if (sinceParams.length > 0) {
if (StringUtils.isNotBlank(sinceParams[0])) {
try {
InstantDt since = new InstantDt(sinceParams[0]);
return ParameterUtil.fromInstant(myType, since);
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid " + Constants.PARAM_SINCE + " value: " + sinceParams[0]);
}
}
}
}
return ParameterUtil.fromInstant(myType, null);
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:SinceParameter.java
示例7: translateQueryParametersIntoServerArgument
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Override
public Object translateQueryParametersIntoServerArgument(Request theRequest, Object theRequestContents) throws InternalErrorException, InvalidRequestException {
String[] sinceParams = theRequest.getParameters().remove(Constants.PARAM_COUNT);
if (sinceParams != null) {
if (sinceParams.length > 0) {
if (StringUtils.isNotBlank(sinceParams[0])) {
try {
IntegerDt since = new IntegerDt(sinceParams[0]);
return ParameterUtil.fromInteger(myType, since);
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid " + Constants.PARAM_COUNT + " value: " + sinceParams[0]);
}
}
}
}
return ParameterUtil.fromInteger(myType, null);
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:CountParameter.java
示例8: testGenerateDiagnosticReport
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testGenerateDiagnosticReport() throws DataFormatException {
DiagnosticReport value = new DiagnosticReport();
value.getName().setText("Some Diagnostic Report");
value.addResult().setReference("Observation/1");
value.addResult().setReference("Observation/2");
value.addResult().setReference("Observation/3");
NarrativeDt narrative = new NarrativeDt();
gen.generateNarrative("http://hl7.org/fhir/profiles/DiagnosticReport", value, narrative);
String output = narrative.getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString(value.getName().getText().getValue()));
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:17,代码来源:DefaultThymeleafNarrativeGeneratorTest.java
示例9: testModelExtension
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testModelExtension() throws DataFormatException {
MyOrganization org = new MyOrganization();
org.getName().setValue("org0");
MyPatient patient = new MyPatient();
patient.addIdentifier("foo", "bar");
patient.getManagingOrganization().setResource(org);
IParser p = ourCtx.newXmlParser().setPrettyPrint(true);
String str = p.encodeResourceToString(patient);
ourLog.info(str);
MyPatient parsed = ourCtx.newXmlParser().parseResource(MyPatient.class, str);
assertEquals("foo", parsed.getIdentifierFirstRep().getSystem().getValueAsString());
// assertEquals(MyOrganization.class, parsed.getManagingOrganization().getResource().getClass());
// MyOrganization parsedOrg = (MyOrganization) parsed.getManagingOrganization().getResource();
// assertEquals("arg0", parsedOrg.getName().getValue());
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:ModelExtensionTest.java
示例10: updatePatient
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
/**
* The "@Update" annotation indicates that this method supports replacing an existing
* resource (by ID) with a new instance of that resource.
*
* @param theId
* This is the ID of the patient to update
* @param thePatient
* This is the actual resource to save
* @return This method returns a "MethodOutcome"
*/
@Update()
public MethodOutcome updatePatient(@IdParam IdDt theId, @ResourceParam Patient thePatient) {
validateResource(thePatient);
Long id;
try {
id = theId.getIdPartAsLong();
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid ID " + theId.getValue() + " - Must be numeric");
}
/*
* Throw an exception (HTTP 404) if the ID is not known
*/
if (!myIdToPatientVersions.containsKey(id)) {
throw new ResourceNotFoundException(theId);
}
addNewVersion(thePatient, id);
return new MethodOutcome();
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:33,代码来源:PatientResourceProvider.java
示例11: testGenerateDiagnosticReport
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testGenerateDiagnosticReport() throws DataFormatException {
DiagnosticReport value = new DiagnosticReport();
value.getName().setText("Some Diagnostic Report");
value.addResult().setReference("Observation/1");
value.addResult().setReference("Observation/2");
value.addResult().setReference("Observation/3");
NarrativeDt narrative = new NarrativeDt();
myGen.generateNarrative("http://hl7.org/fhir/profiles/DiagnosticReport", value, narrative);
String output = narrative.getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString(value.getName().getTextElement().getValue()));
}
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:17,代码来源:DefaultThymeleafNarrativeGeneratorTestDstu2.java
示例12: setValue
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
/**
* Sets the value for this type using the given Java Date object as the time, and using the specified precision, as
* well as the local timezone as determined by the local operating system. Both of
* these properties may be modified in subsequent calls if neccesary.
*
* @param theValue
* The date value
* @param thePrecision
* The precision
* @throws DataFormatException
*/
public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (getTimeZone() == null) {
setTimeZone(TimeZone.getDefault());
}
myPrecision = thePrecision;
myFractionalSeconds = "";
if (theValue != null) {
long millis = theValue.getTime() % 1000;
if (millis < 0) {
// This is for times before 1970 (see bug #444)
millis = 1000 + millis;
}
String fractionalSeconds = Integer.toString((int) millis);
myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0');
}
super.setValue(theValue);
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:29,代码来源:BaseDateTimeType.java
示例13: validateCriteriaAndReturnResourceDefinition
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
public RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(Subscription theResource) {
String query = theResource.getCriteria();
if (isBlank(query)) {
throw new UnprocessableEntityException("Subscription.criteria must be populated");
}
int sep = query.indexOf('?');
if (sep <= 1) {
throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
}
String resType = query.substring(0, sep);
if (resType.contains("/")) {
throw new UnprocessableEntityException("Subscription.criteria must be in the form \"{Resource Type}?[params]\"");
}
RuntimeResourceDefinition resDef;
try {
resDef = getContext().getResourceDefinition(resType);
} catch (DataFormatException e) {
throw new UnprocessableEntityException("Subscription.criteria contains invalid/unsupported resource type: " + resType);
}
return resDef;
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:25,代码来源:FhirResourceDaoSubscriptionDstu2.java
示例14: testCloneIntoPrimitiveFails
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testCloneIntoPrimitiveFails() {
StringDt source = new StringDt("STR");
MoneyDt target = new MoneyDt();
ourCtx.newTerser().cloneInto(source, target, true);
assertTrue(target.isEmpty());
try {
ourCtx.newTerser().cloneInto(source, target, false);
fail();
} catch (DataFormatException e) {
// good
}
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:FhirTerserDstu2Test.java
示例15: testGeneratePatient
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testGeneratePatient() throws DataFormatException {
Patient value = new Patient();
value.addIdentifier().setSystem("urn:names").setValue("123456");
value.addName().setFamily("blow").addGiven("joe").addGiven((String) null).addGiven("john");
//@formatter:off
value.addAddress()
.addLine("123 Fake Street").addLine("Unit 1")
.setCity("Toronto").setState("ON").setCountry("Canada");
//@formatter:on
value.setBirthDate(new Date());
Narrative narrative = new Narrative();
myGen.generateNarrative(ourCtx, value, narrative);
String output = narrative.getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString("<div class=\"hapiHeaderText\">joe john <b>BLOW </b></div>"));
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:22,代码来源:DefaultThymeleafNarrativeGeneratorDstu3Test.java
示例16: testGenerateDiagnosticReport
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testGenerateDiagnosticReport() throws DataFormatException {
DiagnosticReport value = new DiagnosticReport();
value.getCode().setText("Some Diagnostic Report");
value.addResult().setReference("Observation/1");
value.addResult().setReference("Observation/2");
value.addResult().setReference("Observation/3");
Narrative narrative = new Narrative();
myGen.generateNarrative(ourCtx, value, narrative);
String output = narrative.getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString(value.getCode().getTextElement().getValue()));
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:DefaultThymeleafNarrativeGeneratorDstu3Test.java
示例17: testCloneIntoCompositeMismatchedFields
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testCloneIntoCompositeMismatchedFields() {
QuantityDt source = new QuantityDt();
source.setSystem("SYSTEM");
source.setUnit("UNIT");
IdentifierDt target = new IdentifierDt();
ourCtx.newTerser().cloneInto(source, target, true);
assertEquals("SYSTEM", target.getSystem());
try {
ourCtx.newTerser().cloneInto(source, target, false);
fail();
} catch (DataFormatException e) {
// good
}
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:19,代码来源:FhirTerserDstu2Test.java
示例18: testCloneIntoPrimitiveFails
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Test
public void testCloneIntoPrimitiveFails() {
StringType source = new StringType("STR");
Money target = new Money();
ourCtx.newTerser().cloneInto(source, target, true);
assertTrue(target.isEmpty());
try {
ourCtx.newTerser().cloneInto(source, target, false);
fail();
} catch (DataFormatException e) {
// good
}
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:17,代码来源:FhirTerserDstu3Test.java
示例19: main
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@SuppressWarnings("unused")
public static void main(String[] args) throws DataFormatException, IOException {
Patient patient = new Patient();
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
patient.setGender(AdministrativeGenderEnum.MALE);
FhirContext ctx = FhirContext.forDstu2();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
MyClientInterface client = ctx.newRestfulClient(MyClientInterface.class, "http://foo/fhir");
IdentifierDt searchParam = new IdentifierDt("urn:someidentifiers", "7000135");
List<Patient> clients = client.findPatientsByIdentifier(searchParam);
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:21,代码来源:QuickUsage.java
示例20: translateQueryParametersIntoServerArgument
import ca.uhn.fhir.parser.DataFormatException; //导入依赖的package包/类
@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
String[] sinceParams = theRequest.getParameters().get(Constants.PARAM_COUNT);
if (sinceParams != null) {
if (sinceParams.length > 0) {
if (StringUtils.isNotBlank(sinceParams[0])) {
try {
IntegerDt since = new IntegerDt(sinceParams[0]);
return ParameterUtil.fromInteger(myType, since);
} catch (DataFormatException e) {
throw new InvalidRequestException("Invalid " + Constants.PARAM_COUNT + " value: " + sinceParams[0]);
}
}
}
}
return ParameterUtil.fromInteger(myType, null);
}
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:CountParameter.java
注:本文中的ca.uhn.fhir.parser.DataFormatException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论