forked from hapifhir/hapi-fhir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up parsers so that elements are always encoded according to the…
…ir order in the structures that contain them
- Loading branch information
1 parent
364f11a
commit 2f37015
Showing
52 changed files
with
2,364 additions
and
896 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
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
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
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
51 changes: 51 additions & 0 deletions
51
hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildExtension.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,51 @@ | ||
package ca.uhn.fhir.context; | ||
|
||
import static org.hamcrest.Matchers.emptyCollectionOf; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.hl7.fhir.instance.model.api.IBase; | ||
import org.hl7.fhir.instance.model.api.IBaseExtension; | ||
|
||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum; | ||
import ca.uhn.fhir.model.api.annotation.Child; | ||
import ca.uhn.fhir.model.api.annotation.Description; | ||
|
||
public class RuntimeChildExtension extends RuntimeChildAny { | ||
|
||
private RuntimeChildUndeclaredExtensionDefinition myExtensionElement; | ||
|
||
public RuntimeChildExtension(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation) { | ||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation); | ||
} | ||
|
||
@Override | ||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) { | ||
return getElementName(); | ||
} | ||
|
||
@Override | ||
public Set<String> getValidChildNames() { | ||
return Collections.singleton(getElementName()); | ||
} | ||
|
||
// @Override | ||
// public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) { | ||
// if (IBaseExtension.class.isAssignableFrom(theDatatype)) { | ||
// return myExtensionElement; | ||
// } | ||
// return super.getChildElementDefinitionByDatatype(theDatatype); | ||
// } | ||
// | ||
// @Override | ||
// void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { | ||
// super.sealAndInitialize(theContext, theClassToElementDefinitions); | ||
// | ||
// myExtensionElement = theContext.getRuntimeChildUndeclaredExtensionDefinition(); | ||
// } | ||
|
||
|
||
} |
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
68 changes: 5 additions & 63 deletions
68
hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceReferenceDefinition.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 |
---|---|---|
@@ -1,83 +1,25 @@ | ||
package ca.uhn.fhir.context; | ||
|
||
/* | ||
* #%L | ||
* HAPI FHIR - Core Library | ||
* %% | ||
* Copyright (C) 2014 - 2016 University Health Network | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.hl7.fhir.instance.model.api.IAnyResource; | ||
import org.hl7.fhir.instance.model.api.IBase; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
|
||
import ca.uhn.fhir.model.api.IResource; | ||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; | ||
|
||
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<BaseResourceReferenceDt> { | ||
import org.hl7.fhir.instance.model.api.IBaseReference; | ||
|
||
private final List<Class<? extends IBaseResource>> myResourceTypes; | ||
private HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition> myResourceTypeToDefinition; | ||
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementCompositeDefinition<IBaseReference> { | ||
|
||
/** | ||
* Constructor | ||
* @param theStandardType | ||
*/ | ||
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IBaseResource>> theResourceTypes, boolean theStandardType) { | ||
super(theName, BaseResourceReferenceDt.class, theStandardType); | ||
if (theResourceTypes == null || theResourceTypes.isEmpty()) { | ||
throw new ConfigurationException("Element '" + theName + "' has no resource types noted"); | ||
} | ||
myResourceTypes = theResourceTypes; | ||
} | ||
|
||
public List<Class<? extends IBaseResource>> getResourceTypes() { | ||
return myResourceTypes; | ||
public RuntimeResourceReferenceDefinition(String theName, Class<? extends IBaseReference> theImplementingClass, boolean theStandardType) { | ||
super(theName, theImplementingClass, theStandardType); | ||
} | ||
|
||
@Override | ||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { | ||
myResourceTypeToDefinition = new HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition>(); | ||
for (Class<? extends IBaseResource> next : myResourceTypes) { | ||
if (next.equals(IResource.class) || next.equals(IAnyResource.class) || next.equals(IBaseResource.class)) { | ||
continue; | ||
} | ||
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next); | ||
if (definition == null) { | ||
throw new ConfigurationException("Couldn't find definition for: " + next.getCanonicalName()); | ||
} | ||
myResourceTypeToDefinition.put(next, definition); | ||
} | ||
super.sealAndInitialize(theContext, theClassToElementDefinitions); | ||
} | ||
|
||
@Override | ||
public ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum getChildType() { | ||
return ChildTypeEnum.RESOURCE_REF; | ||
} | ||
|
||
public RuntimeResourceDefinition getDefinitionForResourceType(Class<? extends IResource> theType) { | ||
RuntimeResourceDefinition retVal = myResourceTypeToDefinition.get(theType); | ||
if (retVal == null) { | ||
throw new ConfigurationException("Unknown type: " + theType.getCanonicalName()); | ||
} | ||
return retVal; | ||
} | ||
|
||
} |
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
Oops, something went wrong.