Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

In this page you can find the example usage for java.util LinkedHashMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:org.openmeetings.servlet.outputhandler.UploadController.java

private LinkedHashMap<String, Object> prepareMessage(UploadInfo info) {
    LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
    hs.put("user", usersDao.getUser(info.userId));
    return hs;/*www  .j  a v a2 s  .c  o m*/
}

From source file:com.intel.iotkitlib.UserManagement.java

/**
 * Change the password for the user//from   w w w .j a  va  2  s .co m
 *
 * @param emailAddress    The email address of the user
 * @param currentPassword The current password for the user
 * @param newPassword     The new password for the user
 * @return For async model, return CloudResponse which wraps true if the request of REST
 * call is valid; otherwise false. The actual result from
 * the REST call is return asynchronously as part {@link RequestStatusHandler#readResponse}.
 * For synch model, return CloudResponse which wraps HTTP return code and response.
 * @throws JSONException
 */
public CloudResponse changePassword(String emailAddress, String currentPassword, String newPassword)
        throws JSONException {
    if (emailAddress == null || currentPassword == null || newPassword == null) {
        Log.d(TAG, ERR_INVALID_EMAIL);
        return new CloudResponse(false, ERR_INVALID_EMAIL);
    }
    String body;
    if ((body = createBodyForChangePassword(currentPassword, newPassword)) == null) {
        return new CloudResponse(false, ERR_INVALID_BODY);
    }
    //initiating put for change password request
    HttpPutTask changePassword = new HttpPutTask();
    changePassword.setHeaders(basicHeaderList);
    changePassword.setRequestBody(body);
    LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>();
    linkedHashMap.put("email", emailAddress);
    String url = objIotKit.prepareUrl(objIotKit.changePassword, linkedHashMap);
    return super.invokeHttpExecuteOnURL(url, changePassword);
}

From source file:com.cristian.tareask.controller.TaskController.java

@RequestMapping(value = "/tasks", method = RequestMethod.GET)
public String task(Model m, HttpSession session, @RequestParam(value = "view", required = false) String group) {

    List<Object> taskModel = new ArrayList<Object>();

    if ((session.getAttribute("namesession")) != null) {
        User u = new User();
        u = userService.getUserByName(session.getAttribute("namesession").toString());

        List<Task> t = new ArrayList<Task>();
        if (group != null) {
            t = taskService.getTasksGroupByUserId(u.getId());
        } else {/*from  w  w  w.ja  v a2s  .  c  om*/
            t = taskService.getTasksByUserId(u.getId());
        }

        for (int i = 0; i < t.size(); i++) {

            LinkedHashMap<String, Object> taskArray = new LinkedHashMap<>();
            LinkedHashMap<String, String> task = new LinkedHashMap<>();

            List<Milestone> milestones = milestoneService.getMilestonesByTask(t.get(i).getId());

            int close = 0;

            List<Object> milestonesArray = new ArrayList<Object>();
            for (int a = 0; a < milestones.size(); a++) {
                if ("close".equals(milestones.get(a).getMilestoneStatus().getStatus())) {
                    //percentage = ((done += 1)/milestones.size())*100;
                    close += 1;
                }

                LinkedHashMap<String, String> milestone = new LinkedHashMap<>();

                // Build Milestone
                milestone.put("id", milestones.get(a).getId().toString());
                milestone.put("title", milestones.get(a).getTitle());
                milestone.put("description", milestones.get(a).getDescription());
                milestone.put("status", milestones.get(a).getMilestoneStatus().getStatus());
                milestone.put("order", milestones.get(a).getOrder().toString());
                milestonesArray.add(milestone);

            }

            List<TaskReport> reports = taskReportService.getReportsByTask(t.get(i).getId());
            List<Object> reportsArray = new ArrayList<Object>();
            for (int b = 0; b < reports.size(); b++) {

                LinkedHashMap<String, String> report = new LinkedHashMap<>();

                report.put("id", reports.get(b).getId().toString());
                report.put("title", reports.get(b).getTitle());
                report.put("description", reports.get(b).getDescription());
                report.put("date", reports.get(b).getDate().toString());
                reportsArray.add(report);
            }

            List<Object> messagesArray = new ArrayList<Object>();
            if (group != null) {

                List<GroupMessage> messages = groupMessageService.getGroupMessagesByTask(t.get(i).getId());

                for (int c = 0; c < messages.size(); c++) {

                    LinkedHashMap<String, String> message = new LinkedHashMap<>();
                    message.put("id", messages.get(c).getId().toString());
                    message.put("group", messages.get(c).getGroup().getId().toString());
                    message.put("user",
                            messages.get(c).getUser().getName() + " " + messages.get(c).getUser().getSubname());
                    message.put("subject", messages.get(c).getSubject());
                    message.put("message", messages.get(c).getMessage());
                    message.put("date", messages.get(c).getDate().toString());
                    messagesArray.add(message);
                }
            }

            List<Incidence> incidences = incidenceService.getIncidencesByTaskId(t.get(i).getId());
            List<Object> incidencesArray = new ArrayList<Object>();
            Integer incidenceTotal = 0;
            for (int d = 0; d < incidences.size(); d++) {

                LinkedHashMap<String, String> incidence = new LinkedHashMap<>();
                incidence.put("id", incidences.get(d).getId().toString());
                incidence.put("title", incidences.get(d).getTitle());
                incidence.put("description", incidences.get(d).getDescription());
                incidence.put("date", incidences.get(d).getDate().toString());
                incidence.put("status", incidences.get(d).getIncidenceStatus().getStatus());
                if ("open".equals(incidences.get(d).getIncidenceStatus().getStatus())) {
                    incidenceTotal += 1;
                }
                incidencesArray.add(incidence);
            }

            //Build Task
            task.put("id", t.get(i).getId().toString());
            task.put("title", t.get(i).getTitle());
            task.put("description", t.get(i).getDescription());
            task.put("dateCreate", t.get(i).getDateCreate().toString());
            task.put("dateFinish", t.get(i).getDateFinish().toString());
            task.put("status", t.get(i).getTaskStatus().getStatus());
            if (t.get(i).getGroup() != null) {
                task.put("group", t.get(i).getGroup().toString());
            }
            if (t.get(i).getUser() != null) {
                task.put("userId", t.get(i).getUser().getId().toString());
            }
            task.put("priority", t.get(i).getTaskPriority().getPriority());

            Date today = new Date();
            Date dateTwo = t.get(i).getDateFinish();
            long diff = today.getTime() - dateTwo.getTime();
            long countDays = (diff / (1000 * 60 * 60 * 24));
            task.put("countDays", Long.toString((Math.abs(countDays))));

            double x = close;
            double y = milestones.size();
            double percentage = ((x / y) * 100);

            task.put("completed", Integer.toString((int) percentage));
            task.put("incidencetotal", incidenceTotal.toString());

            taskArray.put("task", task);
            taskArray.put("milestones", milestonesArray);
            taskArray.put("reports", reportsArray);
            taskArray.put("messages", messagesArray);
            taskArray.put("incidences", incidencesArray);
            taskModel.add(taskArray);
        }

        //m.addAttribute("taskslist", t);
        if (group != null) {
            m.addAttribute("group", group);
        }
        m.addAttribute("taskmodel", taskModel);
        return "views/tasks";
    }

    return "redirect:index.html";
}

From source file:com.logsniffer.reader.grok.GrokTextReader.java

@Override
public LinkedHashMap<String, FieldBaseTypes> getFieldTypes() throws FormatException {
    init();/*  w w  w.  j a  v  a2s. c  o m*/
    final LinkedHashMap<String, FieldBaseTypes> fields = super.getFieldTypes();
    fields.putAll(grokBean.getGrok(groksRegistry).getFieldTypes());
    if (overflowAttribute != null && !fields.containsKey(overflowAttribute)) {
        fields.put(overflowAttribute, FieldBaseTypes.STRING);
    }
    return fields;
}

From source file:com.intel.iotkitlib.RuleManagement.java

/**
 * Update the rule.//from   ww w. j a va  2 s .  com
 *
 * @param updateRuleObj the information that is used to update the rule with.
 * @param ruleId        the identifier for the rule to be updated.
 * @return For async model, return CloudResponse which wraps true if the request of REST
 * call is valid; otherwise false. The actual result from
 * the REST call is return asynchronously as part {@link RequestStatusHandler#readResponse}.
 * For synch model, return CloudResponse which wraps HTTP return code and response.
 * @throws JSONException
 */
public CloudResponse updateARule(Rule updateRuleObj, String ruleId) throws JSONException {
    if (updateRuleObj == null) {
        Log.d(TAG, ERR_INVALID_RULE);
        return new CloudResponse(false, ERR_INVALID_RULE);
    }
    String body;
    if ((body = createBodyForRuleCreation(updateRuleObj)) == null) {
        return new CloudResponse(false, ERR_INVALID_BODY);
    }
    //initiating put for rule updation
    HttpPutTask updateRule = new HttpPutTask();
    updateRule.setHeaders(basicHeaderList);
    updateRule.setRequestBody(body);
    LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>();
    linkedHashMap.put("rule_id", ruleId);
    String url = objIotKit.prepareUrl(objIotKit.updateRule, linkedHashMap);
    return super.invokeHttpExecuteOnURL(url, updateRule);
}

From source file:org.focusns.common.event.support.EventInterceptor.java

private Map<String, Object> getArguments(Method method, Object[] args) {
    LinkedHashMap<String, Object> argumentMap = new LinkedHashMap<String, Object>();
    String[] paramNames = paramNameDiscoverer.getParameterNames(method);
    if (paramNames != null) {
        for (int i = 0; i < paramNames.length; i++) {
            argumentMap.put(paramNames[i], args[i]);
        }/* ww w.  j  a  v a2  s .c  o m*/
    }
    return argumentMap;
}

From source file:com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatchDefault.java

@SuppressWarnings({ "rawtypes", "unchecked" })
protected LinkedHashMap toStringMapper() {
    LinkedHashMap m = new LinkedHashMap();

    m.put(FPPropertyConstants.UNIT_CODE, this.unitCode);

    return m;/*from w ww . j  a  va  2 s.  c  om*/
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by vessel
 * type. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.     /*ww  w  .j av a2s  .c  o m*/
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against vessel type.
 */
public JFreeChart createHistogramVesselType(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getVesselType())) {
            freqs_cats.put(ev.getVesselType(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getVesselType()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by vessel type", "Vessel Type",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:com.aerofs.baseline.errors.BaseExceptionMapper.java

@Nullable
private String constructEntity(T throwable) {
    LinkedHashMap<String, Object> errorFields = Maps.newLinkedHashMap();

    int errorCode = getErrorCode(throwable);
    String errorName = getErrorName(throwable);
    String errorType = throwable.getClass().getSimpleName();
    String errorText = getErrorText(throwable);

    errorFields.put("error_code", errorCode);
    errorFields.put("error_name", errorName);
    errorFields.put("error_type", errorType);

    addErrorFields(throwable, errorFields);

    if (errorText != null) {
        errorFields.put("error_text", errorText);
    }/*from  w  ww . j  a  v a2s  .co m*/

    if (responseEntity == ErrorResponseEntity.INCLUDE_STACK_IN_RESPONSE) {
        errorFields.put("error_trace", Throwables.getStackTraceAsString(throwable));
    }

    try {
        return MAPPER.writeValueAsString(errorFields);
    } catch (JsonProcessingException e) {
        return String.format(
                "{\"error_code\":\"%d\",\"error_name\":\"%s\",\"error_type\":\"%s\",\"error_text\":\"%s\",\"error_trace\":\"%s\"}",
                errorCode, errorName, throwable.getClass().getSimpleName(), errorText,
                Throwables.getStackTraceAsString(throwable));
    }
}

From source file:com.johan.vertretungsplan.parser.UntisMonitorParser.java

public Vertretungsplan getVertretungsplan() throws IOException, JSONException {
    new LoginHandler(schule).handleLogin(executor, cookieStore, username, password); //

    JSONArray urls = schule.getData().getJSONArray("urls");
    String encoding = schule.getData().getString("encoding");
    List<Document> docs = new ArrayList<Document>();

    for (int i = 0; i < urls.length(); i++) {
        JSONObject url = urls.getJSONObject(i);
        loadUrl(url.getString("url"), encoding, url.getBoolean("following"), docs);
    }/*  w ww  .  j  a  v  a  2  s. c  o  m*/

    LinkedHashMap<String, VertretungsplanTag> tage = new LinkedHashMap<String, VertretungsplanTag>();
    for (Document doc : docs) {
        if (doc.title().contains("Untis")) {
            VertretungsplanTag tag = parseMonitorVertretungsplanTag(doc, schule.getData());
            if (!tage.containsKey(tag.getDatum())) {
                tage.put(tag.getDatum(), tag);
            } else {
                VertretungsplanTag tagToMerge = tage.get(tag.getDatum());
                tagToMerge.merge(tag);
                tage.put(tag.getDatum(), tagToMerge);
            }
        } else {
            //Fehler
        }
    }
    Vertretungsplan v = new Vertretungsplan();
    v.setTage(new ArrayList<VertretungsplanTag>(tage.values()));

    return v;
}