Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

-- Remove the Rating table as the rating system has been removed
DROP TABLE IF EXISTS skylinetoolsstore.Rating;
13 changes: 0 additions & 13 deletions SkylineToolsStore/resources/schemas/skylinetoolsstore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,4 @@
<ns:column columnName="Languages"/>
</ns:columns>
</ns:table>
<ns:table tableName="rating" tableDbType="TABLE">
<ns:columns>
<ns:column columnName="_ts"/>
<ns:column columnName="rowid"/>
<ns:column columnName="createdby"/>
<ns:column columnName="created"/>
<ns:column columnName="modified"/>
<ns:column columnName="rating"/>
<ns:column columnName="toolid"/>
<ns:column columnName="review"/>
<ns:column columnName="title"/>
</ns:columns>
</ns:table>
</ns:tables>
129 changes: 0 additions & 129 deletions SkylineToolsStore/src/org/labkey/skylinetoolsstore/RatingManager.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import org.labkey.api.view.UnauthorizedException;
import org.labkey.api.webdav.WebdavResource;
import org.labkey.api.webdav.WebdavService;
import org.labkey.skylinetoolsstore.model.Rating;
import org.labkey.skylinetoolsstore.model.SkylineTool;
import org.labkey.skylinetoolsstore.view.SkylineToolDetails;
import org.labkey.skylinetoolsstore.view.SkylineToolStoreUrls;
Expand Down Expand Up @@ -613,7 +612,8 @@ else if (!getContainer().hasPermission(getUser(), InsertPermission.class))
@Override
public void addNavTrail(NavTree root)
{
root.addChild(getToolStoreNav(getContainer())).addChild("Upload Tool", getURL());
root.addChild(getToolStoreNav(getContainer()));
root.addChild("Upload Tool", getURL());
}

public ActionURL getURL()
Expand Down Expand Up @@ -645,151 +645,6 @@ private void redirectToToolStoreContainer(SkylineTool tool, ActionURL originalUr
}
}

@RequiresNoPermission
public class SubmitRatingAction extends AbstractController implements PermissionCheckable
{
private static final String NO_TITLE = "You did not enter a valid title.";
private static final String NO_RATING = "You did not submit a valid rating. Ratings must be between 1 and 5.";
private static final String NO_REVIEW = "You did not submit a valid review.";
private static final String ALREADY_REVIEWED = "You have already left a review for this tool.";

public SubmitRatingAction()
{
}

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
{
final User user = getUser();
final String toolIdString = httpServletRequest.getParameter("toolId");
int toolId = (toolIdString != null && !toolIdString.isEmpty()) ? Integer.parseInt(toolIdString) : -1;

final String ratingIdString = httpServletRequest.getParameter("ratingId");
int ratingId;
try {
ratingId = (ratingIdString != null && !ratingIdString.isEmpty()) ? Integer.parseInt(ratingIdString) : -1;
} catch(Exception e) {
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
}
Rating rating = (ratingId < 0) ? null : RatingManager.get().getRatingById(ratingId);
final SkylineTool tool = SkylineToolsStoreManager.get().getTool((toolId >= 0) ? toolId : rating.getToolId());

final String ratingValueString = httpServletRequest.getParameter("value");
final int ratingValue;
try {
ratingValue = Integer.parseInt(ratingValueString);
} catch(Exception e) {
return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
}
final String ratingTitle = httpServletRequest.getParameter("title");
final String review = httpServletRequest.getParameter("review");

if (ratingId < 0 && RatingManager.get().userLeftRating(tool.getIdentifier(), getUser()))
{
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
ALREADY_REVIEWED);
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "hideForm",
true);
}
else if (ratingTitle == null || ratingTitle.isEmpty())
{
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
NO_TITLE);
}
else if (ratingValue < 1 || ratingValue > 5)
{
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
NO_RATING);
}
else if (review == null || review.isEmpty())
{
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form",
NO_REVIEW);
}
else if (user.isGuest())
{
throw new Exception();
}
else if (tool == null || (ratingId >= 0 && rating == null))
{
throw new Exception();
}
else
{
if (rating == null)
{
// Adding new rating
rating = new Rating(ratingValue, review, toolId, ratingTitle);
rating.setContainer(getContainer().getId());
RatingManager.get().insertRating(user, rating);
}
else
{
// Editing existing rating
if (rating.getCreatedBy() != user.getUserId() && !getUser().hasSiteAdminPermission())
{
throw new Exception();
}
rating.setTitle(ratingTitle);
rating.setRating(ratingValue);
rating.setReview(review);
RatingManager.get().editRating(rating, user);
}
return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool));
}

if (toolId >= 0)
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "toolId", toolId);
if (ratingId >= 0)
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "ratingId", ratingId);
if (ratingTitle != null)
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formTitle", ratingTitle);
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formValue", ratingValue);
if (review != null)
getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formReview", review);

return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null);
}

@Override
public void checkPermissions() throws UnauthorizedException
{

}
}

@RequiresNoPermission
public class DeleteRatingAction extends AbstractController implements PermissionCheckable
{
public DeleteRatingAction()
{
}

@Override
public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
{
int id = NumberUtils.toInt(httpServletRequest.getParameter("id"), -1);
int user = getUser().getUserId();
final Rating rating = RatingManager.get().getRatingById(id);
if(rating != null)
{
if (user == rating.getCreatedBy() || getUser().hasSiteAdminPermission())
RatingManager.get().deleteRating(id);
else
throw new Exception();
}

final SkylineTool tool = SkylineToolsStoreManager.get().getTool(rating.getToolId());
return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool));
}

@Override
public void checkPermissions() throws UnauthorizedException
{

}
}

@RequiresNoPermission
public class InsertSupplementAction extends AbstractController implements PermissionCheckable
{
Expand Down Expand Up @@ -948,7 +803,6 @@ public boolean handlePost(IdForm idForm, BindException errors) throws Exception
// TODO: Should be in a transaction
for (SkylineTool toDelete : SkylineToolsStoreManager.get().getToolsByIdentifier(tool.getIdentifier()))
{
RatingManager.get().deleteRatingsByToolId(toDelete.getRowId());
ContainerManager.delete(toDelete.lookupContainer(), getUser());
}

Expand Down Expand Up @@ -1027,7 +881,6 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest,
if (tools.length == 1)
throw new Exception();

RatingManager.get().deleteRatingsByToolId(tool.getRowId());
ContainerManager.delete(tools[0].lookupContainer(), getUser());

if (tools.length > 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 16.2;
return 25.001;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,4 @@ public TableInfo getTableInfoSkylineTool()
{
return getSchema().getTable("SkylineTool");
}

public TableInfo getTableInfoRating()
{
return getSchema().getTable("Rating");
}
}
Loading
Loading