diff --git a/arc-core/src/main/java/fr/insee/arc/core/dataobjects/ViewEnum.java b/arc-core/src/main/java/fr/insee/arc/core/dataobjects/ViewEnum.java index c78b33374..aea763857 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/dataobjects/ViewEnum.java +++ b/arc-core/src/main/java/fr/insee/arc/core/dataobjects/ViewEnum.java @@ -11,7 +11,7 @@ public enum ViewEnum { , VIEW_MODULE("view_module",false,ColumnEnum.MODULE_ORDER,ColumnEnum.MODULE_NAME) - , IHM_CHARGEMENT_REGLE("ihm_chargement_regle", false, ColumnEnum.ID_REGLE, ColumnEnum.ID_NORME, ColumnEnum.VALIDITE_INF, ColumnEnum.VALIDITE_SUP, ColumnEnum.VERSION, ColumnEnum.PERIODICITE, ColumnEnum.TYPE_FICHIER, ColumnEnum.DELIMITER, ColumnEnum.FORMAT, ColumnEnum.COMMENTAIRE) + , IHM_CHARGEMENT_REGLE("ihm_chargement_regle", false, ColumnEnum.ID_NORME, ColumnEnum.PERIODICITE, ColumnEnum.VALIDITE_INF, ColumnEnum.VALIDITE_SUP, ColumnEnum.VERSION, ColumnEnum.ID_REGLE, ColumnEnum.TYPE_FICHIER, ColumnEnum.DELIMITER, ColumnEnum.FORMAT, ColumnEnum.COMMENTAIRE) , IHM_NORMAGE_REGLE("ihm_normage_regle", false, ColumnEnum.ID_NORME, ColumnEnum.PERIODICITE, ColumnEnum.VALIDITE_INF, ColumnEnum.VALIDITE_SUP, ColumnEnum.VERSION, ColumnEnum.ID_CLASSE, ColumnEnum.RUBRIQUE, ColumnEnum.RUBRIQUE_NMCL, ColumnEnum.ID_REGLE, ColumnEnum.TODO, ColumnEnum.COMMENTAIRE) , IHM_CONTROLE_REGLE("ihm_controle_regle", false, ColumnEnum.ID_NORME, ColumnEnum.PERIODICITE, ColumnEnum.VALIDITE_INF, ColumnEnum.VALIDITE_SUP, ColumnEnum.VERSION, ColumnEnum.ID_CLASSE, ColumnEnum.RUBRIQUE_PERE, ColumnEnum.RUBRIQUE_FILS, ColumnEnum.BORNE_INF, ColumnEnum.BORNE_SUP, ColumnEnum.CONDITION, ColumnEnum.PRE_ACTION, ColumnEnum.ID_REGLE, ColumnEnum.TODO, ColumnEnum.COMMENTAIRE, ColumnEnum.XSD_ORDRE, ColumnEnum.XSD_LABEL_FILS, ColumnEnum.XSD_ROLE, ColumnEnum.BLOCKING_THRESHOLD, ColumnEnum.ERROR_ROW_PROCESSING) , IHM_FILTRAGE_REGLE("ihm_filtrage_regle", false) diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java index 23fe383fd..03cc98e37 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java @@ -177,5 +177,35 @@ private ArcPreparedStatementBuilder moduleQuery(int moduleIndex, GuiModules modu return query; } + + + public void initializeViewChargement(VObject viewChargement) { + + ViewEnum dataModelChargement = ViewEnum.IHM_CHARGEMENT_REGLE; + + ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); + + query.append(SQL.SELECT); + query.append(query.sqlListeOfColumnsFromModel(dataModelChargement)); + query.append(SQL.FROM); + query.append(dataObjectService.getView(dataModelChargement)); + query.append(SQL.WHERE); + query.append(sqlEqualWithFirstSelectedRecord(ColumnEnum.ID_NORME)); + query.append(SQL.AND); + query.append(sqlEqualWithFirstSelectedRecord(ColumnEnum.PERIODICITE)); + query.append(SQL.AND); + query.append(sqlEqualWithFirstSelectedRecord(ColumnEnum.VALIDITE_INF)); + query.append(SQL.AND); + query.append(sqlEqualWithFirstSelectedRecord(ColumnEnum.VALIDITE_SUP)); + query.append(SQL.AND); + query.append(sqlEqualWithFirstSelectedRecord(ColumnEnum.VERSION)); + + // build the default value when adding a record + HashMap defaultInputFields = buildDefaultInputFieldsWithFirstSelectedRecord(ColumnEnum.ID_NORME, + ColumnEnum.PERIODICITE, ColumnEnum.VALIDITE_INF, ColumnEnum.VALIDITE_SUP, ColumnEnum.VERSION); + + vObjectService.initialize(viewChargement, query, dataObjectService.getView(dataModelChargement), defaultInputFields); + + } } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java index a649482f8..9942f30f0 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java @@ -187,25 +187,23 @@ public void initializeViewModules(VObject viewModules, VObject viewRulesSet) { * Initialize the {@link VObject} of a load ruleset. Only * get the load rule link to the selected rule set. */ - public void initializeChargement(VObject moduleView, VObject viewRulesSet, VObject viewModules, String theTableName) { - Map> selection = viewRulesSet.mapContentSelected(); + public void initializeChargement(VObject viewChargement, VObject viewRulesSet, VObject viewModules, String theTableName) { + + + Map> viewRulesSetSelectedRecords = viewRulesSet.mapContentSelected(); ArrayList> moduleSelection =viewModules.listContentSelected(); - if (!selection.isEmpty() && !moduleSelection.isEmpty() + if (!viewRulesSetSelectedRecords.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.load))) { - HashMap type = viewRulesSet.mapHeadersType(); - ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); - requete.append("select id_norme,periodicite,validite_inf,validite_sup,version,id_regle,type_fichier, delimiter, format, commentaire from arc.ihm_chargement_regle"); - whereRuleSetEquals(requete, selection, type); - - vObjectService.initialize(moduleView, requete, theTableName, defaultRuleInputFields(selection)); + dao.setSelectedRecords(viewRulesSetSelectedRecords); + dao.initializeViewChargement(viewChargement); + } else { - vObjectService.destroy(moduleView); + vObjectService.destroy(viewChargement); } } - /** * Initialize the {@link VObject} of a load ruleset. Only * get the load rule link to the selected rule set. diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNormage.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNormage.java index 1a4ff47be..2ec93b78d 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNormage.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNormage.java @@ -38,7 +38,7 @@ public String selectNormage(Model model) { * @return success */ public String addNormage(Model model) { - return addLineVobject(model, RESULT_SUCCESS, this.views.getViewMapping()); + return addLineVobject(model, RESULT_SUCCESS, this.views.getViewNormage()); } /** @@ -48,7 +48,7 @@ public String addNormage(Model model) { * @return */ public String deleteNormage(Model model) { - return deleteLineVobject(model, RESULT_SUCCESS, this.views.getViewMapping()); + return deleteLineVobject(model, RESULT_SUCCESS, this.views.getViewNormage()); } /** @@ -58,7 +58,7 @@ public String deleteNormage(Model model) { * @return */ public String updateNormage(Model model) { - return updateVobject(model, RESULT_SUCCESS, this.views.getViewMapping()); + return updateVobject(model, RESULT_SUCCESS, this.views.getViewNormage()); } /** @@ -68,7 +68,7 @@ public String updateNormage(Model model) { */ public String sortNormage(Model model) { - return sortVobject(model, RESULT_SUCCESS, this.views.getViewMapping()); + return sortVobject(model, RESULT_SUCCESS, this.views.getViewNormage()); } /**