Skip to content

Commit

Permalink
Merge pull request #304 from diging/develop
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
jdamerow authored Jun 14, 2022
2 parents d5f4e7c + 241fbac commit 8251890
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

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).
You can find Virtual Spaces documentation [here](https://diging.github.io/virtual-spaces-2.0/).
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package edu.asu.diging.vspace.core.data;

import java.util.List;

import org.javers.spring.annotation.JaversSpringDataAuditable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import edu.asu.diging.vspace.core.model.impl.ModuleLink;
import edu.asu.diging.vspace.core.model.IModuleLink;

@Repository
@JaversSpringDataAuditable
public interface ModuleLinkRepository extends PagingAndSortingRepository<ModuleLink, String> {

@Query("select moduleLink from ModuleLink moduleLink where module_id = ?1")
List<IModuleLink> findModuleLinksByModuleId(String moduleId);

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.asu.diging.vspace.web.exception;
package edu.asu.diging.vspace.core.exception;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.asu.diging.vspace.web.exception;
package edu.asu.diging.vspace.core.exception;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.asu.diging.vspace.web.exception;
package edu.asu.diging.vspace.core.exception;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.asu.diging.vspace.web.exception;
package edu.asu.diging.vspace.core.exception;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.asu.diging.vspace.web.exception;
package edu.asu.diging.vspace.core.exception;

import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class ModuleLink extends VSpaceElement implements IModuleLink {
@JoinColumn(name="space_id", nullable=false)
private ISpace space;

@ManyToOne(targetEntity=Module.class)
@JoinColumn(name="module_id", nullable=false)
@ManyToOne(targetEntity=Module.class, optional=true)
@JoinColumn(name="module_id", nullable=true)
private IModule module;

/* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISequence;
import edu.asu.diging.vspace.core.model.ISlide;
Expand All @@ -24,4 +25,6 @@ public interface IModuleManager {
ISequence checkIfSequenceExists(String moduleId, String sequenceId);

Page<IModule> findByNameOrDescription(Pageable requestedPage,String searchText);

void deleteModule(String moduleId) throws ModuleNotFoundException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@
import java.util.List;
import java.util.Optional;

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 org.springframework.transaction.annotation.Transactional;

import edu.asu.diging.vspace.core.data.ModuleLinkRepository;
import edu.asu.diging.vspace.core.data.ModuleRepository;
import edu.asu.diging.vspace.core.data.SequenceRepository;
import edu.asu.diging.vspace.core.data.SlideRepository;
import edu.asu.diging.vspace.core.data.display.ModuleLinkDisplayRepository;
import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
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.impl.Module;
import edu.asu.diging.vspace.core.model.impl.ModuleLink;
import edu.asu.diging.vspace.core.services.IModuleManager;

@Transactional
@Service
public class ModuleManager implements IModuleManager {


@Autowired
private ModuleLinkRepository moduleLinkRepo;

@Autowired
private ModuleRepository moduleRepo;
Expand All @@ -34,6 +42,12 @@ public class ModuleManager implements IModuleManager {
@Autowired
private SequenceRepository sequenceRepo;

@Autowired
private SlideManager slideManager;

@Autowired
private ModuleLinkDisplayRepository moduleLinkDisplayRepo;

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -89,4 +103,33 @@ public ISequence checkIfSequenceExists(String moduleId, String sequenceId) {
public Page<IModule> findByNameOrDescription(Pageable requestedPage,String searchText) {
return moduleRepo.findDistinctByNameContainingOrDescriptionContaining(requestedPage,searchText,searchText);
}

@Transactional(rollbackFor = Exception.class)
@Override
public void deleteModule(String moduleId) throws ModuleNotFoundException {
if(moduleId == null) {
return;
}
moduleLinkRepo.findModuleLinksByModuleId(moduleId).forEach(
moduleLink -> {
moduleLinkDisplayRepo.deleteByLink(moduleLink);
moduleLinkRepo.deleteById(moduleLink.getId());
});
//delete all slides
Optional<Module> moduleOptional = moduleRepo.findById(moduleId);
if(moduleOptional.isPresent()) {
Module module = moduleOptional.get();
module.getSlides().forEach(
slide -> {
slideManager.deleteSlideById(slide.getId(), moduleId);
});
getModuleSequences(moduleId).forEach(
sequence -> {
sequenceRepo.deleteById(sequence.getId());
});
} else {
throw new ModuleNotFoundException("Module not found");
}
moduleRepo.deleteById(moduleId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ private SpaceOverview createSpaceNode(Space space, String contextPath) {
linkPathBuilder.append(SpaceController.STAFF_SPACE_PATH);
linkPathBuilder.append(space.getId());
spaceOverview.setLink(linkPathBuilder.toString());
StringBuilder imagePathBuilder = new StringBuilder();
imagePathBuilder.append(contextPath);
imagePathBuilder.append(ImageApiController.API_IMAGE_PATH);
imagePathBuilder.append(space.getImage().getId());
spaceOverview.setImg(imagePathBuilder.toString());
if(space.getImage() != null) {
StringBuilder imagePathBuilder = new StringBuilder();
imagePathBuilder.append(contextPath);
imagePathBuilder.append(ImageApiController.API_IMAGE_PATH);
imagePathBuilder.append(space.getImage().getId());
spaceOverview.setImg(imagePathBuilder.toString());
}
spaceOverview.setModule(false);
if (space.getSpaceStatus() != null && (space.getSpaceStatus().equals(SpaceStatus.UNPUBLISHED))) {
spaceOverview.setUnpublished(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.core.exception.SequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SlideNotFoundException;
import edu.asu.diging.vspace.core.exception.SlidesInSequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SpaceNotFoundException;

@ControllerAdvice
public class ExhibitionExceptionHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.core.exception.SpaceNotFoundException;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISpace;
import edu.asu.diging.vspace.core.model.impl.ExhibitionAboutPage;
import edu.asu.diging.vspace.core.services.IExhibitionAboutPageManager;
import edu.asu.diging.vspace.core.services.IModuleManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.web.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.web.exception.SpaceNotFoundException;
import edu.asu.diging.vspace.core.model.impl.ModuleStatus;

@Controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.core.exception.SequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SlidesInSequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SpaceNotFoundException;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISequence;
import edu.asu.diging.vspace.core.model.ISlide;
Expand All @@ -17,10 +21,6 @@
import edu.asu.diging.vspace.core.services.IModuleManager;
import edu.asu.diging.vspace.core.services.ISequenceManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.web.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.web.exception.SequenceNotFoundException;
import edu.asu.diging.vspace.web.exception.SlidesInSequenceNotFoundException;
import edu.asu.diging.vspace.web.exception.SpaceNotFoundException;

@Controller
public class ExhibitionSequencesController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import edu.asu.diging.vspace.core.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.core.exception.SequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SlideNotFoundException;
import edu.asu.diging.vspace.core.exception.SlidesInSequenceNotFoundException;
import edu.asu.diging.vspace.core.exception.SpaceDoesNotExistException;
import edu.asu.diging.vspace.core.exception.SpaceNotFoundException;
import edu.asu.diging.vspace.core.model.IModule;
import edu.asu.diging.vspace.core.model.ISequence;
import edu.asu.diging.vspace.core.model.ISlide;
Expand All @@ -23,11 +28,6 @@
import edu.asu.diging.vspace.core.services.ISequenceManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.core.services.impl.SlideManager;
import edu.asu.diging.vspace.web.exception.ModuleNotFoundException;
import edu.asu.diging.vspace.web.exception.SequenceNotFoundException;
import edu.asu.diging.vspace.web.exception.SlideNotFoundException;
import edu.asu.diging.vspace.web.exception.SlidesInSequenceNotFoundException;
import edu.asu.diging.vspace.web.exception.SpaceNotFoundException;

@Controller
public class ExhibitionSlideController {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package edu.asu.diging.vspace.web.staff;


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.ui.Model;
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.ModuleNotFoundException;
import edu.asu.diging.vspace.core.services.IModuleManager;

@Controller
public class DeleteModuleController {

private final Logger logger = LoggerFactory.getLogger(getClass());

@Autowired
private IModuleManager moduleManager;

@RequestMapping(value="/staff/module/{moduleId}/delete", method=RequestMethod.DELETE)
public ResponseEntity<String> deleteModule(@PathVariable("moduleId") String moduleId, Model model) {
try {
moduleManager.deleteModule(moduleId);
} catch (ModuleNotFoundException exception) {
logger.error("Could not delete Module.", exception);
return new ResponseEntity<String>("Sorry, unable to delete the module.",
HttpStatus.NOT_FOUND);
}
return new ResponseEntity<String>("Ok", HttpStatus.OK);
}
}
Loading

0 comments on commit 8251890

Please sign in to comment.