@Override @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void updateCollectionItem( String collectionId, final String collectionItemId, CollectionItem newCollectionItem, User user) { final CollectionItem collectionItem = this.getCollectionDao().getCollectionItem(collectionItemId); rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM); if (newCollectionItem.getNarration() != null) { collectionItem.setNarration(newCollectionItem.getNarration()); } if (newCollectionItem.getStart() != null) { collectionItem.setStart(newCollectionItem.getStart()); } if (newCollectionItem.getStop() != null) { collectionItem.setStop(newCollectionItem.getStop()); } if (newCollectionItem.getPosition() != null) { Collection parentCollection = getCollectionDao().getCollectionByUser(collectionId, user.getPartyUid()); this.resetSequence( parentCollection, collectionItem.getCollectionItemId(), newCollectionItem.getPosition(), user.getPartyUid(), COLLECTION_ITEM); } this.getCollectionDao().save(collectionItem); }
@Override public ActionResponseDTO<Classpage> createClasspage( Classpage newClasspage, CollectionItem newCollectionItem, String gooruOid, User user) throws Exception { Errors errors = validateClasspage(newClasspage); if (!errors.hasErrors()) { this.getCollectionRepository().save(newClasspage); this.getUserGroupService() .createGroup( newClasspage.getTitle(), newClasspage.getClasspageCode(), "System", user, null); if (gooruOid != null && !gooruOid.isEmpty() && newCollectionItem != null) { CollectionItem collectionItem = new CollectionItem(); collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType()); collectionItem.setPlannedEndDate(newCollectionItem.getPlannedEndDate()); collectionItem.setNarration(newCollectionItem.getNarration()); collectionItem = this.createCollectionItem( gooruOid, newClasspage.getGooruOid(), collectionItem, newClasspage.getUser(), CollectionType.COLLECTION.getCollectionType(), false) .getModel(); Set<CollectionItem> collectionItems = new TreeSet<CollectionItem>(); collectionItems.add(collectionItem); newClasspage.setCollectionItems(collectionItems); this.getCollectionRepository().save(newClasspage); } } return new ActionResponseDTO<Classpage>(newClasspage, errors); }