屋頂上的騎兵

          首頁 新隨筆 聚合 管理
            5 Posts :: 0 Stories :: 0 Comments :: 0 Trackbacks

          通過一個integer類型屬性來表示對象所處的狀態:

          CASE:
          Invitor:邀請者對象模型
          Integer Invitor.joinstatus:邀請者所處參加狀態
          當前存在狀態聲明:是否被邀請,是否注冊用戶,是否拒絕,是否審批

          設計思路:
          bit0: 1-invited? , 0-not invited
          bit1: 1-registed , 0-not registed
          bit2: 1-refused? , 0-not refused
          bit3: 1-approved , 0-not approved

          Example:0111(7)=the invitor is invited ,and is registed ,and has been refused without approved.

          //判斷joinstatus狀態
          public static String theStatusOfApplicant(Invitor iv) throws TrainingAppException {
          ??String status = "default";
          ??if (((iv.getJoinStatus() & 0x8) == 0) && ((iv.getJoinStatus() & 0x4) == 0)) {
          ???status = "default";// 待批準(0x0)
          ??}
          ??if (((iv.getJoinStatus() & 0x8) == 0x8) && ((iv.getJoinStatus() & 0x4) == 0)) {
          ???status = "approved";// 已審批(0x4)
          ??}
          ??if (((iv.getJoinStatus() & 0x4) > 0) && ((iv.getJoinStatus() & 0x8) == 0)) {
          ???status = "refused";// 已拒絕(0x8)
          ??}
          ??return status;
          ?}
          //更新joinstatus狀態(審批和拒絕為互斥)
          private void updateJoinstatus(MainTrainingInfo mtrInfo, List<Invitor> invitors, Integer opertorType) {
          ??for (Iterator it = invitors.iterator(); it.hasNext();) {
          ???Invitor iv = (Invitor) it.next();
          ???if (APPLY_OPERTORTYPE_APPROVE == opertorType.intValue()) { // approve
          ????iv.setJoinStatus((iv.getJoinStatus() | 0x8) & 0x8);
          ???} else {
          ????iv.setJoinStatus((iv.getJoinStatus() | 0x4) & 0x4); // refuse
          ???}
          ???iv.setMainId(mtrInfo);
          ???mtrInfo.getInvitor().add(iv);
          ??}

          ??persistence.update(mtrInfo);
          ??if (APPLY_OPERTORTYPE_APPROVE == opertorType.intValue()) { // approve
          ???log.info(" ### 申請已獲批準,發送邀請郵件.");
          ???// Send Mails.
          ???try {
          ????instanceMailSendService.approveInvitorSendMail(mtrInfo, invitors, getHostEmail(mtrInfo),
          ??????MainTrainingInfoUtil.getLocale(mtrInfo), true, true);
          ???} catch (Exception e) {
          ????log.error(e.toString());
          ???}

          ??}
          ?}

          posted on 2007-04-23 19:39 alex-0927 閱讀(404) 評論(0)  編輯  收藏 所屬分類: 技術小結

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 蓬溪县| 邵阳市| 昭觉县| 张家港市| 读书| 玉溪市| 漳浦县| 巴楚县| 卓资县| 冀州市| 商丘市| 五寨县| 河池市| 聂拉木县| 德兴市| 广河县| 张掖市| 比如县| 德州市| 清河县| 和田县| 镇雄县| 长葛市| 广宗县| 东丰县| 永宁县| 醴陵市| 胶州市| 岚皋县| 雷山县| 西和县| 汶上县| 报价| 苏州市| 北碚区| 永仁县| 蓬莱市| 延长县| 沙湾县| 和静县| 顺义区|