Package org.apache.ctakes.ytex.uima.types

Examples of org.apache.ctakes.ytex.uima.types.KeyValuePair


    JCas jCas = engine.newJCas();
    jCas.setDocumentText(text);
    // create a docKey so we can find the doc
    long key = System.currentTimeMillis();
    DocKey docKey = new DocKey(jCas);
    KeyValuePair kvp = new KeyValuePair(jCas);
    kvp.setKey("instance_id");
    kvp.setValueLong(key);
    FSArray fsa = new FSArray(jCas, 1);
    fsa.set(0, kvp);
    docKey.setKeyValuePairs(fsa);
    docKey.addToIndexes();
    // run the analysis engine
View Full Code Here


    FSArray keyValuePairs = new FSArray(aCAS, id.size());
    int i = 0;
    for (Map.Entry<String, Object> idVal : id.entrySet()) {
      String key = idVal.getKey();
      Object val = idVal.getValue();
      KeyValuePair p = new KeyValuePair(aCAS);
      p.setKey(key);
      if (val instanceof Number) {
        p.setValueLong(((Number) val).longValue());
      } else if (val instanceof String) {
        p.setValueString((String) val);
      } else {
        log.warn("Don't know how to handle key attribute, converting to string, key="
            + key + ", value=" + val);
        p.setValueString(val.toString());
      }
      keyValuePairs.set(i, p);
      i++;
    }
    docKey.setKeyValuePairs(keyValuePairs);
View Full Code Here

        formattedTableName).append(" set ");
    List<Object> args = new ArrayList<Object>();
    boolean bFirstArg = true;
    // iterate over key/value pairs
    for (int i = 0; i < fsa.size(); i++) {
      KeyValuePair kp = (KeyValuePair) fsa.get(i);
      String key = kp.getKey();
      if (key.equalsIgnoreCase("instance_id")) {
        // instance_id is something we 'know' about - set it
        document.setInstanceID(kp.getValueLong());
      } else if (key.equalsIgnoreCase("instance_key")) {
        document.setInstanceKey(kp.getValueString());
      } else if (this.docTableCols.containsKey(key)) {
        // only attempt to map keys that correspond to valid columns
        boolean badArg = false;
        // verify that the value matches the datatype
        // if valueString not null then assume integer
        if (kp.getValueString() != null
            && stringTypes.contains(docTableCols.get(key))) {
          args.add(kp.getValueString());
        } else if (numericTypes.contains(docTableCols.get(key))) {
          args.add(kp.getValueLong());
        } else {
          // invalid type for argument
          badArg = true;
          log.warn("document_id: " + documentId
              + ", bad type for key=" + key + ", value="
              + kp.getValueString() == null ? kp.getValueLong()
              : kp.getValueString());
        }
        if (!badArg) {
          // update
          if (!bFirstArg) {
            queryBuilder.append(", ");
          }
          queryBuilder.append(DBUtil.formatFieldName(key));
          queryBuilder.append("=? ");
          bFirstArg = false;
        }
      } else {
        // don't know what to do with this key attribute
        log.warn("document_id: " + documentId
            + ", could not map key attribute " + kp.getKey());
      }
    }
    if (args.size() > 0) {
      // have something to update - add the where condition
      queryBuilder.append(" where document_id = ?");
View Full Code Here

TOP

Related Classes of org.apache.ctakes.ytex.uima.types.KeyValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.