Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story/vspc 208 #341

Open
wants to merge 117 commits into
base: develop
Choose a base branch
from
Open

Story/vspc 208 #341

wants to merge 117 commits into from

Conversation

pooja-thalur
Copy link
Member

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

(you can copy the ticket if it hasn't changed)

https://diging.atlassian.net/browse/VSPC-208

...Put description here...
On the exhibition configuration page where you can set the exhibition title, etc. There should be three additional settings: scene link icon, module link icon, and external link icon. For each setting the user should be able to upload an image to be used as the default image for all links of that type.

This ticket requires changes on the staff side (to configure the link images) and the public side (use the default image if configured) for "arrow" type links.

Anything else the reviewer needs to know?

... describe here ...

bnayak4 added 30 commits June 9, 2022 16:22
@jdamerow jdamerow closed this Jun 10, 2024
# Conflicts:
#	vspace/src/main/java/edu/asu/diging/vspace/core/services/IImageService.java
*@param image - The image data as a byte array
*@param filename - The name of the file to be stored
*@return {@link IVSImage} instance
*@throws FileStorageException If there is an error storing the file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that true? where is it thrown?

exhibition = (Exhibition) exhibitManager.storeExhibition(exhibition);
attributes.addAllAttributes(addSuccessAttributes(exhibition));

return new RedirectView(request.getContextPath() + "/staff/exhibit/config");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be three different forms to submit the default images; each should call this function with a parameter defining which default image to set; and then map the parameter to a function that sets the default on the image at exhibition.

*/
@RequestMapping(value = "/staff/exhibit/config/link/defaultImage", method = RequestMethod.POST)
public RedirectView createOrUpdateLinkImage(HttpServletRequest request,
@RequestParam(required = false, name = "exhibitionParam") String exhibitID,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be needed; right now, you can just get the start exhibition

@jdamerow jdamerow closed this Jun 11, 2024
@pooja-thalur pooja-thalur reopened this Jun 13, 2024
public static final String API_DEFAULT_SPACE_IMAGE_PATH = "/api/image/default/link/space/";
public static final String API_DEFAULT_MODULE_IMAGE_PATH = "/api/image/default/link/module/";
public static final String API_DEFAULT_EXTERNAL_IMAGE_PATH = "/api/image/default/link/external/";
public static final String API_DEFAULT_SPACE_IMAGE_STATUS = "/api/exhibition/default/link/image/status/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API endpoints should be in the api package.

@jdamerow
Copy link
Member

Make it so, Jenkins.

@jdamerow
Copy link
Member

There are test failures.

@jdamerow jdamerow closed this Jun 26, 2024
@pooja-thalur pooja-thalur reopened this Jun 28, 2024
}

/**
* Method to store an image in the file location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what file location? this is confusing. the method only gets an image and a filename, right? nothing about location?

relativePath = storage.storeFile(image, filename, storedImage.getId());
} catch (FileStorageException e) {
logger.error(DEFAULT_IMAGE_EXCEPTION,e);
returnValue.getErrorMsgs().add(DEFAULT_IMAGE_EXCEPTION + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is the case and the image can't be stored, the vsimage object should not be stored either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 291 deleting the vsimage object if an exception occurs, as we are using its id to store the image


exhibition.setCustomMessage(customMessage);
}

exhibition = (Exhibition) exhibitManager.storeExhibition(exhibition);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be casted to Exhibition here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because exhibitManager.storeExhibition(exhibition) is returning IExhibition type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but why would it need to be Exhibition here?

* @throws IOException if an input or output error occurs
*/
@RequestMapping(value = "/staff/exhibit/config/link/defaultImage", method = RequestMethod.POST)
public RedirectView createOrUpdateLinkImage(HttpServletRequest request,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in its own controller

attributes.addAttribute("alertType", "danger");
attributes.addAttribute("showAlert", "true");
attributes.addAttribute("message", "Couldn't save the default image");
return new RedirectView(request.getContextPath() + "/staff/exhibit/config");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context path should not be needed here. if the method returns String, you can just return redirect:/path....

else if(linkType.equals("external")) {
IVSImage externalLinkDefaultImage = imageService.storeImage(image.getBytes(), image.getOriginalFilename());
exhibition.setExternalLinkDefaultImage(externalLinkDefaultImage);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty ugly and would get worse if we add more link types. as said before, there should be a map that maps "space", "module",... to IExhibition::setSpace... and then there is no if/else needed here, just getting the right method from the map and apply it.

}

@Test
public void test_storeDefaultImage_Error() throws FileStorageException, IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error

@jdamerow jdamerow closed this Jul 3, 2024
@pooja-thalur pooja-thalur reopened this Jul 10, 2024
relativePath = storage.storeFile(image, filename, storedImage.getId());
} catch (FileStorageException e) {
logger.error(DEFAULT_IMAGE_EXCEPTION,e);
returnValue.getErrorMsgs().add(DEFAULT_IMAGE_EXCEPTION + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@Controller
public class DefaultLinkImageController {

private static final Map<String, BiConsumer<Exhibition, IVSImage>> imageSetterMap = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be static

IExhibitionManager exhibitManager;

@Autowired
IImageService imageService;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those need to be private

@jdamerow jdamerow closed this Jul 10, 2024
@pooja-thalur pooja-thalur reopened this Sep 6, 2024
# Conflicts:
#	vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants