use of org.n52.series.db.beans.ProcedureHistoryEntity in project SOS by 52North.
the class DescribeSensorDaoImpl method getProcedureDescriptions.
/**
* @param request
* DescribeSensorRequest request
* @param session
* Hibernate session
* @return Matching procedure descriptions
* @throws OwsExceptionReport
* If an error occurs
*/
private List<SosProcedureDescription<?>> getProcedureDescriptions(DescribeSensorRequest request, Session session) throws OwsExceptionReport {
Set<String> possibleProcedureDescriptionFormats = getPossibleProcedureDescriptionFormats(request.getProcedureDescriptionFormat());
final ProcedureEntity procedure = new ProcedureDAO(daoFactory).getProcedureForIdentifier(request.getProcedure(), possibleProcedureDescriptionFormats, request.getValidTime(), session);
List<SosProcedureDescription<?>> list = Lists.newLinkedList();
if (procedure != null) {
if (procedure.hasProcedureHistory()) {
for (ProcedureHistoryEntity validProcedureTime : daoFactory.getProcedureHistoryDAO().get(procedure, possibleProcedureDescriptionFormats, request.getValidTime(), session)) {
SosProcedureDescription<?> sosProcedureDescription = procedureConverter.createSosProcedureDescriptionFromValidProcedureTime(procedure, request.getProcedureDescriptionFormat(), validProcedureTime, request.getVersion(), getRequestedLocale(request), session);
list.add(convertProcedureDescription(sosProcedureDescription, request));
}
}
} else {
SosProcedureDescription<?> procedureDescription = getProcedureDescription(request, session);
if (procedureDescription != null) {
list.add(procedureDescription);
} else {
if (!request.isSetValidTime()) {
throw new NoApplicableCodeException().causedBy(new IllegalArgumentException(LOG_PARAMETER_PROCEDURE_NOT_NULL)).setStatus(HTTPStatus.INTERNAL_SERVER_ERROR);
}
}
}
return list;
}
use of org.n52.series.db.beans.ProcedureHistoryEntity in project SOS by 52North.
the class HibernateObservationBuilder method getValidProcedureTime.
protected ProcedureHistoryEntity getValidProcedureTime() {
ProcedureHistoryEntity validProcedureTime = (ProcedureHistoryEntity) session.createCriteria(ProcedureHistoryEntity.class).add(Restrictions.eq(ProcedureHistoryEntity.PROCEDURE, getProcedure())).uniqueResult();
if (validProcedureTime == null) {
validProcedureTime = new ProcedureHistoryEntity();
validProcedureTime.setXml(XML_TOKEN);
validProcedureTime.setEndTime(null);
validProcedureTime.setStartTime(new Date());
validProcedureTime.setProcedure(getProcedure());
validProcedureTime.setFormat(getProcedureDescriptionFormat());
session.save(validProcedureTime);
session.flush();
}
return validProcedureTime;
}
use of org.n52.series.db.beans.ProcedureHistoryEntity in project SOS by 52North.
the class ProcedureHistoryDAO method setEndTime.
/**
* Set valid end time to valid procedure time object for procedure
* identifier
*
* @param procedureIdentifier
* Procedure identifier
* @param session
* Hibernate session
* @throws UnsupportedOperatorException If an error occurs
* @throws UnsupportedValueReferenceException If an error occurs
* @throws UnsupportedTimeException If an error occurs
*/
public void setEndTime(String procedureIdentifier, String procedureDescriptionFormat, Session session) throws UnsupportedTimeException, UnsupportedValueReferenceException, UnsupportedOperatorException {
ProcedureEntity procedure = new ProcedureDAO(daoFactory).getProcedureForIdentifier(procedureIdentifier, procedureDescriptionFormat, null, session);
Set<ProcedureHistoryEntity> validProcedureTimes = procedure.getProcedureHistory();
for (ProcedureHistoryEntity validProcedureTime : validProcedureTimes) {
if (validProcedureTime.getEndTime() == null) {
validProcedureTime.setEndTime(new DateTime(DateTimeZone.UTC).toDate());
}
}
}
use of org.n52.series.db.beans.ProcedureHistoryEntity in project sensorweb-server-sta by 52North.
the class JSONSensor method handleEncodingType.
protected void handleEncodingType() {
if (encodingType.equalsIgnoreCase(STA_SENSORML_2)) {
self.setFormat(new FormatEntity().setFormat(SENSORML_2));
ProcedureHistoryEntity procedureHistoryEntity = new ProcedureHistoryEntity();
procedureHistoryEntity.setProcedure(self);
procedureHistoryEntity.setFormat(self.getFormat());
procedureHistoryEntity.setStartTime(DateTime.now().toDate());
procedureHistoryEntity.setXml(metadata);
Set<ProcedureHistoryEntity> set = new LinkedHashSet<>();
set.add(procedureHistoryEntity);
self.setProcedureHistory(set);
} else if (encodingType.equalsIgnoreCase(PDF)) {
self.setFormat(new FormatEntity().setFormat(PDF));
self.setDescriptionFile(metadata);
} else {
Assert.notNull(null, INALID_ENCODING_TYPE);
}
}
use of org.n52.series.db.beans.ProcedureHistoryEntity in project SOS by 52North.
the class ProcedureHistoryDAO method insert.
/**
* Insert valid procedure time for procedrue
*
* @param procedure
* Procedure object
* @param xmlDescription
* Procedure XML description
* @param validStartTime
* Valid start time
* @param session
* Hibernate session
* @return The inserted {@link ProcedureHistoryEntity}
*/
public ProcedureHistoryEntity insert(ProcedureEntity procedure, FormatEntity procedureDescriptionFormat, String xmlDescription, DateTime validStartTime, Session session) {
ProcedureHistoryEntity vpd = new ProcedureHistoryEntity();
vpd.setProcedure(procedure);
vpd.setFormat(procedureDescriptionFormat);
vpd.setXml(xmlDescription);
vpd.setStartTime(validStartTime.toDate());
session.save(vpd);
session.flush();
session.refresh(vpd);
return vpd;
}
Aggregations