Project

General

Profile

« Previous | Next » 

Revision 50622

View differences:

AffiliationsDao.java
32 32
			final Group group = new Group((String) map.get("gid"), (String) map.get("gname"), (String) map.get("gtype"));
33 33

  
34 34
			temp.putIfAbsent(pid, new Person(pid, (String) map.get("pname")));
35
			temp.get(pid).getAffiliations().putIfAbsent(year, new TreeSet<>((g1, g2) -> g1.getId().compareTo(g2.getId())));
35
			temp.get(pid).getAffiliations().putIfAbsent(year, new TreeSet<>((g1, g2) -> {
36
				final int n1 = calculateIntegerForGroup(g1.getType());
37
				final int n2 = calculateIntegerForGroup(g2.getType());
38
				return (n1 == n2) ? g1.getId().compareTo(g2.getId()) : Integer.compare(n1, n2);
39
			}));
36 40
			temp.get(pid).getAffiliations().get(year).add(group);
37 41
		}
38 42

  
......
43 47

  
44 48
	}
45 49

  
50
	private int calculateIntegerForGroup(final String type) {
51
		if (type.equalsIgnoreCase("Laboratorio")) {
52
			return 0;
53
		} else if (type.equalsIgnoreCase("Servizio")) {
54
			return 10;
55
		} else if (type.equalsIgnoreCase("Centro")) {
56
			return 20;
57
		} else {
58
			return 100;
59
		}
60
	}
61

  
46 62
	public List<Person> listPersons() {
47 63
		return jdbcTemplate.query("select * from persons", (RowMapper<Person>) (rs, rowNum) -> {
48 64
			return new Person(rs.getString("id"), rs.getString("fullname"));

Also available in: Unified diff