예제 #1
0
    /**
     * Parse the parameters of a connection into a CoreNLP properties file that can be passed into
     * {@link StanfordCoreNLP}, and used in the I/O stages.
     *
     * @param httpExchange The http exchange; effectively, the request information.
     * @return A {@link Properties} object corresponding to a combination of default and passed
     *     properties.
     * @throws UnsupportedEncodingException Thrown if we could not decode the key/value pairs with
     *     UTF-8.
     */
    private Properties getProperties(HttpExchange httpExchange)
        throws UnsupportedEncodingException {
      // Load the default properties
      Properties props = new Properties();
      defaultProps
          .entrySet()
          .stream()
          .forEach(
              entry -> props.setProperty(entry.getKey().toString(), entry.getValue().toString()));

      // Try to get more properties from query string.
      Map<String, String> urlParams = getURLParams(httpExchange.getRequestURI());
      if (urlParams.containsKey("properties")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      } else if (urlParams.containsKey("props")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      }

      // Make sure the properties compile
      props.setProperty(
          "annotators",
          StanfordCoreNLP.ensurePrerequisiteAnnotators(
              props.getProperty("annotators").split("[, \t]+")));

      return props;
    }
예제 #2
0
 public void updateTickets(JiraTickets tickets) throws ExecutionException, InterruptedException {
   for (JiraTicket t : tickets) {
     Promise<Issue> issuePromise = issueRestClient.getIssue(t.getId());
     Issue i = issuePromise.get();
     // find transition (we need ID)
     Iterable<Transition> transitions =
         issueRestClient.getTransitions(i.getTransitionsUri()).get();
     String tName = "Hotfix Failed";
     if (t.isValid()) {
       tName = "Out On Dev";
     }
     Transition transition = find(transitions, tName);
     if (transition == null) {
       continue;
     }
     // prepare fields
     // List<FieldInput> fields = Arrays.asList(   new FieldInput("resolution",
     // ComplexIssueInputFieldValue.with("name", "RerunPass")));
     Comment comment = Comment.valueOf(StringUtils.join(t.getValidationMessages(), "\n"));
     issueRestClient.transition(i, new TransitionInput(transition.getId(), comment));
   }
 }
예제 #3
0
 /**
  * Returns the metadata keys that allow identification of this device profile.
  *
  * <p>Note: if the returned array contains an empty string value (not <code>null</code>, but
  * <code>""</code>!), it means that this profile can be used for <em>all</em> devices.
  *
  * @return an array of metadata keys this profile supports, never <code>null</code>.
  */
 public String[] getDeviceMetadataKeys() {
   final String rawValue = this.properties.get(DEVICE_METADATA_KEYS);
   return StringUtils.tokenizeQuotedStrings(rawValue, ", ");
 }