Skip to content

Commit

Permalink
sonar cloud fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SrdjanStevanetic committed Nov 12, 2024
1 parent c8a90ff commit 609d324
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,12 @@ private void updateIsShownBy(UserSet userSet, String firstItemOld) {
}

public UserSet deleteMultipleItems(List<String> items, UserSet existingUserSet) {
//keep the first item to check if it is changed, for the re-creation of the isShownBy field
String firstItemOld=null;
if(existingUserSet.getItems()!=null && !existingUserSet.getItems().isEmpty()) {
firstItemOld=existingUserSet.getItems().get(0);
}
else {
if(existingUserSet.getItems()==null || existingUserSet.getItems().isEmpty()) {
return existingUserSet;
}

//keep the first item to check if it is changed, for the re-creation of the isShownBy field
String firstItemOld=existingUserSet.getItems().get(0);

boolean itemsRemoved=false;
// check if it is a pinned item, decrease the counter by 1 for entity sets
Expand Down Expand Up @@ -312,22 +310,21 @@ public UserSet insertMultipleItems(List<String> items, String position, int item
}

//update items
UserSet userSet;
if (WebUserSetModelFields.PINNED_POSITION.equals(position)) {
userSet=updateItemsFromPinned(existingUserSet, items);
updateItemsFromPinned(existingUserSet, items);
} else {
userSet=updateItemsFromUnpinned(existingUserSet, items, itemsPosition);
updateItemsFromUnpinned(existingUserSet, items, itemsPosition);
}

//update isShownBy
updateIsShownBy(userSet, firstItemOld);
updateIsShownBy(existingUserSet, firstItemOld);

writeUserSetToDb(userSet);
updatePagination(userSet, getConfiguration());
return userSet;
UserSet updatedSet = writeUserSetToDb(existingUserSet);
updatePagination(updatedSet, getConfiguration());
return updatedSet;
}

private UserSet updateItemsFromPinned(UserSet existingUserSet, List<String> items) {
private void updateItemsFromPinned(UserSet existingUserSet, List<String> items) {
List<String> usersetItems=existingUserSet.getItems();
if(usersetItems==null) {
usersetItems=new ArrayList<>();
Expand All @@ -350,10 +347,9 @@ private UserSet updateItemsFromPinned(UserSet existingUserSet, List<String> item

usersetItems.addAll(0, items);
existingUserSet.setPinned(existingUserSet.getPinned() + items.size());
return existingUserSet;
}

private UserSet updateItemsFromUnpinned(UserSet existingUserSet, List<String> items, int position) throws ItemValidationException {
private void updateItemsFromUnpinned(UserSet existingUserSet, List<String> items, int position) throws ItemValidationException {
List<String> usersetItems=existingUserSet.getItems();
List<String> newItemsCopy=new ArrayList<>(items);
if(usersetItems==null) {
Expand Down Expand Up @@ -382,7 +378,6 @@ private UserSet updateItemsFromUnpinned(UserSet existingUserSet, List<String> it

int positionFinal=calculatePosition(position, usersetItems);
usersetItems.addAll(positionFinal, items);
return existingUserSet;
}

/*
Expand Down

0 comments on commit 609d324

Please sign in to comment.