use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class ApplicationSystemLogicServiceImpl method create.
/**
* 建立 TB_SYS 資料
*
* @param sys
* @param iconOid
* @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<SysVO> create(SysVO sys, String iconOid) throws ServiceException, Exception {
SysIconVO sysIcon = new SysIconVO();
sysIcon.setOid(iconOid);
DefaultResult<SysIconVO> iconResult = this.sysIconService.findObjectByOid(sysIcon);
if (iconResult.getValue() == null) {
throw new ServiceException(iconResult.getSystemMessage().getValue());
}
sys.setIcon(iconResult.getValue().getIconId());
return this.sysService.saveObject(sys);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority 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;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemContextBeanLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysCtxBeanVO> update(SysCtxBeanVO ctxBean, String systemOid) throws ServiceException, Exception {
if (ctxBean == null || super.isBlank(ctxBean.getOid()) || super.isBlank(systemOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysVO sys = new SysVO();
sys.setOid(systemOid);
DefaultResult<SysVO> sResult = this.sysService.findObjectByOid(sys);
if (sResult.getValue() == null) {
throw new ServiceException(sResult.getSystemMessage().getValue());
}
sys = sResult.getValue();
ctxBean.setSystem(sys.getSysId());
DefaultResult<SysCtxBeanVO> anotherResult = this.sysCxtBeanService.findByUK(ctxBean);
if (anotherResult.getValue() != null) {
// 有另一筆相同UK的資料, 但OID不同, 所以這次update 是不允許的
if (!anotherResult.getValue().getOid().equals(ctxBean.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_IS_EXIST));
}
}
if (super.defaultString(ctxBean.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
ctxBean.setDescription(ctxBean.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
}
return this.sysCxtBeanService.updateObject(ctxBean);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemExpressionLogicServiceImpl method updateJob.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysExprJobVO> updateJob(SysExprJobVO exprJob, String systemOid, String expressionOid) throws ServiceException, Exception {
if (null == exprJob || StringUtils.isBlank(exprJob.getOid()) || StringUtils.isBlank(systemOid) || StringUtils.isBlank(expressionOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysVO sys = new SysVO();
sys.setOid(systemOid);
DefaultResult<SysVO> sysResult = this.sysService.findObjectByOid(sys);
if (sysResult.getValue() == null) {
throw new ServiceException(sysResult.getSystemMessage().getValue());
}
sys = sysResult.getValue();
SysExpressionVO expression = new SysExpressionVO();
expression.setOid(expressionOid);
DefaultResult<SysExpressionVO> expressionResult = this.sysExpressionService.findObjectByOid(expression);
if (expressionResult.getValue() == null) {
throw new ServiceException(expressionResult.getSystemMessage().getValue());
}
expression = expressionResult.getValue();
DefaultResult<SysExprJobVO> oldResult = this.sysExprJobService.findObjectByOid(exprJob);
if (oldResult.getValue() == null) {
throw new ServiceException(oldResult.getSystemMessage().getValue());
}
exprJob.setId(oldResult.getValue().getId());
exprJob.setSystem(sys.getSysId());
exprJob.setExprId(expression.getExprId());
exprJob.setRunStatus(oldResult.getValue().getRunStatus());
if (super.isBlank(oldResult.getValue().getRunStatus())) {
exprJob.setRunStatus(ExpressionJobConstants.RUNSTATUS_FAULT);
logger.warn("Before runStatus flag is blank. Expression Job ID: " + oldResult.getValue().getId());
}
this.setStringValueMaxLength(exprJob, "description", MAX_DESCRIPTION_LENGTH);
return this.sysExprJobService.updateObject(exprJob);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemFormLogicServiceImpl method updateMethod.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormMethodVO> updateMethod(SysFormMethodVO formMethod, String formOid) throws ServiceException, Exception {
if (null == formMethod || super.isBlank(formMethod.getOid()) || super.isBlank(formOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<SysFormMethodVO> oldResult = this.sysFormMethodService.findObjectByOid(formMethod);
if (oldResult.getValue() == null) {
throw new ServiceException(oldResult.getSystemMessage().getValue());
}
SysFormVO form = this.findForm(formOid);
formMethod.setFormId(form.getFormId());
// check UK(same "name" and "formId" ) is found. because can update formMethod's UK , so need to check it.
DefaultResult<SysFormMethodVO> ukResult = this.sysFormMethodService.findByUK(formMethod);
if (ukResult.getValue() != null) {
if (!ukResult.getValue().getOid().equals(formMethod.getOid())) {
// same UK found, but is another data.
throw new ServiceException("Please change another name!");
}
}
// clear blob expression
oldResult.getValue().setExpression(null);
this.sysFormMethodService.updateObject(oldResult.getValue());
super.setStringValueMaxLength(formMethod, "description", MAX_DESCRIPTION_LENGTH);
return this.sysFormMethodService.updateObject(formMethod);
}
Aggregations