diff --git a/vspace/src/main/java/edu/asu/diging/simpleusers/web/admin/UsersUtility.java b/vspace/src/main/java/edu/asu/diging/simpleusers/web/admin/UsersUtility.java index 40b272e85..d8fa3efa5 100644 --- a/vspace/src/main/java/edu/asu/diging/simpleusers/web/admin/UsersUtility.java +++ b/vspace/src/main/java/edu/asu/diging/simpleusers/web/admin/UsersUtility.java @@ -1,7 +1,5 @@ package edu.asu.diging.simpleusers.web.admin; -import java.util.ArrayList; -import java.util.List; import java.util.Set; import org.springframework.security.core.authority.SimpleGrantedAuthority; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleLinkRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleLinkRepository.java index b1ad0df82..435c67047 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleLinkRepository.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleLinkRepository.java @@ -1,5 +1,6 @@ package edu.asu.diging.vspace.core.data; +import java.util.Optional; import java.util.List; import org.javers.spring.annotation.JaversSpringDataAuditable; @@ -12,6 +13,7 @@ @Repository @JaversSpringDataAuditable public interface ModuleLinkRepository extends PagingAndSortingRepository { + Optional findByModule_Id(String moduleId); @Query("select moduleLink from ModuleLink moduleLink where module_id = ?1") List findModuleLinksByModuleId(String moduleId); diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceContentBlockRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceContentBlockRepository.java new file mode 100644 index 000000000..6cc5a82bc --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceContentBlockRepository.java @@ -0,0 +1,13 @@ +package edu.asu.diging.vspace.core.data; + +import org.javers.spring.annotation.JaversSpringDataAuditable; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +import edu.asu.diging.vspace.core.model.impl.SpaceBlock; + +@Repository +@JaversSpringDataAuditable +public interface SpaceContentBlockRepository extends PagingAndSortingRepository { + +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceRepository.java index 7107d36e2..530e12352 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceRepository.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SpaceRepository.java @@ -24,4 +24,6 @@ public interface SpaceRepository extends PagingAndSortingRepository findDistinctByNameContainingOrDescriptionContaining(Pageable requestedPage, String name, String description); + + List findByNameLike(String name); } \ No newline at end of file diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/display/SpaceDisplayRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/display/SpaceDisplayRepository.java index 7ca2eeffb..7db185fb1 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/display/SpaceDisplayRepository.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/display/SpaceDisplayRepository.java @@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.stereotype.Repository; + import edu.asu.diging.vspace.core.model.ISpace; import edu.asu.diging.vspace.core.model.display.impl.SpaceDisplay; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/ModuleNotFoundException.java b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/ModuleNotFoundException.java index 72b29bfee..1aaf4a354 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/ModuleNotFoundException.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/ModuleNotFoundException.java @@ -1,7 +1,7 @@ package edu.asu.diging.vspace.core.exception; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Module Not Found") public class ModuleNotFoundException extends Exception { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SequenceNotFoundException.java b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SequenceNotFoundException.java index ede027176..bfe52726a 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SequenceNotFoundException.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SequenceNotFoundException.java @@ -1,7 +1,7 @@ package edu.asu.diging.vspace.core.exception; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Module Not Found") public class SequenceNotFoundException extends Exception { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlideNotFoundException.java b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlideNotFoundException.java index 8c619e489..a186636b5 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlideNotFoundException.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlideNotFoundException.java @@ -1,7 +1,7 @@ package edu.asu.diging.vspace.core.exception; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Slide Not Found") public class SlideNotFoundException extends Exception { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlidesInSequenceNotFoundException.java b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlidesInSequenceNotFoundException.java index 6af71c38a..1ab9a9c09 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlidesInSequenceNotFoundException.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SlidesInSequenceNotFoundException.java @@ -1,7 +1,7 @@ package edu.asu.diging.vspace.core.exception; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Module Not Found") public class SlidesInSequenceNotFoundException extends Exception { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SpaceNotFoundException.java b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SpaceNotFoundException.java index d462a8e91..683e7325b 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SpaceNotFoundException.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/exception/SpaceNotFoundException.java @@ -1,7 +1,7 @@ package edu.asu.diging.vspace.core.exception; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Space Not Found") public class SpaceNotFoundException extends Exception { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/factory/ISpaceBlockFactory.java b/vspace/src/main/java/edu/asu/diging/vspace/core/factory/ISpaceBlockFactory.java new file mode 100644 index 000000000..877bb0b5c --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/factory/ISpaceBlockFactory.java @@ -0,0 +1,10 @@ +package edu.asu.diging.vspace.core.factory; + +import edu.asu.diging.vspace.core.model.ISlide; +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; + +public interface ISpaceBlockFactory { + + ISpaceBlock createSpaceBlock(ISlide slide, String text, ISpace space); +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/factory/impl/SpaceBlockFactory.java b/vspace/src/main/java/edu/asu/diging/vspace/core/factory/impl/SpaceBlockFactory.java new file mode 100644 index 000000000..bf3d8a330 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/factory/impl/SpaceBlockFactory.java @@ -0,0 +1,22 @@ +package edu.asu.diging.vspace.core.factory.impl; + +import org.springframework.stereotype.Service; + +import edu.asu.diging.vspace.core.factory.ISpaceBlockFactory; +import edu.asu.diging.vspace.core.model.ISlide; +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; +import edu.asu.diging.vspace.core.model.impl.SpaceBlock; + +@Service +public class SpaceBlockFactory implements ISpaceBlockFactory { + + @Override + public ISpaceBlock createSpaceBlock(ISlide slide, String title, ISpace space) { + ISpaceBlock spaceBlock = new SpaceBlock(); + spaceBlock.setTitle(title); + spaceBlock.setSlide(slide); + spaceBlock.setSpace(space); + return spaceBlock; + } +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ExhibitionModes.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ExhibitionModes.java index 861781065..cdf69aeed 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ExhibitionModes.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ExhibitionModes.java @@ -1,8 +1,5 @@ package edu.asu.diging.vspace.core.model; -import java.util.ArrayList; -import java.util.List; - public enum ExhibitionModes { ACTIVE(""), diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISpaceBlock.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISpaceBlock.java new file mode 100644 index 000000000..d12849123 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISpaceBlock.java @@ -0,0 +1,17 @@ +package edu.asu.diging.vspace.core.model; + +public interface ISpaceBlock extends IContentBlock { + + void setTitle(String text); + + String getTitle(); + + void setId(String id); + + String getId(); + + ISpace getSpace(); + + void setSpace(ISpace space); + +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/display/impl/ExternalLinkDisplay.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/display/impl/ExternalLinkDisplay.java index 18f11996c..90c762b69 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/display/impl/ExternalLinkDisplay.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/display/impl/ExternalLinkDisplay.java @@ -1,5 +1,6 @@ package edu.asu.diging.vspace.core.model.display.impl; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.OneToOne; @@ -12,8 +13,6 @@ import edu.asu.diging.vspace.core.model.display.IExternalLinkDisplay; import edu.asu.diging.vspace.core.model.impl.ExternalLink; -import javax.persistence.Entity; - @Entity public class ExternalLinkDisplay extends LinkDisplay implements IExternalLinkDisplay { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Exhibition.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Exhibition.java index 9616e4e49..18e5fdf2d 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Exhibition.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Exhibition.java @@ -14,8 +14,10 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.OneToOne; + import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; + import edu.asu.diging.vspace.core.model.ExhibitionModes; import edu.asu.diging.vspace.core.model.IContentBlock; import edu.asu.diging.vspace.core.model.IExhibition; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/ExhibitionAboutPage.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/ExhibitionAboutPage.java index e3090eeac..5542a291f 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/ExhibitionAboutPage.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/ExhibitionAboutPage.java @@ -1,7 +1,5 @@ package edu.asu.diging.vspace.core.model.impl; -import java.util.List; - import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/SpaceBlock.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/SpaceBlock.java new file mode 100644 index 000000000..6dc764119 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/SpaceBlock.java @@ -0,0 +1,37 @@ +package edu.asu.diging.vspace.core.model.impl; + +import javax.persistence.Entity; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; + +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; + +@Entity +public class SpaceBlock extends ContentBlock implements ISpaceBlock { + @Lob + private String title; + + @ManyToOne(targetEntity = Space.class) + private ISpace space; + + @Override + public String getTitle() { + return title; + } + + @Override + public void setTitle(String title) { + this.title = title; + } + + @Override + public ISpace getSpace() { + return space; + } + + @Override + public void setSpace(ISpace space) { + this.space = space; + } +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IContentBlockManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IContentBlockManager.java index 7553478fb..a001357fc 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IContentBlockManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IContentBlockManager.java @@ -7,10 +7,14 @@ import edu.asu.diging.vspace.core.model.IChoiceBlock; import edu.asu.diging.vspace.core.model.IContentBlock; import edu.asu.diging.vspace.core.model.IImageBlock; +import edu.asu.diging.vspace.core.model.ISlide; +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; import edu.asu.diging.vspace.core.model.ITextBlock; import edu.asu.diging.vspace.core.model.IVSImage; import edu.asu.diging.vspace.core.model.IVideoBlock; import edu.asu.diging.vspace.core.model.impl.ContentBlock; +import edu.asu.diging.vspace.core.model.impl.SpaceBlock; import edu.asu.diging.vspace.core.model.impl.TextBlock; import edu.asu.diging.vspace.core.services.impl.CreationReturnValue; @@ -57,8 +61,35 @@ IChoiceBlock createChoiceBlock(String slideId, List selectedChoices, Int boolean showsAll); Integer findMaxContentOrder(String slideId); - + + ISpaceBlock createSpaceBlock(String slideId, String title, Integer contentOrder, ISpace space); + + ISpaceBlock getSpaceBlock(String spaceBlockId); + + void saveSpaceBlock(ISpaceBlock textBlock); + + /** + * Delete a space block using an id and also decrease content order by 1 of all + * the slide's block which are after this block + * + * @param blockId - id of resource to be deleted. If the id is null then the + * functions returns nothing. + * @param slideId - id of the slide in which the text block with blockId is + * present. + * + */ + void deleteSpaceBlockById(String blockId, String slideId) throws BlockDoesNotExistException; + + /** + * Adjusting the content order of the blocks of slide once it is dragged and + * changed position. + * + * @param contentBlockList - The list contains the blocks and the updated + * content order corresponding to each blocks. + */ void updateContentOrder(List contentBlockList) throws BlockDoesNotExistException; void saveVideoBlock(IVideoBlock videoBlock); + + } diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleLinkManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleLinkManager.java index 947842938..dcdea370e 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleLinkManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleLinkManager.java @@ -7,6 +7,7 @@ import edu.asu.diging.vspace.core.model.ISpace; import edu.asu.diging.vspace.core.model.display.IModuleLinkDisplay; + public interface IModuleLinkManager extends ILinkManager { /** diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISpaceManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISpaceManager.java index 06b873380..22225d739 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISpaceManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISpaceManager.java @@ -38,4 +38,17 @@ public interface ISpaceManager { Iterable addIncomingLinkInfoToSpaces(Iterable spaces); Page findByNameOrDescription(Pageable requestedPage,String searchText); + + List findByName(String name); + + /** + * Method to return the requested spaces + * + * @param pageNo. if pageNo<1, 1st page is returned, if pageNo>total pages,last + * page is returned + * @return list of images in the requested pageNo and requested order. + */ + List getSpaces(int pageNo, String sortedBy, String order); + + List getSpaces(int pageNo); } diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ContentBlockManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ContentBlockManager.java index cda886b49..6e235dcb8 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ContentBlockManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ContentBlockManager.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; + import org.apache.tika.Tika; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; @@ -13,6 +14,7 @@ import edu.asu.diging.vspace.core.data.ContentBlockRepository; import edu.asu.diging.vspace.core.data.ImageContentBlockRepository; import edu.asu.diging.vspace.core.data.ImageRepository; +import edu.asu.diging.vspace.core.data.SpaceContentBlockRepository; import edu.asu.diging.vspace.core.data.TextContentBlockRepository; import edu.asu.diging.vspace.core.data.VideoContentBlockRepository; import edu.asu.diging.vspace.core.data.VideoRepository; @@ -23,6 +25,7 @@ import edu.asu.diging.vspace.core.factory.IChoiceBlockFactory; import edu.asu.diging.vspace.core.factory.IImageBlockFactory; import edu.asu.diging.vspace.core.factory.IImageFactory; +import edu.asu.diging.vspace.core.factory.ISpaceBlockFactory; import edu.asu.diging.vspace.core.factory.ITextBlockFactory; import edu.asu.diging.vspace.core.factory.IVideoBlockFactory; import edu.asu.diging.vspace.core.factory.IVideoFactory; @@ -32,6 +35,8 @@ import edu.asu.diging.vspace.core.model.IContentBlock; import edu.asu.diging.vspace.core.model.IImageBlock; import edu.asu.diging.vspace.core.model.ISlide; +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; import edu.asu.diging.vspace.core.model.ITextBlock; import edu.asu.diging.vspace.core.model.IVSImage; import edu.asu.diging.vspace.core.model.IVSVideo; @@ -39,6 +44,7 @@ import edu.asu.diging.vspace.core.model.impl.ChoiceBlock; import edu.asu.diging.vspace.core.model.impl.ContentBlock; import edu.asu.diging.vspace.core.model.impl.ImageBlock; +import edu.asu.diging.vspace.core.model.impl.SpaceBlock; import edu.asu.diging.vspace.core.model.impl.TextBlock; import edu.asu.diging.vspace.core.model.impl.VSImage; import edu.asu.diging.vspace.core.model.impl.VSVideo; @@ -62,6 +68,9 @@ public class ContentBlockManager implements IContentBlockManager { @Autowired private ITextBlockFactory textBlockFactory; + @Autowired + private ISpaceBlockFactory spaceBlockFactory; + @Autowired private IImageBlockFactory imageBlockFactory; @@ -80,6 +89,9 @@ public class ContentBlockManager implements IContentBlockManager { @Autowired private TextContentBlockRepository textBlockRepo; + @Autowired + private SpaceContentBlockRepository spaceBlockRepo; + @Autowired private ImageContentBlockRepository imageBlockRepo; @@ -123,6 +135,15 @@ public ITextBlock createTextBlock(String slideId, String text, Integer contentOr return textBlock; } + @Override + public ISpaceBlock createSpaceBlock(String slideId, String title, Integer contentOrder, ISpace space) { + ISlide slide = slideManager.getSlide(slideId); + ISpaceBlock spaceBlock = spaceBlockFactory.createSpaceBlock(slide, title, space); + spaceBlock.setContentOrder(contentOrder); + spaceBlock = spaceBlockRepo.save((SpaceBlock) spaceBlock); + return spaceBlock; + } + private IVSImage saveImage(byte[] image, String filename) { if (image != null && image.length > 0) { Tika tika = new Tika(); @@ -287,6 +308,37 @@ public void deleteTextBlockById(String blockId, String slideId) throws BlockDoes } + /** + * Delete a space block using an id and also decrease content order by 1 of all + * the slide's block which are after this block + * + * @param blockId - id of resource to be deleted. If the id is null then the + * functions returns nothing. + * @param slideId - id of the slide in which the text block with blockId is + * present. + * + */ + @Override + public void deleteSpaceBlockById(String blockId, String slideId) throws BlockDoesNotExistException { + if (blockId == null) { + return; + } + Integer contentOrder = null; + Optional contentBlock = contentBlockRepository.findById(blockId); + if (contentBlock.isPresent()) { + contentOrder = contentBlock.get().getContentOrder(); + } else { + throw new BlockDoesNotExistException("Block Id not present"); + } + try { + spaceBlockRepo.deleteById(blockId); + updateContentOrder(slideId, contentOrder); + } catch (EmptyResultDataAccessException e) { + throw new BlockDoesNotExistException(e); + } + + } + /** * Delete an image block using an id and also decrease content order by 1 of all * the slide's block which are after this block @@ -383,6 +435,11 @@ public void updateTextBlock(TextBlock textBlock) { textBlockRepo.save((TextBlock) textBlock); } + @Override + public void saveSpaceBlock(ISpaceBlock spaceBlock) { + spaceBlockRepo.save((SpaceBlock) spaceBlock); + } + @Override public void updateImageBlock(IImageBlock imageBlock, byte[] image, String filename) throws ImageCouldNotBeStoredException { @@ -402,7 +459,6 @@ public void updateImageBlock(IImageBlock imageBlock, IVSImage image) { public void updateVideoBlock(IVideoBlock videoBlock, byte[] video, Long fileSize, String url, String filename, String title) throws VideoCouldNotBeStoredException { IVSVideo slideContentVideo = storeVideo(video, fileSize, filename, url, title); - videoBlock.setVideo(slideContentVideo); videoBlockRepo.save((VideoBlock) videoBlock); } @@ -434,6 +490,15 @@ public ITextBlock getTextBlock(String textBlockId) { return null; } + @Override + public ISpaceBlock getSpaceBlock(String spaceBlockId) { + Optional spaceBlock = spaceBlockRepo.findById(spaceBlockId); + if (spaceBlock.isPresent()) { + return spaceBlock.get(); + } + return null; + } + @Override public IChoiceBlock getChoiceBlock(String choiceBlockId) { Optional choiceBlock = choiceBlockRepo.findById(choiceBlockId); @@ -520,9 +585,10 @@ private void updateContentOrder(String slideId, Integer contentOrder) { contentBlockRepository.saveAll(contentBlockList); } } - + @Override - public void saveVideoBlock(IVideoBlock videoBlock){ + public void saveVideoBlock(IVideoBlock videoBlock) { videoRepo.save((VSVideo) videoBlock.getVideo()); + } } diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ExhibitionAboutPageManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ExhibitionAboutPageManager.java index e8ded4ca0..c53c841ea 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ExhibitionAboutPageManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ExhibitionAboutPageManager.java @@ -2,11 +2,13 @@ import java.util.ArrayList; import java.util.List; + import javax.transaction.Transactional; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import edu.asu.diging.vspace.core.data.ExhibitionAboutPageRepository; -import edu.asu.diging.vspace.core.data.ExhibitionRepository; import edu.asu.diging.vspace.core.model.IExhibition; import edu.asu.diging.vspace.core.model.impl.Exhibition; import edu.asu.diging.vspace.core.model.impl.ExhibitionAboutPage; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SpaceManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SpaceManager.java index 63884749c..57c36c255 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SpaceManager.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SpaceManager.java @@ -11,9 +11,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import edu.asu.diging.vspace.core.data.ExhibitionRepository; @@ -29,6 +32,7 @@ import edu.asu.diging.vspace.core.file.IStorageEngine; import edu.asu.diging.vspace.core.model.ISpace; import edu.asu.diging.vspace.core.model.IVSImage; +import edu.asu.diging.vspace.core.model.SortByField; import edu.asu.diging.vspace.core.model.display.ISpaceDisplay; import edu.asu.diging.vspace.core.model.display.impl.SpaceDisplay; import edu.asu.diging.vspace.core.model.impl.Exhibition; @@ -78,6 +82,9 @@ public class SpaceManager implements ISpaceManager { @Autowired private SpaceLinkDisplayRepository spaceLinkDisplayRepo; + + @Value("${page_size}") + private int pageSize; private final Logger logger = LoggerFactory.getLogger(getClass()); @@ -297,4 +304,57 @@ public Iterable addIncomingLinkInfoToSpaces(Iterable spaces) { public Page findByNameOrDescription(Pageable requestedPage, String searchText) { return spaceRepo.findDistinctByNameContainingOrDescriptionContaining(requestedPage, searchText,searchText); } + + @Override + public List findByName(String searchText){ + String searchTerm = "%" + searchText + "%"; + List spaces = spaceRepo.findByNameLike(searchTerm); + List spaceResults = new ArrayList<>(); + spaces.forEach(r -> spaceResults.add(r)); + return spaceResults; + } + + @Override + public List getSpaces(int pageNo) { + return getSpaces(pageNo, SortByField.CREATION_DATE.getValue(), Sort.Direction.DESC.toString()); + } + /** + * Method to return the requested spaces + * + * @param pageNo. if pageNo<1, 1st page is returned, if pageNo>total pages,last + * page is returned + * @return list of images in the requested pageNo and requested order. + */ + @Override + public List getSpaces(int pageNo, String sortedBy, String order) { + Sort sortingParameters = getSortingParameters(sortedBy, order); + if(pageNo < 1) { + pageNo = 1; + } + Pageable pagable = PageRequest.of(pageNo - 1, pageSize, sortingParameters); + Page spaces = spaceRepo.findAll(pagable); + if(spaces.getContent().size() == 0) { + pagable = PageRequest.of(spaces.getTotalPages() - 1, pageSize, sortingParameters); + spaces = spaceRepo.findAll(pagable); + } + List results = new ArrayList<>(); + if(spaces != null) { + spaces.getContent().forEach(i -> results.add(i)); + } + return results; + } + + private Sort getSortingParameters(String sortedBy, String order) { + Sort sortingParameters = Sort.by(SortByField.CREATION_DATE.getValue()).descending(); + if(sortedBy!=null && SortByField.getAllValues().contains(sortedBy)) { + sortingParameters = Sort.by(sortedBy); + } + if(order!=null && order.equalsIgnoreCase(Sort.Direction.ASC.toString())) { + sortingParameters = sortingParameters.ascending(); + } else { + sortingParameters = sortingParameters.descending(); + } + return sortingParameters; + } + } \ No newline at end of file diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideTextBlockResults.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideTextBlockResults.java index b1dbb2390..8c3f260e4 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideTextBlockResults.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideTextBlockResults.java @@ -4,7 +4,6 @@ import java.util.Map; import edu.asu.diging.vspace.core.model.ISlide; -import edu.asu.diging.vspace.core.model.impl.Slide; public class StaffSearchSlideTextBlockResults { diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddChoiceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddChoiceBlockController.java index 6b6f0b595..6cad36731 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddChoiceBlockController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddChoiceBlockController.java @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import edu.asu.diging.vspace.core.data.ContentBlockRepository; import edu.asu.diging.vspace.core.model.IChoiceBlock; import edu.asu.diging.vspace.core.model.ISequence; import edu.asu.diging.vspace.core.services.IContentBlockManager; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleController.java index cdf8976e5..4710938ac 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleController.java @@ -6,7 +6,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddSpaceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddSpaceBlockController.java new file mode 100644 index 000000000..f890ba56e --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddSpaceBlockController.java @@ -0,0 +1,36 @@ +package edu.asu.diging.vspace.web.staff; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; +import edu.asu.diging.vspace.core.services.IContentBlockManager; +import edu.asu.diging.vspace.core.services.ISpaceManager; + +@Controller +public class AddSpaceBlockController { + + @Autowired + private IContentBlockManager contentBlockManager; + + @Autowired + private ISpaceManager spaceManager; + + @RequestMapping(value = "/staff/module/{moduleId}/slide/{slideId}/space", method = RequestMethod.POST) + public ResponseEntity addSpaceBlock(@RequestParam("title") String title,@RequestParam("spaceId") String spaceId, @PathVariable("slideId") String slideId, + @PathVariable("moduleId") String moduleId){ + ISpace space = spaceManager.getSpace(spaceId); + Integer contentOrder = contentBlockManager.findMaxContentOrder(slideId); + contentOrder = contentOrder == null ? 0 : contentOrder + 1; + ISpaceBlock spaceBlock = contentBlockManager.createSpaceBlock(slideId, title, contentOrder, space); + return new ResponseEntity<>(spaceBlock.getId(), HttpStatus.OK); + } + +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteChoiceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteChoiceBlockController.java index 9adf436dc..98116595b 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteChoiceBlockController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteChoiceBlockController.java @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import edu.asu.diging.vspace.core.data.ContentBlockRepository; import edu.asu.diging.vspace.core.exception.BlockDoesNotExistException; import edu.asu.diging.vspace.core.services.IContentBlockManager; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceBlockController.java new file mode 100644 index 000000000..2026f9796 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceBlockController.java @@ -0,0 +1,39 @@ +package edu.asu.diging.vspace.web.staff; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import edu.asu.diging.vspace.core.exception.BlockDoesNotExistException; +import edu.asu.diging.vspace.core.services.IContentBlockManager; + +@Controller +public class DeleteSpaceBlockController { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private IContentBlockManager contentBlockManager; + + @RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/space/{blockId}", method = RequestMethod.DELETE) + public ResponseEntity deleteSpaceBlock(@PathVariable("id") String slideId,@PathVariable("blockId") String blockId) throws IOException { + try { + contentBlockManager.deleteSpaceBlockById(blockId,slideId); + + } catch (BlockDoesNotExistException e) { + logger.warn("Block Id does not exist, bad request.", e); + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceController.java index a9a3d2eee..7feb0f9db 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteSpaceController.java @@ -11,10 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import com.google.gson.JsonObject; - import edu.asu.diging.vspace.core.exception.SpaceDoesNotExistException; -import edu.asu.diging.vspace.core.services.IExhibitionManager; import edu.asu.diging.vspace.core.services.ISpaceManager; @Controller diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteTextBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteTextBlockController.java index cc1d0cca3..269f0365b 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteTextBlockController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DeleteTextBlockController.java @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import edu.asu.diging.vspace.core.data.ContentBlockRepository; import edu.asu.diging.vspace.core.exception.BlockDoesNotExistException; import edu.asu.diging.vspace.core.services.IContentBlockManager; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditSpaceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditSpaceBlockController.java new file mode 100644 index 000000000..5e060a917 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditSpaceBlockController.java @@ -0,0 +1,43 @@ +package edu.asu.diging.vspace.web.staff; + +import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.model.ISpaceBlock; +import edu.asu.diging.vspace.core.model.impl.SpaceBlock; +import edu.asu.diging.vspace.core.services.IContentBlockManager; +import edu.asu.diging.vspace.core.services.ISpaceManager; + +@Controller +public class EditSpaceBlockController { + + @Autowired + private IContentBlockManager contentBlockManager; + + @Autowired + private ISpaceManager spaceManager; + + @RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/space/edit", method = RequestMethod.POST) + public ResponseEntity editSpaceBlock(@PathVariable("id") String slideId, + @RequestParam("spaceBlockId") String blockId, @PathVariable("moduleId") String moduleId, + @RequestParam("spaceBlockTitle") String spaceBlockTitle, @RequestParam("spaceId") String spaceId) + throws IOException { + ISpaceBlock spaceBlock = contentBlockManager.getSpaceBlock(blockId); + ISpace space = spaceManager.getSpace(spaceId); + spaceBlock.setTitle(spaceBlockTitle); + spaceBlock.setSpace(space); + contentBlockManager.saveSpaceBlock(spaceBlock); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/ExhibitionAboutPageController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/ExhibitionAboutPageController.java index 4a4cf7b41..829f94490 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/ExhibitionAboutPageController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/ExhibitionAboutPageController.java @@ -3,22 +3,16 @@ import java.io.IOException; import java.util.List; -import javax.servlet.http.HttpServletRequest; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; -import org.springframework.web.servlet.view.RedirectView; import edu.asu.diging.vspace.core.model.impl.ExhibitionAboutPage; import edu.asu.diging.vspace.core.services.IExhibitionAboutPageManager; -import edu.asu.diging.vspace.core.services.IExhibitionManager; -import edu.asu.diging.vspace.web.staff.forms.SpaceForm; /** * diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SlideController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SlideController.java index e0b533bf8..5ed7fbeb9 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SlideController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SlideController.java @@ -46,16 +46,18 @@ public String listSlides(@PathVariable("id") String id, @PathVariable("moduleId" model.addAttribute("slideSequences", slideManager.getSlideSequences(id, moduleId)); List slideContents = contentBlockManager.getAllContentBlocks(id); model.addAttribute("slideContents", slideContents); - model.addAttribute("contentCount",slideContents.size()>0 ? slideContents.get(slideContents.size()-1).getContentOrder() : 0); - if(slideManager.getSlide(id) instanceof BranchingPoint) { - model.addAttribute("choices", ((IBranchingPoint)slide).getChoices()); - } + model.addAttribute("contentCount", + slideContents.size() > 0 ? slideContents.get(slideContents.size() - 1).getContentOrder() : 0); + if (slideManager.getSlide(id) instanceof BranchingPoint) { + model.addAttribute("choices", ((IBranchingPoint) slide).getChoices()); + } return "staff/modules/slides/slide"; } @RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/contents", method = RequestMethod.GET) - public ResponseEntity> getAllContentBlocks(Model model, @PathVariable("moduleId") String moduleId, @PathVariable("id") String slideId, @ModelAttribute SequenceForm sequenceForm, - Principal principal) { + public ResponseEntity> getAllContentBlocks(Model model, + @PathVariable("moduleId") String moduleId, @PathVariable("id") String slideId, + @ModelAttribute SequenceForm sequenceForm, Principal principal) { List slideContents = contentBlockManager.getAllContentBlocks(slideId); return new ResponseEntity>(slideContents, HttpStatus.OK); diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SpaceBlockController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SpaceBlockController.java new file mode 100644 index 000000000..40da80a59 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/SpaceBlockController.java @@ -0,0 +1,31 @@ +package edu.asu.diging.vspace.web.staff; + +import java.io.IOException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import edu.asu.diging.vspace.core.model.ISpaceBlock; +import edu.asu.diging.vspace.core.services.IContentBlockManager; + +@Controller +public class SpaceBlockController { + + @Autowired + private IContentBlockManager contentBlockManager; + + @RequestMapping(value = "/staff/module/{moduleId}/slide/{id}/space/{blockId}", method = RequestMethod.GET) + public ResponseEntity getSpaceBlock(@PathVariable("id") String slideId, + @PathVariable("blockId") String blockId) throws IOException { + ISpaceBlock spaceBlock = contentBlockManager.getSpaceBlock(blockId); + if(spaceBlock == null) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + return new ResponseEntity(spaceBlock,HttpStatus.OK); + } + +} diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchController.java index 6ee62cbdc..08e5a13b6 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchController.java @@ -10,9 +10,6 @@ import edu.asu.diging.vspace.core.model.IModule; import edu.asu.diging.vspace.core.model.ISlide; import edu.asu.diging.vspace.core.model.ISpace; -import edu.asu.diging.vspace.core.model.impl.Module; -import edu.asu.diging.vspace.core.model.impl.Slide; -import edu.asu.diging.vspace.core.model.impl.Space; import edu.asu.diging.vspace.core.services.IStaffSearchManager; @Controller diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSpaceController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSpaceController.java index b6ab7ed46..8b25ae9dd 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSpaceController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSpaceController.java @@ -47,4 +47,4 @@ private List paginationForSpace(String spacePagenum, String searchTerm) Page spacePage = staffSearchManager.searchInSpaces(searchTerm, Integer.parseInt(spacePagenum)); return spacePage.getContent(); } -} +} \ No newline at end of file diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSpacesSearchController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSpacesSearchController.java new file mode 100644 index 000000000..cf0d972ab --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSpacesSearchController.java @@ -0,0 +1,47 @@ +package edu.asu.diging.vspace.web.staff; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import edu.asu.diging.vspace.core.model.ISpace; +import edu.asu.diging.vspace.core.services.ISpaceManager; + + +@Controller +public class StaffSpacesSearchController { + + @Autowired + private ISpaceManager spaceManager; + + @RequestMapping("/staff/spaces/search") + public ResponseEntity search(@RequestParam(value = "term", required = false) String search) { + List spaces = null; + if (search != null && !search.trim().isEmpty()) { + spaces = spaceManager.findByName(search); + } else { + spaces = spaceManager.getAllSpaces(); + } + + ObjectMapper mapper = new ObjectMapper(); + ArrayNode idArray = mapper.createArrayNode(); + for (ISpace space: spaces) { + ObjectNode spaceNode = mapper.createObjectNode(); + spaceNode.put("id", space.getId()); + spaceNode.put("name", space.getName()); + idArray.add(spaceNode); + } + return new ResponseEntity (idArray.toString(), HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateContentOrderController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateContentOrderController.java index 40339ce72..75d409c53 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateContentOrderController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateContentOrderController.java @@ -36,4 +36,4 @@ public ResponseEntity> adjustContentOrder(@RequestBody List>(contentBlockList,HttpStatus.OK); } -} +} \ No newline at end of file diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateStartSequenceModuleController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateStartSequenceModuleController.java index d9b30962c..88c8e1be0 100644 --- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateStartSequenceModuleController.java +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/UpdateStartSequenceModuleController.java @@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; -import org.springframework.web.servlet.view.RedirectView; import edu.asu.diging.vspace.core.model.IModule; import edu.asu.diging.vspace.core.services.IModuleManager; diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/forms/SpaceContentBlockForm.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/forms/SpaceContentBlockForm.java new file mode 100644 index 000000000..dd741de81 --- /dev/null +++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/forms/SpaceContentBlockForm.java @@ -0,0 +1,20 @@ +package edu.asu.diging.vspace.web.staff.forms; + +public class SpaceContentBlockForm { + + private String title; + private String spaceName; + + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getSpaceName() { + return spaceName; + } + public void setSpaceName(String spaceName) { + this.spaceName = spaceName; + } +} diff --git a/vspace/src/main/webapp/WEB-INF/views/exhibition/module.html b/vspace/src/main/webapp/WEB-INF/views/exhibition/module.html index f2153bf87..77499bdc6 100644 --- a/vspace/src/main/webapp/WEB-INF/views/exhibition/module.html +++ b/vspace/src/main/webapp/WEB-INF/views/exhibition/module.html @@ -134,6 +134,8 @@

[[${currentSlideCon.name}]]

[(${contents.htmlRenderedText()})]
+