@@ -63,6 +63,7 @@ private String prepareStringInput(String input) {
63
63
return input .trim ();
64
64
}
65
65
66
+ @ Deprecated
66
67
private void printAffiliations () {
67
68
String sql = "SELECT * FROM organizations" ;
68
69
Connection conn = login ();
@@ -105,6 +106,7 @@ public String getProjectName(String projectIdentifier) {
105
106
return res ;
106
107
}
107
108
109
+ @ Deprecated
108
110
private void removePersonFromAllProjects (int userID ) {
109
111
logger .info ("Trying to remove all project associations of user with ID " + userID );
110
112
String sql = "DELETE FROM projects_persons WHERE person_id = ?" ;
@@ -123,6 +125,7 @@ private void removePersonFromAllProjects(int userID) {
123
125
}
124
126
}
125
127
128
+ @ Deprecated
126
129
private void removePersonFromAllAffiliationRoles (int userID ) {
127
130
logger .info ("Trying to remove all affiliation associations of user with ID " + userID );
128
131
String sql = "DELETE FROM persons_organizations WHERE person_id = ?" ;
@@ -547,6 +550,7 @@ public void printProjects() {
547
550
}
548
551
}
549
552
553
+ @ Deprecated
550
554
public Map <String , Integer > getAffiliationMap () {
551
555
Map <String , Integer > res = new HashMap <String , Integer >();
552
556
String sql = "SELECT * FROM organizations" ;
@@ -619,6 +623,7 @@ public Map<String, Integer> getAffiliationMap() {
619
623
return res ;
620
624
}
621
625
626
+ @ Deprecated
622
627
public int addNewAffiliation (Affiliation affiliation ) {
623
628
int res = -1 ;
624
629
logger .info ("Trying to add new affiliation to the DB" );
@@ -839,6 +844,7 @@ public void printTableNames() throws SQLException {
839
844
logout (conn );
840
845
}
841
846
847
+ @ Deprecated
842
848
public boolean addOrUpdatePersonAffiliationConnections (int personID ,
843
849
List <PersonAffiliationConnectionInfo > newConnections ) {
844
850
Connection conn = login ();
@@ -914,15 +920,15 @@ public boolean addOrUpdatePersonAffiliationConnections(int personID,
914
920
915
921
public List <Integer > getPersonAffiliationIDs (int person_id ) {
916
922
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 = ?" ;
918
924
Connection conn = login ();
919
925
PreparedStatement statement = null ;
920
926
try {
921
927
statement = conn .prepareStatement (sql );
922
928
statement .setInt (1 , person_id );
923
929
ResultSet rs = statement .executeQuery ();
924
930
while (rs .next ()) {
925
- res .add (rs .getInt ("organization_id " ));
931
+ res .add (rs .getInt ("affiliation_id " ));
926
932
}
927
933
} catch (SQLException e ) {
928
934
e .printStackTrace ();
@@ -932,6 +938,7 @@ public List<Integer> getPersonAffiliationIDs(int person_id) {
932
938
return res ;
933
939
}
934
940
941
+ @ Deprecated
935
942
public List <Person > getPersonTable () {
936
943
List <Person > res = new ArrayList <Person >();
937
944
String lnk = "persons_organizations" ;
@@ -967,6 +974,7 @@ public List<Person> getPersonTable() {
967
974
return res ;
968
975
}
969
976
977
+ @ Deprecated
970
978
public Set <String > getInstituteNames () {
971
979
Set <String > res = new HashSet <String >();
972
980
String sql = "SELECT institute FROM organizations" ;
@@ -988,6 +996,7 @@ public Set<String> getInstituteNames() {
988
996
return res ;
989
997
}
990
998
999
+ @ Deprecated
991
1000
public Affiliation getOrganizationInfosFromInstitute (String institute ) {
992
1001
institute = prepareStringInput (institute );
993
1002
Affiliation res = null ;
@@ -1041,6 +1050,7 @@ public Affiliation getOrganizationInfosFromInstitute(String institute) {
1041
1050
return res ;
1042
1051
}
1043
1052
1053
+ @ Deprecated
1044
1054
public Affiliation getOrganizationInfosFromOrg (String organization ) {
1045
1055
organization = prepareStringInput (organization );
1046
1056
Affiliation res = null , maybe = null ;
@@ -1077,6 +1087,7 @@ public Affiliation getOrganizationInfosFromOrg(String organization) {
1077
1087
return res ;
1078
1088
}
1079
1089
1090
+ @ Deprecated
1080
1091
public List <Affiliation > getAffiliationTable () {
1081
1092
List <Affiliation > res = new ArrayList <Affiliation >();
1082
1093
String sql = "SELECT * from organizations" ;
@@ -1139,19 +1150,18 @@ public String getInvestigatorForProject(String projectIdentifier) {
1139
1150
* @return AffiliationID, forwarded to getAffiliationWithID
1140
1151
*/
1141
1152
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" ;
1147
1157
Connection conn = login ();
1148
1158
1149
1159
int affiliationID = -1 ;
1150
1160
1151
1161
try (PreparedStatement statement = conn .prepareStatement (sql )) {
1152
1162
ResultSet rs = statement .executeQuery ();
1153
1163
while (rs .next ()) {
1154
- affiliationID = rs .getInt ("organizations .id" );
1164
+ affiliationID = rs .getInt ("affiliation .id" );
1155
1165
1156
1166
}
1157
1167
statement .close ();
@@ -1218,8 +1228,8 @@ public List<Person> getPersonWithAffiliations(Integer personID) {
1218
1228
List <Person > res = new ArrayList <Person >();
1219
1229
String lnk = "person_affiliation" ;
1220
1230
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
1223
1233
+ ".person_id AND affiliation.id = " + lnk + ".affiliation_id" ;
1224
1234
System .out .println (sql );
1225
1235
Connection conn = login ();
@@ -1251,7 +1261,7 @@ public List<Person> getPersonWithAffiliations(Integer personID) {
1251
1261
1252
1262
private Affiliation getAffiliationWithID (int id ) {
1253
1263
Affiliation res = null ;
1254
- String sql = "SELECT * from organizations WHERE id = ?" ;
1264
+ String sql = "SELECT * from affiliation WHERE id = ?" ;
1255
1265
1256
1266
Connection conn = login ();
1257
1267
PreparedStatement statement = null ;
@@ -1260,32 +1270,21 @@ private Affiliation getAffiliationWithID(int id) {
1260
1270
statement .setInt (1 , id );
1261
1271
ResultSet rs = statement .executeQuery ();
1262
1272
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 = "" ;
1272
1281
String street = rs .getString ("street" );
1273
- String zipCode = rs .getString ("zip_code " );
1282
+ String zipCode = rs .getString ("postal_code " );
1274
1283
String city = rs .getString ("city" );
1275
1284
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 = "" ;
1279
1286
String contact = null ;
1280
1287
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
- }
1289
1288
res = new Affiliation (id , groupName , acronym , organization , institute , faculty , contact ,
1290
1289
head , street , zipCode , city , country , webpage );
1291
1290
}
@@ -1299,23 +1298,20 @@ private Affiliation getAffiliationWithID(int id) {
1299
1298
1300
1299
public Person getPerson (int id ) {
1301
1300
Person res = null ;
1302
- String sql = "SELECT * FROM persons WHERE persons .id = ?" ;
1301
+ String sql = "SELECT * FROM person WHERE person .id = ?" ;
1303
1302
Connection conn = login ();
1304
1303
PreparedStatement statement = null ;
1305
1304
try {
1306
1305
statement = conn .prepareStatement (sql );
1307
1306
statement .setInt (1 , id );
1308
1307
ResultSet rs = statement .executeQuery ();
1309
1308
while (rs .next ()) {
1310
- String username = rs .getString ("username " );
1309
+ String username = rs .getString ("user_id " );
1311
1310
String title = rs .getString ("title" );
1312
1311
String first = rs .getString ("first_name" );
1313
- String last = rs .getString ("family_name " );
1312
+ String last = rs .getString ("last_name " );
1314
1313
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 );
1319
1315
}
1320
1316
} catch (SQLException e ) {
1321
1317
e .printStackTrace ();
@@ -1340,6 +1336,7 @@ private void endQuery(Connection c, PreparedStatement p) {
1340
1336
}
1341
1337
}
1342
1338
1339
+ @ Deprecated
1343
1340
public void setAffiliationVIP (int affi , int person , String role ) {
1344
1341
role = prepareStringInput (role );
1345
1342
logger .info ("Trying to set/change affiliation-specific role " + role );
@@ -1365,8 +1362,8 @@ public List<Person> getPersonsByName(String one, String two) {
1365
1362
two = prepareStringInput (two );
1366
1363
List <Person > res = new ArrayList <Person >();
1367
1364
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 ?)" ;
1370
1367
Connection conn = login ();
1371
1368
PreparedStatement statement = null ;
1372
1369
try {
@@ -1380,13 +1377,12 @@ public List<Person> getPersonsByName(String one, String two) {
1380
1377
int id = rs .getInt ("id" );
1381
1378
List <Person > found = getPersonWithAffiliations (id );
1382
1379
if (found .isEmpty ()) {
1383
- String username = rs .getString ("username " );
1380
+ String username = rs .getString ("user_id " );
1384
1381
String title = rs .getString ("title" );
1385
1382
String first = rs .getString ("first_name" );
1386
- String last = rs .getString ("family_name " );
1383
+ String last = rs .getString ("last_name " );
1387
1384
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" ));
1390
1386
} else
1391
1387
res .add (found .get (0 ));// TODO set all of them!
1392
1388
}
@@ -1419,12 +1415,12 @@ public List<Person> getPersonsContaining(String personQuery) {
1419
1415
int id = rs .getInt ("id" );
1420
1416
List <Person > found = getPersonWithAffiliations (id );
1421
1417
if (found .isEmpty ()) {
1422
- String username = rs .getString ("username " );
1418
+ String username = rs .getString ("user_id " );
1423
1419
String title = rs .getString ("title" );
1424
1420
String first = rs .getString ("first_name" );
1425
- String last = rs .getString ("family_name " );
1421
+ String last = rs .getString ("last_name " );
1426
1422
String eMail = rs .getString ("email" );
1427
- String phone = rs . getString ( "phone" ) ;
1423
+ String phone = "" ;
1428
1424
res .add (new Person (username , title , first , last , eMail , phone , -1 , "N/A" , "N/A" ));
1429
1425
} else
1430
1426
res .add (found .get (0 ));// TODO set all of them!
@@ -1437,6 +1433,7 @@ public List<Person> getPersonsContaining(String personQuery) {
1437
1433
return res ;
1438
1434
}
1439
1435
1436
+ @ Deprecated
1440
1437
public List <Affiliation > getAffiliationsContaining (String affiQuery ) {
1441
1438
List <Affiliation > res = new ArrayList <Affiliation >();
1442
1439
@@ -1600,28 +1597,7 @@ public List<CollaboratorWithResponsibility> getCollaboratorsOfProject(String pro
1600
1597
} finally {
1601
1598
endQuery (conn , statement );
1602
1599
}
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
+
1625
1601
return res ;
1626
1602
}
1627
1603
0 commit comments