@Override public Object preCreate(Entity record, Date now) throws UnifyException { ((ClusterSequenceNumber) record).setVersionNo(1L); return record.getId(); }
break; case ManageRecordModifier.MODIFY: if (ManageRecordModifier.isEditable(modifier) && record != null && !record.isReserved() && isEditable(record)) { if (!ManageRecordModifier.isAlternateSave(modifier)) {
/** * Returns the ids of selected items in search result table. * * @throws UnifyException * if an error occurs */ protected List<Long> getSelectedIds() throws UnifyException { if (table.getSelectedRows() > 0) { Integer[] selectedIndexes = table.getSelectedRowIndexes(); List<Long> selectedIds = new ArrayList<Long>(); for (int i = 0; i < selectedIndexes.length; i++) { selectedIds.add((Long) recordList.get(selectedIndexes[i]).getId()); } return selectedIds; } return Collections.emptyList(); }
protected void doDeleteRecord() throws UnifyException { T record = crudData.getRecord(); genericService.delete(record.getClass(), record.getId()); }
private void updateChildRecords(SqlEntityInfo sqlEntityInfo, Entity record) throws UnifyException { Object id = record.getId(); deleteChildRecords(sqlEntityInfo, id); createChildRecords(sqlEntityInfo, record, id); }
@SuppressWarnings("unchecked") private void prepareView() throws UnifyException { int index = table.getViewIndex(); record = find((U) recordList.get(index).getId()); recordList.set(index, record); onPrepareView(record, false); loadSessionOnRefresh(); }
@Override protected T loadSelectedRecordForView() throws UnifyException { T record = super.loadSelectedRecordForView(); getCrudData().setWrappedRecord(doFindWrappedRecord(record.getId())); return record; }
@SuppressWarnings("unchecked") @Action public String updateAndNextRecord() throws UnifyException { doUpdate(); record = find((U) record.getId()); recordList.set(table.getViewIndex(), record); if (table.isViewIndexAtLast()) { return done(); } return nextRecord(); }
@Override public int deleteById(Entity record) throws UnifyException { SqlEntityInfo sqlEntityInfo = sqlDataSourceDialect.getSqlEntityInfo(record.getClass()); SqlStatement sqlStatement = sqlDataSourceDialect.prepareDeleteByPkStatement(record.getClass(), record.getId()); EntityPolicy entityPolicy = sqlEntityInfo.getEntityPolicy(); int result; deleteChildRecords(sqlEntityInfo, record.getId()); if (result == 0) { throw new UnifyException(UnifyCoreErrorConstants.RECORD_WITH_PK_NOT_FOUND, record.getClass(), record.getId());
sqlStatement = sqlDataSourceDialect.prepareDeleteByPkVersionStatement(record.getClass(), record.getId(), oldVersionNo); } else { sqlStatement = sqlDataSourceDialect.prepareDeleteByPkStatement(record.getClass(), record.getId()); deleteChildRecords(sqlEntityInfo, record.getId()); if (result == 0) { throw new UnifyException(UnifyCoreErrorConstants.RECORD_WITH_PK_VERSION_NOT_FOUND, record.getClass(), record.getId(), oldVersionNo);
if (result == 0) { throw new UnifyException(UnifyCoreErrorConstants.RECORD_WITH_PK_NOT_FOUND, record.getClass(), record.getId());