diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseResourceProvider.java similarity index 94% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceProvider.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseResourceProvider.java index 3a58850d5ac..02005f2bc5d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseResourceProvider.java @@ -1,9 +1,8 @@ -package ca.uhn.fhir.jpa.entity; +package ca.uhn.fhir.jpa.dao; import java.util.HashMap; import java.util.List; -import ca.uhn.fhir.jpa.dao.IFhirResourceDao; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.primitive.IdDt; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IndexedParam.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IndexedParam.java new file mode 100644 index 00000000000..da785fca6a4 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IndexedParam.java @@ -0,0 +1,7 @@ +package ca.uhn.fhir.jpa.dao; + +public @interface IndexedParam { + + String path(); + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceIndexedSearchParam.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceIndexedSearchParam.java new file mode 100644 index 00000000000..55d26fe524d --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/BaseResourceIndexedSearchParam.java @@ -0,0 +1,33 @@ +package ca.uhn.fhir.jpa.entity; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.DiscriminatorType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class BaseResourceIndexedSearchParam implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "RES_ID") + private Long myId; + + @ManyToOne(optional=false) + @Column(name="RESOURCE_PID", nullable=false) + private BaseResourceTable> myResource; + + +} diff --git a/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/PatientResourceProvider.java b/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/PatientResourceProvider.java index 6a3f7190090..25f0f978991 100644 --- a/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/PatientResourceProvider.java +++ b/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/PatientResourceProvider.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import ca.uhn.fhir.jpa.entity.BaseResourceProvider; +import ca.uhn.fhir.jpa.dao.BaseResourceProvider; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.annotation.Description; diff --git a/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/QuestionnaireResourceProvider.java b/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/QuestionnaireResourceProvider.java index 3c963e3fe9c..2f6c18c717e 100644 --- a/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/QuestionnaireResourceProvider.java +++ b/hapi-fhir-jpaserver-test/src/main/java/ca/uhn/fhir/jpa/test/QuestionnaireResourceProvider.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.jpa.test; -import ca.uhn.fhir.jpa.entity.BaseResourceProvider; +import ca.uhn.fhir.jpa.dao.BaseResourceProvider; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.dstu.resource.Questionnaire; diff --git a/hapi-tinder-plugin/src/main/resources/vm/jpa_entity.vm b/hapi-tinder-plugin/src/main/resources/vm/jpa_entity.vm new file mode 100644 index 00000000000..51cc60e5fca --- /dev/null +++ b/hapi-tinder-plugin/src/main/resources/vm/jpa_entity.vm @@ -0,0 +1,45 @@ +#parse ( "/vm/templates.vm" ) + +package ${packageBase}; + +@ResourceDef(name="${className}", profile="${profile}", id="${id}") +public class ${className}ResourceTable extends BaseResourceTable<${className}> { + +#foreach ( $param in $searchParams ) +#if( ${param.typeCapitalized} == 'String' ) + @IndexedParam(path="${param.path}") + @Column(length=100) + private String ${param.name}; +#elseif( ${param.typeCapitalized} == 'Date' ) + @IndexedParam(path="${param.path}") + @Column() + private String ${param.name}; + + /** + * Fluent Client search parameter constant for ${param.name} + *
+ * Description: ${param.description}
+ * Type: ${param.type}
+ * Path: ${param.path}
+ *