use of org.n52.shetland.ogc.sos.response.UpdateSensorResponse in project arctic-sea by 52North.
the class UpdateSensorResponseEncoderTest method should_encode_UpdateSensor_response.
@Test
public void should_encode_UpdateSensor_response() throws EncodingException {
final UpdateSensorResponse response = new UpdateSensorResponse();
final String updatedProcedure = "updatedProcedure";
response.setUpdatedProcedure(updatedProcedure);
final XmlObject encodedResponse = encoder.encode(response);
assertThat(encodedResponse, is(instanceOf(UpdateSensorDescriptionResponseDocument.class)));
final UpdateSensorDescriptionResponseDocument doc = (UpdateSensorDescriptionResponseDocument) encodedResponse;
assertThat(doc.isNil(), is(FALSE));
assertThat(doc.getUpdateSensorDescriptionResponse().getUpdatedProcedure(), is(updatedProcedure));
assertThat(doc.validate(), is(TRUE));
}
use of org.n52.shetland.ogc.sos.response.UpdateSensorResponse in project SOS by 52North.
the class SosUpdateSensorDescriptionOperatorV20 method receive.
@Override
public UpdateSensorResponse receive(UpdateSensorRequest request) throws OwsExceptionReport {
UpdateSensorResponse response = getOperationHandler().updateSensorDescription(request);
getServiceEventBus().submit(new SensorModification(request, response));
return response;
}
use of org.n52.shetland.ogc.sos.response.UpdateSensorResponse in project SOS by 52North.
the class UpdateSensorDescriptionHandler method updateSensorDescription.
@Override
public synchronized UpdateSensorResponse updateSensorDescription(UpdateSensorRequest request) throws OwsExceptionReport {
Session session = null;
Transaction transaction = null;
try {
session = sessionHolder.getSession();
transaction = session.beginTransaction();
UpdateSensorResponse response = new UpdateSensorResponse();
response.setService(request.getService());
response.setVersion(request.getVersion());
for (SosProcedureDescription<?> procedureDescription : request.getProcedureDescriptions()) {
DateTime currentTime = new DateTime(DateTimeZone.UTC);
// TODO: check for all validTimes of descriptions for this
// identifier
// ITime validTime =
// getValidTimeForProcedure(procedureDescription);
ProcedureEntity procedure = daoFactory.getProcedureDAO().getProcedureForIdentifier(request.getProcedureIdentifier(), session);
FormatEntity procedureDescriptionFormat = new DaoFactory().getProcedureDescriptionFormatDAO().getFormatEntityObject(request.getProcedureDescriptionFormat(), session);
Set<ProcedureHistoryEntity> procedureHistories = procedure.getProcedureHistory();
ProcedureHistoryDAO procedureHistroyDAO = daoFactory.getProcedureHistoryDAO();
for (ProcedureHistoryEntity procedureHistroy : procedureHistories) {
if (procedureHistroy.getFormat().getFormat().equals(procedureDescriptionFormat.getFormat()) && procedureHistroy.getEndTime() == null) {
procedureHistroy.setEndTime(currentTime.toDate());
procedureHistroyDAO.update(procedureHistroy, session);
}
}
procedureHistroyDAO.insert(procedure, procedureDescriptionFormat, getSensorDescriptionFromProcedureDescription(procedureDescription), currentTime, session);
}
session.flush();
transaction.commit();
response.setUpdatedProcedure(request.getProcedureIdentifier());
return response;
} catch (HibernateException he) {
if (transaction != null) {
transaction.rollback();
}
throw new NoApplicableCodeException().causedBy(he).withMessage("Error while processing data for UpdateSensorDescription document!");
} finally {
sessionHolder.returnSession(session);
}
}
Aggregations