Skip to content

Commit de077e5

Browse files
Release/1.9.0 (#23)
* remove unnecessary tabs, use new database structure (#22) * remove unnecessary tabs, use new database structure * add comment block * increase snapshot version to 1.9.0 * prepare version 1.9.0
1 parent 13624ad commit de077e5

File tree

4 files changed

+185
-196
lines changed

4 files changed

+185
-196
lines changed

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.8.2</version>
12+
<version>1.9.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/portal/portlet/UserDBPortletUI.java

+154-165
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import java.util.List;
99
import java.util.Map;
1010
import java.util.Objects;
11-
import java.util.Set;
1211
import org.apache.commons.lang3.StringUtils;
13-
import org.apache.commons.lang3.tuple.ImmutablePair;
14-
import org.apache.commons.lang3.tuple.Pair;
1512
import org.apache.logging.log4j.LogManager;
1613
import org.apache.logging.log4j.Logger;
1714
import com.liferay.portal.model.User;
@@ -151,56 +148,49 @@ private void initTabs() {
151148
options.setSelectedTab(rightsMissingTab);
152149
options.setEnabled(false);
153150
} else {
154-
affiMap = dbControl.getAffiliationMap();
155151
personMap = dbControl.getPersonMap();
156-
Map<String, Integer> colNamesToMaxLength = fillMaxInputLengthMap();
157-
158-
Set<String> instituteNames = dbControl.getInstituteNames();
159-
List<String> facultyEnums =
160-
dbControl.getPossibleEnumsForColumnsInTable("organizations", "faculty");
161-
List<String> affiliationRoles =
162-
dbControl.getPossibleEnumsForColumnsInTable("persons_organizations", "occupation");
163-
List<String> titleEnums = dbControl.getPossibleEnumsForColumnsInTable("persons", "title");
164-
165-
PersonInput addUserTab =
166-
new PersonInput(titleEnums, affiMap, affiliationRoles, colNamesToMaxLength,
167-
new AffiliationInput(instituteNames, facultyEnums, personMap, colNamesToMaxLength));
168-
options.addTab(addUserTab, "New Person");
169-
170-
AffiliationInput addAffilTab =
171-
new AffiliationInput(instituteNames, facultyEnums, personMap, colNamesToMaxLength);
172-
options.addTab(addAffilTab, "New Affiliation");
173-
174-
175-
SearchView searchView = new SearchView();
176-
options.addTab(searchView, "Search Entries");
177-
178-
List<Affiliation> affiTable = dbControl.getAffiliationTable();
179-
Map<Integer, Pair<String, String>> affiPeople = new HashMap<Integer, Pair<String, String>>();
180-
for (Affiliation a : affiTable) {
181-
int id = a.getID();
182-
affiPeople.put(id,
183-
new ImmutablePair<String, String>(a.getContactPerson(), a.getHeadName()));
184-
}
185-
186-
PersonBatchUpload batchTab = new PersonBatchUpload(titleEnums, affiliationRoles, affiMap);
187-
options.addTab(batchTab, "Upload Person Table");
188-
189-
AffiliationVIPTab vipTab = new AffiliationVIPTab(personMap, affiMap, affiPeople);
190-
options.addTab(vipTab, "Edit Affiliation VIPs");
191-
192-
MultiAffiliationTab multiAffilTab =
193-
new MultiAffiliationTab(personMap, affiMap, affiliationRoles);
194-
options.addTab(multiAffilTab, "Additional Person-Affiliations");
195-
196-
if (!admin) {
197-
options.getTab(multiAffilTab).setEnabled(false);
198-
options.getTab(vipTab).setEnabled(false);
199-
200-
// options.getTab(3).setEnabled(false);
201-
// options.getTab(4).setEnabled(false);
202-
}
203152

153+
/*
154+
* Removed since 1.8.0 as most of the functionality moved to offer-manager-portlet 2
155+
*
156+
*
157+
* affiMap = dbControl.getAffiliationMap();
158+
*
159+
* Map<String, Integer> colNamesToMaxLength = fillMaxInputLengthMap();
160+
*
161+
* Set<String> instituteNames = dbControl.getInstituteNames(); List<String> facultyEnums =
162+
* dbControl.getPossibleEnumsForColumnsInTable("organizations", "faculty"); List<String>
163+
* affiliationRoles = dbControl.getPossibleEnumsForColumnsInTable("persons_organizations",
164+
* "occupation"); List<String> titleEnums =
165+
* dbControl.getPossibleEnumsForColumnsInTable("persons", "title");
166+
*
167+
* PersonInput addUserTab = new PersonInput(titleEnums, affiMap, affiliationRoles,
168+
* colNamesToMaxLength, new AffiliationInput(instituteNames, facultyEnums, personMap,
169+
* colNamesToMaxLength)); options.addTab(addUserTab, "New Person");
170+
*
171+
* AffiliationInput addAffilTab = new AffiliationInput(instituteNames, facultyEnums,
172+
* personMap, colNamesToMaxLength); options.addTab(addAffilTab, "New Affiliation");
173+
*
174+
* SearchView searchView = new SearchView(); options.addTab(searchView, "Search Entries");
175+
*
176+
* List<Affiliation> affiTable = dbControl.getAffiliationTable(); Map<Integer, Pair<String,
177+
* String>> affiPeople = new HashMap<Integer, Pair<String, String>>(); for (Affiliation a :
178+
* affiTable) { int id = a.getID(); affiPeople.put(id, new ImmutablePair<String,
179+
* String>(a.getContactPerson(), a.getHeadName())); } PersonBatchUpload batchTab = new
180+
* PersonBatchUpload(titleEnums, affiliationRoles, affiMap); options.addTab(batchTab,
181+
* "Upload Person Table");
182+
*
183+
* AffiliationVIPTab vipTab = new AffiliationVIPTab(personMap, affiMap, affiPeople);
184+
* options.addTab(vipTab, "Edit Affiliation VIPs");
185+
*
186+
* MultiAffiliationTab multiAffilTab = new MultiAffiliationTab(personMap, affiMap,
187+
* affiliationRoles); options.addTab(multiAffilTab, "Additional Person-Affiliations");
188+
*
189+
* if (!admin) { options.getTab(multiAffilTab).setEnabled(false);
190+
* options.getTab(vipTab).setEnabled(false);
191+
*
192+
* options.getTab(3).setEnabled(false); options.getTab(4).setEnabled(false); }
193+
*/
204194
String userID = "";
205195
if (PortalUtils.isLiferayPortlet()) {
206196
logger.info("DB Tools running on Liferay, fetching user ID.");
@@ -248,8 +238,119 @@ private void initTabs() {
248238
options.addTab(projectView, "Projects");
249239
options.getTab(projectView).setEnabled(!userProjects.isEmpty());
250240

251-
initPortletToDBFunctionality(addAffilTab, addUserTab, batchTab, multiAffilTab, vipTab,
252-
searchView, projectView);
241+
// initPortletToDBFunctionality(addAffilTab, addUserTab, batchTab, multiAffilTab, vipTab,
242+
// searchView, projectView);
243+
projectView.getProjectTable().addValueChangeListener(new ValueChangeListener() {
244+
245+
private Map<String, String> expTypeCodeTranslation = new HashMap<String, String>() {
246+
{
247+
put("Q_EXPERIMENTAL_DESIGN", "Patients/Sources");
248+
put("Q_SAMPLE_EXTRACTION", "Sample Extracts");
249+
put("Q_SAMPLE_PREPARATION", "Sample Preparations");
250+
put("Q_MS_MEASUREMENT", "Mass Spectrometry");
251+
put("Q_NGS_MEASUREMENT", "NGS Sequencing");
252+
};
253+
};
254+
255+
@Override
256+
public void valueChange(ValueChangeEvent event) {
257+
Object item = projectView.getProjectTable().getValue();
258+
if (item != null) {
259+
String project = item.toString();
260+
// get collaborators associated to openbis experiments
261+
List<CollaboratorWithResponsibility> collaborators =
262+
dbControl.getCollaboratorsOfProject(project);
263+
// get openbis experiments and type
264+
Map<String, String> existingExps = new HashMap<String, String>();
265+
for (Experiment e : openbis.getExperimentsForProject2(project)) {
266+
String type = expTypeCodeTranslation.get(e.getExperimentTypeCode());
267+
String id = e.getIdentifier();
268+
if (type != null)
269+
existingExps.put(id, type);
270+
}
271+
// add types for experiments with existing collaborators
272+
for (CollaboratorWithResponsibility c : collaborators) {
273+
String identifier = c.getOpenbisIdentifier();
274+
c.setType(existingExps.get(identifier));
275+
existingExps.remove(identifier);
276+
}
277+
// add empty entries and type for applicable experiments without collaborators
278+
for (String expID : existingExps.keySet()) {
279+
String code = expID.split("/")[3];
280+
CollaboratorWithResponsibility c =
281+
new CollaboratorWithResponsibility(-1, "", expID, code, "Contact");
282+
c.setType(existingExps.get(expID));
283+
collaborators.add(c);
284+
}
285+
projectView.setCollaboratorsOfProject(collaborators);
286+
287+
Person investigator = getPersonOrNull(projectMap.get(item).getInvestigator());
288+
Person manager = getPersonOrNull(projectMap.get(item).getManager());
289+
Person contact = getPersonOrNull(projectMap.get(item).getContact());
290+
291+
projectView.handleProjectValueChange(item, investigator, contact, manager);
292+
} else {
293+
projectView.handleProjectDeselect();
294+
}
295+
}
296+
297+
private Person getPersonOrNull(String name) {
298+
if (personMap.get(name) != null) {
299+
return dbControl.getPersonWithAffiliations(personMap.get(name)).get(0);
300+
}
301+
return null;
302+
}
303+
});
304+
305+
projectView.getInfoCommitButton().addClickListener(new ClickListener() {
306+
307+
@Override
308+
public void buttonClick(ClickEvent event) {
309+
ProjectInfo info = projectView.getEditedInfo();
310+
if (info != null) {
311+
String code = info.getProjectCode();
312+
int id = info.getProjectID();
313+
if (id < 1)
314+
id = dbControl.addProjectToDB("/" + info.getSpace() + "/" + code,
315+
info.getSecondaryName());
316+
else
317+
dbControl.addOrChangeSecondaryNameForProject(id, info.getSecondaryName());
318+
if (info.getInvestigator() == null || info.getInvestigator().isEmpty())
319+
dbControl.removePersonFromProject(id, "PI");
320+
else
321+
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getInvestigator()), "PI");
322+
if (info.getContact() == null || info.getContact().isEmpty())
323+
dbControl.removePersonFromProject(id, "Contact");
324+
else
325+
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getContact()), "Contact");
326+
if (info.getManager() == null || info.getManager().isEmpty())
327+
dbControl.removePersonFromProject(id, "Manager");
328+
else
329+
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getManager()), "Manager");
330+
projectView.updateChangedInfo(info);
331+
}
332+
}
333+
});;
334+
projectView.getPeopleCommitButton().addClickListener(new ClickListener() {
335+
336+
@Override
337+
public void buttonClick(ClickEvent event) {
338+
List<CollaboratorWithResponsibility> links = projectView.getNewResponsibilities();
339+
for (CollaboratorWithResponsibility c : links) {
340+
int experimentID = c.getExperimentID();
341+
if (experimentID < 1)
342+
experimentID = dbControl.addExperimentToDB(c.getOpenbisIdentifier());
343+
String name = c.getPerson();
344+
int personID = -1;
345+
if (personMap.get(name) != null)
346+
personID = personMap.get(name);
347+
if (personID < 1)
348+
dbControl.removePersonFromExperiment(experimentID);
349+
else
350+
dbControl.addOrUpdatePersonToExperiment(experimentID, personID, "Contact");
351+
}
352+
}
353+
});;
253354
}
254355
}
255356

@@ -344,118 +445,6 @@ public void buttonClick(ClickEvent event) {
344445
}
345446
});
346447

347-
projects.getProjectTable().addValueChangeListener(new ValueChangeListener() {
348-
349-
private Map<String, String> expTypeCodeTranslation = new HashMap<String, String>() {
350-
{
351-
put("Q_EXPERIMENTAL_DESIGN", "Patients/Sources");
352-
put("Q_SAMPLE_EXTRACTION", "Sample Extracts");
353-
put("Q_SAMPLE_PREPARATION", "Sample Preparations");
354-
put("Q_MS_MEASUREMENT", "Mass Spectrometry");
355-
put("Q_NGS_MEASUREMENT", "NGS Sequencing");
356-
};
357-
};
358-
359-
@Override
360-
public void valueChange(ValueChangeEvent event) {
361-
Object item = projects.getProjectTable().getValue();
362-
if (item != null) {
363-
String project = item.toString();
364-
// get collaborators associated to openbis experiments
365-
List<CollaboratorWithResponsibility> collaborators =
366-
dbControl.getCollaboratorsOfProject(project);
367-
// get openbis experiments and type
368-
Map<String, String> existingExps = new HashMap<String, String>();
369-
for (Experiment e : openbis.getExperimentsOfProjectByCode(project)) {
370-
String type = expTypeCodeTranslation.get(e.getType().getCode());
371-
String id = e.getIdentifier().getIdentifier();
372-
if (type != null)
373-
existingExps.put(id, type);
374-
}
375-
// add types for experiments with existing collaborators
376-
for (CollaboratorWithResponsibility c : collaborators) {
377-
String identifier = c.getOpenbisIdentifier();
378-
c.setType(existingExps.get(identifier));
379-
existingExps.remove(identifier);
380-
}
381-
// add empty entries and type for applicable experiments without collaborators
382-
for (String expID : existingExps.keySet()) {
383-
String code = expID.split("/")[3];
384-
CollaboratorWithResponsibility c =
385-
new CollaboratorWithResponsibility(-1, "", expID, code, "Contact");
386-
c.setType(existingExps.get(expID));
387-
collaborators.add(c);
388-
}
389-
projects.setCollaboratorsOfProject(collaborators);
390-
391-
Person investigator = getPersonOrNull(projectMap.get(item).getInvestigator());
392-
Person manager = getPersonOrNull(projectMap.get(item).getManager());
393-
Person contact = getPersonOrNull(projectMap.get(item).getContact());
394-
395-
projects.handleProjectValueChange(item, investigator, contact, manager);
396-
} else {
397-
projects.handleProjectDeselect();
398-
}
399-
}
400-
401-
private Person getPersonOrNull(String name) {
402-
if (personMap.get(name) != null) {
403-
return dbControl.getPersonWithAffiliations(personMap.get(name)).get(0);
404-
}
405-
return null;
406-
}
407-
});
408-
409-
projects.getInfoCommitButton().addClickListener(new ClickListener() {
410-
411-
@Override
412-
public void buttonClick(ClickEvent event) {
413-
ProjectInfo info = projects.getEditedInfo();
414-
if (info != null) {
415-
String code = info.getProjectCode();
416-
int id = info.getProjectID();
417-
if (id < 1)
418-
id = dbControl.addProjectToDB("/" + info.getSpace() + "/" + code,
419-
info.getSecondaryName());
420-
else
421-
dbControl.addOrChangeSecondaryNameForProject(id, info.getSecondaryName());
422-
if (info.getInvestigator() == null || info.getInvestigator().isEmpty())
423-
dbControl.removePersonFromProject(id, "PI");
424-
else
425-
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getInvestigator()), "PI");
426-
if (info.getContact() == null || info.getContact().isEmpty())
427-
dbControl.removePersonFromProject(id, "Contact");
428-
else
429-
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getContact()), "Contact");
430-
if (info.getManager() == null || info.getManager().isEmpty())
431-
dbControl.removePersonFromProject(id, "Manager");
432-
else
433-
dbControl.addOrUpdatePersonToProject(id, personMap.get(info.getManager()), "Manager");
434-
projects.updateChangedInfo(info);
435-
}
436-
}
437-
});;
438-
projects.getPeopleCommitButton().addClickListener(new ClickListener() {
439-
440-
@Override
441-
public void buttonClick(ClickEvent event) {
442-
List<CollaboratorWithResponsibility> links = projects.getNewResponsibilities();
443-
for (CollaboratorWithResponsibility c : links) {
444-
int experimentID = c.getExperimentID();
445-
if (experimentID < 1)
446-
experimentID = dbControl.addExperimentToDB(c.getOpenbisIdentifier());
447-
String name = c.getPerson();
448-
int personID = -1;
449-
if (personMap.get(name) != null)
450-
personID = personMap.get(name);
451-
if (personID < 1)
452-
dbControl.removePersonFromExperiment(experimentID);
453-
else
454-
dbControl.addOrUpdatePersonToExperiment(experimentID, personID, "Contact");
455-
}
456-
}
457-
});;
458-
459448
search.getSearchAffiliationButton().addClickListener(new Button.ClickListener() {
460449
@Override
461450
public void buttonClick(ClickEvent event) {

0 commit comments

Comments
 (0)