use of com.netsteadfast.greenstep.base.model.DefaultResult in project bamboobsc by billchen198318.
the class MeasureDataCalendarUtils method findMeasureData.
/**
* 這個 method 主要給 Expression 使用, 避免近入LogicService 處理時影響到 Transaction
*
* @param kpiId
* @param date
* @param frequency
* @param orgaId
* @param emplId
* @return
* @throws ServiceException
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public static MeasureDataVO findMeasureData(String kpiId, String date, String frequency, String orgaId, String emplId) throws ServiceException, Exception {
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_DEFAULT);
transactionTemplate.setReadOnly(true);
MeasureDataVO measureData = null;
try {
measureData = (MeasureDataVO) transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
MeasureDataVO value = new MeasureDataVO();
value.setKpiId(kpiId);
value.setDate(date);
value.setFrequency(frequency);
value.setOrgId(orgaId);
value.setEmpId(emplId);
try {
DefaultResult<MeasureDataVO> mdResult = measureDataService.findByUK(value);
if (mdResult.getValue() != null) {
value = mdResult.getValue();
} else {
value = null;
}
} catch (Exception e) {
e.printStackTrace();
value = null;
}
return value;
}
});
} catch (Exception e) {
throw e;
}
return measureData;
}
use of com.netsteadfast.greenstep.base.model.DefaultResult in project bamboobsc by billchen198318.
the class SwotLogicServiceImpl method create.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> create(String visionOid, String organizationOid, List<SwotVO> datas) throws ServiceException, Exception {
if (super.isBlank(visionOid) || super.isBlank(organizationOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
VisionVO vision = new VisionVO();
vision.setOid(visionOid);
DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
if (vResult.getValue() == null) {
throw new ServiceException(vResult.getSystemMessage().getValue());
}
vision = vResult.getValue();
OrganizationVO organization = this.findOrganizationData(organizationOid);
//因為 dojo 的 dijit.InlineEditBox 元件特性是, 沒有修改過, 就不會產生editor , 所以修改模式下用全部刪除後->再全部新增會有問題
//this.delete(vision.getVisId());
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
result.setValue(Boolean.TRUE);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
Map<String, Object> params = new HashMap<String, Object>();
for (SwotVO swot : datas) {
if (!vision.getVisId().equals(swot.getVisId()) || !organization.getOrgId().equals(swot.getOrgId())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
this.setStringValueMaxLength(swot, "issues", MAX_ISSUES_LENGTH);
params.clear();
params.put("perId", swot.getPerId());
if (this.perspectiveService.countByParams(params) < 1) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
if (this.swotService.countByUK(swot) > 0) {
// 修改 ISSUES
this.updateIssues(swot);
} else {
// 新增
this.swotService.saveObject(swot);
}
}
return result;
}
Aggregations