Search in sources :

Example 1 with SysCalendarNoteVO

use of com.netsteadfast.greenstep.vo.SysCalendarNoteVO in project bamboobsc by billchen198318.

the class SystemCalendarNoteManagementAction method loadSysCalendarNoteData.

/**
	 * 載入編輯mode需要的資料
	 * 
	 * @throws ServiceException
	 * @throws Exception
	 */
private void loadSysCalendarNoteData() throws ServiceException, Exception {
    this.transformFields2ValueObject(this.sysCalendarNote, new String[] { "oid" });
    DefaultResult<SysCalendarNoteVO> result = this.sysCalendarNoteService.findObjectByOid(sysCalendarNote);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.sysCalendarNote = result.getValue();
    AccountVO account = new AccountVO();
    account.setAccount(sysCalendarNote.getAccount());
    DefaultResult<AccountVO> aResult = this.accountService.findByUK(account);
    if (aResult.getValue() == null) {
        throw new ServiceException(aResult.getSystemMessage().getValue());
    }
    account = aResult.getValue();
    this.accountOid = account.getOid();
    this.calendarNoteDate = sysCalendarNote.getDate().substring(0, 4) + "-" + sysCalendarNote.getDate().substring(4, 6) + "-" + sysCalendarNote.getDate().substring(6, 8);
    String[] time = this.sysCalendarNote.getTime().split(Constants.DATETIME_DELIMITER);
    this.startHour = time[0].substring(0, 2);
    this.startMinutes = time[0].substring(2, 4);
    this.endHour = time[1].substring(0, 2);
    this.endMinutes = time[1].substring(2, 4);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO)

Example 2 with SysCalendarNoteVO

use of com.netsteadfast.greenstep.vo.SysCalendarNoteVO in project bamboobsc by billchen198318.

the class SystemCalendarNoteSaveOrUpdateAction method save.

/**
	 * 儲存 TB_SYS_CALENDAR_NOTE
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    String accountOid = this.getFields().get("accountOid");
    SysCalendarNoteVO sysCalendarNote = new SysCalendarNoteVO();
    sysCalendarNote = this.transformFields2ValueObject(sysCalendarNote, new String[] { "title", "note", "date", "time", "contact" });
    sysCalendarNote.setAlert(YesNo.NO);
    if ("true".equals(this.getFields().get("alert"))) {
        sysCalendarNote.setAlert(YesNo.YES);
    }
    DefaultResult<SysCalendarNoteVO> result = this.systemCalendarNoteLogicService.create(sysCalendarNote, accountOid);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.message = result.getSystemMessage().getValue();
    this.success = IS_YES;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO)

Example 3 with SysCalendarNoteVO

use of com.netsteadfast.greenstep.vo.SysCalendarNoteVO in project bamboobsc by billchen198318.

the class SystemCalendarNoteSaveOrUpdateAction method delete.

/**
	 * 刪除 TB_SYS_CALENDAR_NOTE
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysCalendarNoteVO sysCalendarNote = new SysCalendarNoteVO();
    sysCalendarNote = this.transformFields2ValueObject(sysCalendarNote, new String[] { "oid" });
    DefaultResult<Boolean> result = this.sysCalendarNoteService.deleteObject(sysCalendarNote);
    if (result.getValue() == null || !result.getValue()) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.message = result.getSystemMessage().getValue();
    this.success = IS_YES;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO)

Example 4 with SysCalendarNoteVO

use of com.netsteadfast.greenstep.vo.SysCalendarNoteVO in project bamboobsc by billchen198318.

the class SystemCalendarNoteLogicServiceImpl method create.

/**
	 * 產生 TB_SYS_CALENDAR_NOTE 資料
	 * 
	 * @param sysCalendarNote
	 * @param accountOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysCalendarNoteVO> create(SysCalendarNoteVO sysCalendarNote, String accountOid) throws ServiceException, Exception {
    if (super.isBlank(accountOid) || null == sysCalendarNote) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    AccountVO account = new AccountVO();
    account.setOid(accountOid);
    DefaultResult<AccountVO> aResult = this.accountService.findObjectByOid(account);
    if (aResult.getValue() == null) {
        throw new ServiceException(aResult.getSystemMessage().getValue());
    }
    account = aResult.getValue();
    sysCalendarNote.setDate(sysCalendarNote.getDate().replaceAll("/", "").replaceAll("-", ""));
    sysCalendarNote.setAccount(account.getAccount());
    String canendarId = this.sysCalendarNoteService.findForMaxCalendarId(account.getAccount(), sysCalendarNote.getDate());
    if (StringUtils.isBlank(canendarId)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    sysCalendarNote.setCalendarId(canendarId);
    if (super.defaultString(sysCalendarNote.getNote()).length() > MAX_NOTE_LENGTH) {
        sysCalendarNote.setNote(sysCalendarNote.getNote().substring(0, MAX_NOTE_LENGTH));
    }
    DefaultResult<SysCalendarNoteVO> result = this.sysCalendarNoteService.saveObject(sysCalendarNote);
    this.createMailHelper(result.getValue());
    return result;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with SysCalendarNoteVO

use of com.netsteadfast.greenstep.vo.SysCalendarNoteVO in project bamboobsc by billchen198318.

the class SystemCalendarNoteSaveOrUpdateAction method update.

/**
	 * 更新 TB_SYS_CALENDAR_NOTE
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    SysCalendarNoteVO sysCalendarNote = new SysCalendarNoteVO();
    sysCalendarNote = this.transformFields2ValueObject(sysCalendarNote, new String[] { "oid", "title", "note", "date", "time", "contact" });
    sysCalendarNote.setAlert(YesNo.NO);
    if ("true".equals(this.getFields().get("alert"))) {
        sysCalendarNote.setAlert(YesNo.YES);
    }
    DefaultResult<SysCalendarNoteVO> result = this.systemCalendarNoteLogicService.update(sysCalendarNote);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.message = result.getSystemMessage().getValue();
    this.success = IS_YES;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)5 SysCalendarNoteVO (com.netsteadfast.greenstep.vo.SysCalendarNoteVO)5 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)2 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 Transactional (org.springframework.transaction.annotation.Transactional)1