Skip to content

Commit

Permalink
Fixed native sqls for the user table and fixed an improper test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaar, Bjørn-Andre committed Dec 18, 2023
1 parent b938d89 commit 1e7abd6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;

@Entity
public class ClassificationAccessCounter {
@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ public List<ClassificationFamilySummary> findClassificationFamilySummaries(Strin
"select family.id, family.name, family.icon_name, count(classification.id) from classification_family family "
+ "left outer join classification_series classification on classification.classification_family_id=family.id "
+ " and classification.deleted = false"
+ " and (:section is null or :section = (select user.section from user user where user.id = classification.contact_person_id)) "
+ " and (:section is null or :section = (select usr.section from user usr where usr.id = classification.contact_person_id)) "
+ " and (:classificationType is null or :classificationType = classification.classification_type) "
+ "group by family.id"
// @formatter:on
).setParameter("section", section).setParameter("classificationType", classificationType == null ? null
: classificationType.name()).getResultList();

for (Object[] columns : rows) {
result.add(new ClassificationFamilySummary(((BigInteger) columns[0]).longValue(), converter
result.add(new ClassificationFamilySummary((Long) columns[0], converter
.convertToEntityAttribute((String) columns[1]), (String) columns[2],
((BigInteger) columns[3]).longValue()));
(Long) columns[3]));
}
return result;
}
Expand All @@ -88,7 +88,7 @@ public List<ClassificationFamilySummary> findPublicClassificationFamilySummaries
+ " and classification.copyrighted <> '1' "
+ " and (:classificationType is null or :classificationType = classification.classification_type) "
+ " and (:section is null or :section "
+ " = (select user.section from user user where user.id = classification.contact_person_id)) "
+ " = (select usr.section from user usr where usr.id = classification.contact_person_id)) "
+ " group by family.id"
// @formatter:on
).setParameter("section", section).setParameter("classificationType", classificationType == null ? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public void getStaticalUnitsOverViewTest() {
Integer.MAX_VALUE));
assertEquals(2, result.getContent().size());
List<StatisticalEntity> resultList = result.getContent();
assertEquals("Duppeditt", resultList.get(0).getName());
assertEquals(Long.valueOf(2), resultList.get(0).getCount());
assertEquals("Dingseboms", resultList.get(1).getName());
assertEquals(Long.valueOf(1), resultList.get(1).getCount());
assertEquals("Dingseboms", resultList.get(0).getName());
assertEquals(Long.valueOf(1), resultList.get(0).getCount());
assertEquals("Duppeditt", resultList.get(1).getName());
assertEquals(Long.valueOf(2), resultList.get(1).getCount());
}

@Test
Expand Down

0 comments on commit 1e7abd6

Please sign in to comment.