Example usage for java.util Optional OPTIONAL

List of usage examples for java.util Optional OPTIONAL

Introduction

In this page you can find the example usage for java.util Optional OPTIONAL.

Prototype

OPTIONAL

Source Link

Usage

From source file:com.bidorbuy.graylog.alarmcallbacks.jira.JiraAlarmCallback.java

@Override
public ConfigurationRequest getRequestedConfiguration() {
    final ConfigurationRequest configurationRequest = new ConfigurationRequest();

    configurationRequest.addField(new TextField(CK_JIRA_INSTANCE_URL, "JIRA Instance URL", "",
            "JIRA server URL.", ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_USERNAME, "JIRA username", "",
            "Username to login to JIRA and create issues.", ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest/*  w w w. j  a va2 s .c om*/
            .addField(new TextField(CK_JIRA_PASSWORD, "JIRA password", "", "Password to login to JIRA.",
                    ConfigurationField.Optional.NOT_OPTIONAL, TextField.Attribute.IS_PASSWORD));

    configurationRequest.addField(new TextField(CK_JIRA_PROJECT_KEY, "JIRA project Key", "",
            "Project under which the issue will be created.", ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_ISSUE_TYPE, "JIRA issue Type", "Bug", "Type of issue.",
            ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_MESSAGE_TEMPLATE, "JIRA message template",
            CONST_JIRA_MESSAGE_TEMPLATE.replaceAll("\n", "\\\n"), "Message template for JIRA",
            ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(
            new TextField(CK_JIRA_TITLE_TEMPLATE, "JIRA issue title template", CONST_JIRA_TITLE_TEMPLATE,
                    "Title template for JIRA tasks", ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(new TextField(CK_GRAYLOG_URL, "Graylog URL", null,
            "URL to your Graylog web interface. Used to build links in alarm notification.",
            ConfigurationField.Optional.NOT_OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_PRIORITY, "JIRA Issue Priority", "Minor",
            "Priority of the issue.", ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_LABELS, "JIRA Labels", "",
            "List of comma-separated labels to add to this issue - i.e. graylog",
            ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_COMPONENTS, "JIRA Components", "",
            "List of comma-separated components to add to this issue.", ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_MESSAGE_REGEX, "Message regex", "",
            "Message regex to extract message content. Example: " + CONST_JIRA_MESSAGE_REGEX,
            ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_MD5_HASH_PATTERN, "JIRA MD5 pattern", "",
            "Pattern to construct MD5. Example: " + CONST_JIRA_MD5_TEMPLATE,
            ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_MD5_CUSTOM_FIELD, "JIRA MD5 custom field", "",
            "Custom field name for the MD5 hash, this will be in the format of customfield_####. If not set, we will try and find it",
            ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_MD5_FILTER_QUERY, "JIRA duplicate filter query", "",
            "Additional filter query to check for duplicates. Example: " + CONST_JIRA_MD5_FILTER_QUERY_TEMPLATE,
            ConfigurationField.Optional.OPTIONAL));

    configurationRequest.addField(new TextField(CK_JIRA_GRAYLOG_MAPPING, "JIRA/Graylog field mapping", "",
            "List of comma-separated Graylog/JIRA mapping fields to automatically map Graylog message fields into JIRA",
            ConfigurationField.Optional.OPTIONAL));

    return configurationRequest;
}

From source file:com.glaf.oa.optional.web.springmvc.OptionalController.java

@RequestMapping("/save")
public ModelAndView save(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    params.remove("status");
    params.remove("wfStatus");

    Optional optional = new Optional();
    Tools.populate(optional, params);/*from  ww  w .  j a  va2  s  .c  o  m*/
    optional.setId(RequestUtils.getInt(request, "id"));
    optional.setCode(request.getParameter("code"));
    optional.setPrice(RequestUtils.getDouble(request, "price"));
    optional.setRemark(request.getParameter("remark"));
    optional.setCreateDate(new Date());

    optional.setCreateBy(actorId);

    optionalService.save(optional);

    return this.list(request, modelMap);
}

From source file:com.glaf.oa.optional.web.springmvc.OptionalController.java

@ResponseBody
@RequestMapping("/saveOptional")
public byte[] saveOptional(HttpServletRequest request) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    Optional optional = new Optional();
    try {//from  w  w  w.j  a v  a2  s.  c  om
        Tools.populate(optional, params);
        optional.setId(RequestUtils.getInt(request, "id"));
        optional.setCode(request.getParameter("code"));
        optional.setPrice(RequestUtils.getDouble(request, "price"));
        optional.setRemark(request.getParameter("remark"));
        optional.setCreateBy(request.getParameter("createBy"));
        optional.setCreateDate(RequestUtils.getDate(request, "createDate"));
        optional.setUpdateDate(RequestUtils.getDate(request, "updateDate"));
        optional.setUpdateBy(request.getParameter("updateBy"));
        optional.setCreateBy(actorId);
        this.optionalService.save(optional);

        return ResponseUtils.responseJsonResult(true);
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    }
    return ResponseUtils.responseJsonResult(false);
}