Exemplo n.º 1
0
 private ModelMap getQuote(Link link, UID source, boolean mark) {
   ModelMap map = new ModelMap();
   String quote = link.getQuote() != null ? link.getQuote() : ((Item) source).getContent();
   if (mark) {
     quote =
         link.getTaggedQuote() != null
             ? link.getTaggedQuote()
             : ((Item) source).getTaggedContent();
   }
   map.put("quote", quote);
   map.put("uri", source.getUri());
   return map;
 }
Exemplo n.º 2
0
  @RequestMapping(value = "/", method = RequestMethod.GET)
  @Model
  public ModelMap get(
      @RequestParam("name") String termName, @RequestParam(required = false) boolean mark) {
    termName = termName.replace("_", " ");
    TermsMap.TermProvider provider = termsMap.getTermProvider(termName);
    if (provider == null) {
      throw new QuietException(format("Термин `%s` отсутствует", termName));
    }

    if (provider.hasMainTerm()) {
      provider = provider.getMainTermProvider();
    }

    ModelMap modelMap = new ModelMap(); // (ModelMap) getModelMap(term);

    Term term = provider.getTerm();

    modelMap.put("uri", term.getUri());
    modelMap.put("name", term.getName());
    if (mark) {
      if (term.getTaggedShortDescription() == null && term.getShortDescription() != null) {
        term.setTaggedShortDescription(termsMarker.mark(term.getShortDescription()));
        termDao.save(term);
      }
      if (term.getTaggedDescription() == null && term.getDescription() != null) {
        term.setTaggedDescription(termsMarker.mark(term.getDescription()));
        termDao.save(term);
      }
      modelMap.put("shortDescription", term.getTaggedShortDescription());
      modelMap.put("description", term.getTaggedDescription());
    } else {
      modelMap.put("shortDescription", term.getShortDescription());
      modelMap.put("description", term.getDescription());
    }

    // LINKS

    List<ModelMap> quotes = new ArrayList<ModelMap>();
    Set<UID> related = new LinkedHashSet<UID>();
    Set<UID> aliases = new LinkedHashSet<UID>();

    UID code = null;
    List<Link> links = linkDao.getAllLinks(term.getUri());
    for (Link link : links) {
      UID source = link.getUid1().getUri().equals(term.getUri()) ? link.getUid2() : link.getUid1();
      if (link.getQuote() != null || source instanceof Item) {
        quotes.add(getQuote(link, source, mark));
      } else if (ABBREVIATION.equals(link.getType()) || ALIAS.equals(link.getType())) {
        aliases.add(source);
      } else if (CODE.equals(link.getType())) {
        code = source;
      } else {
        related.add(source);
      }
    }

    // Нужно также включить цитаты всех синонимов и сокращений и кода
    Set<UID> aliasesQuoteSources = new HashSet<UID>(aliases);
    if (code != null) {
      aliasesQuoteSources.add(code);
    }
    for (UID uid : aliasesQuoteSources) {
      List<Link> aliasLinksWithQuote = linkDao.getAllLinks(uid.getUri());
      for (Link link : aliasLinksWithQuote) {
        UID source = link.getUid1().getUri().equals(uid.getUri()) ? link.getUid2() : link.getUid1();
        if (link.getQuote() != null || source instanceof Item) {
          quotes.add(getQuote(link, source, mark));
        } else if (ABBREVIATION.equals(link.getType())
            || ALIAS.equals(link.getType())
            || CODE.equals(link.getType())) {
          // Синонимы синонимов :) по идее их не должно быть, но если вдруг...
          // как минимум один есть и этот наш основной термин
          if (!source.getUri().equals(term.getUri())) {
            aliases.add(source);
          }
        } else {
          related.add(source);
        }
      }
    }
    sort(
        quotes,
        new Comparator<ModelMap>() {
          @Override
          public int compare(ModelMap o1, ModelMap o2) {
            return ((String) o1.get("uri")).compareTo((String) o2.get("uri"));
          }
        });

    modelMap.put("code", code);
    modelMap.put("quotes", quotes);
    modelMap.put("related", toPlainObjectWithoutContent(related));
    modelMap.put("aliases", toPlainObjectWithoutContent(aliases));
    modelMap.put("categories", searchController.inCategories(termName));

    return modelMap;
  }
Exemplo n.º 3
0
  // 增加用户
  public boolean add(String strUserId) {
    String strSql = "";
    strId = UID.getID();
    try {
      // 把用户信息写入数据库
      strSql =
          "INSERT INTO "
              + strTableName
              + "  (strId, strUserId, strPWD, strName, intError, intState, dBirthday, strSex, strIntro,intType, strUnitId, strUnitCode,"
              + " strNation, strMobile, strEmail, strMsnQQ,strOPhone, strHPhone, strDuty, strStation, intLoginNum, dLatestLoginTime,fOnlineTime, strCaNO, "
              + "strDepart, strCssType,  strLinkAdd, strCreator, dtCreatTime,intUserType) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,str_to_date(?,'%Y-%m-%d %T'),?,?,?,?,?,?,str_to_date(?,'%Y-%m-%d %T'),?)";
      db.prepareStatement(strSql);
      db.setString(1, strId);
      db.setString(2, strUserId.replaceAll(" ", ""));
      db.setString(3, MD5.getMD5ofString(Constants.resetPass)); // strPWD
      db.setString(4, strName);
      db.setInt(5, 0);
      db.setInt(6, 0);
      db.setString(7, dBirthday);
      db.setString(8, strSex);
      db.setString(9, strIntro);
      db.setInt(10, intType);
      db.setString(11, strUnitId);
      db.setString(
          12,
          ""); // strUnitCode                  new Unit(globa, false).retFieldValue("strUnitCode",
               // strUnitId)
      db.setString(13, strNation);
      db.setString(14, strMobile);
      db.setString(15, strEmail);
      db.setString(16, strMsnQQ);
      db.setString(17, strOPhone);
      db.setString(18, strHPhone);
      db.setString(19, strDuty);
      db.setString(20, strStation);
      db.setInt(21, intLoginNum);
      db.setString(22, Format.getDateTime());
      db.setDouble(23, 0);
      db.setString(24, strCaNO);
      db.setString(25, strDepart);
      db.setString(26, strCssType);
      db.setString(27, strLinkAdd);
      db.setString(28, globa.loginName);
      db.setString(29, Format.getDateTime());
      db.setInt(30, intUserType);

      if (db.executeUpdate() > 0) {
        Globa.logger0(
            "增加用户信息",
            globa.loginName,
            globa.loginIp,
            strSql,
            "用户管理",
            globa.userSession.getStrDepart());
        return true;
      } else return false;
    } catch (Exception e) {
      System.out.println("增加用户信息时出错!!");
      e.printStackTrace();
      return false;
    }
  }