private static boolean containID(String ids, String id) {
   boolean contain = false;
   if (StringUtils.isNotEmpty(ids) && StringUtils.isNotEmpty(id)) {
     String[] temps = ids.split(",");
     for (String temp : temps) {
       if (temp.equals(id)) {
         contain = true;
         break;
       }
     }
   }
   return contain;
 }
 @SuppressWarnings("unchecked")
 @Override
 public Map<String, List<NoticeModel>> getTop5Notice() throws ServiceException {
   // TODO Auto-generated method stub
   Map<String, List<NoticeModel>> noticeMap = new LinkedHashMap<String, List<NoticeModel>>();
   int countMax = 5;
   DetachedCriteria criteria = DetachedCriteria.forClass(DirectoryModel.class);
   String type = "news";
   criteria.add(Restrictions.eq("type", type));
   List<DirectoryModel> directoryList = directoryDAO.getListByCriteria(criteria);
   if (directoryList != null && directoryList.size() > 0) {
     for (DirectoryModel model : directoryList) {
       DetachedCriteria criteria2 = DetachedCriteria.forClass(NoticeModel.class);
       if (StringUtils.isNotEmpty(model.getName()))
         criteria2.add(Restrictions.eq("type", model.getName()));
       List<NoticeModel> list = noticeDAO.getListByCriteria(criteria2);
       List<NoticeModel> top5List = new ArrayList<NoticeModel>();
       for (int i = 0; i < list.size() && i < countMax; i++) {
         top5List.add(list.get(i));
       }
       noticeMap.put(model.getName(), top5List);
     }
   }
   return noticeMap;
 }
 @SuppressWarnings("unchecked")
 @Override
 public List<NoticeModel> getNotices(String userId, String beginDate, String endDate, String type)
     throws ServiceException {
   // TODO Auto-generated method stub
   DetachedCriteria criteria = DetachedCriteria.forClass(NoticeModel.class);
   if (StringUtils.isNotEmpty(userId) && (!userId.equals("1"))) {
     criteria.add(Restrictions.like("teacherAttendIds", userId, MatchMode.ANYWHERE));
   }
   if (StringUtils.isNotEmpty(beginDate))
     criteria.add(Restrictions.sqlRestriction("postTime >= '" + beginDate + " 00:00:00'"));
   if (StringUtils.isNotEmpty(endDate))
     criteria.add(Restrictions.sqlRestriction("postTime <= '" + endDate + " 23:59:59'"));
   if (StringUtils.isNotEmpty(type)) criteria.add(Restrictions.eq("type", type));
   criteria.add(Restrictions.eq("status", NoticeModel.EStatus.Published.getValue()));
   criteria.addOrder(Order.desc("postTime"));
   return noticeDAO.getListByCriteria(criteria);
 }
  @Override
  public void saveNotice(NoticeModel model, String attachmentIds) throws ServiceException {
    if (StringUtils.isEmpty(model.getId())) model.setPostTime(new Date());
    if (model.getLastEditorId() != null) model.setLastEditTime(new Date());

    noticeDAO.saveOrUpdate(model);

    if (StringUtils.isNotEmpty(attachmentIds)) {
      String[] ids = attachmentIds.split(";");
      for (int i = 0; i < ids.length; i++) {
        AttachmentModel attachment = attachmentDAO.get(ids[i]);
        attachment.setBelongObject(NoticeModel.class.getSimpleName());
        attachment.setBelongObjectId(model.getId());
        attachmentDAO.saveOrUpdate(attachment);
      }
    }
    NoticeModel newModel = noticeDAO.get(model.getId());
    noticeDAO.merge(newModel);
  }
Exemplo n.º 5
0
 @SuppressWarnings("unchecked")
 @Override
 public List<GroupModel> getGroupsBySchool(String school) throws DAOException {
   // TODO Auto-generated method stub
   if (StringUtils.isNotEmpty(school)) {
     DetachedCriteria criteria = DetachedCriteria.forClass(GroupModel.class);
     criteria.add(Restrictions.eq("schoolId", school));
     return this.getListByCriteria(criteria);
   }
   return null;
 }
Exemplo n.º 6
0
  @Override
  public DepartmentModel saveDepartment(
      DepartmentModel clientDepartment,
      String parentDepartmentId,
      String headSchoolDepartmentId,
      String masterUserIds,
      String leaderUserIds) {
    if (StringUtils.isEmpty(clientDepartment.getId())) {
      if (StringUtils.isNotEmpty(masterUserIds)) {
        String[] masterIds = masterUserIds.split(";");
        for (String id : masterIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !clientDepartment.getMasterStaffs().contains(user))
            clientDepartment.getMasterStaffs().add(user);
        }
      }
      if (StringUtils.isNotEmpty(leaderUserIds)) {
        String[] leaderIds = leaderUserIds.split(";");
        for (String id : leaderIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !clientDepartment.getLeaderStaffs().contains(user))
            clientDepartment.getLeaderStaffs().add(user);
        }
      }
      if (StringUtils.isEmpty(parentDepartmentId)) {
        if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
          clientDepartment
              .getHeadSchoolLeaderDepartments()
              .add(departmentDAO.get(headSchoolDepartmentId));
        }
        departmentDAO.saveOrUpdate(clientDepartment);
        return clientDepartment;
      } else {
        DepartmentModel parent = departmentDAO.get(parentDepartmentId);
        if (parent == null) return null;
        else {
          // 以下代码 2012.4.5 ysc 解决增加报错问题
          departmentDAO.saveOrUpdate(clientDepartment);
          // 以上代码 2012.4.5 ysc 解决增加报错问题
          parent.getChildDepartments().add(clientDepartment);
          if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
            clientDepartment
                .getHeadSchoolLeaderDepartments()
                .add(departmentDAO.get(headSchoolDepartmentId));
          }
          departmentDAO.saveOrUpdate(parent);
          return clientDepartment;
        }
      }
    } else {

      DepartmentModel dbDepartment = departmentDAO.get(clientDepartment.getId());
      dbDepartment.setName(clientDepartment.getName());
      dbDepartment.setDetail(clientDepartment.getDetail());
      dbDepartment.setLevel(clientDepartment.getLevel());
      dbDepartment.setPhone(clientDepartment.getPhone());
      dbDepartment.setCreationDate(clientDepartment.getCreationDate());
      dbDepartment.setSequence(clientDepartment.getSequence());
      dbDepartment.setSchoolId(clientDepartment.getSchoolId());
      dbDepartment.setHrFlag(clientDepartment.getHrFlag());
      dbDepartment.setLearnManageFlag(clientDepartment.getLearnManageFlag());
      dbDepartment.setTechFlag(clientDepartment.getTechFlag());
      dbDepartment.setConsultFlag(clientDepartment.getConsultFlag());
      dbDepartment.setConsultantFlag(clientDepartment.getConsultantFlag());
      if (StringUtils.isNotEmpty(headSchoolDepartmentId)) {
        dbDepartment.getHeadSchoolLeaderDepartments().clear();
        dbDepartment
            .getHeadSchoolLeaderDepartments()
            .add(departmentDAO.get(headSchoolDepartmentId));
      }
      dbDepartment.getMasterStaffs().clear();
      if (StringUtils.isNotEmpty(masterUserIds)) {
        String[] masterIds = masterUserIds.split(";");
        for (String id : masterIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !dbDepartment.getMasterStaffs().contains(user))
            dbDepartment.getMasterStaffs().add(user);
        }
      }
      dbDepartment.getLeaderStaffs().clear();
      if (StringUtils.isNotEmpty(leaderUserIds)) {
        String[] leaderIds = leaderUserIds.split(";");
        for (String id : leaderIds) {
          UserModel user = userDAO.get(id);
          if (user != null && !dbDepartment.getLeaderStaffs().contains(user))
            dbDepartment.getLeaderStaffs().add(user);
        }
      }
      departmentDAO.saveOrUpdate(dbDepartment);
      return dbDepartment;
    }
  }