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:com.jaspersoft.jasperserver.jaxrs.poc.hypermedia.common.representation.Link.java

@Override
public LinkedHashMap<Relation, EmbeddedElement> toMap() {
    LinkedHashMap<Relation, EmbeddedElement> map = new LinkedHashMap<Relation, EmbeddedElement>();
    map.put(relation, this);
    return map;// w w w. j a  v  a 2  s  .co  m
}

From source file:org.obiba.mica.core.service.SchemaFormContentFileService.java

private void saveFiles(Iterable files, String entityPath) {
    if (files != null)
        files.forEach(file -> {/* w w w.j a  va 2  s  .  c o m*/
            LinkedHashMap map = (LinkedHashMap) file;
            map.put("path", entityPath);
            fileStoreService.save(map.get("id").toString());
        });
}

From source file:net.opentsdb.ConfigReader.java

public static String[] load(final Config config, final String[] args) {
    InputStream is = null;//from w ww  .ja  v a2s  .c om
    String[] noConfigArgs = {};
    try {

        is = ConfigReader.class.getClassLoader().getResourceAsStream(CONFIG_PATH);
        ArrayNode an = (ArrayNode) JSON.getMapper().readTree(is);
        final LinkedHashMap<String, ConfigurationItem> citems = new LinkedHashMap<String, ConfigurationItem>(
                an.size());
        final HashMap<String, ConfigurationItem> clOptions = new HashMap<String, ConfigurationItem>();
        for (int i = 0; i < an.size(); i++) {
            JsonNode jn = an.get(i);
            ConfigurationItem ci = JSON.getMapper().convertValue(jn, ConfigurationItem.class);
            ci.resolve();
            if (ci.getCl() != null) {
                clOptions.put(ci.getCl(), ci);
            }
            if (ci.getValue() != null) {
                //config.overrideConfig(ci.getKey(), ci.getValue().toString());
                ci.validate();
                citems.put(ci.getKey(), ci);
            }
            //System.out.println(ci.dump());
        }

        final ArgP argp = newArgP();
        noConfigArgs = argp.parse(args);
        final Map<String, String> argpOptions = argp.getParsed();
        if (!argpOptions.isEmpty()) {
            for (Map.Entry<String, String> entry : argpOptions.entrySet()) {
                ConfigurationItem argCi = clOptions.get(entry.getKey());
                if (argCi != null) {
                    argCi.setValueAsText(entry.getValue());
                    citems.put(argCi.getKey(), argCi);
                }
            }
        }
        // Write the configuration to an OpenTSDB config         
        for (ConfigurationItem configItem : citems.values()) {
            config.overrideConfig(configItem.getKey(), configItem.getValueStr());
        }
        return noConfigArgs;
    } catch (Exception ex) {
        throw new RuntimeException("Failed to load resource [" + CONFIG_PATH + "]", ex);
    }
}

From source file:org.kitodo.data.index.elasticsearch.type.ProjectType.java

@SuppressWarnings("unchecked")
@Override//  w  w  w  .j  av  a 2s .  com
public HttpEntity createDocument(Project project) {

    LinkedHashMap<String, String> orderedProjectMap = new LinkedHashMap<>();
    orderedProjectMap.put("name", project.getTitle());
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String startDate = project.getStartDate() != null ? dateFormat.format(project.getStartDate()) : null;
    orderedProjectMap.put("startDate", startDate);
    String endDate = project.getEndDate() != null ? dateFormat.format(project.getEndDate()) : null;
    orderedProjectMap.put("endDate", endDate);
    String numberOfPages = project.getNumberOfPages() != null ? project.getNumberOfPages().toString() : "null";
    orderedProjectMap.put("numberOfPages", numberOfPages);
    String numberOfVolumes = project.getNumberOfVolumes() != null ? project.getNumberOfVolumes().toString()
            : "null";
    orderedProjectMap.put("numberOfVolumes", numberOfVolumes);
    String archived = project.getProjectIsArchived() != null ? project.getProjectIsArchived().toString()
            : "null";
    orderedProjectMap.put("archived", archived);

    JSONObject projectObject = new JSONObject(orderedProjectMap);

    JSONArray processes = new JSONArray();
    List<Process> projectProcesses = project.getProcesses();
    for (Process process : projectProcesses) {
        JSONObject processObject = new JSONObject();
        processObject.put("id", process.getId().toString());
        processes.add(processObject);
    }
    projectObject.put("processes", processes);

    JSONArray users = new JSONArray();
    List<User> projectUsers = project.getUsers();
    for (User user : projectUsers) {
        JSONObject userObject = new JSONObject();
        userObject.put("id", user.getId().toString());
        users.add(userObject);
    }
    projectObject.put("users", users);

    JSONArray projectFileGroups = new JSONArray();
    List<ProjectFileGroup> projectProjectFileGroups = project.getProjectFileGroups();
    for (ProjectFileGroup projectFileGroup : projectProjectFileGroups) {
        JSONObject projectFileGroupObject = new JSONObject();
        projectFileGroupObject.put("name", projectFileGroup.getName());
        projectFileGroupObject.put("path", projectFileGroup.getPath());
        projectFileGroupObject.put("mimeType", projectFileGroup.getMimeType());
        projectFileGroupObject.put("suffix", projectFileGroup.getSuffix());
        projectFileGroupObject.put("folder", projectFileGroup.getFolder());
        projectFileGroups.add(projectFileGroupObject);
    }
    projectObject.put("projectFileGroups", projectFileGroups);

    return new NStringEntity(projectObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.logsniffer.fields.filter.support.AbstractTransformationFilter.java

@Override
public final void filterKnownFields(final LinkedHashMap<String, FieldBaseTypes> knownFields) {
    knownFields.put(targetField, getTargetType());
}

From source file:com.fortify.bugtracker.tgt.tfs.processor.TFSTargetProcessorSubmitIssues.java

@Override
protected TargetIssueLocator submitIssue(Context context, LinkedHashMap<String, Object> issueData) {
    TFSRestConnection conn = TFSConnectionFactory.getConnection(context);
    issueData.put("System.Title", StringUtils.abbreviate((String) issueData.get("System.Title"), 254));
    return conn.submitIssue(ICLIOptionsTFS.CLI_TFS_COLLECTION.getValue(context),
            ICLIOptionsTFS.CLI_TFS_PROJECT.getValue(context), getWorkItemType(), issueData);
}

From source file:org.kitodo.data.index.elasticsearch.type.TaskType.java

@SuppressWarnings("unchecked")
@Override// w ww  . java 2  s .  c o  m
public HttpEntity createDocument(Task task) {

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    LinkedHashMap<String, String> orderedTaskMap = new LinkedHashMap<>();
    orderedTaskMap.put("title", task.getTitle());
    String priority = task.getPriority() != null ? task.getPriority().toString() : "null";
    orderedTaskMap.put("priority", priority);
    String ordering = task.getOrdering() != null ? task.getOrdering().toString() : "null";
    orderedTaskMap.put("ordering", ordering);
    String processingStatus = task.getProcessingStatusEnum() != null ? task.getProcessingStatusEnum().toString()
            : "null";
    orderedTaskMap.put("processingStatus", processingStatus);
    String processingTime = task.getProcessingTime() != null ? dateFormat.format(task.getProcessingTime())
            : null;
    orderedTaskMap.put("processingTime", processingTime);
    String processingBegin = task.getProcessingBegin() != null ? dateFormat.format(task.getProcessingBegin())
            : null;
    orderedTaskMap.put("processingBegin", processingBegin);
    String processingEnd = task.getProcessingEnd() != null ? dateFormat.format(task.getProcessingEnd()) : null;
    orderedTaskMap.put("processingEnd", processingEnd);
    orderedTaskMap.put("homeDirectory", String.valueOf(task.getHomeDirectory()));
    orderedTaskMap.put("typeMetadata", String.valueOf(task.isTypeMetadata()));
    orderedTaskMap.put("typeAutomatic", String.valueOf(task.isTypeAutomatic()));
    orderedTaskMap.put("typeImportFileUpload", String.valueOf(task.isTypeImportFileUpload()));
    orderedTaskMap.put("typeExportRussian", String.valueOf(task.isTypeExportRussian()));
    orderedTaskMap.put("typeImagesRead", String.valueOf(task.isTypeImagesRead()));
    orderedTaskMap.put("typeImagesWrite", String.valueOf(task.isTypeImagesWrite()));
    orderedTaskMap.put("batchStep", String.valueOf(task.isBatchStep()));
    String processingUser = task.getProcessingUser() != null ? task.getProcessingUser().getId().toString()
            : "null";
    orderedTaskMap.put("processingUser", processingUser);
    String process = task.getProcess() != null ? task.getProcess().getId().toString() : "null";
    orderedTaskMap.put("process", process);

    JSONObject taskObject = new JSONObject(orderedTaskMap);

    JSONArray users = new JSONArray();
    List<User> taskUsers = task.getUsers();
    for (User user : taskUsers) {
        JSONObject propertyObject = new JSONObject();
        propertyObject.put("id", user.getId());
        users.add(propertyObject);
    }
    taskObject.put("users", users);

    JSONArray userGroups = new JSONArray();
    List<UserGroup> taskUserGroups = task.getUserGroups();
    for (UserGroup userGroup : taskUserGroups) {
        JSONObject userGroupObject = new JSONObject();
        userGroupObject.put("id", userGroup.getId().toString());
        userGroups.add(userGroupObject);
    }
    taskObject.put("userGroups", userGroups);

    return new NStringEntity(taskObject.toJSONString(), ContentType.APPLICATION_JSON);
}

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

@RequestMapping(value = "/import.upload", method = RequestMethod.POST)
protected void service(HttpServletRequest request, HttpServletResponse httpServletResponse)
        throws ServletException {

    UploadInfo info = validate(request, true);
    try {// w  w  w  .  ja  va 2 s  . c  om
        String moduleName = request.getParameter("moduleName");
        if (moduleName == null) {
            moduleName = "moduleName";
        }
        log.debug("moduleName: " + moduleName);
        InputStream is = info.file.getInputStream();

        if (moduleName.equals("users")) {
            log.error("Import Users");
            userImport.addUsersByDocument(is);

        } else if (moduleName.equals("language")) {
            log.error("Import Language");
            String language = request.getParameter("secondid");
            if (language == null) {
                language = "0";
            }
            Long language_id = Long.valueOf(language).longValue();
            log.debug("language_id: " + language_id);

            languageImport.addLanguageByDocument(language_id, is);
        }

        log.debug("Return And Close");

        LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
        hs.put("user", usersDao.getUser(info.userId));
        hs.put("message", "library");
        hs.put("action", "import");

        log.debug("moduleName.equals(userprofile) ? " + moduleName);

        log.debug("moduleName.equals(userprofile) ! ");

        scopeApplicationAdapter.sendMessageWithClientByPublicSID(hs, info.publicSID);

    } catch (Exception er) {
        log.error("ERROR importing:", er);
        throw new ServletException(er);
    }
}

From source file:org.eda.fpsrv.StrTable.java

public String toJSONString() throws JsonProcessingException {
    LinkedHashMap<String, String> h_map = new LinkedHashMap<>();
    for (String key : keySet())
        h_map.put(key, get(key));
    //        return new Gson().toJson(h_map, h_map.getClass());
    return new ObjectMapper().writeValueAsString(h_map);
}

From source file:com.fortify.bugtracker.tgt.jira.processor.JiraTargetProcessorSubmitIssues.java

@Override
protected TargetIssueLocator submitIssue(Context context, LinkedHashMap<String, Object> issueFields) {
    JiraRestConnection conn = JiraConnectionFactory.getConnection(context);
    issueFields.put("project.key", ICLIOptionsJira.CLI_JIRA_PROJECT_KEY.getValue(context));
    issueFields.put("issuetype.name", getIssueType());
    issueFields.put("summary", StringUtils.abbreviate((String) issueFields.get("summary"), 254));
    return conn.submitIssue(issueFields);
}