use of de.metas.ui.web.base.model.I_WEBUI_Board_RecordAssignment in project metasfresh-webui-api by metasfresh.
the class BoardDescriptorRepository method addCardForDocumentId.
public BoardCard addCardForDocumentId(final int boardId, final int laneId, @NonNull final DocumentId documentId, final int position) {
final BoardDescriptor board = getBoardDescriptor(boardId);
board.assertLaneIdExists(laneId);
final int cardId = documentId.toInt();
final JSONBoardChangedEventsListBuilder eventsCollector = JSONBoardChangedEventsList.builder();
Services.get(ITrxManager.class).run(ITrx.TRXNAME_ThreadInherited, () -> {
try {
final I_WEBUI_Board_RecordAssignment assignment = InterfaceWrapperHelper.newInstance(I_WEBUI_Board_RecordAssignment.class);
assignment.setAD_Org_ID(Env.CTXVALUE_AD_Org_ID_Any);
assignment.setWEBUI_Board_ID(boardId);
assignment.setWEBUI_Board_Lane_ID(laneId);
assignment.setRecord_ID(cardId);
// will be updated later
assignment.setSeqNo(Integer.MAX_VALUE);
InterfaceWrapperHelper.save(assignment);
} catch (final DBUniqueConstraintException ex) {
throw new AdempiereException("Card was already added to this board", ex).setParameter("boardI", boardId).setParameter("laneId", laneId).setParameter("cardId", cardId);
}
final LaneCardsSequence orderedCardIds = changeCardsOrder(boardId, laneId, cardIds -> cardIds.addCardIdAtPosition(cardId, position));
eventsCollector.event(JSONBoardLaneChangedEvent.of(boardId, laneId, orderedCardIds.getCardIds()));
});
final BoardCard card = getCard(boardId, cardId);
sendEvents(board, eventsCollector.build());
return card;
}
Aggregations