Opened 9 years ago

Closed 9 years ago

#1972 closed defect (fixed)

Items not belonging to a project appear in the Project->Items list

Reported by: Nicklas Nordborg Owned by: everyone
Priority: critical Milestone: BASE 3.6.3
Component: core Version:
Keywords: Cc:

Description

  • Create one item of a type that can be shared, for example a Sample.
  • Create one project and make it the active project.
  • Go to the 'Items' tab in the project. The list will include the sample that was created in the first step.

The list should only include items that have been shared to the project. Selecting different options in the preset selection list doesn't make any difference.

Change History (2)

comment:1 by Nicklas Nordborg, 9 years ago

It seems like it doesn't happen to all kinds of items. For example, if a Tag is created it will not appear in the project list.

Another thing to notice is that if specific item types are selected from the "Item type" filter list, the items that are not part of the project go away. This is also a clue to what may be the root cause of this:

If we filter on "Item type" the code will issue one query for each type of item, but if there is no filter a generic query for ShareableData is used (see Project.java line 579-613)

In the generic case, Hibernate automatically creates a number of SQL queries. Most have a filter applied to them WHERE ... projectkey_id IN (...) which should take care of only loading items in the current project. However, for biomaterials, Hibernate skipped this filter. Another difference is that Hibernate uses a single query to load biosources, sample and extracts since those are located in the same database table.

Starting up BASE 3.5 the filter is applied also to the query that load biomaterials. This points us to [6934] for #1950. After some more comparisons between BASE 3.5 and 3.6 it is noticed that in BASE 3.5 we define Hibernate filters for the BioMaterial class but not for BioSource, Sample or Extract, but in BASE 3.6, the filters are defined for BioSource, Sample and Extract.

One could argue that this is a bug in Hibernate since we have defined and enabled filters that are not applied when loading some items.

Possible solutions are to define filters also for the abstract classes (as in BASE 3.5) or to always use the method were we query for one specific item type at a time.

The Trashcan code have similar issues since it may use a query for RemovableData items. In this case, the restriction is coded into the main query instead of using a Hibernate filter. However a Hibernate filter is used to restrict on owner to the currently logged in user. In this case it means that a user may see items in the trashcan that are owned by other users. As it happens, this issue was fixed (using the one query per item type method) as a side-effect when implementing #1966 (BASE 3.7).

comment:2 by Nicklas Nordborg, 9 years ago

Resolution: fixed
Status: newclosed

(In [7024]) Fixes #1972: Items not belonging to a project appear in the Project->Items list

This undo several changes made in [6934]. The generic filters are now defined the same way as before that change. Item-specific filters are defined only if there is an Item defined for the current class.

Note: See TracTickets for help on using tickets.