Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ispyb/ISPyB
Browse files Browse the repository at this point in the history
  • Loading branch information
hormiai76 committed Oct 8, 2020
2 parents ca21c44 + 6081adc commit 8f893fb
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 179 deletions.
2 changes: 1 addition & 1 deletion ispyb-bcr-ear/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>
</parent>
<artifactId>ispyb-bcr-ear</artifactId>
<packaging>ear</packaging>
Expand Down
152 changes: 0 additions & 152 deletions ispyb-bcr/hs_err_pid1656.log

This file was deleted.

2 changes: 1 addition & 1 deletion ispyb-bcr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>

</parent>
<artifactId>ispyb-bcr</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ispyb-ear/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>
</parent>
<artifactId>ispyb-ear</artifactId>
<packaging>ear</packaging>
Expand Down
2 changes: 1 addition & 1 deletion ispyb-ejb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>
</parent>
<artifactId>ispyb-ejb3</artifactId>
<packaging>jar</packaging>
Expand Down
61 changes: 41 additions & 20 deletions ispyb-ejb/src/main/java/ispyb/server/smis/UpdateFromSMIS.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,20 +545,18 @@ public static void updateThisProposalFromLists(List<ExpSessionInfoLightVO> smisS
getProposal(labContact, lab, person, proposalNumber, proposalCode);

// retrieve person to get it 'personId' for persistence of the labContact
String familyName = labContacts[i].getScientistName();
String givenName = labContacts[i].getScientistFirstName();
String siteId = null;
Person3VO currentPerson = null;
// try first to use siteID: better for unicity, but only for people having a siteId, later use personUUID
if (labContacts[i].getSiteId() != null) {
siteId = labContacts[i].getSiteId().toString();
currentPerson = person.findBySiteId(siteId);
} else {
currentPerson = person.findByLogin(labContacts[i].getBllogin());
/*List<Person3VO> persons = person.findByFamilyAndGivenName(familyName, givenName);
if (persons != null && !persons.isEmpty()) {
currentPerson = persons.get(0);
}*/
if (Constants.SITE_IS_ESRF()) {
currentPerson = person.findByLogin(labContacts[i].getUserName());
} else {
currentPerson = person.findByLogin(labContacts[i].getBllogin());
}
}

if (currentPerson != null) {
Expand All @@ -575,7 +573,7 @@ public static void updateThisProposalFromLists(List<ExpSessionInfoLightVO> smisS
LOG.debug("Link between proposal and person added: " + proposalId + " " + currentPerson.getPersonId());
}
}

// fill the laboratory
Laboratory3VO currentLabo = ScientistsFromSMIS.extractLaboratoryInfo(labContacts[i]);
LOG.debug("current labo is : " + currentLabo.getAddress());
Expand Down Expand Up @@ -665,7 +663,7 @@ private static void loadProposers(ProposalParticipantInfoLightVO[] mainProposers
String proposalCode = StringUtils.getProposalCode(uoCode, proposalNumber);

LOG.debug("Proposal found : " + proposalCode + proposalNumber + " uoCode = " + uoCode);
LOG.debug("Bllogin : " + mainProp.getBllogin());
LOG.debug("Bllogin : " + mainProp.getBllogin() + " - username = " + mainProp.getUserName());

List<Proposal3VO> listProposals = proposal.findByCodeAndNumber(proposalCode, proposalNumber, false, false, false);

Expand All @@ -688,14 +686,24 @@ private static void loadProposers(ProposalParticipantInfoLightVO[] mainProposers
String currentGivenName = currentPerson.getGivenName();
String currentSiteId = currentPerson.getSiteId();
String currentEmail = currentPerson.getEmailAddress();
String currentLogin = currentPerson.getLogin();
// main proposer
String familyName = mainProp.getScientistName();
String givenName = mainProp.getScientistFirstName();
String siteId = null;
String email = mainProp.getScientistEmail();
String username = mainProp.getUserName();

if (Constants.SITE_IS_ESRF() && mainProp.getSiteId() != null )
siteId=mainProp.getSiteId().toString();
if (Constants.SITE_IS_ESRF() ) {
siteId = (mainProp.getSiteId() != null) ? mainProp.getSiteId().toString() : null;

// fill the login if it was null before or if it has changed
if (currentLogin == null || (username != null && !StringUtils.matchString(currentLogin, username))) {
currentPerson.setLogin(username);
currentPerson = person.merge(currentPerson);
LOG.debug("Update person with username: " + username);
}
}

if (Constants.getSite().equals(SITE.EMBL)) {
if (!StringUtils.matchString(mainProp.getBllogin(), currentPerson.getLogin())) {
Expand Down Expand Up @@ -859,6 +867,8 @@ private static void loadSamples(SampleSheetInfoLightVO[] smisSamples) throws Exc
}
}

// this method is only used by MAX IV for now, if used for others, it should be adapted:
// for ESRF the bllogin should be replaced by username
private static void loadParticipants(ProposalParticipantInfoLightVO[] participants)
throws Exception
{
Expand All @@ -879,14 +889,16 @@ private static void loadParticipants(ProposalParticipantInfoLightVO[] participan
{
LOG.debug("proposal already exists");
Proposal3VO proposalVO = (Proposal3VO)listProposals.get(0);

Person3VO personEnt = person.findByLogin(participant.getBllogin());
if (personEnt == null) {
personEnt = new Person3VO();
personEnt.setLogin(participant.getBllogin());
}

personEnt.setGivenName(participant.getScientistFirstName());
personEnt.setFamilyName(participant.getScientistName());
personEnt.setFamilyName(participant.getScientistName());

//TODO: Add more details

personEnt = person.merge(personEnt);
Expand Down Expand Up @@ -1216,6 +1228,7 @@ private static void retrieveSession(Proposal3VO proplv, ExpSessionInfoLightVO se
@SuppressWarnings({ "unused", "rawtypes" })
private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp, Laboratory3Service lab,
Person3Service person, String proposalNumber, String proposalCode) throws Exception {

// main proposer
String familyName = mainProp.getScientistName();
String givenName = mainProp.getScientistFirstName();
Expand All @@ -1227,6 +1240,7 @@ private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp,
if (Constants.SITE_IS_ESRF() && mainProp.getSiteId()!= null) {
siteId = mainProp.getSiteId().toString();
}
String login = (Constants.SITE_IS_ESRF() ) ? mainProp.getUserName() : mainProp.getBllogin();

// labo
Integer labId;
Expand Down Expand Up @@ -1255,6 +1269,7 @@ private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp,
LOG.debug("getting SMIS WS labo already exists");
}

// Person
Person3VO persv = new Person3VO();
Integer persId;
boolean personDoesNotExist = true;
Expand All @@ -1263,8 +1278,18 @@ private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp,
Person3VO personVO = person.findBySiteId(siteId);
if (personVO != null ) {
persv = personVO;
if (persv.getLogin() == null || !persv.getLogin().equalsIgnoreCase(login)) {
persv.setLogin(login);
persv = person.merge(persv);
}
personDoesNotExist = false;
}
} else if (login != null ){
Person3VO personVO = person.findByLogin(login);
if (personVO != null ) {
persv = personVO;
personDoesNotExist = false;
}
} else {
List<Person3VO> listPerson = person.findByFamilyAndGivenName(familyName, givenName);
if (!listPerson.isEmpty()) {
Expand All @@ -1282,15 +1307,12 @@ private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp,
persv.setLaboratoryVO(labv);
persv.setFaxNumber(faxNumber);
persv.setSiteId(siteId);

/** Adding the logging **/
LOG.debug("Adding login: " + persv.getLogin());

persv.setLogin(mainProp.getBllogin());
persv.setLogin(login);

persv = person.merge(persv);
persId = persv.getPersonId();

LOG.debug("getting SMIS WS person created");
LOG.debug("getting SMIS WS person created with login = " + persv.getLogin());
} else {
// person is existing but may has changed labo : we set the new
// labId
Expand Down Expand Up @@ -1367,9 +1389,8 @@ private static Proposal3VO getProposal(ProposalParticipantInfoLightVO mainProp,
propv.setType(Constants.PROPOSAL_MX_BX);
}
break;
}
}
return propv;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion ispyb-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>
</parent>

<artifactId>ispyb-ui</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ispyb-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ispyb</groupId>
<artifactId>ispyb-parent</artifactId>
<version>5.23</version>
<version>5.24</version>
</parent>
<artifactId>ispyb-ws</artifactId>
<packaging>war</packaging>
Expand Down
Loading

0 comments on commit 8f893fb

Please sign in to comment.