Esempio n. 1
0
  @ResponseBody
  @RequestMapping(value = "chooseJobs", method = RequestMethod.POST, produces = MediaTypes.JSON)
  public Map<String, Object> chooseJobs(@RequestParam("id") Integer id) {
    /**
     * 根节点下不会直接挂载作业,其他节点下可以挂载子节点和作业
     *
     * <p>如果传入的id是0,代表根节点,此时获取根节点下所有子节点 当点击一个子节点后,判断此节点是否为智能节点,如果是智能节点,则查找smart_group_query表
     * 如果是非智能节点,则获取此节点下的子节点和作业 GROUP_TYPE_ID=9 代表智能节点; GROUP_TYPE_ID=4代表非智能节点
     */
    List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
    if (id == 0) {
      List<GroupBean> firstLevelJobGroupList = groupService.findFirstLevelJobGroup();
      groupBeanList.addAll(firstLevelJobGroupList);
    } else {
      List<GroupBean> childJobGroup = groupService.findChildJobGroup(id);
      groupBeanList.addAll(childJobGroup);

      BLGroup groupNode = groupService.findByGroupId(id);
      if (groupNode.getGROUP_TYPE_ID() == 4) {
        List<GroupBean> staticJobList = groupService.findStaticJob(groupNode);
        groupBeanList.addAll(staticJobList);
      } else {
        List<GroupBean> smartJobList = groupService.findSmartJob(groupNode);
        groupBeanList.addAll(smartJobList);
      }
    }

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("data", groupBeanList);
    return resultMap;
  }
Esempio n. 2
0
  @ResponseBody
  @RequestMapping(
      value = "chooseDeviceBYBBSA",
      method = RequestMethod.POST,
      produces = MediaTypes.JSON)
  public Map<String, Object> chooseDeviceBYBBSA(
      @RequestParam("id") Integer id, HttpServletRequest request) throws SQLException {
    List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
    if (id == 0) {
      List<GroupBean> firstLevelDeviceList = groupService.findFirstLevelDeviceGroup();
      groupBeanList.addAll(firstLevelDeviceList);
    } else {
      List<GroupBean> childDeviceGroup = groupService.findDeviceGroupWithId(id);
      groupBeanList.addAll(childDeviceGroup);

      BLGroup groupNode = groupService.findByGroupId(id);
      if (groupNode.getGROUP_TYPE_ID() == 1) {
        List<GroupBean> staticDeviceList = groupService.findStaticDeviceNode(id);
        groupBeanList.addAll(staticDeviceList);
      } else {
        List<GroupBean> smartDeviceList = groupService.findSmartDeviceNode(id);
        groupBeanList.addAll(smartDeviceList);
      }
    }

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("data", groupBeanList);
    // resultMap.put("data",deviceFilter.deviceFilterRole(groupBeanList,UserNameUtil.getUserNameByRequest(request)) );
    return resultMap;
  }
Esempio n. 3
0
  /** GET /users/suggestions -> suggest users to follow */
  @RequestMapping(
      value = "/rest/users/suggestions",
      method = RequestMethod.GET,
      produces = "application/json")
  @ResponseBody
  public Collection<User> suggestions() {
    User currentUser = userService.getCurrentUser();
    final String login = currentUser.getLogin();
    if (log.isDebugEnabled()) {
      log.debug("REST request to get the last active tweeters list (except " + login + ").");
    }

    Collection<String> exceptions = userService.getFriendsForUser(login);
    exceptions.add(login);

    Collection<Tweet> tweets = timelineService.getDayline("");
    Map<String, User> users = new HashMap<String, User>();
    for (Tweet tweet : tweets) {
      if (exceptions.contains(tweet.getLogin())) continue;

      users.put(tweet.getLogin(), userService.getUserProfileByLogin(tweet.getLogin()));
      if (users.size() == 3) break; // suggestions list limit
    }
    return users.values();
  }
 /**
  * 把list转为map 方便查找
  *
  * @param list 数据库有效数据列表
  * @return map
  */
 private <T extends TrendValue> Map<String, T> tomap(List<T> list) {
   Map<String, T> map = new LinkedHashMap<>();
   for (T value : list) {
     map.put(value.getDate(), value);
   }
   return map;
 }
 /**
  * 填充数据
  *
  * @param list 数据库有效数据列表
  * @return 填充的数据
  */
 private <T extends TrendValue> List<T> fulldata(
     List<T> list, DateFormat format, int field, Date start, Date end, Class<T> clazz) {
   Map<String, T> map = tomap(list);
   Calendar calendar = Calendar.getInstance();
   calendar.setTime(start);
   List<T> nlist = new ArrayList<>();
   while (calendar.getTime().before(end)) {
     String keytime = format.format(calendar.getTime());
     T value = map.get(keytime);
     if (value == null) {
       value = AfReflecter.newInstance(clazz);
       value.setEmpty();
       value.setDate(keytime);
       value.setTime(calendar.getTime());
       nlist.add(value);
     } else {
       nlist.add(value);
       map.remove(keytime);
     }
     calendar.add(field, 1);
   }
   for (Map.Entry<String, T> entry : map.entrySet()) {
     nlist.add(entry.getValue());
   }
   return nlist;
 }
Esempio n. 6
0
 @RequestMapping(value = "/productos", params = "term", produces = "application/json")
 public @ResponseBody List<LabelValueBean> productos(
     HttpServletRequest request, @RequestParam("term") String filtro) {
   for (String nombre : request.getParameterMap().keySet()) {
     log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
   }
   Map<String, Object> params = new HashMap<>();
   params.put("almacen", request.getSession().getAttribute("almacenId"));
   params.put("filtro", filtro);
   params = productoDao.lista(params);
   List<LabelValueBean> valores = new ArrayList<>();
   List<Producto> productos = (List<Producto>) params.get("productos");
   for (Producto producto : productos) {
     StringBuilder sb = new StringBuilder();
     sb.append(producto.getSku());
     sb.append(" | ");
     sb.append(producto.getNombre());
     sb.append(" | ");
     sb.append(producto.getDescripcion());
     sb.append(" | ");
     sb.append(producto.getExistencia()).append(" ").append(producto.getUnidadMedida());
     sb.append(" | ");
     sb.append(producto.getPrecioUnitario());
     valores.add(new LabelValueBean(producto.getId(), sb.toString()));
   }
   return valores;
 }
 public Map<String, String> toParamsMap(JSONObject json) throws JSONException {
   Map<String, String> retMap = new HashMap<String, String>();
   Iterator<String> keysItr = json.keys();
   while (keysItr.hasNext()) {
     String key = keysItr.next();
     String value = (String) json.get(key);
     retMap.put(key, value);
   }
   return retMap;
 }
Esempio n. 8
0
 @ResponseBody
 @RequestMapping(value = "searchJobs", method = RequestMethod.POST, produces = MediaTypes.JSON)
 public Map<String, Object> searchJobs(
     @RequestParam("name") String name,
     @RequestParam("value") String value,
     HttpServletRequest request,
     HttpServletResponse response) {
   Map<String, Object> resultMap = new HashMap<String, Object>();
   resultMap.put("data", blGroupService.findJobByQuery(name, value));
   return resultMap;
 }
Esempio n. 9
0
 @RequestMapping(value = "/events/{name}", method = GET)
 public Map<String, Object> getSingleEvent(
     @PathVariable("name") String eventName, Principal principal) {
   Map<String, Object> out = new HashMap<>();
   final String username = principal.getName();
   final EventWithStatistics event =
       eventStatisticsManager.getSingleEventWithStatistics(eventName, username);
   out.put("event", event);
   out.put("organization", eventManager.loadOrganizer(event.getEvent(), username));
   return out;
 }
  private static String getCommaseparatedStringFromList(List controllIdList) {
    StringBuilder result = new StringBuilder();

    for (int i = 0; i < controllIdList.size(); i++) {
      Map map = (Map) controllIdList.get(i);
      if (map.get("control_ids") != null) {
        result.append(map.get("control_ids"));
        result.append(",");
      }
    }
    return result.length() > 0 ? result.substring(0, result.length() - 1) : "";
  }
Esempio n. 11
0
 @ResponseBody
 @RequestMapping(value = "findJobGroup/{id}", method = RequestMethod.GET)
 public Map<String, String> findJobGroup(@PathVariable("id") Integer id) {
   BLGroup blGroup = groupService.getGroupNodeWithChildNode(id);
   Map<String, String> map = new LinkedHashMap<String, String>();
   map.put(blGroup.getGROUP_ID().toString(), blGroup.getNAME());
   while (blGroup.getPARENT_GROUP_ID() != 0 && !"Jobs".equals(blGroup.getNAME())) {
     blGroup = groupService.getGroupNodeWithChildNode(blGroup.getPARENT_GROUP_ID());
     map.put(blGroup.getGROUP_ID().toString(), blGroup.getNAME());
   }
   return map;
 }
 @RequiresPermissions({"categoryWord-get"})
 @RequestMapping(
     method = RequestMethod.POST,
     value = "/query",
     headers = "Accept=application/json")
 public @ResponseBody Map<String, Object> query(@RequestBody Map<String, String> params) {
   List<CategoryWord> rows = categoryWordService.findLikeAnyWhere(params);
   Map<String, Object> result = new HashMap<String, Object>();
   result.put("total", rows.size());
   result.put("rows", rows);
   return result;
 }
 /*
  * TODO: Refactor this code.
  */
 private byte[] signMethod(Map<String, String> parameters) throws NoSuchAlgorithmException {
   String toHash = "";
   List<String> paramNames = new ArrayList<String>(parameters.keySet());
   Collections.sort(paramNames);
   for (String paramName : paramNames) {
     toHash += paramName + parameters.get(paramName);
   }
   toHash += SECRET;
   byte[] hashMe = toHash.getBytes();
   MessageDigest mg = MessageDigest.getInstance("md5");
   hashMe = mg.digest(hashMe);
   return hashMe;
 }
  @RequestMapping(method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_REPORT_READ)
  public @ResponseBody void getNumberOfEarlyAlertsByReasons(
      final HttpServletResponse response,
      final @RequestParam(required = false) UUID campusId,
      final @RequestParam(required = false) String termCode,
      final @RequestParam(required = false) Date createDateFrom,
      final @RequestParam(required = false) Date createDateTo,
      final @RequestParam(required = false) ObjectStatus objectStatus,
      final @RequestParam(required = false, defaultValue = DEFAULT_REPORT_TYPE) String reportType)
      throws ObjectNotFoundException, IOException {

    final DateTerm dateTerm = new DateTerm(createDateFrom, createDateTo, termCode, termService);
    final Map<String, Object> parameters = Maps.newHashMap();
    final Campus campus = SearchParameters.getCampus(campusId, campusService);

    if (StringUtils.isBlank(termCode)
        || termCode.trim().toLowerCase().equals("not used") && createDateFrom != null) {
      dateTerm.setTerm(null);
    } else if (termCode != null && createDateFrom == null) {
      dateTerm.setStartEndDates(null, null);
    }

    SearchParameters.addCampusToParameters(campus, parameters);
    SearchParameters.addDateTermToMap(dateTerm, parameters);

    List<Triple<String, Long, Long>> reasonTotals =
        earlyAlertService.getEarlyAlertReasonTypeCountByCriteria(
            campus,
            dateTerm.getTermCodeNullPossible(),
            dateTerm.getStartDate(),
            dateTerm.getEndDate(),
            objectStatus);

    List<EarlyAlertReasonCountsTO> results =
        earlyAlertService.getStudentEarlyAlertReasonCountByCriteria(
            dateTerm.getTermCodeNullPossible(),
            dateTerm.getStartDate(),
            dateTerm.getEndDate(),
            campus,
            objectStatus);

    if (results == null) {
      results = new ArrayList<>();
    }

    SearchParameters.addDateTermToMap(dateTerm, parameters);
    parameters.put(REASON_TOTALS, reasonTotals);

    renderReport(response, parameters, results, REPORT_URL, reportType, REPORT_FILE_TITLE);
  }
  /**
   * 类别词chineseWord唯一性验证
   *
   * @param chineseWord
   * @return
   */
  @RequestMapping(
      method = RequestMethod.GET,
      value = "/uniqueValidName",
      headers = "Accept=application/json")
  public @ResponseBody boolean uniqueValidName(String chineseWord) {
    Map<String, String> map = new HashMap<String, String>();
    try {
      chineseWord = URLDecoder.decode(chineseWord, "UTF-8");
    } catch (UnsupportedEncodingException e) {

    }
    map.put("chineseWord", chineseWord);
    return categoryWordService.uniqueValid(map);
  }
Esempio n. 16
0
  /**
   * Handles requests with message handler implementation. Previously sets Http request method as
   * header parameter.
   *
   * @param method
   * @param requestEntity
   * @return
   */
  private ResponseEntity<String> handleRequestInternal(
      HttpMethod method, HttpEntity<String> requestEntity) {
    Map<String, ?> httpRequestHeaders = headerMapper.toHeaders(requestEntity.getHeaders());
    Map<String, String> customHeaders = new HashMap<String, String>();
    for (Entry<String, List<String>> header : requestEntity.getHeaders().entrySet()) {
      if (!httpRequestHeaders.containsKey(header.getKey())) {
        customHeaders.put(
            header.getKey(), StringUtils.collectionToCommaDelimitedString(header.getValue()));
      }
    }

    HttpServletRequest request =
        ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    UrlPathHelper pathHelper = new UrlPathHelper();

    customHeaders.put(CitrusHttpMessageHeaders.HTTP_REQUEST_URI, pathHelper.getRequestUri(request));
    customHeaders.put(
        CitrusHttpMessageHeaders.HTTP_CONTEXT_PATH, pathHelper.getContextPath(request));

    String queryParams = pathHelper.getOriginatingQueryString(request);
    customHeaders.put(
        CitrusHttpMessageHeaders.HTTP_QUERY_PARAMS, queryParams != null ? queryParams : "");

    customHeaders.put(CitrusHttpMessageHeaders.HTTP_REQUEST_METHOD, method.toString());

    Message<?> response =
        messageHandler.handleMessage(
            MessageBuilder.withPayload(requestEntity.getBody())
                .copyHeaders(convertHeaderTypes(httpRequestHeaders))
                .copyHeaders(customHeaders)
                .build());

    return generateResponse(response);
  }
  void Initialize() throws Exception {
    try {

      departamentos = divisionPoliticaService.getAllDepartamentos();
      catClasif = catalogoService.getClasificacionesFinalRotavirus();
      catResp = catalogoService.getRespuesta();
      registroVacunas = catalogoService.getRegistrosVacuna();
      tipoVacunaRotavirus = catalogoService.getTiposVacunasRotavirus();
      caracteristaHeceses = catalogoService.getCaracteristasHeces();
      gradoDeshidratacions = catalogoService.getGradosDeshidratacion();
      condicionEgresos = catalogoService.getCondicionEgreso();
      salaRotaVirusList = catalogoService.getSalasRotaVirus();

      mapModel = new HashMap<>();

      mapModel.put("departamentos", departamentos);
      mapModel.put("catClasif", catClasif);
      mapModel.put("catResp", catResp);
      mapModel.put("registroVacunas", registroVacunas);
      mapModel.put("tipoVacunaRotavirus", tipoVacunaRotavirus);
      mapModel.put("caracteristaHeceses", caracteristaHeceses);
      mapModel.put("gradoDeshidratacions", gradoDeshidratacions);
      mapModel.put("condicionEgresos", condicionEgresos);
      mapModel.put("salas", salaRotaVirusList);

    } catch (Exception ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
Esempio n. 18
0
 @ResponseBody
 @RequestMapping(
     value = "searchDeviceBYBBSA",
     method = RequestMethod.POST,
     produces = MediaTypes.JSON)
 public Map<String, Object> searchDeviceBYBBSA(
     @RequestParam("deviceIP") String deviceIP, HttpServletRequest request) {
   List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
   groupBeanList = deviceService.findDeviceByIP(entityManager, deviceIP);
   // groupBeanList=
   // deviceFilter.deviceFilterRole(groupBeanList,UserNameUtil.getUserNameByRequest(request));
   Map<String, Object> resultMap = new HashMap<String, Object>();
   resultMap.put("data", groupBeanList);
   return resultMap;
 }
Esempio n. 19
0
  /**
   * Checks for collection typed header values and convert them to comma delimited String. We need
   * this for further header processing e.g when forwarding headers to JMS queues.
   *
   * @param headers the http request headers.
   */
  private Map<String, Object> convertHeaderTypes(Map<String, ?> headers) {
    Map<String, Object> convertedHeaders = new HashMap<String, Object>();

    for (Entry<String, ?> header : headers.entrySet()) {
      if (header.getValue() instanceof Collection<?>) {
        Collection<?> value = (Collection<?>) header.getValue();
        convertedHeaders.put(header.getKey(), StringUtils.collectionToCommaDelimitedString(value));
      } else if (header.getValue() instanceof MediaType) {
        convertedHeaders.put(header.getKey(), header.getValue().toString());
      } else {
        convertedHeaders.put(header.getKey(), header.getValue());
      }
    }

    return convertedHeaders;
  }
 @ModelAttribute("poolSettings")
 public PoolSettings getPoolSettings(
     /*@PathVariable("accountId") Long accountId,
     @PathVariable("poolId") Long poolId */ HttpServletRequest request) {
   //        return getAccountPool( accountId, poolId ).getPoolSettings();
   Map pathVariables =
       (Map)
           request.getAttribute(
               "org.springframework.web.servlet.HandlerMapping.uriTemplateVariables");
   if (pathVariables.containsKey("accountId") && pathVariables.containsKey("poolId")) {
     long accountId = Long.parseLong((String) pathVariables.get("accountId"));
     long poolId = Long.parseLong((String) pathVariables.get("poolId"));
     return poolDao.readPoolByIdAndAccountId(poolId, accountId).getPoolSettings();
   } else {
     return null;
   }
 }
  /**
   * Guardar datos de una notificación rotavirus (agregar o actualizar)
   *
   * @param request con los datos de la notificación
   * @param response con el resultado de la acción
   * @throws ServletException
   * @throws IOException
   */
  @RequestMapping(
      value = "save",
      method = RequestMethod.POST,
      consumes = MediaType.APPLICATION_JSON_VALUE,
      produces = "application/json")
  protected void save(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String json = "";
    String resultado = "";
    String idNotificacion = "";
    try {
      logger.debug("Guardando datos de Ficha Rotavirus");
      BufferedReader br =
          new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF8"));
      json = br.readLine();
      FichaRotavirus fichaRotavirus = jSonToFichaRotavirus(json);
      if (fichaRotavirus.getDaNotificacion() == null) {
        DaNotificacion noti = guardarNotificacion(json, request);
        fichaRotavirus.setDaNotificacion(noti);
      } else {
        if (fichaRotavirus.getFechaInicioDiarrea() != null) {
          fichaRotavirus
              .getDaNotificacion()
              .setFechaInicioSintomas(fichaRotavirus.getFechaInicioDiarrea());
          daNotificacionService.updateNotificacion(fichaRotavirus.getDaNotificacion());
        }
      }
      rotaVirusService.saveOrUpdate(fichaRotavirus);
      idNotificacion = fichaRotavirus.getDaNotificacion().getIdNotificacion();
    } catch (Exception ex) {
      logger.error(ex.getMessage(), ex);
      ex.printStackTrace();
      resultado = messageSource.getMessage("msg.error.save.rota", null, null);
      resultado = resultado + ". \n " + ex.getMessage();

    } finally {
      Map<String, String> map = new HashMap<String, String>();
      map.put("mensaje", resultado);
      map.put("idNotificacion", idNotificacion);
      String jsonResponse = new Gson().toJson(map);
      response.getOutputStream().write(jsonResponse.getBytes());
      response.getOutputStream().close();
    }
  }
 @RequiresPermissions({"categoryWord-get"})
 @RequestMapping(
     method = RequestMethod.GET,
     value =
         "/get/EnglishWord/{englishWord}/ChineseWord/{chineseWord}/EsglisgAb/{esglisgAb}/Remark/{remark}",
     headers = "Accept=application/json")
 public @ResponseBody List<CategoryWord> getByParams(
     @PathVariable(value = "englishWord") String englishWord,
     @PathVariable(value = "chineseWord") String chineseWord,
     @PathVariable(value = "esglisgAb") String esglisgAb,
     @PathVariable(value = "remark") String remark) {
   Map<String, String> params = new HashMap<String, String>();
   if (!"isNull".equals(englishWord)) params.put("englishWord", englishWord);
   if (!"isNull".equals(chineseWord)) params.put("chineseWord", chineseWord);
   if (!"isNull".equals(esglisgAb)) params.put("esglisgAb", esglisgAb);
   if (!"isNull".equals(remark)) params.put("remark", remark);
   List<CategoryWord> words = categoryWordService.findBy(params);
   return words;
 }
  /** @return poolConfigurationId => poolStatus map. */
  @RequestMapping(value = "/admin/pools/status", method = RequestMethod.GET)
  @ResponseBody
  public Map<Long, PoolStatus> getPoolsStatus() {
    Map<Long /* poolConfigurationId */, PoolStatus> resultMap = new HashMap<Long, PoolStatus>();
    // get pool status for all pools
    Collection<PoolStatus> poolStatuses = poolManagerApi.listStatuses();
    // map every status found to its pool configuration
    List<PoolConfigurationModel> poolConfigurationModels = poolDao.readPools();
    for (PoolConfigurationModel poolConfiguration : poolConfigurationModels) {
      Long poolConfigurationId = poolConfiguration.getId();

      for (PoolStatus poolStatus : poolStatuses) {
        if (poolStatus.getPoolId().equals(poolConfiguration.getPoolSettings().getUuid())) {
          resultMap.put(poolConfigurationId, poolStatus);
        }
      }
    }

    return resultMap;
  }
 @Scheduled(cron = "${scheduled.cron}")
 public void countTechnicalJobs() {
   jsonConfigRepository
       .getSkillConfig()
       .stream()
       .forEach(
           term -> {
             Map<String, Double> avgSalary =
                 vietnamWorksJobStatisticService.getAverageSalaryBySkill(term, JOB_LEVEL_ALL);
             messagingTemplate.convertAndSend(
                 "/topic/jobs/term/" + term.getKey(),
                 new TechnicalTermResponse.Builder()
                     .withTerm(term.getKey())
                     .withLabel(term.getLabel())
                     .withAverageSalaryMin(avgSalary.get("SALARY_MIN"))
                     .withAverageSalaryMax(avgSalary.get("SALARY_MAX"))
                     .withCount(vietnamWorksJobStatisticService.count(term))
                     .build());
           });
 }
 @SendTo("/topic/jobs/terms")
 @MessageMapping("/jobs/terms")
 public List<TechnicalTermResponse> countTechnicalTerms() {
   List<TechnicalTermResponse> terms = new LinkedList<>();
   jsonConfigRepository
       .getSkillConfig()
       .stream()
       .forEach(
           term -> {
             Map<String, Double> avgSalary =
                 vietnamWorksJobStatisticService.getAverageSalaryBySkill(term, JOB_LEVEL_ALL);
             terms.add(
                 new TechnicalTermResponse.Builder()
                     .withTerm(term.getKey())
                     .withLabel(term.getLabel())
                     .withCount(vietnamWorksJobStatisticService.count(term))
                     .withAverageSalaryMin(avgSalary.get("SALARY_MIN"))
                     .withAverageSalaryMax(avgSalary.get("SALARY_MAX"))
                     .build());
           });
   return terms;
 }
Esempio n. 26
0
  /**
   * Generates the Http response message from given Spring Integration message.
   *
   * @param responseMessage message received from the message handler
   * @return an HTTP entity as response
   */
  private ResponseEntity<String> generateResponse(Message<?> responseMessage) {
    if (responseMessage == null) {
      return new ResponseEntity<String>(HttpStatus.OK);
    }

    HttpHeaders httpHeaders = new HttpHeaders();
    headerMapper.fromHeaders(responseMessage.getHeaders(), httpHeaders);

    Map<String, ?> messageHeaders = responseMessage.getHeaders();
    for (Entry<String, ?> header : messageHeaders.entrySet()) {
      if (!header.getKey().startsWith(CitrusMessageHeaders.PREFIX)
          && !MessageUtils.isSpringInternalHeader(header.getKey())
          && !httpHeaders.containsKey(header.getKey())) {
        httpHeaders.add(header.getKey(), header.getValue().toString());
      }
    }

    if (httpHeaders.getContentType() == null) {
      httpHeaders.setContentType(
          MediaType.parseMediaType(
              contentType.contains("charset") ? contentType : contentType + ";charset=" + charset));
    }

    HttpStatus status = HttpStatus.OK;
    if (responseMessage.getHeaders().containsKey(CitrusHttpMessageHeaders.HTTP_STATUS_CODE)) {
      status =
          HttpStatus.valueOf(
              Integer.valueOf(
                  responseMessage
                      .getHeaders()
                      .get(CitrusHttpMessageHeaders.HTTP_STATUS_CODE)
                      .toString()));
    }

    responseCache =
        new ResponseEntity<String>(responseMessage.getPayload().toString(), httpHeaders, status);

    return responseCache;
  }
Esempio n. 27
0
 @RequestMapping(value = "/proveedores", params = "term", produces = "application/json")
 public @ResponseBody List<LabelValueBean> proveedores(
     HttpServletRequest request, @RequestParam("term") String filtro) {
   for (String nombre : request.getParameterMap().keySet()) {
     log.debug("Param: {} : {}", nombre, request.getParameterMap().get(nombre));
   }
   Map<String, Object> params = new HashMap<>();
   params.put("empresa", request.getSession().getAttribute("empresaId"));
   params.put("filtro", filtro);
   params = proveedorDao.lista(params);
   List<LabelValueBean> valores = new ArrayList<>();
   List<Proveedor> proveedores = (List<Proveedor>) params.get("proveedores");
   for (Proveedor proveedor : proveedores) {
     StringBuilder sb = new StringBuilder();
     sb.append(proveedor.getNombre());
     sb.append(" | ");
     sb.append(proveedor.getRfc());
     sb.append(" | ");
     sb.append(proveedor.getNombreCompleto());
     valores.add(new LabelValueBean(proveedor.getId(), sb.toString(), proveedor.getNombre()));
   }
   return valores;
 }
Esempio n. 28
0
  @ResponseBody
  @RequestMapping(
      value = "getIPAndPathByGroupID",
      method = RequestMethod.POST,
      produces = MediaTypes.JSON)
  public Map<String, Object> getIPAndPathByGroupID(@RequestParam("groupids") String groupids) {
    List<String> ipAddress = new ArrayList<String>();
    String groupPaths = "";
    String[] groups = groupids.split(",");
    for (String groupid : groups) {
      ipAddress = groupService.getIPAddressByGroupID(Integer.parseInt(groupid), ipAddress);
      groupPaths += groupService.getGroupPathByGroupID(Integer.parseInt(groupid)) + ",";
    }
    String ripAddress = "";
    for (String ip : ipAddress) {
      ripAddress += ip + ",";
    }
    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("ipAddress", ripAddress.substring(0, ripAddress.length() - 1));
    resultMap.put("groupPaths", groupPaths.substring(0, groupPaths.length() - 1));

    return resultMap;
  }
Esempio n. 29
0
  /**
   * 지정한 조건의 파일 처리 이력을 조회한다.
   *
   * <p>auditConditionMap 처리 이력 조건 정보
   *
   * @return 파일 처리 목록
   */
  @RequestMapping(value = "list", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  @ResponseBody
  public Response getAuditHistories(
      @RequestParam String clusterName,
      @RequestParam(defaultValue = "") String startDate,
      @RequestParam(defaultValue = "") String endDate,
      @RequestParam(defaultValue = "") String path,
      @RequestParam(defaultValue = "ALL") String auditType,
      @RequestParam(defaultValue = "0") int nextPage,
      @RequestParam(defaultValue = "10") int limit) {

    EngineService engineService = this.getEngineService(clusterName);
    FileSystemAuditRemoteService service = engineService.getFileSystemAuditRemoteService();
    int level = getSessionUserLevel();
    String username = level == 1 ? "" : getSessionUsername();
    int totalRows =
        service.getTotalCountOfAuditHistories(startDate, endDate, path, auditType, username);

    Map auditConditionMap = new HashMap();

    auditConditionMap.put("level", level);
    auditConditionMap.put("username", username);
    auditConditionMap.put("startDate", startDate);
    auditConditionMap.put("endDate", endDate);
    auditConditionMap.put("path", path);
    auditConditionMap.put("auditType", auditType);
    auditConditionMap.put("nextPage", nextPage);
    auditConditionMap.put("limit", limit);

    List<AuditHistory> auditHistories = service.getAuditHistories(auditConditionMap);

    Response response = new Response();
    response.getList().addAll(auditHistories);
    response.setTotal(totalRows);
    response.setSuccess(true);

    return response;
  }
  private List getHederAndValueOfPersonInfo(List infoList) throws ParseException {
    List headerAndValueList = new ArrayList();
    for (int i = 0; i < infoList.size(); i++) {

      Map map = (Map) infoList.get(i);
      Set set = map.keySet();
      for (Object s : set) {
        if (map.get(s) != null
            && !Utils.isEmpty(map.get(s).toString().trim())
            && !("id").equals(s)) {
          Map header = new HashMap();
          header.put("header", WordUtils.capitalize(s.toString().replace("_", " ")));
          // if(Utils.isValidXlsStrToDate(map.get(s).toString()))
          //          header.put("value",Utils.getXlsDateToString(map.get(s).toString()));
          // else
          header.put("value", map.get(s).toString());

          headerAndValueList.add(header);
        }
      }
    }
    return headerAndValueList;
  }