diff --git a/README.md b/README.md
index c9193b92e..627fa9789 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,6 @@
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/digingasu/virtual-spaces?color=yellow&label=Docker%20Hub&sort=date)
-Virtual Spaces 2.0 let's you build virtual exhibitions through a web application. Upload images of your (virtual or real) spaces and link them by placing links on them. Create modules that provide more details about the topics you present.
+Virtual Spaces 2.0 lets you build virtual exhibitions through a web application. Upload images of your (virtual or real) spaces and link them by placing links on them. Create modules that provide more details about the topics you present.
You can find Virtual Spaces documentation [here](https://diging.atlassian.net/wiki/spaces/VS2D).
diff --git a/vspace/.classpath b/vspace/.classpath
index 9d58bf752..3aa72561a 100644
--- a/vspace/.classpath
+++ b/vspace/.classpath
@@ -49,4 +49,4 @@
-
+
\ No newline at end of file
diff --git a/vspace/pom.xml b/vspace/pom.xml
index 53d5b0be7..d5fcef347 100644
--- a/vspace/pom.xml
+++ b/vspace/pom.xml
@@ -40,6 +40,7 @@
TomcatServer
+ v0.16.1
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
new file mode 100644
index 000000000..40b272e85
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/simpleusers/web/admin/UsersUtility.java
@@ -0,0 +1,27 @@
+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;
+
+/**
+ * Utility class that contains methods for ListUsersController
+ * @author Glen Dsouza
+ */
+public class UsersUtility {
+
+ /**
+ * This method checks if the User has a specific Role assigned to them.
+ * It takes as parameter a set of User Roles of the type SimpleGrantedAuthority
+ * and it validates if the User Role exists with the second parameter which is
+ * a String of the type of Role we need to validate.
+ * @param userRoles a set of SimpleGrantedAuthority containing details of the roles assigned to a User
+ * @param role the role that needs to be checked against userRoles
+ * @return Boolean: True if User is assigned the role, else False.
+ */
+ public static Boolean checkUserRoleExists(Set userRoles, String role) {
+ return userRoles.stream().anyMatch(roleKey -> (roleKey.toString().equals(role)));
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleRepository.java
index 36913f981..34292dfb2 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleRepository.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/ModuleRepository.java
@@ -3,9 +3,12 @@
import java.util.List;
import org.javers.spring.annotation.JaversSpringDataAuditable;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
+import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.impl.Module;
@Repository
@@ -13,7 +16,9 @@
public interface ModuleRepository extends PagingAndSortingRepository {
List findTop5ByOrderByCreationDateDesc();
-
- List findAllByOrderByCreationDateDesc();
+ Page findDistinctByNameContainingOrDescriptionContaining(Pageable requestedPage, String name,
+ String description);
+
+ List findAllByOrderByCreationDateDesc();
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/SlideRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SlideRepository.java
index 11d27b9a5..5ce307643 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/SlideRepository.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/SlideRepository.java
@@ -3,10 +3,13 @@
import java.util.List;
import org.javers.spring.annotation.JaversSpringDataAuditable;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
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.ISlide;
import edu.asu.diging.vspace.core.model.impl.Sequence;
import edu.asu.diging.vspace.core.model.impl.Slide;
@@ -16,8 +19,11 @@ public interface SlideRepository extends PagingAndSortingRepository findSlidesForModule(String moduleId);
-
+
@Query("SELECT d.sequence FROM Slide d WHERE d.id = ?1")
public List getSequencesForSlide(String slideId);
+ Page findDistinctByNameContainingOrDescriptionContaining(Pageable requestedPage, String name,
+ String description);
+
}
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 6b1a1d334..7107d36e2 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
@@ -3,9 +3,12 @@
import java.util.List;
import org.javers.spring.annotation.JaversSpringDataAuditable;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
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.impl.Space;
import edu.asu.diging.vspace.core.model.impl.SpaceStatus;
@@ -19,4 +22,6 @@ public interface SpaceRepository extends PagingAndSortingRepository findAllByImageId(String imageId);
+ Page findDistinctByNameContainingOrDescriptionContaining(Pageable requestedPage, String name,
+ String description);
}
\ No newline at end of file
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/data/TextContentBlockRepository.java b/vspace/src/main/java/edu/asu/diging/vspace/core/data/TextContentBlockRepository.java
index be7604f95..24c64d7dc 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/data/TextContentBlockRepository.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/data/TextContentBlockRepository.java
@@ -1,13 +1,20 @@
package edu.asu.diging.vspace.core.data;
import org.javers.spring.annotation.JaversSpringDataAuditable;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+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.ISlide;
import edu.asu.diging.vspace.core.model.impl.TextBlock;
@Repository
@JaversSpringDataAuditable
public interface TextContentBlockRepository extends PagingAndSortingRepository {
+ @Query("SELECT DISTINCT c.slide FROM ContentBlock c, TextBlock t WHERE c.id = t.id AND t.text LIKE %?1%")
+ public Page findWithNameOrDescription(Pageable requestedPage, String searchText);
+
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISlide.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISlide.java
index 3c0774842..59985eee6 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISlide.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ISlide.java
@@ -11,5 +11,8 @@ public interface ISlide extends IVSpaceElement {
void setContents(List contents);
List getContents();
-
+
+ IImageBlock getFirstImageBlock();
+
+ ITextBlock getFirstMatchedTextBlock(String searchTerm);
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ITextBlock.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ITextBlock.java
index f5e7fd69a..b86e08556 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/ITextBlock.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/ITextBlock.java
@@ -9,5 +9,7 @@ public interface ITextBlock extends IContentBlock {
void setId(String id);
String getId();
+
+ String htmlRenderedText();
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Slide.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Slide.java
index a073f7e07..350de758e 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Slide.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/Slide.java
@@ -3,6 +3,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Optional;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
@@ -18,28 +19,28 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.asu.diging.vspace.core.model.IContentBlock;
+import edu.asu.diging.vspace.core.model.IImageBlock;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISequence;
import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.model.ITextBlock;
@Entity
public class Slide extends VSpaceElement implements ISlide {
@Id
@GeneratedValue(generator = "slide_id_generator")
- @GenericGenerator(name = "slide_id_generator",
- parameters = @Parameter(name = "prefix", value = "SLI"),
- strategy = "edu.asu.diging.vspace.core.data.IdGenerator")
+ @GenericGenerator(name = "slide_id_generator", parameters = @Parameter(name = "prefix", value = "SLI"), strategy = "edu.asu.diging.vspace.core.data.IdGenerator")
private String id;
@ManyToOne(targetEntity = Module.class)
private IModule module;
- //-------- @JsonIgnore used as this entity will be returned in a controller
- @JsonIgnore
+ // -------- @JsonIgnore used as this entity will be returned in a controller
+ @JsonIgnore
@OneToMany(targetEntity = ContentBlock.class, mappedBy = "slide", cascade = CascadeType.ALL)
private List contents;
-
+
@JsonIgnore
@ManyToMany(mappedBy = "slides", targetEntity = Sequence.class)
private List sequence;
@@ -77,8 +78,7 @@ public IModule getModule() {
/*
* (non-Javadoc)
*
- * @see
- * edu.asu.diging.vspace.core.model.impl.ISlide#setImage(edu.asu.diging.
+ * @see edu.asu.diging.vspace.core.model.impl.ISlide#setImage(edu.asu.diging.
* vspace. core.model.IModule)
*/
@Override
@@ -106,15 +106,14 @@ public int compare(IContentBlock o1, IContentBlock o2) {
/*
* (non-Javadoc)
*
- * @see
- * edu.asu.diging.vspace.core.model.impl.ISlide#setContents(edu.asu.diging.
+ * @see edu.asu.diging.vspace.core.model.impl.ISlide#setContents(edu.asu.diging.
* vspace. core.model.IContentBlock)
*/
@Override
public void setContents(List contents) {
this.contents = contents;
}
-
+
/*
* (non-Javadoc)
*
@@ -127,12 +126,51 @@ public List getSequence() {
/*
* (non-Javadoc)
*
- * @see
- * edu.asu.diging.vspace.core.model.impl.ISlide#setSequence(java.util.List)
+ * @see edu.asu.diging.vspace.core.model.impl.ISlide#setSequence(java.util.List)
*/
public void setSequence(List sequence) {
this.sequence = sequence;
}
+ /**
+ * This Method will retrieve the first ImageBlock of a slide if the ImageBlock
+ * is present
+ *
+ * @return IImageBlock
+ */
+ @Override
+ @JsonIgnore
+ public IImageBlock getFirstImageBlock() {
+ List allBlocks = getContents();
+ if (allBlocks != null) {
+ Optional firstImageBlock = allBlocks.stream()
+ .filter(contentBlock -> contentBlock instanceof ImageBlock).findFirst();
+ if (firstImageBlock.isPresent()) {
+ return (ImageBlock) firstImageBlock.get();
+ }
+ }
+ return null;
+ }
+ /**
+ * This Method will return the first Text block whose content has searchTerm in
+ * it.
+ *
+ * @param searchTerm the search string which is being searched.
+ * @return TextBlock
+ */
+ @Override
+ @JsonIgnore
+ public ITextBlock getFirstMatchedTextBlock(String searchTerm) {
+ List allBlocks = getContents();
+ if (allBlocks != null) {
+ Optional firstMatchedTextBlock = allBlocks.stream()
+ .filter(contentBlock -> contentBlock instanceof TextBlock)
+ .filter(contentBlock -> ((TextBlock) contentBlock).getText().contains(searchTerm)).findFirst();
+ if (firstMatchedTextBlock.isPresent()) {
+ return (TextBlock) firstMatchedTextBlock.get();
+ }
+ }
+ return null;
+ }
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/TextBlock.java b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/TextBlock.java
index 3e6db108f..2ffb5a31b 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/TextBlock.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/model/impl/TextBlock.java
@@ -37,6 +37,13 @@ public void setText(String text) {
this.text = text;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * edu.asu.diging.vspace.core.model.impl.ITextBlock#htmlRenderedText()
+ */
+ @Override
@Transient
public String htmlRenderedText() {
Parser parser = Parser.builder().build();
@@ -44,5 +51,4 @@ public String htmlRenderedText() {
HtmlRenderer renderer = HtmlRenderer.builder().build();
return renderer.render(document);
}
-
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleManager.java
index 5f5e74b23..d8956f85e 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleManager.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IModuleManager.java
@@ -2,6 +2,9 @@
import java.util.List;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISequence;
import edu.asu.diging.vspace.core.model.ISlide;
@@ -19,5 +22,6 @@ public interface IModuleManager {
List getModuleSequences(String moduleId);
ISequence checkIfSequenceExists(String moduleId, String sequenceId);
-
+
+ Page findByNameOrDescription(Pageable requestedPage,String searchText);
}
\ No newline at end of file
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISlideManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISlideManager.java
index b08b27249..947f4c9ce 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISlideManager.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/ISlideManager.java
@@ -1,14 +1,17 @@
package edu.asu.diging.vspace.core.services;
+import java.util.List;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
import edu.asu.diging.vspace.core.model.IBranchingPoint;
+import edu.asu.diging.vspace.core.model.IChoice;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISlide;
import edu.asu.diging.vspace.core.model.display.SlideType;
-import java.util.List;
-
import edu.asu.diging.vspace.core.model.impl.Sequence;
import edu.asu.diging.vspace.core.model.impl.Slide;
-import edu.asu.diging.vspace.core.model.IChoice;
import edu.asu.diging.vspace.web.staff.forms.SlideForm;
public interface ISlideManager {
@@ -28,5 +31,6 @@ public interface ISlideManager {
void deleteSlideById(String slideId, String moduleId);
List getSlideSequences(String slideId, String moduleId);
-
+
+ Page findByNameOrDescription(Pageable requestedPage,String searchText);
}
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 e1e046e6a..ec812cdfd 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
@@ -2,6 +2,9 @@
import java.util.List;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
import edu.asu.diging.vspace.core.exception.SpaceDoesNotExistException;
import edu.asu.diging.vspace.core.model.ISpace;
import edu.asu.diging.vspace.core.model.IVSImage;
@@ -33,5 +36,6 @@ public interface ISpaceManager {
List getIncomingLinks(String id);
Iterable addIncomingLinkInfoToSpaces(Iterable spaces);
-
+
+ Page findByNameOrDescription(Pageable requestedPage,String searchText);
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/IStaffSearchManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IStaffSearchManager.java
new file mode 100644
index 000000000..a358b2e68
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/IStaffSearchManager.java
@@ -0,0 +1,18 @@
+package edu.asu.diging.vspace.core.services;
+
+import org.springframework.data.domain.Page;
+
+import edu.asu.diging.vspace.core.model.IModule;
+import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.model.ISpace;
+
+public interface IStaffSearchManager {
+
+ Page searchInSpaces(String searchTerm, int page);
+
+ Page searchInModules(String searchTerm, int page);
+
+ Page searchInSlides(String searchTerm, int page);
+
+ Page searchInSlideTexts(String searchTerm, int page);
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ModuleManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ModuleManager.java
index 5d8b6e06d..29e30db40 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ModuleManager.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/ModuleManager.java
@@ -8,6 +8,8 @@
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import edu.asu.diging.vspace.core.data.ModuleRepository;
@@ -82,4 +84,9 @@ public List getModuleSequences(String moduleId) {
public ISequence checkIfSequenceExists(String moduleId, String sequenceId) {
return sequenceRepo.findSequenceForModuleAndSequence(moduleId,sequenceId);
}
+
+ @Override
+ public Page findByNameOrDescription(Pageable requestedPage,String searchText) {
+ return moduleRepo.findDistinctByNameContainingOrDescriptionContaining(requestedPage,searchText,searchText);
+ }
}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SlideManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SlideManager.java
index bb92a52c3..fefd99c1e 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SlideManager.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SlideManager.java
@@ -10,6 +10,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import edu.asu.diging.vspace.core.data.BranchingPointRepository;
@@ -30,7 +32,6 @@
import edu.asu.diging.vspace.core.services.ISlideManager;
import edu.asu.diging.vspace.web.staff.forms.SlideForm;
-
@Service
public class SlideManager implements ISlideManager {
@@ -56,33 +57,39 @@ public class SlideManager implements ISlideManager {
@Override
public ISlide createSlide(IModule module, SlideForm slideForm, SlideType type) {
- ISlide slide = slideFactory.createSlide(module, slideForm, type);
+ ISlide slide = slideFactory.createSlide(module, slideForm, type);
return slideRepo.save((Slide) slide);
}
@Override
public IBranchingPoint createBranchingPoint(IModule module, SlideForm slideForm, SlideType type) {
- ISlide branchingPoint = slideFactory.createSlide(module, slideForm, type);
+ ISlide branchingPoint = slideFactory.createSlide(module, slideForm, type);
return bpointRepo.save((BranchingPoint) branchingPoint);
}
@Override
public void updateBranchingPoint(IBranchingPoint branchingPoint, List editedChoiceSequenceIds) {
- List existingChoices=branchingPoint.getChoices();
- List existingChoiceSequenceIds=existingChoices.stream().map(choiceSequence -> choiceSequence.getSequence().getId()).collect(Collectors.toList());
- List deletedChoiceSequenceIds = (List) CollectionUtils.subtract(existingChoiceSequenceIds, editedChoiceSequenceIds);
- List addedChoiceSequenceIds = (List) CollectionUtils.subtract(editedChoiceSequenceIds,existingChoiceSequenceIds);
+ List existingChoices = branchingPoint.getChoices();
+ List existingChoiceSequenceIds = existingChoices.stream()
+ .map(choiceSequence -> choiceSequence.getSequence().getId()).collect(Collectors.toList());
+ List deletedChoiceSequenceIds = (List) CollectionUtils.subtract(existingChoiceSequenceIds,
+ editedChoiceSequenceIds);
+ List addedChoiceSequenceIds = (List) CollectionUtils.subtract(editedChoiceSequenceIds,
+ existingChoiceSequenceIds);
List newlyAddedChoices = choiceFactory.createChoices(addedChoiceSequenceIds);
existingChoices.addAll(newlyAddedChoices);
- List choicesToDelete = existingChoices.stream().filter(choice -> deletedChoiceSequenceIds.contains(choice.getSequence().getId())).collect(Collectors.toList());
+ List choicesToDelete = existingChoices.stream()
+ .filter(choice -> deletedChoiceSequenceIds.contains(choice.getSequence().getId()))
+ .collect(Collectors.toList());
existingChoices.removeIf(choice -> deletedChoiceSequenceIds.contains(choice.getSequence().getId()));
branchingPoint.setChoices(existingChoices);
bpointRepo.save((BranchingPoint) branchingPoint);
/*
- * We did not use deleteAll on choiceRepo as choicesToDelete is a list of IChoice
- * and cannot be casted into Choice and objects of other type can also implement IChoice
+ * We did not use deleteAll on choiceRepo as choicesToDelete is a list of
+ * IChoice and cannot be casted into Choice and objects of other type can also
+ * implement IChoice
*/
- for(IChoice deletedChoice : choicesToDelete) {
+ for (IChoice deletedChoice : choicesToDelete) {
choiceRepo.deleteById(deletedChoice.getId());
}
}
@@ -112,7 +119,7 @@ public void updateSlide(Slide slide) {
@Override
public void deleteSlideById(String slideId, String moduleId) {
- if(slideId == null) {
+ if (slideId == null) {
logger.error("Slide Id cannot be null.");
return;
}
@@ -121,11 +128,11 @@ public void deleteSlideById(String slideId, String moduleId) {
Slide slideObj = (Slide) getSlide(slideId);
List slideObjToRemove = new ArrayList<>();
slideObjToRemove.add(slideObj);
- if(slideObj == null) {
+ if (slideObj == null) {
return;
}
for (Sequence sequence : sequences) {
- if(sequence.getSlides().contains(slideObj)) {
+ if (sequence.getSlides().contains(slideObj)) {
sequence.getSlides().removeAll(slideObjToRemove);
sequenceRepo.save(sequence);
}
@@ -154,4 +161,10 @@ public List getSlideSequences(String slideId, String moduleId) {
}
return sequenceSlides;
}
+
+ @Override
+ public Page findByNameOrDescription(Pageable requestedPage, String searchText) {
+
+ return slideRepo.findDistinctByNameContainingOrDescriptionContaining(requestedPage, searchText,searchText);
+ }
}
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 12ad85664..63884749c 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
@@ -5,7 +5,6 @@
import java.util.List;
import java.util.Optional;
-import javax.persistence.EntityNotFoundException;
import javax.transaction.Transactional;
import org.apache.tika.Tika;
@@ -13,6 +12,8 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import edu.asu.diging.vspace.core.data.ExhibitionRepository;
@@ -291,4 +292,9 @@ public Iterable addIncomingLinkInfoToSpaces(Iterable spaces) {
}
return spaces;
}
+
+ @Override
+ public Page findByNameOrDescription(Pageable requestedPage, String searchText) {
+ return spaceRepo.findDistinctByNameContainingOrDescriptionContaining(requestedPage, searchText,searchText);
+ }
}
\ No newline at end of file
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/StaffSearchManager.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/StaffSearchManager.java
new file mode 100644
index 000000000..34ca9c3eb
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/StaffSearchManager.java
@@ -0,0 +1,184 @@
+package edu.asu.diging.vspace.core.services.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+import edu.asu.diging.vspace.core.data.TextContentBlockRepository;
+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.services.IModuleManager;
+import edu.asu.diging.vspace.core.services.ISlideManager;
+import edu.asu.diging.vspace.core.services.ISpaceManager;
+import edu.asu.diging.vspace.core.services.IStaffSearchManager;
+
+/**
+ * This class has all the methods with the business logics for searching a word
+ * in staff page.
+ *
+ * @author Avirup Biswas
+ *
+ */
+@Service
+public class StaffSearchManager implements IStaffSearchManager {
+
+ @Value("${page_size}")
+ private int pageSize;
+
+ @Autowired
+ private ISpaceManager spaceManager;
+
+ @Autowired
+ private IModuleManager moduleManager;
+
+ @Autowired
+ private ISlideManager slideManager;
+
+ @Autowired
+ private TextContentBlockRepository textContentBlockRepo;
+
+ /**
+ * Method to return the requested spaces whose name or description contains the
+ * search string
+ *
+ * @param searchTerm string which has been searched
+ * @param page. The page number starts from 1.
+ * @return set of spaces whose name or description contains the search string in
+ * the requested page.
+ */
+ @Override
+ public Page searchInSpaces(String searchTerm, int page) {
+ /* if page<1, 1st page is returned */
+ if (page < 1) {
+ page = 1;
+ }
+ Pageable requestedPageForSpace = PageRequest.of(page - 1, pageSize);
+ Page spacePage = spaceManager.findByNameOrDescription(requestedPageForSpace, searchTerm);
+ int totalSpacePage = spacePage.getTotalPages();
+ /*
+ * spring will just return an empty dataset if a page that is greater than the
+ * total number of pages is returned. So, the page given (except when it's < 1,
+ * then set it to 1) and then checking if the total page count is smaller than
+ * the given one (if so, make another request). In most cases the page number
+ * will be within the range of pages, so we would need only one db call. Only in
+ * cases where the page number is wrong, would a second one be needed.if
+ * page>total pages,last page is returned.
+ */
+ if (page > totalSpacePage) {
+ totalSpacePage = totalSpacePage == 0 ? 1 : totalSpacePage;
+ requestedPageForSpace = PageRequest.of(totalSpacePage - 1, pageSize);
+ spacePage = spaceManager.findByNameOrDescription(requestedPageForSpace, searchTerm);
+ }
+ return spacePage;
+ }
+
+ /**
+ * Method to return the requested modules whose name or description contains the
+ * search string
+ *
+ * @param searchTerm string which has been searched
+ * @param page. The page number starts from 1.
+ * @return set of modules whose name or description contains the search string
+ * in the requested page.
+ */
+ @Override
+ public Page searchInModules(String searchTerm, int page) {
+ /* if page<1, 1st page is returned */
+ if (page < 1) {
+ page = 1;
+ }
+ Pageable requestedPageForModule = PageRequest.of(page - 1, pageSize);
+ Page modulePage = moduleManager.findByNameOrDescription(requestedPageForModule, searchTerm);
+ int totalModulePage = modulePage.getTotalPages();
+ /*
+ * spring will just return an empty dataset if a page that is greater than the
+ * total number of pages is returned. So, the page given (except when it's < 1,
+ * then set it to 1) and then checking if the total page count is smaller than
+ * the given one (if so, make another request). In most cases the page number
+ * will be within the range of pages, so we would need only one db call. Only in
+ * cases where the page number is wrong, would a second one be needed.if
+ * page>total pages,last page is returned.
+ */
+ if (page > totalModulePage) {
+ totalModulePage = totalModulePage == 0 ? 1 : totalModulePage;
+ requestedPageForModule = PageRequest.of(totalModulePage - 1, pageSize);
+ modulePage = moduleManager.findByNameOrDescription(requestedPageForModule, searchTerm);
+ }
+ return modulePage;
+ }
+
+ /**
+ * Method to return the requested slides whose name or description contains the
+ * search string
+ *
+ * @param searchTerm string which has been searched
+ * @param page. The page number starts from 1.
+ * @return set of slides whose name or description contains the search string in
+ * the requested page.
+ */
+ @Override
+ public Page searchInSlides(String searchTerm, int page) {
+ /* if page<1, 1st page is returned */
+ if (page < 1) {
+ page = 1;
+ }
+ Pageable requestedPageForSlide = PageRequest.of(page - 1, pageSize);
+ Page slidePage = slideManager.findByNameOrDescription(requestedPageForSlide, searchTerm);
+ int totalSlidePage = slidePage.getTotalPages();
+ /*
+ * spring will just return an empty dataset if a page that is greater than the
+ * total number of pages is returned. So, the page given (except when it's < 1,
+ * then set it to 1) and then checking if the total page count is smaller than
+ * the given one (if so, make another request). In most cases the page number
+ * will be within the range of pages, so we would need only one db call. Only in
+ * cases where the page number is wrong, would a second one be needed.if
+ * page>total pages,last page is returned.
+ */
+ if (page > totalSlidePage) {
+ totalSlidePage = totalSlidePage == 0 ? 1 : totalSlidePage;
+ requestedPageForSlide = PageRequest.of(totalSlidePage - 1, pageSize);
+ slidePage = slideManager.findByNameOrDescription(requestedPageForSlide, searchTerm);
+ }
+ return slidePage;
+ }
+
+ /**
+ * Method to return the requested slides whose text blocks contains the search
+ * string
+ *
+ * @param searchTerm string which has been searched
+ * @param page. The page number starts from 1.
+ * @return list of slides whose text blocks contains the search string in the
+ * requested page.
+ */
+ @Override
+ public Page searchInSlideTexts(String searchTerm, int page) {
+ /* if page<1, 1st page is returned */
+ if (page < 1) {
+ page = 1;
+ }
+ Pageable requestedPageForSlideText = PageRequest.of(page - 1, pageSize);
+ Page slidetextPage = textContentBlockRepo.findWithNameOrDescription(requestedPageForSlideText,
+ searchTerm);
+ int totalSlideTextPage = slidetextPage.getTotalPages();
+ /*
+ * spring will just return an empty dataset if a page that is greater than the
+ * total number of pages is returned. So, the page given (except when it's < 1,
+ * then set it to 1) and then checking if the total page count is smaller than
+ * the given one (if so, make another request). In most cases the page number
+ * will be within the range of pages, so we would need only one db call. Only in
+ * cases where the page number is wrong, would a second one be needed.if
+ * page>total pages,last page is returned.
+ */
+ if (page > totalSlideTextPage) {
+ totalSlideTextPage = totalSlideTextPage == 0 ? 1 : totalSlideTextPage;
+ requestedPageForSlideText = PageRequest.of(totalSlideTextPage - 1, pageSize);
+ slidetextPage = textContentBlockRepo.findWithNameOrDescription(requestedPageForSlideText, searchTerm);
+ }
+ return slidetextPage;
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchModuleResults.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchModuleResults.java
new file mode 100644
index 000000000..7020f2318
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchModuleResults.java
@@ -0,0 +1,39 @@
+package edu.asu.diging.vspace.core.services.impl.model;
+
+import java.util.List;
+import java.util.Map;
+
+import edu.asu.diging.vspace.core.model.IModule;
+
+public class StaffSearchModuleResults {
+
+ private List modules;
+
+ private Map moduleImageIdMap;
+
+ private Map moduleAlertMessages;
+
+ public List getModules() {
+ return modules;
+ }
+
+ public void setModules(List modules) {
+ this.modules = modules;
+ }
+
+ public Map getModuleImageIdMap() {
+ return moduleImageIdMap;
+ }
+
+ public void setModuleImageIdMap(Map moduleImageIdMap) {
+ this.moduleImageIdMap = moduleImageIdMap;
+ }
+
+ public Map getModuleAlertMessages() {
+ return moduleAlertMessages;
+ }
+
+ public void setModuleAlertMessages(Map moduleAlertMessages) {
+ this.moduleAlertMessages = moduleAlertMessages;
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideResults.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideResults.java
new file mode 100644
index 000000000..a4da9dd45
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideResults.java
@@ -0,0 +1,29 @@
+package edu.asu.diging.vspace.core.services.impl.model;
+
+import java.util.List;
+import java.util.Map;
+
+import edu.asu.diging.vspace.core.model.ISlide;
+
+public class StaffSearchSlideResults {
+
+ private List slides;
+
+ private Map firstImageOfSlide;
+
+ public List getSlides() {
+ return slides;
+ }
+
+ public void setSlides(List slides) {
+ this.slides = slides;
+ }
+
+ public Map getFirstImageOfSlide() {
+ return firstImageOfSlide;
+ }
+
+ public void setFirstImageOfSlide(Map firstImageOfSlide) {
+ this.firstImageOfSlide = firstImageOfSlide;
+ }
+}
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
new file mode 100644
index 000000000..b1dbb2390
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSlideTextBlockResults.java
@@ -0,0 +1,40 @@
+package edu.asu.diging.vspace.core.services.impl.model;
+
+import java.util.List;
+import java.util.Map;
+
+import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.model.impl.Slide;
+
+public class StaffSearchSlideTextBlockResults {
+
+ private List slidesWithMatchedTextBlock;
+
+ private Map slideToFirstImageMap;
+
+ private Map slideToFirstTextBlockMap;
+
+ public List getSlidesWithMatchedTextBlock() {
+ return slidesWithMatchedTextBlock;
+ }
+
+ public void setSlidesWithMatchedTextBlock(List slidesWithMatchedTextBlock) {
+ this.slidesWithMatchedTextBlock = slidesWithMatchedTextBlock;
+ }
+
+ public Map getSlideToFirstImageMap() {
+ return slideToFirstImageMap;
+ }
+
+ public void setSlideToFirstImageMap(Map slideToFirstImageMap) {
+ this.slideToFirstImageMap = slideToFirstImageMap;
+ }
+
+ public Map getSlideToFirstTextBlockMap() {
+ return slideToFirstTextBlockMap;
+ }
+
+ public void setSlideToFirstTextBlockMap(Map slideToFirstTextBlockMap) {
+ this.slideToFirstTextBlockMap = slideToFirstTextBlockMap;
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSpaceResults.java b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSpaceResults.java
new file mode 100644
index 000000000..0b31dabf5
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/model/StaffSearchSpaceResults.java
@@ -0,0 +1,19 @@
+package edu.asu.diging.vspace.core.services.impl.model;
+
+import java.util.List;
+
+import edu.asu.diging.vspace.core.model.ISpace;
+
+public class StaffSearchSpaceResults {
+
+ private List spaces;
+
+ public List getSpaces() {
+ return spaces;
+ }
+
+ public void setSpaces(List spaces) {
+ this.spaces = spaces;
+ }
+
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleLinkController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleLinkController.java
index 5fcf88ac8..eb0b30338 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleLinkController.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/AddModuleLinkController.java
@@ -10,6 +10,7 @@
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.multipart.MultipartFile;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -36,7 +37,7 @@ public class AddModuleLinkController {
public ResponseEntity createModuleLink(@PathVariable("id") String id, @RequestParam("x") String x,
@RequestParam("y") String y, @RequestParam("rotation") String rotation, @RequestParam("moduleLinkLabel") String title,
@RequestParam("linkedModule") String linkedModuleId, @RequestParam("moduleLinkLabel") String moduleLinkLabel,
- @RequestParam("type") String displayType)
+ @RequestParam("moduleType") String displayType, @RequestParam("moduleLinkImage") MultipartFile file)
throws NumberFormatException, SpaceDoesNotExistException, IOException, ImageCouldNotBeStoredException {
ISpace source = spaceManager.getSpace(id);
@@ -50,12 +51,19 @@ public ResponseEntity createModuleLink(@PathVariable("id") String id, @R
node.put("errorMessage", "No link coordinates specified.");
return new ResponseEntity(mapper.writeValueAsString(node), HttpStatus.BAD_REQUEST);
}
-
+
+ byte[] linkImage = null;
+ String filename = null;
+ if (file != null) {
+ linkImage = file.getBytes();
+ filename = file.getOriginalFilename();
+ }
+
DisplayType type = displayType.isEmpty() ? null : DisplayType.valueOf(displayType);
IModuleLinkDisplay display;
try {
display = moduleLinkManager.createLink(title, id, new Float(x), new Float(y),
- new Integer(rotation), linkedModuleId, moduleLinkLabel, type, null, null);
+ new Integer(rotation), linkedModuleId, moduleLinkLabel, type, linkImage, filename);
} catch (SpaceDoesNotExistException e) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.createObjectNode();
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DashboardController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DashboardController.java
index 27d6ef5d8..1ec954eef 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DashboardController.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/DashboardController.java
@@ -30,4 +30,4 @@ public String displayDashboard(Model model) {
return "staff/dashboard/dashboard";
}
-}
+}
\ No newline at end of file
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditModuleLinkController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditModuleLinkController.java
index cf9b31a27..8d64eb2ae 100644
--- a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditModuleLinkController.java
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/EditModuleLinkController.java
@@ -9,6 +9,7 @@
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.multipart.MultipartFile;
import edu.asu.diging.vspace.core.exception.ImageCouldNotBeStoredException;
import edu.asu.diging.vspace.core.exception.LinkDoesNotExistsException;
@@ -32,16 +33,22 @@ public ResponseEntity editModuleLink(@PathVariable("id") String id, @Req
@RequestParam("y") String y, @RequestParam("rotation") String rotation, @RequestParam("moduleLinkLabel") String title,
@RequestParam("linkedModule") String linkedModuleId, @RequestParam("moduleLinkLabel") String moduleLinkLabel,
@RequestParam("moduleLinkIdValueEdit") String moduleLinkIdValueEdit, @RequestParam("moduleLinkDisplayId") String moduleLinkDisplayId,
- @RequestParam("type") String displayType)
+ @RequestParam("type") String displayType, @RequestParam("moduleLinkImage") MultipartFile file)
throws NumberFormatException, SpaceDoesNotExistException, LinkDoesNotExistsException, IOException, ImageCouldNotBeStoredException {
ResponseEntity validation = checkIfSpaceExists(spaceManager, id, x, y);
if(validation!=null) {
return validation;
}
+ byte[] linkImage = null;
+ String filename = null;
+ if (file != null) {
+ linkImage = file.getBytes();
+ filename = file.getOriginalFilename();
+ }
DisplayType type = displayType.isEmpty() ? null : DisplayType.valueOf(displayType);
IModuleLinkDisplay display = (IModuleLinkDisplay) moduleLinkManager.updateLink(title, id, new Float(x), new Float(y),
- new Integer(rotation), linkedModuleId, moduleLinkLabel, moduleLinkIdValueEdit, moduleLinkDisplayId, type, null, null);
+ new Integer(rotation), linkedModuleId, moduleLinkLabel, moduleLinkIdValueEdit, moduleLinkDisplayId, type, linkImage, filename);
return success(display.getLink().getId(), display.getId(), display.getPositionX(), display.getPositionY(), display.getRotation(),null,title,displayType,linkedModuleId,null);
}
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
new file mode 100644
index 000000000..6ee62cbdc
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchController.java
@@ -0,0 +1,120 @@
+package edu.asu.diging.vspace.web.staff;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+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
+public class StaffSearchController {
+
+ @Autowired
+ private IStaffSearchManager staffSearchManager;
+
+ @RequestMapping(value = "/staff/search")
+ public String searchInVspace(
+ @RequestParam(value = "spacePagenum", required = false, defaultValue = "1") String spacePagenum,
+ @RequestParam(value = "modulePagenum", required = false, defaultValue = "1") String modulePagenum,
+ @RequestParam(value = "slidePagenum", required = false, defaultValue = "1") String slidePagenum,
+ @RequestParam(value = "slideTextPagenum", required = false, defaultValue = "1") String slideTextPagenum,
+ Model model, @RequestParam(name = "searchText") String searchTerm) {
+
+ paginationForSpace(spacePagenum, model, searchTerm);
+
+ paginationForModule(modulePagenum, model, searchTerm);
+
+ paginationForSlide(slidePagenum, model, searchTerm);
+
+ paginationForSlideText(slideTextPagenum, model, searchTerm);
+
+ model.addAttribute("searchWord", searchTerm);
+
+ return "/staff/search/staffSearch";
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the spaces corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose name or description
+ * contains the search string. The spacePagenum is starting from 1.
+ *
+ * @param spacePagenum current page number sent as request parameter in the URL.
+ * @param model This the object of Model attribute in spring MVC.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private void paginationForSpace(String spacePagenum, Model model, String searchTerm) {
+ Page spacePage = staffSearchManager.searchInSpaces(searchTerm, Integer.parseInt(spacePagenum));
+ model.addAttribute("spaceCurrentPageNumber", Integer.parseInt(spacePagenum));
+ model.addAttribute("spaceTotalPages", spacePage.getTotalPages());
+ model.addAttribute("spaceSearchResults", spacePage.getContent());
+ model.addAttribute("spaceCount", spacePage.getTotalElements());
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the module corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose name or description
+ * contains the search string. The modulePagenum is starting from 1.
+ *
+ * @param modulePagenum current page number sent as request parameter in the
+ * URL.
+ * @param model This the object of Model attribute in spring MVC.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private void paginationForModule(String modulePagenum, Model model, String searchTerm) {
+ Page modulePage = staffSearchManager.searchInModules(searchTerm, Integer.parseInt(modulePagenum));
+ model.addAttribute("moduleCurrentPageNumber", Integer.parseInt(modulePagenum));
+ model.addAttribute("moduleTotalPages", modulePage.getTotalPages());
+ model.addAttribute("moduleSearchResults", modulePage.getContent());
+ model.addAttribute("moduleCount", modulePage.getTotalElements());
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the slides corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose name or description
+ * contains the search string. The slidePagenum is starting from 1.
+ *
+ * @param slidePagenum current page number sent as request parameter in the URL.
+ * @param model This the object of Model attribute in spring MVC.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private void paginationForSlide(String slidePagenum, Model model, String searchTerm) {
+ Page slidePage = staffSearchManager.searchInSlides(searchTerm, Integer.parseInt(slidePagenum));
+ model.addAttribute("slideCurrentPageNumber", Integer.parseInt(slidePagenum));
+ model.addAttribute("slideTotalPages", slidePage.getTotalPages());
+ model.addAttribute("slideSearchResults", slidePage.getContent());
+ model.addAttribute("slideCount", slidePage.getTotalElements());
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the slides corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose text block contains the
+ * search string. The slideTextPagenum is starting from 1.
+ *
+ * @param slideTextPagenum current page number sent as request parameter in the
+ * URL.
+ * @param model This the object of Model attribute in spring MVC.
+ *
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private void paginationForSlideText(String slideTextPagenum, Model model, String searchTerm) {
+ Page slideTextPage = staffSearchManager.searchInSlideTexts(searchTerm,
+ Integer.parseInt(slideTextPagenum));
+ model.addAttribute("slideTextCurrentPageNumber", Integer.parseInt(slideTextPagenum));
+ model.addAttribute("slideTextTotalPages", slideTextPage.getTotalPages());
+ model.addAttribute("slideTextSearchResults", slideTextPage.getContent());
+ model.addAttribute("slideTextCount", slideTextPage.getTotalElements());
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchModuleController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchModuleController.java
new file mode 100644
index 000000000..972d730fc
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchModuleController.java
@@ -0,0 +1,82 @@
+package edu.asu.diging.vspace.web.staff;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import edu.asu.diging.vspace.core.model.IModule;
+import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.model.impl.Slide;
+import edu.asu.diging.vspace.core.services.ISequenceManager;
+import edu.asu.diging.vspace.core.services.IStaffSearchManager;
+import edu.asu.diging.vspace.core.services.impl.model.StaffSearchModuleResults;
+
+@Controller
+public class StaffSearchModuleController {
+
+ @Autowired
+ private IStaffSearchManager staffSearchManager;
+
+ @Autowired
+ private ISequenceManager sequenceManager;
+
+ @RequestMapping(value = "/staff/search/module")
+ public ResponseEntity searchInVspace(
+ @RequestParam(value = "modulePagenum", required = false, defaultValue = "1") String modulePagenum,
+ Model model, @RequestParam(name = "searchText") String searchTerm) {
+
+ List moduleList = paginationForModule(modulePagenum, searchTerm);
+ StaffSearchModuleResults staffSearch = new StaffSearchModuleResults();
+ staffSearch.setModules(moduleList);
+
+ Map moduleFirstSlideImage = new HashMap<>();
+ Map isModuleConfiguredMap = new HashMap<>();
+
+ for (IModule module : moduleList) {
+ if (module.getStartSequence() == null) {
+ isModuleConfiguredMap.put(module.getId(), false);
+ moduleFirstSlideImage.put(module.getId(), null);
+ } else {
+ isModuleConfiguredMap.put(module.getId(), true);
+ String startSequenceID = module.getStartSequence().getId();
+ List slides = sequenceManager.getSequence(startSequenceID) != null
+ ? sequenceManager.getSequence(startSequenceID).getSlides()
+ : null;
+
+ Slide slide = slides != null && !slides.isEmpty() ? (Slide) slides.get(0) : null;
+
+ if (slide != null && slide.getFirstImageBlock() != null) {
+ moduleFirstSlideImage.put(module.getId(), slide.getFirstImageBlock().getImage().getId());
+ }
+ }
+ }
+ staffSearch.setModuleImageIdMap(moduleFirstSlideImage);
+ staffSearch.setModuleAlertMessages(isModuleConfiguredMap);
+ return new ResponseEntity(staffSearch, HttpStatus.OK);
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the module corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose name or description
+ * contains the search string.
+ *
+ * @param modulePagenum current page number sent as request parameter in the
+ * URL.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private List paginationForModule(String modulePagenum, String searchTerm) {
+ Page modulePage = staffSearchManager.searchInModules(searchTerm, Integer.parseInt(modulePagenum));
+ return modulePage.getContent();
+ }
+
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideController.java
new file mode 100644
index 000000000..cf7581cc9
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideController.java
@@ -0,0 +1,59 @@
+package edu.asu.diging.vspace.web.staff;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.services.IStaffSearchManager;
+import edu.asu.diging.vspace.core.services.impl.model.StaffSearchSlideResults;
+
+@Controller
+public class StaffSearchSlideController {
+
+ @Autowired
+ private IStaffSearchManager staffSearchManager;
+
+ @RequestMapping(value = "/staff/search/slide")
+ public ResponseEntity searchInVspace(
+ @RequestParam(value = "slidePagenum", required = false, defaultValue = "1") String slidePagenum,
+ Model model, @RequestParam(name = "searchText") String searchTerm) {
+
+ List slideList = paginationForSlide(slidePagenum, searchTerm);
+ StaffSearchSlideResults staffSearch = new StaffSearchSlideResults();
+ staffSearch.setSlides(slideList);
+
+ Map slideFirstImage = new HashMap<>();
+
+ for (ISlide slide : slideList) {
+ if (slide != null && slide.getFirstImageBlock() != null) {
+ slideFirstImage.put(slide.getId(), slide.getFirstImageBlock().getImage().getId());
+ }
+ }
+ staffSearch.setFirstImageOfSlide(slideFirstImage);
+ return new ResponseEntity(staffSearch, HttpStatus.OK);
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the slides corresponding to
+ * the page number specified in the input parameter(spacePagenum) whose name or
+ * description contains the search string.
+ *
+ * @param slidePagenum current page number sent as request parameter in the URL.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private List paginationForSlide(String slidePagenum, String searchTerm) {
+ Page slidePage = staffSearchManager.searchInSlides(searchTerm, Integer.parseInt(slidePagenum));
+ return slidePage.getContent();
+ }
+}
diff --git a/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideTextController.java b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideTextController.java
new file mode 100644
index 000000000..d0c9f1d54
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSlideTextController.java
@@ -0,0 +1,71 @@
+package edu.asu.diging.vspace.web.staff;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import edu.asu.diging.vspace.core.model.ISlide;
+import edu.asu.diging.vspace.core.services.IStaffSearchManager;
+import edu.asu.diging.vspace.core.services.impl.model.StaffSearchSlideTextBlockResults;
+
+@Controller
+public class StaffSearchSlideTextController {
+
+ @Autowired
+ private IStaffSearchManager staffSearchManager;
+
+ @RequestMapping(value = "/staff/search/slideText")
+ public ResponseEntity searchInVspace(HttpServletRequest request,
+ @RequestParam(value = "slideTextPagenum", required = false, defaultValue = "1") String slideTextPagenum,
+ Model model, @RequestParam(name = "searchText") String searchTerm) {
+
+ List slideTextList = paginationForSlideText(slideTextPagenum, searchTerm);
+ StaffSearchSlideTextBlockResults staffSearch = new StaffSearchSlideTextBlockResults();
+ staffSearch.setSlidesWithMatchedTextBlock(slideTextList);
+
+ Map slideTextFirstImageMap = new HashMap<>();
+
+ Map slideTextFirstTextBlockMap = new HashMap<>();
+
+ for (ISlide slide : slideTextList) {
+ if (slide != null) {
+ if (slide.getFirstImageBlock() != null) {
+ slideTextFirstImageMap.put(slide.getId(), slide.getFirstImageBlock().getImage().getId());
+ }
+ if (slide.getFirstMatchedTextBlock(searchTerm) != null) {
+ slideTextFirstTextBlockMap.put(slide.getId(), slide.getFirstMatchedTextBlock(searchTerm).htmlRenderedText());
+ }
+ }
+ }
+ staffSearch.setSlideToFirstImageMap(slideTextFirstImageMap);
+ staffSearch.setSlideToFirstTextBlockMap(slideTextFirstTextBlockMap);
+ return new ResponseEntity(staffSearch, HttpStatus.OK);
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the slides corresponding to the page number
+ * specified in the input parameter(spacePagenum) whose text block contains the
+ * search string
+ *
+ * @param slideTextPagenum current page number sent as request parameter in the
+ * URL.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private List paginationForSlideText(String slideTextPagenum, String searchTerm) {
+ Page slideTextPage = staffSearchManager.searchInSlideTexts(searchTerm,
+ Integer.parseInt(slideTextPagenum));
+ return slideTextPage.getContent();
+ }
+}
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
new file mode 100644
index 000000000..b6ab7ed46
--- /dev/null
+++ b/vspace/src/main/java/edu/asu/diging/vspace/web/staff/StaffSearchSpaceController.java
@@ -0,0 +1,50 @@
+package edu.asu.diging.vspace.web.staff;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+import edu.asu.diging.vspace.core.model.ISpace;
+import edu.asu.diging.vspace.core.services.IStaffSearchManager;
+import edu.asu.diging.vspace.core.services.impl.model.StaffSearchSpaceResults;
+
+@Controller
+public class StaffSearchSpaceController {
+
+ @Autowired
+ private IStaffSearchManager staffSearchManager;
+
+ @RequestMapping(value = "/staff/search/space")
+ public ResponseEntity searchInVspace(
+ @RequestParam(value = "spacePagenum", required = false, defaultValue = "1") String spacePagenum,
+ Model model, @RequestParam(name = "searchText") String searchTerm) throws JsonProcessingException {
+
+ List spaceList = paginationForSpace(spacePagenum, searchTerm);
+ StaffSearchSpaceResults staffSearch = new StaffSearchSpaceResults();
+ staffSearch.setSpaces(spaceList);
+ return new ResponseEntity(staffSearch, HttpStatus.OK);
+ }
+
+ /**
+ * This method is used to search the search string specified in the input
+ * parameter(searchTerm) and return the spaces corresponding to
+ * the page number specified in the input parameter(spacePagenum) whose name or
+ * description contains the search string.
+ *
+ * @param spacePagenum current page number sent as request parameter in the URL.
+ * @param searchTerm This is the search string which is being searched.
+ */
+ private List paginationForSpace(String spacePagenum, String searchTerm) {
+ Page spacePage = staffSearchManager.searchInSpaces(searchTerm, Integer.parseInt(spacePagenum));
+ return spacePage.getContent();
+ }
+}
diff --git a/vspace/src/main/resources/config.properties b/vspace/src/main/resources/config.properties
index 723d1415a..5aacd55f2 100644
--- a/vspace/src/main/resources/config.properties
+++ b/vspace/src/main/resources/config.properties
@@ -9,3 +9,4 @@ page_size=10
image_category_SPACE_BACKGROUND_IMAGE=Space Background Image
image_category_SLIDE_IMAGE=Slide Image
image_category_LINK_IMAGE=Link Image
+buildNum=${buildNumber}
\ No newline at end of file
diff --git a/vspace/src/main/webapp/WEB-INF/views/exhibition/space.html b/vspace/src/main/webapp/WEB-INF/views/exhibition/space.html
index 7a4755b12..d65b92ac1 100644
--- a/vspace/src/main/webapp/WEB-INF/views/exhibition/space.html
+++ b/vspace/src/main/webapp/WEB-INF/views/exhibition/space.html
@@ -209,8 +209,8 @@
let maxWidth='(max-width: 1200px)';
function openNav(){
- $("#mySidenav").css("width", "250px");
- }
+ $("#mySidenav").css("width", "250px");
+ }
function closeNav(){
$("#mySidenav").css("width", "0");
}
@@ -324,7 +324,7 @@
'overflow': 'visible'
});
}
- })
+ });
moduleLinks.forEach(function(link,index){
if(link!=null){
var posX = parseInt($("#space").css('margin-left')) + $("#space").position().left;
@@ -332,7 +332,13 @@
var moduleLink = $('');
var moduleLinkURL = [[@{|/exhibit/${space?.id}/module/|}]]+link.link.module.id;
moduleLink.attr("href", moduleLinkURL);
- var linkDisplay = $(''+link.link.name+'
');
+ var linkDisplay;
+ if(link.type=="IMAGE" && link.image != null){
+ var moduleImageURL = [[@{/api/image/}]]+link.image.id;
+ linkDisplay = $('');
+ } else {
+ linkDisplay = $(''+link.link.name+'
');
+ }
linkDisplay.css('position', 'absolute');
linkDisplay.css('transform', 'rotate('+link.rotation+'deg)');
linkDisplay.css('fill', 'grey');
diff --git a/vspace/src/main/webapp/WEB-INF/views/layouts/main.html b/vspace/src/main/webapp/WEB-INF/views/layouts/main.html
index 2a4b3e0ae..d3ecbaa47 100644
--- a/vspace/src/main/webapp/WEB-INF/views/layouts/main.html
+++ b/vspace/src/main/webapp/WEB-INF/views/layouts/main.html
@@ -46,7 +46,9 @@
@@ -60,14 +57,20 @@
-
-
+
+
diff --git a/vspace/src/main/webapp/WEB-INF/views/layouts/navbar_staff.html b/vspace/src/main/webapp/WEB-INF/views/layouts/navbar_staff.html
index 2b9b36407..978e3ef7a 100644
--- a/vspace/src/main/webapp/WEB-INF/views/layouts/navbar_staff.html
+++ b/vspace/src/main/webapp/WEB-INF/views/layouts/navbar_staff.html
@@ -1,8 +1,5 @@
-