コード例 #1
0
 @Override
 public ActionResponseDTO<Classpage> createClasspage(
     Classpage classpage, boolean addToUserClasspage, String assignmentId) throws Exception {
   Errors errors = validateClasspage(classpage);
   if (!errors.hasErrors()) {
     this.getCollectionRepository().save(classpage);
     if (assignmentId != null && !assignmentId.isEmpty()) {
       CollectionItem collectionItem = new CollectionItem();
       collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
       collectionItem =
           this.createClasspageItem(
                   assignmentId,
                   classpage.getGooruOid(),
                   collectionItem,
                   classpage.getUser(),
                   CollectionType.CLASSPAGE.getCollectionType())
               .getModel();
       Set<CollectionItem> collectionItems = new TreeSet<CollectionItem>();
       collectionItems.add(collectionItem);
       classpage.setCollectionItems(collectionItems);
     }
     if (addToUserClasspage) {
       CollectionItem collectionItem = new CollectionItem();
       collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
       this.createClasspageItem(
           classpage.getGooruOid(),
           null,
           collectionItem,
           classpage.getUser(),
           CollectionType.USER_CLASSPAGE.getCollectionType());
     }
     this.getCollectionRepository().save(classpage);
   }
   return new ActionResponseDTO<Classpage>(classpage, errors);
 }
コード例 #2
0
 @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);
 }