Author: bleny Date: 2011-05-30 09:07:03 +0000 (Mon, 30 May 2011) New Revision: 1301 Log: more help to user when creating contact for ObsDeb Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-05-27 13:29:43 UTC (rev 1300) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-05-30 09:07:03 UTC (rev 1301) @@ -465,8 +465,11 @@ } else if (obsProgram == ObsProgram.OBSVENTE) { newContact.setContactState(ContactState.OBSERVATION_EXPECTED); } else { - newContact.setContactState(ContactState.OBSERVATION_DONE); - newContact.setObservationType(row.getObservationType()); + if (row.isPhoneCall()) { + newContact.setContactState(ContactState.CONTACT_START); + } else if (row.isFieldWorkObservation()) { + newContact.setContactState(ContactState.OBSERVATION_DONE); + } } ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -490,6 +493,7 @@ // coordinator tells who are the observers. We can hope that the observers // who was on the observation are the one expected if (newContact.getObsProgram() == ObsProgram.OBSDEB) { + newContact.setObservationType(row.getObservationType()); newContact.setObservationBeginDate(row.getExpectedDate()); newContact.setObservationEndDate(row.getExpectedDate()); newContact.setLandingDate(row.getExpectedDate()); @@ -499,6 +503,19 @@ newContact.setSecondaryObservers(expectedObservers); newContact.removeSecondaryObservers(newContact.getMainObserver()); } + + if (row.isFieldWorkObservation()) { + // on the field work, the observer went in the observation unit + // given in the row. If this unit contains only one port, we + // can suppose he went in this one + ServiceReferential serviceReferential = + context.getServiceFactory().getServiceReferential(); + List<TerrestrialLocation> allPorts = + serviceReferential.getAllPorts(row.getObservationUnit()); + if (allPorts.size() == 1) { + newContact.setTerrestrialLocation(allPorts.get(0)); + } + } } if (newContact.getObsProgram() == ObsProgram.OBSVENTE) {