コード例 #1
0
  public void updateUser(GenericRequestParam genericRequestParam) {
    final Map<String, User> users = getUsers();
    final Set<User> forUpdateOrCreate = Sets.newHashSet();

    for (Map.Entry<String, Object> entry : genericRequestParam.getParams().entrySet()) {
      final String[] n = entry.getKey().split(":");

      if (n.length == 2) {
        String username = n[0];
        final User user = ObjectUtils.defaultIfNull(users.get(username), new User(username));
        final String roleAsString = n[1];
        final String code = entry.getValue().toString();

        if ("courier".equalsIgnoreCase(roleAsString)) {
          Courier courier = courierService.findOneByCode(code);
          user.setCourier(courier);
        } else if ("wireless".equalsIgnoreCase(roleAsString)) {
          WirelessCenter wc = wirelessCenterService.findOneByCode(code);
          user.setWirelessCenter(wc);
        }

        forUpdateOrCreate.add(user);
      }
    }

    userRepository.save(forUpdateOrCreate);
  }
コード例 #2
0
ファイル: BrowsableFileField.java プロジェクト: debedb/pdfsam
 public BrowsableFileField(FileType fileType, OpenType openType) {
   setBrowseWindowTitle(DefaultI18nContext.getInstance().i18n("Select a file"));
   getBrowseButton().setOnAction(handler);
   getTextField().setOnAction(handler);
   this.fileType = ObjectUtils.defaultIfNull(fileType, FileType.ALL);
   this.openType = ObjectUtils.defaultIfNull(openType, OpenType.OPEN);
   if (FileType.ALL != fileType) {
     getTextField()
         .setPromptText(
             String.format(
                 "%s: %s",
                 DefaultI18nContext.getInstance().i18n("Select a file"),
                 fileType.getFilter().getExtensions()));
   } else {
     getTextField().setPromptText(DefaultI18nContext.getInstance().i18n("Select a file"));
   }
   setOnDragOver(e -> dragConsume(e, this.onDragOverConsumer()));
   setOnDragDropped(e -> dragConsume(e, this.onDragDropped()));
 }
コード例 #3
0
  public void createUser(GenericRequestParam genericRequestParam) {

    if (genericRequestParam != null && MapUtils.isNotEmpty(genericRequestParam.getParams())) {

      Map<String, Object> params = genericRequestParam.getParams();

      String username = null;
      {
        if (params.containsKey("username")) {
          username = params.get("username").toString();
        }
      }

      String courierCode = null;
      {
        if (params.containsKey("courier")) {
          courierCode = params.get("courier").toString();
        }
      }

      String wirelessCenterCode = null;
      {
        if (params.containsKey("wireless")) {
          wirelessCenterCode = params.get("wireless").toString();
        }
      }

      if (username != null) {
        User user =
            ObjectUtils.defaultIfNull(
                userRepository.findOne(User_.username(username)), new User(username));

        if (StringUtils.isNotBlank(courierCode)) {
          Courier courier = courierService.findOneByCode(courierCode);
          if (courier != null) {
            user.setCourier(courier);
          }
        }

        if (StringUtils.isNotBlank(wirelessCenterCode)) {
          WirelessCenter wirelessCenter = wirelessCenterService.findOneByCode(wirelessCenterCode);
          if (wirelessCenter != null) {
            user.setWirelessCenter(wirelessCenter);
          }
        }

        userRepository.save(user);
      }
    }
  }
コード例 #4
0
  protected ClassLoaderInterface getClassLoaderInterface() {

    /*
    if there is a ClassLoaderInterface in the context, use it, otherwise
    default to the default ClassLoaderInterface (a wrapper around the current
    thread classloader)
    using this, other plugins (like OSGi) can plugin their own classloader for a while
    and it will be used by Convention (it cannot be a bean, as Convention is likely to be
    called multiple times, and it need to use the default ClassLoaderInterface during normal startup)
    */
    ClassLoaderInterface classLoaderInterface = null;
    ActionContext ctx = ActionContext.getContext();
    if (ctx != null)
      classLoaderInterface =
          (ClassLoaderInterface) ctx.get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);

    return (ClassLoaderInterface)
        ObjectUtils.defaultIfNull(
            classLoaderInterface,
            new ClassLoaderInterfaceDelegate(Thread.currentThread().getContextClassLoader()));
  }
コード例 #5
0
 private boolean isInsideActionTag() {
   if (ActionContext.getContext() == null) return false;
   Object attribute =
       ServletActionContext.getRequest().getAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION);
   return (Boolean) ObjectUtils.defaultIfNull(attribute, Boolean.FALSE);
 }