Commit 2dfb72c0 authored by PECQUOT's avatar PECQUOT
Browse files

git-svn-id: https://scmforge.ifremer.fr/authscm/lp1ee9d/svn/reefdb/trunk@1470 cd918a83-917d-4a2a-92d7-bc1d03929fc5
parent 0cedd247
......@@ -476,23 +476,19 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
}
public boolean isCleanCacheAtStartup() {
boolean result = applicationConfig.getOptionAsBoolean(ReefDbConfigurationOption.CACHE_CLEAN_AT_STARTUP.getKey());
return result;
return applicationConfig.getOptionAsBoolean(ReefDbConfigurationOption.CACHE_CLEAN_AT_STARTUP.getKey());
}
public boolean isHibernateShowSql() {
boolean result = applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_SHOW_SQL.getKey());
return result;
return applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_SHOW_SQL.getKey());
}
public boolean isHibernateUseSqlComment() {
boolean result = applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_USE_SQL_COMMENT.getKey());
return result;
return applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_USE_SQL_COMMENT.getKey());
}
public boolean isHibernateFormatSql() {
boolean result = applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_FORMAT_SQL.getKey());
return result;
return applicationConfig.getOptionAsBoolean(Quadrige2ConfigurationOption.HIBERNATE_FORMAT_SQL.getKey());
}
/**
......@@ -718,9 +714,7 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
}
public KeyStroke getShortCut(String actionName) {
KeyStroke result = applicationConfig.getOptionAsKeyStroke(
"reefdb.ui." + actionName);
return result;
return applicationConfig.getOptionAsKeyStroke("reefdb.ui." + actionName);
}
public String getDateFormat() {
......@@ -943,10 +937,6 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_ELEMENT_CODE_MEASURE_RESULT.getKey());
}
public String getControlElementCodeCounting() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_ELEMENT_CODE_COUNTING.getKey());
}
public String getControlElementCodeSamplingOperation() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_ELEMENT_CODE_SAMPLING_OPERATION.getKey());
}
......@@ -963,16 +953,32 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_COMMENT.getKey());
}
public String getControlFeatureCodeSurveyPositioningComment() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_POSITIONING_COMMENT.getKey());
public String getControlFeatureCodeSurveyValidationComment() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_VALIDATION_COMMENT.getKey());
}
public String getControlFeatureCodeSurveyDate() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_DATE.getKey());
public String getControlFeatureCodeSurveyControlDate() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_CONTROL_DATE.getKey());
}
public String getControlFeatureCodeSurveyUpdateDate() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_UPDATE_DATE.getKey());
}
public String getControlFeatureCodeSurveyValidationDate() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_VALIDATION_DATE.getKey());
}
public String getControlFeatureCodeSurveyDepartment() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_DEPARTMENT.getKey());
}
public String getControlFeatureCodeSurveyPositioningPrecision() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_POSITIONING_PRECISION.getKey());
}
public String getControlFeatureCodeSurveyFieldObservation() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_FIELD_OBSERVATION.getKey());
public String getControlFeatureCodeSurveyDate() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_DATE.getKey());
}
public String getControlFeatureCodeSurveyTime() {
......@@ -1023,18 +1029,6 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_PRECISION_DEPTH.getKey());
}
public String getControlFeatureCodeSurveyOccasion() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_OCCASION.getKey());
}
public String getControlFeatureCodeSurveyUnit() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_UNIT.getKey());
}
// public String getControlFeatureCodeSurveyDragZone() {
// return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SURVEY_DRAG_ZONE.getKey());
// }
public String getControlFeatureCodeSamplingOperationComment() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_COMMENT.getKey());
}
......@@ -1059,46 +1053,30 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_DEPTH_MAX.getKey());
}
public String getControlFeatureCodeSamplingOperationLatitudeMax() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_LATITUDE_MAX.getKey());
}
public String getControlFeatureCodeSamplingOperationLatitudeMin() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_LATITUDE_MIN.getKey());
}
public String getControlFeatureCodeSamplingOperationLongitudeMax() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_LONGITUDE_MAX.getKey());
}
public String getControlFeatureCodeSamplingOperationLongitudeMin() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_LONGITUDE_MIN.getKey());
}
public String getControlFeatureCodeSamplingOperationPositioning() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_POSITIONNING.getKey());
}
public String getControlFeatureCodeSamplingOperationName() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_NAME.getKey());
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_POSITIONING.getKey());
}
public String getControlFeatureCodeSamplingOperationDepthLevel() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_DEPTH_LEVEL.getKey());
public String getControlFeatureCodeSamplingOperationPositioningPrecision() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_POSITIONING_PRECISION.getKey());
}
public String getControlFeatureCodeSamplingOperationIndividualCount() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_INDIVIDUAL_COUNT.getKey());
public String getControlFeatureCodeSamplingOperationName() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_NAME.getKey());
}
public String getControlFeatureCodeSamplingOperationDepartment() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_DEPARTMENT.getKey());
}
public String getControlFeatureCodeSamplingOperationProgram() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_PROGRAM.getKey());
}
public String getControlFeatureCodeSamplingOperationSize() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_SAMPLING_OPERATION_SIZE.getKey());
}
......@@ -1111,40 +1089,16 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_ANALYST.getKey());
}
public String getControlFeatureCodeMeasureResultAnalysisInstrument() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_ANALYSIS_INSTRUMENT.getKey());
public String getControlFeatureCodeMeasureResultTaxonGroup() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_TAXON_GROUP.getKey());
}
public String getControlFeatureCodeMeasureResultFraction() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_FRACTION.getKey());
public String getControlFeatureCodeMeasureResultTaxon() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_TAXON.getKey());
}
public String getControlFeatureCodeMeasureResultMethod() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_METHOD.getKey());
}
public String getControlFeatureCodeMeasureResultIndividualNumber() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_INDIVIDUAL_NUMBER.getKey());
}
public String getControlFeatureCodeMeasureResultParameter() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_PARAMETER.getKey());
}
public String getControlFeatureCodeMeasureResultPrecision() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_PRECISION.getKey());
}
public String getControlFeatureCodeMeasureResultSupport() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_SUPPORT.getKey());
}
public String getControlFeatureCodeMeasureResultUncertaintyUnit() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_UNCERTAINTY_UNIT.getKey());
}
public String getControlFeatureCodeMeasureResultUncertaintyValue() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_UNCERTAINTY_VALUE.getKey());
public String getControlFeatureCodeMeasureResultPmfm() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_PMFM.getKey());
}
public String getControlFeatureCodeMeasureResultNumericalValue() {
......@@ -1155,62 +1109,6 @@ public final class ReefDbConfiguration extends ApplicationConfiguration implemen
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_MEASURE_RESULT_QUALITATIVE_VALUE.getKey());
}
public String getControlFeatureCodeCountingAnalyst() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_ANALYST.getKey());
}
public String getControlFeatureCodeCountingAnalysisInstrument() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_ANALYSIS_INSTRUMENT.getKey());
}
public String getControlFeatureCodeCountingFraction() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_FRACTION.getKey());
}
public String getControlFeatureCodeCountingMethod() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_METHOD.getKey());
}
public String getControlFeatureCodeCountingIndividualNumber() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_INDIVIDUAL_NUMBER.getKey());
}
public String getControlFeatureCodeCountingParameter() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_PARAMETER.getKey());
}
public String getControlFeatureCodeCountingPrecision() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_PRECISION.getKey());
}
public String getControlFeatureCodeCountingSupport() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_SUPPORT.getKey());
}
public String getControlFeatureCodeCountingUncertaintyUnit() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_UNCERTAINTY_UNIT.getKey());
}
public String getControlFeatureCodeCountingUncertaintyValue() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_UNCERTAINTY_VALUE.getKey());
}
public String getControlFeatureCodeCountingNumericalValue() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_NUMERICAL_VALUE.getKey());
}
public String getControlFeatureCodeCountingQualitativeValue() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_QUALITATIVE_VALUE.getKey());
}
public String getControlFeatureCodeCountingTaxonGroup() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_TAXON_GROUP.getKey());
}
public String getControlFeatureCodeCountingTaxon() {
return applicationConfig.getOption(ReefDbConfigurationOption.CONTROL_FEATURE_COUNTING_TAXON.getKey());
}
public int getFunctionIdEmpty() {
return applicationConfig.getOptionAsInt(ReefDbConfigurationOption.FUNCTION_ID_EMPTY.getKey());
}
......
......@@ -287,6 +287,7 @@ public class ReefDbMeasurementDaoImpl extends MeasurementDaoImpl implements Reef
// Survey
target.setSurvey(load(SurveyImpl.class, survey.getSurveyId()));
target.setSamplingOperation(null);
if (CollectionUtils.isNotEmpty(survey.getPrograms())) {
for (Program program : survey.getPrograms()) {
......@@ -339,6 +340,7 @@ public class ReefDbMeasurementDaoImpl extends MeasurementDaoImpl implements Reef
// Survey
target.setSurvey(load(SurveyImpl.class, survey.getSurveyId()));
target.setSamplingOperation(null);
if (CollectionUtils.isNotEmpty(survey.getPrograms())) {
for (Program program : survey.getPrograms()) {
......@@ -400,6 +402,8 @@ public class ReefDbMeasurementDaoImpl extends MeasurementDaoImpl implements Reef
target = get(measurement.getId());
}
// TODO : throw exception or create a new measurement if target == null ?
target.setObjectType(load(ObjectTypeImpl.class, Daos.SAMPLING_OPERATION_OBJECT_TYPE));
target.setObjectId(samplingOperation.getSamplingOperId());
......@@ -407,7 +411,7 @@ public class ReefDbMeasurementDaoImpl extends MeasurementDaoImpl implements Reef
target.setSamplingOperation(load(SamplingOperationImpl.class, samplingOperation.getSamplingOperId()));
// Survey
target.setSurvey(load(SurveyImpl.class, samplingOperation.getSurvey().getSurveyId()));
target.setSurvey(null);
if (CollectionUtils.isNotEmpty(samplingOperation.getPrograms())) {
for (Program program : samplingOperation.getPrograms()) {
......@@ -463,7 +467,7 @@ public class ReefDbMeasurementDaoImpl extends MeasurementDaoImpl implements Reef
target.setSamplingOperation(load(SamplingOperationImpl.class, samplingOperation.getSamplingOperId()));
// Survey
target.setSurvey(load(SurveyImpl.class, samplingOperation.getSurvey().getSurveyId()));
target.setSurvey(null);
if (CollectionUtils.isNotEmpty(samplingOperation.getPrograms())) {
for (Program program : samplingOperation.getPrograms()) {
......
......@@ -135,6 +135,9 @@ public class ReefDbSamplingOperationDaoImpl extends SamplingOperationDaoImpl imp
allMeasurements.addAll(samplingOperation.getMeasurements());
allMeasurements.addAll(samplingOperation.getIndividualMeasurements());
measurementDao.saveMeasurementsBySamplingOperationId(samplingOperation.getId(), allMeasurements);
getSession().flush();
getSession().clear();
}
}
......@@ -231,7 +234,7 @@ public class ReefDbSamplingOperationDaoImpl extends SamplingOperationDaoImpl imp
Integer posSystemId = (Integer) it.next();
if (posSystemId != null) {
result.setPositioning(referentialDao.getPositionningSystemById(posSystemId));
result.setPositioning(referentialDao.getPositioningSystemById(posSystemId));
}
result.setSamplingCoordinate(GeometryUtils.getCoordinate((String) it.next()));
......
......@@ -432,7 +432,7 @@ public class ReefDbSurveyDaoImpl extends SurveyDaoImpl implements ReefDbSurveyDa
// positionning system
Integer positioningSystemId = (Integer) source.next();
if (positioningSystemId != null) {
result.setPositioningSystem(referentialDao.getPositionningSystemById(positioningSystemId));
result.setPositioningSystem(referentialDao.getPositioningSystemById(positioningSystemId));
}
result.setPositioningComment((String) source.next());
......
......@@ -35,7 +35,7 @@ public interface ReefDbReferentialDao {
String DEPTH_VALUE_BY_ID_CACHE = "depthValueById";
String UNIT_BY_ID_CACHE = "unitById";
String ANALYSIS_INSTRUMENT_BY_ID_CACHE = "analysisInstrumentById";
String POSITIONNING_SYSTEM_BY_ID = "positionningSystemById";
String POSITIONING_SYSTEM_BY_ID = "positioningSystemById";
String QUALITY_FLAG_BY_CODE = "qualityFlagByCode";
@Cacheable(value = "allSamplingEquipments")
......@@ -100,11 +100,11 @@ public interface ReefDbReferentialDao {
@Cacheable(value = QUALITY_FLAG_BY_CODE)
QualityLevelDTO getQualityFlagByCode(String qualityFlagCode);
@Cacheable(value = "allPositionningSystems")
List<PositioningSystemDTO> getAllPositionningSystems();
@Cacheable(value = "allPositioningSystems")
List<PositioningSystemDTO> getAllPositioningSystems();
@Cacheable(value = POSITIONNING_SYSTEM_BY_ID)
PositioningSystemDTO getPositionningSystemById(int posSystemId);
@Cacheable(value = POSITIONING_SYSTEM_BY_ID)
PositioningSystemDTO getPositioningSystemById(int posSystemId);
@Cacheable(value = "allGroupingTypes")
List<GroupingTypeDTO> getAllGroupingTypes();
......
......@@ -434,9 +434,9 @@ public class ReefDbReferentialDaoImpl extends HibernateDaoSupport implements Ree
}
@Override
public List<PositioningSystemDTO> getAllPositionningSystems() {
public List<PositioningSystemDTO> getAllPositioningSystems() {
Cache cacheById = cacheService.getCache(POSITIONNING_SYSTEM_BY_ID);
Cache cacheById = cacheService.getCache(POSITIONING_SYSTEM_BY_ID);
Iterator<Object[]> it = queryIterator("allPositioningSystems");
......@@ -453,7 +453,7 @@ public class ReefDbReferentialDaoImpl extends HibernateDaoSupport implements Ree
}
@Override
public PositioningSystemDTO getPositionningSystemById(int posSystemId) {
public PositioningSystemDTO getPositioningSystemById(int posSystemId) {
Object[] source = queryUnique("positioningSystemById", "posSystemId", IntegerType.INSTANCE, posSystemId);
if (source == null) {
......
......@@ -236,7 +236,7 @@ public class ReefDbMonitoringLocationDaoImpl extends MonitoringLocationDaoImpl i
result.setDayLightSavingTime(Daos.convertToBoolean(source.next()));
result.setHarbourCode((String) source.next());
result.setStatus(Daos.getStatus((String) source.next()));
result.setPositioning(referentialDao.getPositionningSystemById((Integer) source.next()));
result.setPositioning(referentialDao.getPositioningSystemById((Integer) source.next()));
result.setCoordinate(GeometryUtils.getCoordinate((String) source.next()));
return result;
}
......
......@@ -70,7 +70,10 @@ public interface ReefDbRuleListDao {
* @param type
* @param controlDate
*/
void updateControlDate(Collection<Integer> controledElementsPks, ControlElementValues type, Date controlDate);
void updateSurveysControlDate(Collection<Integer> controledElementsPks, Date controlDate);
void updateSamplingOperationsControlDate(Collection<Integer> controledElementsPks, Date controlDate);
void updateMeasurementsControlDate(Collection<Integer> controledElementsPks, Date controlDate);
void updateTaxonMeasurementsControlDate(Collection<Integer> controledElementsPks, Date controlDate);
}
......@@ -33,8 +33,6 @@ import fr.ifremer.quadrige2.core.dao.referential.pmfm.*;
import fr.ifremer.quadrige2.core.dao.system.rule.*;
import fr.ifremer.quadrige2.core.dao.technical.Daos;
import fr.ifremer.reefdb.config.ReefDbConfiguration;
import fr.ifremer.reefdb.dao.administration.program.ReefDbProgramDao;
import fr.ifremer.reefdb.dao.referential.ReefDbReferentialDao;
import fr.ifremer.reefdb.dao.referential.pmfm.ReefDbPmfmDao;
import fr.ifremer.reefdb.dto.ReefDbBeanFactory;
import fr.ifremer.reefdb.dto.ReefDbBeans;
......@@ -46,11 +44,11 @@ import fr.ifremer.reefdb.dto.enums.*;
import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
import fr.ifremer.reefdb.dto.system.FunctionDTO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.type.DateType;
import org.hibernate.type.IntegerType;
......@@ -81,13 +79,6 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
@Resource(name = "reefDbPmfmDao")
protected ReefDbPmfmDao pmfmDao;
@Resource(name = "reefDbReferentialDao")
protected ReefDbReferentialDao referentialDao;
@Resource(name = "reefDbProgramDao")
protected ReefDbProgramDao programDao;
// TODO to init from configuration
private int functionIdMinMax;
private int functionIdIn;
private int functionIdEmpty;
......@@ -158,9 +149,7 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
throw new DataRetrievalFailureException("can't load rule list with code = " + ruleListCode);
}
RuleListDTO result = toRuleListDTO(Arrays.asList(source).iterator());
return result;
return toRuleListDTO(Arrays.asList(source).iterator());
}
@Override
......@@ -295,32 +284,35 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
deleteControlRules(ruleCodes);
}
List<String> ruleListCodes = ReefDbBeans.collectProperties(ruleLists, "code");
Query q = createQuery("deleteRuleListsByCodes").setParameterList("ruleListCodes", ReefDbBeans.getListWithoutNull(ruleListCodes));
q.executeUpdate();
createQuery("deleteRuleListsByCodes").setParameterList("ruleListCodes", ReefDbBeans.getListWithoutNull(ruleListCodes)).executeUpdate();
}
@Override
public void updateControlDate(Collection<Integer> controledElementsPks, ControlElementValues type, Date controlDate) {
Query q = null;
switch(type) {
case SURVEY :
q = createQuery("updateSurveyControlDate").setParameterList("surveyIds", controledElementsPks);
break;
case SAMPLING_OPERATION :
q = createQuery("updateSamplingOperationControlDate").setParameterList("operationIds", controledElementsPks);
break;
case MEASURE_RESULT :
q = createQuery("updateMeasurementControlDate").setParameterList("measurementIds", controledElementsPks);
break;
case COUNTING :
q = createQuery("updateTaxonMeasurementControlDate").setParameterList("taxonMeasurementIds", controledElementsPks);
break;
}
if (q != null) {
q.setParameter("controlDate", controlDate);
q.executeUpdate();
}
public void updateSurveysControlDate(Collection<Integer> controledElementsPks, Date controlDate) {
createQuery("updateSurveyControlDate")
.setParameterList("surveyIds", controledElementsPks)
.setParameter("controlDate", controlDate).executeUpdate();
}
@Override
public void updateSamplingOperationsControlDate(Collection<Integer> controledElementsPks, Date controlDate) {
createQuery("updateSamplingOperationControlDate")
.setParameterList("operationIds", controledElementsPks)
.setParameter("controlDate", controlDate).executeUpdate();
}
@Override
public void updateMeasurementsControlDate(Collection<Integer> controledElementsPks, Date controlDate) {
createQuery("updateMeasurementControlDate")
.setParameterList("measurementIds", controledElementsPks)
.setParameter("controlDate", controlDate).executeUpdate();
}
@Override
public void updateTaxonMeasurementsControlDate(Collection<Integer> controledElementsPks, Date controlDate) {
createQuery("updateTaxonMeasurementControlDate")
.setParameterList("taxonMeasurementIds", controledElementsPks)
.setParameter("controlDate", controlDate).executeUpdate();
}
// INTERNAL METHODS
......@@ -393,9 +385,6 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
case MEASURE_RESULT:
controlFeature = ControlFeatureMeasureResultValues.toControlFeatureDTO(controlFeatureCode);
break;
case COUNTING:
controlFeature = ControlFeatureCountingValues.toControlFeatureDTO(controlFeatureCode);
break;
case SAMPLING_OPERATION:
controlFeature = ControlFeatureSamplingOperationValues.toControlFeatureDTO(controlFeatureCode);
break;
......@@ -544,7 +533,6 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
for (ControlRuleDTO rule : beanRules) {
Rule ruleEntity = null;
boolean isNewRule = false;
if (rulesByCode.containsKey(rule.getCode())) {
ruleEntity = rulesByCode.remove(rule.getCode());
......@@ -562,16 +550,21 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
}
deleteControlRules(rulesByCode.keySet());
}
return target;
}
private void beanToChildRuleEntity(ControlRuleDTO source, Rule target, RuleList targetRuleList) {
Function function = null;
Function function;
if (source.getFunction() != null) {
function = getFunctionById(source.getFunction().getId());
} else {
throw new DataRetrievalFailureException("ControlRuleDTO object has no Function");
}
if (function == null) {
throw new DataRetrievalFailureException(String.format("function not found with id=%s", source.getFunction().getId()));
}
boolean isNewRule = false;
......@@ -770,12 +763,24 @@ public class ReefDbRuleListDaoImpl extends RuleListDaoImpl implements ReefDbRule
private FunctionParameter getFunctionParameterById(Integer functionParameterId) {
return (FunctionParameter) getSession().get(FunctionParameterImpl.class, functionParameterId);
}
private void deleteControlRules(Collection<String> ruleCodes) {
Query q = createQuery("deleteRulesByCodes").setParameterList("ruleCodes", ReefDbBeans.getListWithoutNull(ruleCodes));
q.executeUpdate();
List<String> codes = ReefDbBeans.getListWithoutNull(ruleCodes);