use of org.n52.series.db.beans.PhenomenonEntity in project SOS by 52North.
the class ObservablePropertyDAO method getObservableProperty.
private PhenomenonEntity getObservableProperty(String identifier, Map<String, PhenomenonEntity> observableProperties, Session session) {
// TODO check if this is still required
if (identifier == null) {
return null;
}
PhenomenonEntity observableProperty = observableProperties.get(identifier);
if (observableProperty != null) {
return observableProperty;
}
observableProperty = getObservablePropertyForIdentifier(identifier, session);
observableProperties.put(identifier, observableProperty);
return observableProperty;
}
use of org.n52.series.db.beans.PhenomenonEntity in project SOS by 52North.
the class ObservablePropertyDAO method getObservableProperties.
/**
* Get observable property objects for observable property identifiers
*
* @param identifiers
* Observable property identifiers
* @param session
* Hibernate session
* @return Observable property objects
*/
@SuppressWarnings("unchecked")
public List<PhenomenonEntity> getObservableProperties(final List<String> identifiers, final Session session) {
Criteria criteria = session.createCriteria(PhenomenonEntity.class).add(Restrictions.in(PhenomenonEntity.IDENTIFIER, identifiers));
LOGGER.trace("QUERY getObservableProperties(identifiers): {}", HibernateHelper.getSqlString(criteria));
return criteria.list();
}
use of org.n52.series.db.beans.PhenomenonEntity in project SOS by 52North.
the class ObservablePropertyDAO method insertNonExisting.
protected void insertNonExisting(AbstractPhenomenon sosObsProp, Map<String, PhenomenonEntity> existing, Session session) throws HibernateException {
if (!existing.containsKey(sosObsProp.getIdentifier())) {
PhenomenonEntity obsProp = new PhenomenonEntity();
addIdentifierNameDescription(sosObsProp, obsProp, session);
session.save(obsProp);
session.flush();
session.refresh(obsProp);
existing.put(obsProp.getIdentifier(), obsProp);
}
if (sosObsProp instanceof OmCompositePhenomenon) {
insertNonExisting(((OmCompositePhenomenon) sosObsProp).getPhenomenonComponents(), existing, session);
}
}
use of org.n52.series.db.beans.PhenomenonEntity in project SOS by 52North.
the class ObservablePropertyDAO method getObservablePropertiesForIdentifiers.
/**
* Get observable properties by identifiers
*
* @param identifiers
* The observable property identifiers
* @param session
* Hibernate session
* @return Observable property objects
*/
@SuppressWarnings("unchecked")
public List<PhenomenonEntity> getObservablePropertiesForIdentifiers(final Collection<String> identifiers, final Session session) {
Criteria criteria = session.createCriteria(PhenomenonEntity.class).add(Restrictions.in(PhenomenonEntity.IDENTIFIER, identifiers));
LOGGER.trace("QUERY getObservablePropertiesForIdentifiers(identifiers): {}", HibernateHelper.getSqlString(criteria));
return (List<PhenomenonEntity>) criteria.list();
}
use of org.n52.series.db.beans.PhenomenonEntity in project SOS by 52North.
the class ObservablePropertyDAO method insertHierachy.
protected void insertHierachy(OmCompositePhenomenon parent, Map<String, PhenomenonEntity> existing, Session session) throws HibernateException {
PhenomenonEntity parentObsProp = getObservableProperty(parent.getIdentifier(), existing, session);
for (OmObservableProperty child : parent) {
PhenomenonEntity childObsProp = getObservableProperty(child.getIdentifier(), existing, session);
childObsProp.addParent(parentObsProp);
session.update(childObsProp);
}
// do not save the parent, as it would result in a duplicate key
// error...
session.flush();
session.refresh(parentObsProp);
}
Aggregations