コード例 #1
0
ファイル: Script.java プロジェクト: hilotec/elexis-3-core
 /**
  * Replace variables of the form [Patient.Name] in the script with their respective values for the
  * current call
  *
  * @param script the script
  * @param params all Variables to replace
  * @return the parsed Script
  */
 private static String parse(String script, PersistentObject... params) {
   if (params == null) {
     params = new PersistentObject[0];
   }
   Matcher matcher = varPattern.matcher(script);
   // Suche Variablen der Form [Patient.Alter]
   StringBuffer sb = new StringBuffer();
   while (matcher.find()) {
     boolean bMatched = false;
     String var = matcher.group().replaceAll("[\\[\\]]", StringTool.leer);
     String[] fields = var.split("\\.");
     if (fields.length > 1) {
       String fqname = "ch.elexis.data." + fields[0];
       for (PersistentObject o : params) {
         if (o.getClass().getName().equals(fqname)) {
           String repl = o.get(fields[1]);
           repl = repl.replace('\\', '/');
           repl = repl.replace('\"', ' ');
           repl = repl.replace('\n', ' ');
           repl = repl.replace('\r', ' ');
           matcher.appendReplacement(sb, "\"" + repl + "\"");
           bMatched = true;
         }
       }
     }
     if (!bMatched) {
       matcher.appendReplacement(sb, "\"\"");
     }
   }
   matcher.appendTail(sb);
   return sb.toString();
 }
コード例 #2
0
 public String getUpdateStatement(PersistentObject object) {
   return getStatement(object.getClass(), updateStatements, "update");
 }
コード例 #3
0
 public String getInsertStatement(PersistentObject object) {
   return getStatement(object.getClass(), insertStatements, "insert");
 }