コード例 #1
0
  private void saveMyFavorite() {
    Item item = vfMyFavorite.getForm().getValues();
    String createId = (String) item.getItemProperty("createIn").getValue();
    String newForder = (String) item.getItemProperty("newFolder").getValue();

    if (FieldUtil.isNotEmpty(createId) && FieldUtil.isNotEmpty(newForder)) {
      Dialog dialog =
          new Dialog(
              Dialog.MODE.VALIDATE,
              messageResource.getMessage(
                  "501014",
                  locale,
                  termResource.getTerm("Create In"),
                  termResource.getTerm("New Folder")));
      return;
    }
    String category;
    if (createId != null) {
      category = createId;
    } else {
      category = newForder;
    }

    List<Item> selection = gridFilter.getGrid().getSelection();
    Item i = selection.get(0);
    String candidateUuid = (String) i.getItemProperty("candidateUuid").getValue();
    Candidate candidate = candidateService.get(candidateUuid);
    CandFavorite candFavorite = new CandFavorite();
    candFavorite.setCandidate(candidate);
    candFavorite.setCategory(category);
    candFavorite.setManager(currentUser);

    try {
      candFavoriteService.save(candFavorite);
    } catch (DuplicateConflictException d) {
      LOGGER.debug("DuplicateConflictException: ", d);
      Dialog dialog = new Dialog(Dialog.MODE.VALIDATE, d.getLocalizedMessage(locale));
      return;
    } catch (ConstraintConflictException c) {
      LOGGER.debug("ConstraintConflictException: ", c);
      Dialog dialog =
          new Dialog(Dialog.MODE.VALIDATE, ViolationUtils.getViolation(c.getViolations(), locale));
      return;
    } catch (OperationFailureException o) {
      LOGGER.error("Exception: ", o);
      Messagebox.hint(messageResource.getMessage("200001"));
      return;
    }
    // success
    Messagebox.info(messageResource.getMessage("100025"));
    closeMyFavorite();
    refresh();
  }
コード例 #2
0
  private void check(String instruction) {

    Map<String, Object> data = new HashMap<>();

    List<Item> selection = grid.getSelection();

    if (selection.size() == 0) {
      Messagebox.hint(messageResource.getMessage("100003"));
      return;
    }

    List<PropertysetItem> items = ItemUtils.getItemsIsolated(selection);

    data.put("items", items);

    CommandEvent.ExecuteEvent event = CommandEvent.createExecuteEvent(this, instruction, data);
    fireEvent(event);

    // 記錄 最後是誰讀取了此Candidate, 並記錄時間
    Item item = selection.get(0);
    String candidateUuid = (String) item.getItemProperty("candidateUuid").getValue();
    Candidate candidate = candidateService.get(candidateUuid);

    Account reader = this.currentUser;

    try {
      candProfileReadService.save(candidate, reader);
    } catch (DuplicateConflictException d) {
      LOGGER.debug("DuplicateConflictException: ", d);
      Dialog dialog = new Dialog(Dialog.MODE.VALIDATE, d.getLocalizedMessage(locale));
      return;
    } catch (ConstraintConflictException c) {
      LOGGER.debug("ConstraintConflictException: ", c);
      Dialog dialog =
          new Dialog(Dialog.MODE.VALIDATE, ViolationUtils.getViolation(c.getViolations(), locale));
      return;
    } catch (OperationFailureException o) {
      LOGGER.error("Exception: ", o);
      Messagebox.hint(messageResource.getMessage("200001"));
      return;
    }

    // 標記此筆資料已經讀取過
    Label lRead = new Label();
    lRead.setSizeUndefined();
    lRead.setContentMode(ContentMode.HTML);
    lRead.setValue(FontAwesome.TAG.getHtml());
    item.getItemProperty("read").setValue(lRead);
  }