Skip to content

Commit c860790

Browse files
Release/2.0.0 (#33)
* Bump Version to 2.0.0-SNAPSHOT and remove travis remnants * use new tables where needed, deprecate code otherwise (#32)
1 parent e7cf14d commit c860790

File tree

4 files changed

+50
-73
lines changed

4 files changed

+50
-73
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 2.0.0 (2022-04-01)
4+
* Fix references to old tables
5+
36
## 1.9.4 (2022-01-04)
47
* Fix CVE-2021-44832
58
* Increase log4j-version `2.17.0` -> `2.17.1`

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# User Database Portlet
22

3-
[![Build Status](https://travis-ci.com/qbicsoftware/user-db-portlet.svg?branch=development)](https://travis-ci.com/qbicsoftware/user-db-portlet)[![Code Coverage]( https://codecov.io/gh/qbicsoftware/user-db-portlet/branch/development/graph/badge.svg)](https://codecov.io/gh/qbicsoftware/user-db-portlet)
4-
53
User Database Portlet - User DB Tools Portlet enables users to add people and affiliations to the SQL user database.
64

75
## Author

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>3.1.4</version>
1010
</parent>
1111
<artifactId>user-db-portlet</artifactId>
12-
<version>1.9.4</version>
12+
<version>2.0.0</version>
1313
<name>User Database Portlet</name>
1414
<url>http://github.com/qbicsoftware/user-db-portlet</url>
1515
<packaging>war</packaging>

src/main/java/life/qbic/userdb/DBManager.java

+46-70
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ private String prepareStringInput(String input) {
6363
return input.trim();
6464
}
6565

66+
@Deprecated
6667
private void printAffiliations() {
6768
String sql = "SELECT * FROM organizations";
6869
Connection conn = login();
@@ -105,6 +106,7 @@ public String getProjectName(String projectIdentifier) {
105106
return res;
106107
}
107108

109+
@Deprecated
108110
private void removePersonFromAllProjects(int userID) {
109111
logger.info("Trying to remove all project associations of user with ID " + userID);
110112
String sql = "DELETE FROM projects_persons WHERE person_id = ?";
@@ -123,6 +125,7 @@ private void removePersonFromAllProjects(int userID) {
123125
}
124126
}
125127

128+
@Deprecated
126129
private void removePersonFromAllAffiliationRoles(int userID) {
127130
logger.info("Trying to remove all affiliation associations of user with ID " + userID);
128131
String sql = "DELETE FROM persons_organizations WHERE person_id = ?";
@@ -547,6 +550,7 @@ public void printProjects() {
547550
}
548551
}
549552

553+
@Deprecated
550554
public Map<String, Integer> getAffiliationMap() {
551555
Map<String, Integer> res = new HashMap<String, Integer>();
552556
String sql = "SELECT * FROM organizations";
@@ -619,6 +623,7 @@ public Map<String, Integer> getAffiliationMap() {
619623
return res;
620624
}
621625

626+
@Deprecated
622627
public int addNewAffiliation(Affiliation affiliation) {
623628
int res = -1;
624629
logger.info("Trying to add new affiliation to the DB");
@@ -839,6 +844,7 @@ public void printTableNames() throws SQLException {
839844
logout(conn);
840845
}
841846

847+
@Deprecated
842848
public boolean addOrUpdatePersonAffiliationConnections(int personID,
843849
List<PersonAffiliationConnectionInfo> newConnections) {
844850
Connection conn = login();
@@ -914,15 +920,15 @@ public boolean addOrUpdatePersonAffiliationConnections(int personID,
914920

915921
public List<Integer> getPersonAffiliationIDs(int person_id) {
916922
List<Integer> res = new ArrayList<Integer>();
917-
String sql = "SELECT * FROM persons_organizations WHERE person_id = ?";
923+
String sql = "SELECT * FROM person_affiliation WHERE person_id = ?";
918924
Connection conn = login();
919925
PreparedStatement statement = null;
920926
try {
921927
statement = conn.prepareStatement(sql);
922928
statement.setInt(1, person_id);
923929
ResultSet rs = statement.executeQuery();
924930
while (rs.next()) {
925-
res.add(rs.getInt("organization_id"));
931+
res.add(rs.getInt("affiliation_id"));
926932
}
927933
} catch (SQLException e) {
928934
e.printStackTrace();
@@ -932,6 +938,7 @@ public List<Integer> getPersonAffiliationIDs(int person_id) {
932938
return res;
933939
}
934940

941+
@Deprecated
935942
public List<Person> getPersonTable() {
936943
List<Person> res = new ArrayList<Person>();
937944
String lnk = "persons_organizations";
@@ -967,6 +974,7 @@ public List<Person> getPersonTable() {
967974
return res;
968975
}
969976

977+
@Deprecated
970978
public Set<String> getInstituteNames() {
971979
Set<String> res = new HashSet<String>();
972980
String sql = "SELECT institute FROM organizations";
@@ -988,6 +996,7 @@ public Set<String> getInstituteNames() {
988996
return res;
989997
}
990998

999+
@Deprecated
9911000
public Affiliation getOrganizationInfosFromInstitute(String institute) {
9921001
institute = prepareStringInput(institute);
9931002
Affiliation res = null;
@@ -1041,6 +1050,7 @@ public Affiliation getOrganizationInfosFromInstitute(String institute) {
10411050
return res;
10421051
}
10431052

1053+
@Deprecated
10441054
public Affiliation getOrganizationInfosFromOrg(String organization) {
10451055
organization = prepareStringInput(organization);
10461056
Affiliation res = null, maybe = null;
@@ -1077,6 +1087,7 @@ public Affiliation getOrganizationInfosFromOrg(String organization) {
10771087
return res;
10781088
}
10791089

1090+
@Deprecated
10801091
public List<Affiliation> getAffiliationTable() {
10811092
List<Affiliation> res = new ArrayList<Affiliation>();
10821093
String sql = "SELECT * from organizations";
@@ -1139,19 +1150,18 @@ public String getInvestigatorForProject(String projectIdentifier) {
11391150
* @return AffiliationID, forwarded to getAffiliationWithID
11401151
*/
11411152
public int getAffiliationIDForPersonID(Integer personID) {
1142-
String lnk = "persons_organizations";
1143-
String sql =
1144-
"SELECT persons.*, organizations.*, " + lnk + ".occupation FROM persons, organizations, "
1145-
+ lnk + " WHERE persons.id = " + Integer.toString(personID) + " AND persons.id = " + lnk
1146-
+ ".person_id and organizations.id = " + lnk + ".organization_id";
1153+
String lnk = "person_affiliation";
1154+
String sql = "SELECT person.*, affiliation.* FROM person, affiliation, " + lnk
1155+
+ " WHERE person.id = " + Integer.toString(personID) + " AND person.id = " + lnk
1156+
+ ".person_id and affiliation.id = " + lnk + ".affiliation_id";
11471157
Connection conn = login();
11481158

11491159
int affiliationID = -1;
11501160

11511161
try (PreparedStatement statement = conn.prepareStatement(sql)) {
11521162
ResultSet rs = statement.executeQuery();
11531163
while (rs.next()) {
1154-
affiliationID = rs.getInt("organizations.id");
1164+
affiliationID = rs.getInt("affiliation.id");
11551165

11561166
}
11571167
statement.close();
@@ -1218,8 +1228,8 @@ public List<Person> getPersonWithAffiliations(Integer personID) {
12181228
List<Person> res = new ArrayList<Person>();
12191229
String lnk = "person_affiliation";
12201230
String sql =
1221-
"SELECT person.*, affiliation.id, affiliation.organization FROM person, affiliation, "
1222-
+ lnk + " WHERE person.id = " + Integer.toString(personID) + " AND person.id = " + lnk
1231+
"SELECT person.*, affiliation.id, affiliation.organization FROM person, affiliation, " + lnk
1232+
+ " WHERE person.id = " + Integer.toString(personID) + " AND person.id = " + lnk
12231233
+ ".person_id AND affiliation.id = " + lnk + ".affiliation_id";
12241234
System.out.println(sql);
12251235
Connection conn = login();
@@ -1251,7 +1261,7 @@ public List<Person> getPersonWithAffiliations(Integer personID) {
12511261

12521262
private Affiliation getAffiliationWithID(int id) {
12531263
Affiliation res = null;
1254-
String sql = "SELECT * from organizations WHERE id = ?";
1264+
String sql = "SELECT * from affiliation WHERE id = ?";
12551265

12561266
Connection conn = login();
12571267
PreparedStatement statement = null;
@@ -1260,32 +1270,21 @@ private Affiliation getAffiliationWithID(int id) {
12601270
statement.setInt(1, id);
12611271
ResultSet rs = statement.executeQuery();
12621272
while (rs.next()) {
1263-
String groupName = rs.getString("group_name");
1264-
String acronym = rs.getString("group_acronym");
1265-
if (acronym == null)
1266-
acronym = "";
1267-
String organization = rs.getString("umbrella_organization");
1268-
String faculty = rs.getString("faculty");
1269-
String institute = rs.getString("institute");
1270-
if (institute == null)
1271-
institute = "";
1273+
String groupName = rs.getString("organization");
1274+
String acronym = "";
1275+
String organization = rs.getString("address_addition");
1276+
if (organization == null) {
1277+
organization = "";
1278+
}
1279+
String faculty = rs.getString("category");
1280+
String institute = "";
12721281
String street = rs.getString("street");
1273-
String zipCode = rs.getString("zip_code");
1282+
String zipCode = rs.getString("postal_code");
12741283
String city = rs.getString("city");
12751284
String country = rs.getString("country");
1276-
String webpage = rs.getString("webpage");
1277-
int contactID = rs.getInt("main_contact");
1278-
int headID = rs.getInt("head");
1285+
String webpage = "";
12791286
String contact = null;
12801287
String head = null;
1281-
if (contactID > 0) {
1282-
Person c = getPerson(contactID);
1283-
contact = c.getFirstName() + " " + c.getLastName();
1284-
}
1285-
if (headID > 0) {
1286-
Person h = getPerson(headID);
1287-
head = h.getFirstName() + " " + h.getLastName();
1288-
}
12891288
res = new Affiliation(id, groupName, acronym, organization, institute, faculty, contact,
12901289
head, street, zipCode, city, country, webpage);
12911290
}
@@ -1299,23 +1298,20 @@ private Affiliation getAffiliationWithID(int id) {
12991298

13001299
public Person getPerson(int id) {
13011300
Person res = null;
1302-
String sql = "SELECT * FROM persons WHERE persons.id = ?";
1301+
String sql = "SELECT * FROM person WHERE person.id = ?";
13031302
Connection conn = login();
13041303
PreparedStatement statement = null;
13051304
try {
13061305
statement = conn.prepareStatement(sql);
13071306
statement.setInt(1, id);
13081307
ResultSet rs = statement.executeQuery();
13091308
while (rs.next()) {
1310-
String username = rs.getString("username");
1309+
String username = rs.getString("user_id");
13111310
String title = rs.getString("title");
13121311
String first = rs.getString("first_name");
1313-
String last = rs.getString("family_name");
1312+
String last = rs.getString("last_name");
13141313
String eMail = rs.getString("email");
1315-
String phone = rs.getString("phone");
1316-
res = new Person(username, title, first, last, eMail, phone, -1, null, null);// TODO add
1317-
// every
1318-
// affiliation?
1314+
res = new Person(username, title, first, last, eMail, "", -1, null, null);
13191315
}
13201316
} catch (SQLException e) {
13211317
e.printStackTrace();
@@ -1340,6 +1336,7 @@ private void endQuery(Connection c, PreparedStatement p) {
13401336
}
13411337
}
13421338

1339+
@Deprecated
13431340
public void setAffiliationVIP(int affi, int person, String role) {
13441341
role = prepareStringInput(role);
13451342
logger.info("Trying to set/change affiliation-specific role " + role);
@@ -1365,8 +1362,8 @@ public List<Person> getPersonsByName(String one, String two) {
13651362
two = prepareStringInput(two);
13661363
List<Person> res = new ArrayList<Person>();
13671364

1368-
String sql = "SELECT * from persons where (first_name LIKE ? AND family_name LIKE ?) OR "
1369-
+ "(family_name LIKE ? AND first_name LIKE ?)";
1365+
String sql = "SELECT * from person where (first_name LIKE ? AND last_name LIKE ?) OR "
1366+
+ "(last_name LIKE ? AND first_name LIKE ?)";
13701367
Connection conn = login();
13711368
PreparedStatement statement = null;
13721369
try {
@@ -1380,13 +1377,12 @@ public List<Person> getPersonsByName(String one, String two) {
13801377
int id = rs.getInt("id");
13811378
List<Person> found = getPersonWithAffiliations(id);
13821379
if (found.isEmpty()) {
1383-
String username = rs.getString("username");
1380+
String username = rs.getString("user_id");
13841381
String title = rs.getString("title");
13851382
String first = rs.getString("first_name");
1386-
String last = rs.getString("family_name");
1383+
String last = rs.getString("last_name");
13871384
String eMail = rs.getString("email");
1388-
String phone = rs.getString("phone");
1389-
res.add(new Person(username, title, first, last, eMail, phone, -1, "N/A", "N/A"));
1385+
res.add(new Person(username, title, first, last, eMail, "", -1, "N/A", "N/A"));
13901386
} else
13911387
res.add(found.get(0));// TODO set all of them!
13921388
}
@@ -1419,12 +1415,12 @@ public List<Person> getPersonsContaining(String personQuery) {
14191415
int id = rs.getInt("id");
14201416
List<Person> found = getPersonWithAffiliations(id);
14211417
if (found.isEmpty()) {
1422-
String username = rs.getString("username");
1418+
String username = rs.getString("user_id");
14231419
String title = rs.getString("title");
14241420
String first = rs.getString("first_name");
1425-
String last = rs.getString("family_name");
1421+
String last = rs.getString("last_name");
14261422
String eMail = rs.getString("email");
1427-
String phone = rs.getString("phone");
1423+
String phone = "";
14281424
res.add(new Person(username, title, first, last, eMail, phone, -1, "N/A", "N/A"));
14291425
} else
14301426
res.add(found.get(0));// TODO set all of them!
@@ -1437,6 +1433,7 @@ public List<Person> getPersonsContaining(String personQuery) {
14371433
return res;
14381434
}
14391435

1436+
@Deprecated
14401437
public List<Affiliation> getAffiliationsContaining(String affiQuery) {
14411438
List<Affiliation> res = new ArrayList<Affiliation>();
14421439

@@ -1600,28 +1597,7 @@ public List<CollaboratorWithResponsibility> getCollaboratorsOfProject(String pro
16001597
} finally {
16011598
endQuery(conn, statement);
16021599
}
1603-
// now we need to add all projects without person connections
1604-
// sql =
1605-
// "SELECT t1.* FROM experiments t1 LEFT JOIN experiments_persons t2 ON t1.id = t2.experiment_id
1606-
// WHERE t2.experiment_id IS NULL";
1607-
// conn = login();
1608-
// statement = null;
1609-
// try {
1610-
// statement = conn.prepareStatement(sql);
1611-
// ResultSet rs = statement.executeQuery();
1612-
// while (rs.next()) {
1613-
// String[] openbisIDSplit = rs.getString("openbis_experiment_identifier").split("/");
1614-
// int id = rs.getInt("experiments.id");
1615-
// String exp = openbisIDSplit[3];
1616-
// String role = rs.getString("experiment_role");
1617-
// String name = rs.getString("first_name") + " " + rs.getString("family_name");
1618-
// res.add(new CollaboratorWithResponsibility(id, name, exp, role));
1619-
// }
1620-
// } catch (SQLException e) {
1621-
// e.printStackTrace();
1622-
// } finally {
1623-
// endQuery(conn, statement);
1624-
// }
1600+
16251601
return res;
16261602
}
16271603

0 commit comments

Comments
 (0)