-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #437 from DBCG/feature-plugins-test-framework
WIP Test Framework
- Loading branch information
Showing
116 changed files
with
3,125 additions
and
3,118 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
150 changes: 150 additions & 0 deletions
150
core/src/main/java/org/opencds/cqf/ruler/behavior/DaoRegistryUser.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,150 @@ | ||
package org.opencds.cqf.ruler.behavior; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import org.hl7.fhir.instance.model.api.IBaseBundle; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.instance.model.api.IIdType; | ||
import org.opencds.cqf.ruler.utility.Ids; | ||
import org.opencds.cqf.ruler.utility.TypedBundleProvider; | ||
|
||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry; | ||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; | ||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; | ||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; | ||
import ca.uhn.fhir.rest.api.server.IBundleProvider; | ||
import ca.uhn.fhir.rest.api.server.RequestDetails; | ||
|
||
/** | ||
* Simulate FhirDal operations until such time as that is fully baked | ||
*/ | ||
public interface DaoRegistryUser { | ||
|
||
public DaoRegistry getDaoRegistry(); | ||
|
||
default <T extends IBaseResource> T read(Class<T> theResourceClass, String theIdPart) { | ||
checkNotNull(theResourceClass); | ||
checkNotNull(theIdPart); | ||
|
||
return read(theResourceClass, theIdPart, null); | ||
} | ||
|
||
default <T extends IBaseResource> T read(Class<T> theResourceClass, String theIdPart, RequestDetails requestDetails) { | ||
checkNotNull(theResourceClass); | ||
checkNotNull(theIdPart); | ||
checkNotNull(requestDetails); | ||
|
||
return getDaoRegistry().getResourceDao(theResourceClass).read(Ids.newId(theResourceClass, theIdPart), requestDetails); | ||
} | ||
|
||
default <T extends IBaseResource> T read(IIdType theId) { | ||
checkNotNull(theId); | ||
|
||
return read(theId, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
default <T extends IBaseResource> T read(IIdType theId, RequestDetails requestDetails) { | ||
checkNotNull(theId); | ||
|
||
return (T) getDaoRegistry().getResourceDao(theId.getResourceType()).read(theId, requestDetails); | ||
} | ||
|
||
default <T extends IBaseResource> DaoMethodOutcome create(T theResource) { | ||
checkNotNull(theResource); | ||
|
||
return create(theResource, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
default <T extends IBaseResource> DaoMethodOutcome create(T theResource, RequestDetails requestDetails) { | ||
checkNotNull(theResource); | ||
|
||
return ((IFhirResourceDao<T>) getDaoRegistry().getResourceDao(theResource.fhirType())).create(theResource, | ||
requestDetails); | ||
} | ||
|
||
default <T extends IBaseResource> DaoMethodOutcome update(T theResource) { | ||
checkNotNull(theResource); | ||
|
||
return update(theResource, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
default <T extends IBaseResource> DaoMethodOutcome update(T theResource, RequestDetails requestDetails) { | ||
checkNotNull(theResource); | ||
|
||
return ((IFhirResourceDao<T>) getDaoRegistry().getResourceDao(theResource.fhirType())).update(theResource, | ||
requestDetails); | ||
} | ||
|
||
default <T extends IBaseResource> DaoMethodOutcome delete(T theResource) { | ||
checkNotNull(theResource); | ||
|
||
return delete(theResource, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
default <T extends IBaseResource> DaoMethodOutcome delete(T theResource, RequestDetails requestDetails) { | ||
checkNotNull(theResource); | ||
|
||
return ((IFhirResourceDao<T>) getDaoRegistry().getResourceDao(theResource.fhirType())) | ||
.delete(theResource.getIdElement(), requestDetails); | ||
} | ||
|
||
default DaoMethodOutcome delete(IIdType theIdType) { | ||
checkNotNull(theIdType); | ||
|
||
return delete(theIdType, null); | ||
} | ||
|
||
default DaoMethodOutcome delete(IIdType theIdType, RequestDetails requestDetails) { | ||
checkNotNull(theIdType); | ||
|
||
return getDaoRegistry().getResourceDao(theIdType.getResourceType()).delete(theIdType, requestDetails); | ||
} | ||
|
||
default <T extends IBaseBundle> T transaction(T theTransaction) { | ||
checkNotNull(theTransaction); | ||
|
||
return transaction(theTransaction, null); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
default <T extends IBaseBundle> T transaction(T theTransaction, RequestDetails theRequestDetails) { | ||
checkNotNull(theTransaction); | ||
|
||
return (T) getDaoRegistry().getSystemDao().transaction(theRequestDetails, theTransaction); | ||
} | ||
|
||
default <T extends IBaseResource> TypedBundleProvider<T> search(Class<T> theResourceClass, | ||
SearchParameterMap theSearchMap) { | ||
checkNotNull(theResourceClass); | ||
checkNotNull(theSearchMap); | ||
|
||
return search(theResourceClass, theSearchMap, null); | ||
} | ||
|
||
default <T extends IBaseResource> TypedBundleProvider<T> search(Class<T> theResourceClass, SearchParameterMap theSearchMap, | ||
RequestDetails theRequestDetails) { | ||
checkNotNull(theResourceClass); | ||
checkNotNull(theSearchMap); | ||
|
||
return TypedBundleProvider.fromBundleProvider(getDaoRegistry().getResourceDao(theResourceClass).search(theSearchMap, theRequestDetails)); | ||
} | ||
|
||
default IBundleProvider search(String theResourceName, SearchParameterMap theSearchMap) { | ||
checkNotNull(theResourceName); | ||
checkNotNull(theSearchMap); | ||
|
||
return search(theResourceName, theSearchMap, null); | ||
} | ||
|
||
default IBundleProvider search(String theResourceName, SearchParameterMap theSearchMap, | ||
RequestDetails theRequestDetails) { | ||
checkNotNull(theResourceName); | ||
checkNotNull(theSearchMap); | ||
|
||
return getDaoRegistry().getResourceDao(theResourceName).search(theSearchMap); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/main/java/org/opencds/cqf/ruler/behavior/FhirContextUser.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,7 @@ | ||
package org.opencds.cqf.ruler.behavior; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
|
||
public interface FhirContextUser { | ||
FhirContext getFhirContext(); | ||
} |
23 changes: 23 additions & 0 deletions
23
core/src/main/java/org/opencds/cqf/ruler/behavior/IdCreator.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,23 @@ | ||
package org.opencds.cqf.ruler.behavior; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import org.hl7.fhir.instance.model.api.IIdType; | ||
import org.opencds.cqf.ruler.utility.Ids; | ||
|
||
|
||
public interface IdCreator extends FhirContextUser { | ||
|
||
default <T extends IIdType> T newId(String theResourceName, String theResourceId) { | ||
checkNotNull(theResourceName); | ||
checkNotNull(theResourceId); | ||
|
||
return Ids.newId(getFhirContext(), theResourceName, theResourceId); | ||
} | ||
|
||
default <T extends IIdType> T newId(String theResourceId) { | ||
checkNotNull(theResourceId); | ||
|
||
return Ids.newId(getFhirContext(), theResourceId); | ||
} | ||
} |
Oops, something went wrong.