Commit d5a12420 authored by Julia Fischer's avatar Julia Fischer

Blatt 7 - Aufg 2 verbessert mit Alpha-ID DB statt ICD10-DB

parent 81218bef
Pipeline #2638 skipped
This diff is collapsed.
......@@ -20,59 +20,49 @@ import org.hibernate.search.annotations.TokenizerDef;
@Entity
@Indexed
@Table(name = "icd10")
@Table(name = "alpha_id")
@AnalyzerDef(name = "customanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
@Parameter(name = "language", value = "German") }) })
public class ICD10 {
public class AlphaID {
private Integer code_type;
private Integer dimdi_nr;
private Integer print_nr;
private Integer validity;
private String alpha_id;
private String primary_key;
private String star_key;
private String extra_key;
private String text;
public ICD10() {
public AlphaID() {
}
public ICD10(Integer code_type, Integer dimdi_nr, Integer print_nr, String primary_key, String star_key,
public AlphaID(Integer validity, String alpha_id, Integer print_nr, String primary_key, String star_key,
String extra_key, String text) {
this.code_type = code_type;
this.dimdi_nr = dimdi_nr;
this.print_nr = print_nr;
this.validity = validity;
this.alpha_id = alpha_id;
this.primary_key = primary_key;
this.star_key = star_key;
this.extra_key = extra_key;
this.text = text;
}
public Integer getCode_type() {
return code_type;
public Integer getValidity() {
return validity;
}
public void setCode_type(Integer code_type) {
this.code_type = code_type;
public void setValidity(Integer validity) {
this.validity = validity;
}
@Id
public Integer getDimdi_nr() {
return dimdi_nr;
public String getAlpha_id() {
return alpha_id;
}
public void setDimdi_nr(Integer dimdi_nr) {
this.dimdi_nr = dimdi_nr;
}
public Integer getPrint_nr() {
return print_nr;
}
public void setPrint_nr(Integer print_nr) {
this.print_nr = print_nr;
public void setAlpha_id(String alpha_id) {
this.alpha_id = alpha_id;
}
@Analyzer(definition = "customanalyzer")
......@@ -113,11 +103,10 @@ public class ICD10 {
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("code_type: ").append(this.getCode_type())
.append(" | dimdi_nr:").append(this.getDimdi_nr()).append(" | print_nr:").append(this.getPrint_nr())
.append(" | primary_key:").append(this.getPrimary_key()).append(" | star_key:")
.append(this.getStar_key()).append(" | extra_key:").append(this.getExtra_key()).append(" | text:")
.append(this.getText());
StringBuilder stringBuilder = new StringBuilder("validity: ").append(this.getValidity()).append(" | alpha_id:")
.append(this.getAlpha_id()).append(" | primary_key:").append(this.getPrimary_key())
.append(" | star_key:").append(this.getStar_key()).append(" | extra_key:").append(this.getExtra_key())
.append(" | text:").append(this.getText());
return stringBuilder.toString();
}
......
......@@ -36,18 +36,19 @@ public class App {
* @param searchValue
* @return Liste von ICD10-Diagnosen
*/
private static List<ICD10> search(String searchValue) {
private static List<AlphaID> search(String searchValue) {
Session session = HibernateUtil.getSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(ICD10.class).get();
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(AlphaID.class)
.get();
org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword().onFields("text", "primary_key")
.matching(searchValue).createQuery();
// wrap Lucene query in a javax.persistence.Query
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, ICD10.class);
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, AlphaID.class);
List<ICD10> icd10CodeList = fullTextQuery.list();
List<AlphaID> icd10CodeList = fullTextQuery.list();
fullTextSession.close();
......@@ -64,14 +65,14 @@ public class App {
searchValue = searchValue.replace("ohne", "").replace("mit", "");
// Suchen
List<ICD10> result = search(searchValue);
List<AlphaID> result = search(searchValue);
// Ausgabe der Ergebnisse
System.out.println(
"\n >>>>>>> Es wurden " + result.size() + " Einträge gefunden für '" + searchValue + "' <<<<<<< \n");
for (ICD10 icd10 : result) {
System.out.println(icd10.getPrimary_key() + " - " + icd10.getText());
for (AlphaID icd10 : result) {
System.out.println(icd10.getAlpha_id() + " - " + icd10.getPrimary_key() + " - " + icd10.getText());
}
System.exit(0);
......
......@@ -17,6 +17,6 @@
<property name="hibernate.search.default.directory_provider">filesystem</property>
<property name="hibernate.search.default.indexBase">C:\lucene\indexes</property>
<mapping class="org.uebung7.medReader.ICD10"/>
<mapping class="org.uebung7.medReader.AlphaID"/>
</session-factory>
</hibernate-configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment