public TrackingConfigurationVo saveTrackinConfig( TrackingConfigurationVo trackingConfigToSave, TrackingAreaVo trackingAreaToSave) throws StaleObjectException { if (trackingConfigToSave == null && trackingAreaToSave == null) throw new CodingRuntimeException( "Cannot save TrackingConfiguration/TrackingArea if null or get TrackingConfiguration/TrackingArea on null ID . "); DomainFactory factory = getDomainFactory(); if (trackingConfigToSave != null) { if (!trackingConfigToSave.isValidated()) throw new CodingRuntimeException("TrackingConfigurationVo not Validated"); TrackingConfiguration trackingConfig = TrackingConfigurationVoAssembler.extractTrackingConfiguration( factory, trackingConfigToSave); factory.save(trackingConfig); return TrackingConfigurationVoAssembler.create(trackingConfig); } else if (trackingAreaToSave != null) { if (!trackingAreaToSave.isValidated()) throw new CodingRuntimeException("TrackingAreaVo not Validated"); TrackingArea trackingArea = TrackingAreaVoAssembler.extractTrackingArea(factory, trackingAreaToSave); factory.save(trackingArea); return null; } return null; }
public TrackingConfigurationVo getTrackingConfig(LocationRefVo locationRef) { if (locationRef == null) throw new CodingRuntimeException( "Can not get TrackingConfiguration value on null locationID."); StringBuffer hql = new StringBuffer(); hql.append("select trackConfig from TrackingConfiguration as trackConfig "); hql.append("where trackConfig.eDLocation.id = :locationID "); DomainFactory factory = getDomainFactory(); List<?> list = factory.find( hql.toString(), new String[] {"locationID"}, new Object[] {locationRef.getID_Location()}); if (list != null && list.size() > 0) { return TrackingConfigurationVoAssembler .createTrackingConfigurationVoCollectionFromTrackingConfiguration(list) .get(0); } return null; }