[Stacomir-commits] r400 - in pkg/stacomir: R inst/config inst/tests/testthat man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jun 18 20:36:43 CEST 2017
Author: briand
Date: 2017-06-18 20:36:42 +0200 (Sun, 18 Jun 2017)
New Revision: 400
Added:
pkg/stacomir/R/Ref_year.R
pkg/stacomir/inst/config/stacomi_checks.R
pkg/stacomir/inst/tests/testthat/test-09BilanAnnuels.R
pkg/stacomir/inst/tests/testthat/test-13BilanEspeces.R
Removed:
pkg/stacomir/R/RefAnnee.r
pkg/stacomir/inst/tests/testthat/test-09Bilan_MigrationAnnuelle.R
pkg/stacomir/inst/tests/testthat/test-14BilanEspeces.R
Modified:
pkg/stacomir/R/BilanAnnuels.r
pkg/stacomir/R/BilanEspeces.r
pkg/stacomir/R/BilanMigrationInterAnnuelle.r
pkg/stacomir/R/BilanMigrationMult.r
pkg/stacomir/R/Bilan_carlot.r
pkg/stacomir/R/Bilan_poids_moyen.r
pkg/stacomir/R/interface_BilanAnnuels.r
pkg/stacomir/R/interface_BilanMigrationInterannuelle.r
pkg/stacomir/R/interface_bilan_poids_moyen.r
pkg/stacomir/R/setAs.r
pkg/stacomir/R/stacomi.r
pkg/stacomir/R/utilitaires.r
pkg/stacomir/inst/config/generate_Roxygen2.R
pkg/stacomir/inst/config/generate_data.R
pkg/stacomir/inst/config/stacomi_manual_launch.r
pkg/stacomir/inst/config/testthat.R
pkg/stacomir/inst/tests/testthat/test-00stacomir.R
pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R
pkg/stacomir/inst/tests/testthat/test-06Bilan_MigrationInterAnnuelle.R
pkg/stacomir/inst/tests/testthat/test-13BilanAnnuels.R
pkg/stacomir/man/BilanAnnuels-class.Rd
pkg/stacomir/man/BilanEspeces-class.Rd
pkg/stacomir/man/BilanMigrationInterAnnuelle-class.Rd
pkg/stacomir/man/Bilan_poids_moyen-class.Rd
pkg/stacomir/man/RefAnnee-class.Rd
pkg/stacomir/man/RefCheckBox-class.Rd
pkg/stacomir/man/RefChoix-class.Rd
pkg/stacomir/man/RefCoe-class.Rd
pkg/stacomir/man/RefDC-class.Rd
pkg/stacomir/man/RefDF-class.Rd
pkg/stacomir/man/RefHorodate-class.Rd
pkg/stacomir/man/RefListe-class.Rd
pkg/stacomir/man/RefStades-class.Rd
pkg/stacomir/man/RefTaxon-class.Rd
pkg/stacomir/man/Refpar-class.Rd
pkg/stacomir/man/Refparqual-class.Rd
pkg/stacomir/man/Refparquan-class.Rd
pkg/stacomir/man/Refperiode-class.Rd
pkg/stacomir/man/charge-RefAnnee-method.Rd
pkg/stacomir/man/charge-RefChoix-method.Rd
pkg/stacomir/man/choice-RefAnnee-method.Rd
pkg/stacomir/man/choice_c-BilanAnnuels-method.Rd
pkg/stacomir/man/choice_c-BilanMigrationInterAnnuelle-method.Rd
pkg/stacomir/man/choice_c-Bilan_poids_moyen-method.Rd
pkg/stacomir/man/choice_c-RefAnnee-method.Rd
pkg/stacomir/man/validite_Annee.Rd
Log:
Modified: pkg/stacomir/R/BilanAnnuels.r
===================================================================
--- pkg/stacomir/R/BilanAnnuels.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/BilanAnnuels.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -4,14 +4,14 @@
#' @include RefDC.r
#' @include RefTaxon.r
#' @include RefStades.r
-#' @include RefAnnee.r
+#' @include Ref_year.r
#' @slot dc Object of class \code{\link{RefDC-class}}, the counting device, multiple values allowed
#' @slot data Object of class \code{"data.frame"} data for bilan lot
#' @slot taxons An object of class \code{\link{RefTaxon-class}}, multiple values allowed
#' @slot stades An object of class \code{\link{RefStades-class}}, multiple values allowed
-#' @slot anneedebut Object of class \code{\link{RefAnnee-class}}. RefAnnee allows to choose year of beginning
-#' @slot anneefin Object of class \code{\link{RefAnnee-class}}
-#' RefAnnee allows to choose last year of the Bilan
+#' @slot anneedebut Object of class \code{\link{Ref_year-class}}. Ref_year allows to choose year of beginning
+#' @slot anneefin Object of class \code{\link{Ref_year-class}}
+#' Ref_year allows to choose last year of the Bilan
#' @aliases calcule.BilanAnnuels calcule.bilanannuels
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @family Bilan Objects
@@ -24,15 +24,15 @@
taxons="RefTaxon",
stades="RefStades",
data="data.frame",
- anneedebut="RefAnnee",
- anneefin="RefAnnee"
+ anneedebut="Ref_year",
+ anneefin="Ref_year"
),
prototype=prototype(dc=new("RefDC"),
taxons=new("RefTaxon"),
stades=new("RefStades"),
data=data.frame(),
- anneedebut=new("RefAnnee"),
- anneefin=new("RefAnnee")
+ anneedebut=new("Ref_year"),
+ anneefin=new("Ref_year")
)
)
@@ -188,7 +188,7 @@
#' @param anneefin the finishing year
#' @param silent Boolean, if TRUE, information messages are not displayed
#' @return An object of class \link{BilanAnnuels-class}
-#' The choice_c method fills in the data slot for classes \link{RefDC-class}, \link{RefTaxon-class}, \link{RefStades-class} and two slots of \link{RefAnnee-class}
+#' The choice_c method fills in the data slot for classes \link{RefDC-class}, \link{RefTaxon-class}, \link{RefStades-class} and two slots of \link{Ref_year-class}
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
setMethod("choice_c",signature=signature("BilanAnnuels"),definition=function(object,
Modified: pkg/stacomir/R/BilanEspeces.r
===================================================================
--- pkg/stacomir/R/BilanEspeces.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/BilanEspeces.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -10,8 +10,8 @@
#' e.g years. The plot method writes either an histogram or a pie chart of number per
#' year/week/month.
#' @slot dc an object of class \link{RefDC-class}
-#' @slot anneedebut Object of class \code{\link{RefAnnee-class}}
-#' @slot anneefin Object of class \code{\link{RefAnnee-class}}
+#' @slot anneedebut Object of class \code{\link{Ref_year-class}}
+#' @slot anneefin Object of class \code{\link{Ref_year-class}}
#' @slot data \code{data.frame}
#' @slot calcdata \code{data.frame} with data processed by the calc method
#' @slot split Object of class \code{\link{RefListe-class}} RefListe referential class choose within a list
@@ -25,14 +25,14 @@
setClass(Class="BilanEspeces",
representation=
representation(dc="RefDC",
- anneedebut="RefAnnee",
- anneefin="RefAnnee",
+ anneedebut="Ref_year",
+ anneefin="Ref_year",
data="data.frame",
calcdata="data.frame",
split="RefListe"),
prototype=prototype(dc=new("RefDC"),
- anneedebut=new("RefAnnee"),
- anneefin=new("RefAnnee"),
+ anneedebut=new("Ref_year"),
+ anneefin=new("Ref_year"),
data=data.frame(),
calcdata=data.frame(),
split=new("RefListe")
@@ -321,10 +321,12 @@
setMethod("summary",signature=signature(object="BilanEspeces"),definition=function(object,silent=FALSE){
bilesp<-object
if (nrow(bilesp at calcdata)==0) stop("No data in the calcdata slot, did you forget to run calculations ?")
- str_c(str_c(bilesp at dc@dc_selectionne,collapse="+"),
+ loc<-str_c(str_c(bilesp at dc@dc_selectionne,collapse="+"),
bilesp at anneedebut@annee_selectionnee,
bilesp at anneefin@annee_selectionnee,sep="_")
- path=file.path(normalizePath(path.expand(get("datawd",envir=envir_stacomi))),paste("tableEspece",dc,".csv",sep=""),fsep ="\\")
+
+ path=file.path(normalizePath(path.expand(get("datawd",envir=envir_stacomi))),
+ paste("tableEspece",loc,".csv",sep=""),fsep ="\\")
write.table(bilesp at calcdata,path,row.names=TRUE,col.names=TRUE,sep=";",append=FALSE)
if (!silent){
funout(gettextf("writing of %s \n",path))
Modified: pkg/stacomir/R/BilanMigrationInterAnnuelle.r
===================================================================
--- pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -11,14 +11,14 @@
#' period grouping. See \link{write_database,BilanMigration-method} for details about how
#' this method inserts data in the t_bilanjournalier_bjo table.
#'
-#' @include RefAnnee.r
+#' @include Ref_year.r
#' @slot dc An object of class \link{RefDC-class}, the counting device
#' @slot data A \code{data.frame} data loaded from the daily migration table t_bilanmigrationjournalier_bjo
#' @slot taxons An object of class \link{RefTaxon-class}
#' @slot stades An object of class \link{RefStades-class}
-#' @slot anneeDebut An object of class \link{RefAnnee-class}. refAnnee allows to choose year of beginning
-#' @slot anneeFin An object of class \link{RefAnnee-class}
-#' refAnnee allows to choose last year of the Bilan
+#' @slot anneeDebut An object of class \link{Ref_year-class}. ref_year allows to choose year of beginning
+#' @slot anneeFin An object of class \link{Ref_year-class}
+#' ref_year allows to choose last year of the Bilan
#' @slot calcdata A \code{list} of calculated data, filled in by the calcule method
#'
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
@@ -32,16 +32,16 @@
taxons="RefTaxon",
stades="RefStades",
data="data.frame",
- anneeDebut="RefAnnee",
- anneeFin="RefAnnee",
+ anneeDebut="Ref_year",
+ anneeFin="Ref_year",
calcdata="list"
),
prototype=prototype(dc=new("RefDC"),
taxons=new("RefTaxon"),
stades=new("RefStades"),
data=data.frame(),
- anneeDebut=new("RefAnnee"),
- anneeFin=new("RefAnnee"),
+ anneeDebut=new("Ref_year"),
+ anneeFin=new("Ref_year"),
calcdata=list()
)
)
@@ -344,7 +344,7 @@
#' @param anneefin the finishing year
#' @param silent Boolean, if TRUE, information messages are not displayed
#' @return An object of class \link{BilanMigrationInterAnnuelle-class}
-#' The choice_c method fills in the data slot for classes \link{RefDC-class}, \link{RefTaxon-class}, \link{RefStades-class} and two slots of \link{RefAnnee-class}
+#' The choice_c method fills in the data slot for classes \link{RefDC-class}, \link{RefTaxon-class}, \link{RefStades-class} and two slots of \link{Ref_year-class}
#' @aliases choice_c.bmi
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/BilanMigrationMult.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -407,7 +407,7 @@
setMethod("plot",signature(x = "BilanMigrationMult", y = "missing"),definition=function(x, plot.type="standard",color=NULL, color_ope=NULL,silent=FALSE,...){
#browser()
#print("entering plot function")
- #bilanMigrationMult<-bMM_Arzal
+ #bilanMigrationMult<-bMM_Arzal;silent=FALSE
bilanMigrationMult<-x
lestaxons= bilanMigrationMult at taxons@data
lesstades= bilanMigrationMult at stades@data
Modified: pkg/stacomir/R/Bilan_carlot.r
===================================================================
--- pkg/stacomir/R/Bilan_carlot.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/Bilan_carlot.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -71,13 +71,12 @@
#' this method verifies that boxes have been clicked in the user interface and gets the objects pasted in
#' envir_stacomi
#' @param object An object of class \link{Bilan_carlot-class}
-#' @param h a handler
#' @return An object of class \link{Bilan_carlot-class} with slots filled with user choice
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
#' @return An object of the class
#' @keywords internal
-setMethod("charge",signature=signature("Bilan_carlot"),definition=function(object,h) {
+setMethod("charge",signature=signature("Bilan_carlot"),definition=function(object) {
if (exists("refDC",envir_stacomi)) {
object at dc<-get("refDC",envir_stacomi)
} else {
Modified: pkg/stacomir/R/Bilan_poids_moyen.r
===================================================================
--- pkg/stacomir/R/Bilan_poids_moyen.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/Bilan_poids_moyen.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -18,9 +18,9 @@
#' @slot data A \code{"data.frame"} data for bilan lot
#' @slot calcdata A list containing two processed data frames, data and coe
#' @slot dc Object of class \code{\link{RefDC-class}}, the counting device
-#' @slot anneedebut Object of class \code{\link{RefAnnee-class}}. RefAnnee allows to choose the year of beginning
-#' @slot anneefin Object of class \code{\link{RefAnnee-class}}
-#' refAnnee allows to choose last year of the Bilan
+#' @slot anneedebut Object of class \code{\link{Ref_year-class}}. Ref_year allows to choose the year of beginning
+#' @slot anneefin Object of class \code{\link{Ref_year-class}}
+#' ref_year allows to choose last year of the Bilan
#' @slot coe Object of class \code{\link{RefCoe-class}} class loading coefficient
#' of conversion between quantity (weights or volumes of glass eel) and numbers
#' @slot liste Object of class \code{\link{RefListe-class}} RefListe referential
@@ -36,15 +36,15 @@
representation= representation(data="data.frame",
calcdata="list",
dc="RefDC",
- anneedebut="RefAnnee",
- anneefin="RefAnnee",
+ anneedebut="Ref_year",
+ anneefin="Ref_year",
coe="RefCoe",
liste="RefListe"),
prototype=prototype(data=data.frame(),
calcdata=list(),
dc=new("RefDC"),
- anneedebut=new("RefAnnee"),
- anneefin=new("RefAnnee"),
+ anneedebut=new("Ref_year"),
+ anneefin=new("Ref_year"),
coe=new("RefCoe"),
liste=new("RefListe")))
@@ -107,13 +107,13 @@
} else {
funout(gettext("You need to choose a counting device, clic on validate\n",domain="R-stacomiR"),arret=TRUE)
}
- if (exists("refAnneeDebut",envir_stacomi)) {
- object at anneedebut<-get("refAnneeDebut",envir_stacomi)
+ if (exists("ref_yearDebut",envir_stacomi)) {
+ object at anneedebut<-get("ref_yearDebut",envir_stacomi)
} else {
funout(gettext("You need to choose the starting year\n",domain="R-stacomiR"),arret=TRUE)
}
- if (exists("refAnneeFin",envir_stacomi)) {
- object at anneefin<-get("refAnneeFin",envir_stacomi)
+ if (exists("ref_yearFin",envir_stacomi)) {
+ object at anneefin<-get("ref_yearFin",envir_stacomi)
} else {
funout(gettext("You need to choose the ending year\n",domain="R-stacomiR"),arret=TRUE)
}
@@ -131,7 +131,7 @@
#' @param selectedvalue A character to select and object in the \link{RefListe-class}
#' @param silent Boolean, if TRUE, information messages are not displayed
#' @return An object of class \link{Bilan_poids_moyen-class}
-#' The choice_c method fills in the data slot for classes \link{RefDC-class} \link{RefAnnee-class}
+#' The choice_c method fills in the data slot for classes \link{RefDC-class} \link{Ref_year-class}
#' \link{RefCoe-class} \link{RefListe-class}
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
Deleted: pkg/stacomir/R/RefAnnee.r
===================================================================
--- pkg/stacomir/R/RefAnnee.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/RefAnnee.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -1,202 +0,0 @@
-#' Validity check for RefAnnee
-#'
-#' validite_Annee tests for validity within the class
-#'
-#'
-#' @param object An object of class \code{\linkS4class{RefAnnee}}
-#' @return boolean The test for the object Refannee
-#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @keywords internal
-validite_Annee=function(object)
-{
- rep1= class(object at data)=="data.frame"
- rep2= class(object at annee_selectionnee)=="numeric"
-
- return(ifelse(rep1&rep2,TRUE,FALSE))
-}
-#definition de la classe
-
-#' Year reference class
-#'
-#' Class used to select one or several years
-#' @section Objects from the Class: Objects can be created by calls of the form
-#' \code{new("RefAnnee", data=data.frame(), annee_selectionnee=numeric())}.
-#' @include create_generic.r
-#' @slot data A \code{data.frame} with the list of possible years selected as numerics
-#' @slot annee_selectionnee A numeric vector
-#' @keywords classes
-#' @family Referential objects
-#' @author cedric.briand"at"eptb-vilaine.fr
-setClass(Class="RefAnnee",representation=
- representation(data="data.frame",annee_selectionnee="numeric"),
- validity=validite_Annee,
- prototype=prototype(data=data.frame(),annee_selectionnee=numeric()))
-
-#' Loading method for RefAnnee referential objects
-#'
-#' Selects year avalaible either in the bjo table (if ObjetBilan==BilanMigrationInterannelle) or in the t_operation_ope table
-#' @param object An object of class RefAnnee
-#' @param objectBilan The object Bilan, default "Bilan_poids_moyen" other possible value BilanMigrationInterAnnuelle
-#' @return object An object of class RefAnnee with slot data filled with the selected value
-#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @examples
-#' \dontrun{
-#' object=new("RefAnnee")
-#' charge(object)
-#' validObject(annee)
-#' showMethods("charge")
-#' }
-setMethod("charge",signature=signature("RefAnnee"),definition=function(object,objectBilan="Bilan_poids_moyen"){
- requete=new("RequeteODBC")
- requete at baseODBC<-get("baseODBC",envir=envir_stacomi)
- if (objectBilan=="BilanMigrationInterAnnuelle") {
- if (exists("refDC",envir_stacomi)) {
- dc<-get("refDC",envir_stacomi)
- and1<-paste(" AND bjo_dis_identifiant =",dc at dc_selectionne)
- } else {
- and1<-""
- }
- if (exists("refTaxon",envir_stacomi)) {
- taxons<-get("refTaxon",envir_stacomi)
- and2<-stringr::str_c(" AND bjo_tax_code ='",taxons at data$tax_code,"'")
- } else {
- and2<-""
- }
- if (exists("refStades",envir_stacomi)){
- stades<-get("refStades",envir_stacomi)
- and3<-stringr::str_c(" AND bjo_std_code ='",stades at data$std_code,"'")
- } else
- {
- and3=""
- }
- requete at sql=paste("select DISTINCT ON (bjo_annee) bjo_annee from ",
- get("sch",envir=envir_stacomi),
- "t_bilanmigrationjournalier_bjo where bjo_identifiant>0 ",
- # I want and statements to not have to choose the order
- # the where statement is always verified
- and1,and2,and3, sep="")
- } else if (objectBilan=="Bilan_poids_moyen") {
- requete at sql=paste("select DISTINCT ON (year) year from( select date_part('year', ope_date_debut) as year from ",
- get("sch",envir=envir_stacomi),
- "t_operation_ope) as tabletemp",sep="")
- } else if (objectBilan=="BilanAnnuels"|objectBilan=="BilanEspeces") {
- if (exists("refDC",envir_stacomi)) {
- dc<-get("refDC",envir_stacomi)
- and1<-paste(" AND ope_dic_identifiant in ",vector_to_listsql(dc at dc_selectionne))
- } else {
- and1<-""
- }
- if (exists("refTaxon",envir_stacomi)) {
- taxons<-get("refTaxon",envir_stacomi)
- and2<-stringr::str_c(" AND lot_tax_code in ",vector_to_listsql(taxons at data$tax_code))
- } else {
- and2<-""
- }
- if (exists("refStades",envir_stacomi)){
- stades<-get("refStades",envir_stacomi)
- and3<-stringr::str_c(" AND lot_std_code in ",vector_to_listsql(stades at data$std_code))
- } else
- {
- and3=""
- }
- requete at sql=paste("select DISTINCT ON (year) year from (select date_part('year', ope_date_debut) as year from ",
- get("sch",envir=envir_stacomi),
- "t_operation_ope JOIN ",
- get("sch",envir=envir_stacomi),
- "t_lot_lot on lot_ope_identifiant=ope_identifiant",
- " WHERE lot_lot_identifiant is null",
- and1,and2,and3, ") as tabletemp", sep="")
- } else {
- funout(gettextf("Not implemented for objectBilan = %s",objectBilan),arret=TRUE)
- }
- requete<-stacomirtools::connect(requete) # appel de la methode connect de l'object requeteODBC
- object at data<-requete at query
- return(object)
- })
-
-#' choice method for RefAnnee referential
-#'
-#' Allows the selection of year and the assignment in environment envir_stacomi
-#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @param object An object of class \link{RefAnnee-class}
-#' @param nomassign The name to be asssigned in envir_stacomi
-#' @param funoutlabel The label that appears in funout
-#' @param titleFrame Title for the frame
-#' @param preselect The number of the year selected in the gdroplist (integer)
-#' @examples
-#' \dontrun{
-#' object=new("RefAnnee")
-#' object<-charge(object)
-#' win=gwindow(title="test refAnnee")
-#' group=ggroup(container=win,horizontal=FALSE)
-#' choice(object,nomassign="refAnnee",funoutlabel="essai",titleFrame="essai RefAnnee",preselect=1)
-#' dispose(win)
-#' }
-#' @keywords internal
-setMethod("choice",
- signature=signature("RefAnnee"),definition=function(object,
- nomassign="refAnnee",
- funoutlabel=gettext("Year selected\n",domain="R-stacomiR"),
- titleFrame=gettext("Year choice",domain="R-stacomiR"),
- preselect=1){
- if (nrow(object at data) > 0){
- hannee=function(h,...){
- object at annee_selectionnee<-svalue(choice)
- assign(nomassign,object,envir_stacomi)
- funout(funoutlabel)
- }
- group<-get("group",envir=envir_stacomi)
- frame_annee<-gframe(titleFrame)
- assign("frame_annee",frame_annee,envir=envir_stacomi)
- add(group,frame_annee)
- annees=object at data$year
- choice=gdroplist(annees,container=frame_annee,handler=hannee,selected=preselect)
- gbutton("OK", container=frame_annee,handler=hannee)
- } else {
- funout(gettext("Problem when loading data or no data in the database (ODBC link ?)",domain="R-stacomiR"),arret=TRUE)
- }
- })
-
-
-#' choice_c method for RefAnnee referential from the command line
-#'
-#' The choice_c method will issue a warning if the year is not present in the database
-#' Allows the selection of year and the assignment in environment envir_stacomi
-#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @param object An object of class \link{RefAnnee-class}
-#' @param annee The year to select, either as a character or as a numeric
-#' @param nomassign The name to be asssigned in envir_stacomi
-#' @param funoutlabel The label that appears in funout
-#' @param silent Stops messages from being displayed if silent=TRUE, default FALSE
-#' @examples
-#' \dontrun{
-#' object=new("RefAnnee")
-#' object<-charge(object)
-#' win=gwindow(title="test refAnnee")
-#' group=ggroup(container=win,horizontal=FALSE)
-#' choice(object,nomassign="refAnnee",funoutlabel="essai",titleFrame="essai RefAnnee",preselect=1)
-#' dispose(win)
-#' }
-setMethod("choice_c",
- signature=signature("RefAnnee"),definition=function(object,
- annee,
- nomassign="refAnnee",
- funoutlabel=gettext("Year selected\n",domain="R-stacomiR"),
- silent=FALSE
- ){
- if (length(annee)>1) stop("horodate should be a vector of length 1")
- if (class (annee)=="character") annee<-as.numeric(annee)
- # the charge method must be performed before
- gettext("no year",domain="R-stacomiR")
- if ( !annee %in% object at data[,1] ) {
-
- warning(stringr::str_c("Attention, year ",annee," is not available in the database, available years :",
- ifelse(length(object at data$bjo_annee)==0,gettext(" none, were you lazy?",domain="R-stacomiR"),
- stringr::str_c(object at data$bjo_annee,collapse=","))))
- }
- object at annee_selectionnee<-annee
-
- assign(nomassign,object,envir_stacomi)
- if (! silent) funout(funoutlabel)
- return(object)
- })
Copied: pkg/stacomir/R/Ref_year.R (from rev 399, pkg/stacomir/R/RefAnnee.r)
===================================================================
--- pkg/stacomir/R/Ref_year.R (rev 0)
+++ pkg/stacomir/R/Ref_year.R 2017-06-18 18:36:42 UTC (rev 400)
@@ -0,0 +1,202 @@
+#' Validity check for Ref_year
+#'
+#' validite_Annee tests for validity within the class
+#'
+#'
+#' @param object An object of class \code{\linkS4class{Ref_year}}
+#' @return boolean The test for the object Refannee
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @keywords internal
+validite_Annee=function(object)
+{
+ rep1= class(object at data)=="data.frame"
+ rep2= class(object at annee_selectionnee)=="numeric"
+
+ return(ifelse(rep1&rep2,TRUE,FALSE))
+}
+#definition de la classe
+
+#' Year reference class
+#'
+#' Class used to select one or several years
+#' @section Objects from the Class: Objects can be created by calls of the form
+#' \code{new("Ref_year", data=data.frame(), annee_selectionnee=numeric())}.
+#' @include create_generic.r
+#' @slot data A \code{data.frame} with the list of possible years selected as numerics
+#' @slot annee_selectionnee A numeric vector
+#' @keywords classes
+#' @family Referential objects
+#' @author cedric.briand"at"eptb-vilaine.fr
+setClass(Class="Ref_year",representation=
+ representation(data="data.frame",annee_selectionnee="numeric"),
+ validity=validite_Annee,
+ prototype=prototype(data=data.frame(),annee_selectionnee=numeric()))
+
+#' Loading method for Ref_year referential objects
+#'
+#' Selects year avalaible either in the bjo table (if ObjetBilan==BilanMigrationInterannelle) or in the t_operation_ope table
+#' @param object An object of class Ref_year
+#' @param objectBilan The object Bilan, default "Bilan_poids_moyen" other possible value BilanMigrationInterAnnuelle
+#' @return object An object of class Ref_year with slot data filled with the selected value
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples
+#' \dontrun{
+#' object=new("Ref_year")
+#' charge(object)
+#' validObject(annee)
+#' showMethods("charge")
+#' }
+setMethod("charge",signature=signature("Ref_year"),definition=function(object,objectBilan="Bilan_poids_moyen"){
+ requete=new("RequeteODBC")
+ requete at baseODBC<-get("baseODBC",envir=envir_stacomi)
+ if (objectBilan=="BilanMigrationInterAnnuelle") {
+ if (exists("refDC",envir_stacomi)) {
+ dc<-get("refDC",envir_stacomi)
+ and1<-paste(" AND bjo_dis_identifiant =",dc at dc_selectionne)
+ } else {
+ and1<-""
+ }
+ if (exists("refTaxon",envir_stacomi)) {
+ taxons<-get("refTaxon",envir_stacomi)
+ and2<-stringr::str_c(" AND bjo_tax_code ='",taxons at data$tax_code,"'")
+ } else {
+ and2<-""
+ }
+ if (exists("refStades",envir_stacomi)){
+ stades<-get("refStades",envir_stacomi)
+ and3<-stringr::str_c(" AND bjo_std_code ='",stades at data$std_code,"'")
+ } else
+ {
+ and3=""
+ }
+ requete at sql=paste("select DISTINCT ON (bjo_annee) bjo_annee from ",
+ get("sch",envir=envir_stacomi),
+ "t_bilanmigrationjournalier_bjo where bjo_identifiant>0 ",
+ # I want and statements to not have to choose the order
+ # the where statement is always verified
+ and1,and2,and3, sep="")
+ } else if (objectBilan=="Bilan_poids_moyen") {
+ requete at sql=paste("select DISTINCT ON (year) year from( select date_part('year', ope_date_debut) as year from ",
+ get("sch",envir=envir_stacomi),
+ "t_operation_ope) as tabletemp",sep="")
+ } else if (objectBilan=="BilanAnnuels"|objectBilan=="BilanEspeces") {
+ if (exists("refDC",envir_stacomi)) {
+ dc<-get("refDC",envir_stacomi)
+ and1<-paste(" AND ope_dic_identifiant in ",vector_to_listsql(dc at dc_selectionne))
+ } else {
+ and1<-""
+ }
+ if (exists("refTaxon",envir_stacomi)) {
+ taxons<-get("refTaxon",envir_stacomi)
+ and2<-stringr::str_c(" AND lot_tax_code in ",vector_to_listsql(taxons at data$tax_code))
+ } else {
+ and2<-""
+ }
+ if (exists("refStades",envir_stacomi)){
+ stades<-get("refStades",envir_stacomi)
+ and3<-stringr::str_c(" AND lot_std_code in ",vector_to_listsql(stades at data$std_code))
+ } else
+ {
+ and3=""
+ }
+ requete at sql=paste("select DISTINCT ON (year) year from (select date_part('year', ope_date_debut) as year from ",
+ get("sch",envir=envir_stacomi),
+ "t_operation_ope JOIN ",
+ get("sch",envir=envir_stacomi),
+ "t_lot_lot on lot_ope_identifiant=ope_identifiant",
+ " WHERE lot_lot_identifiant is null",
+ and1,and2,and3, ") as tabletemp", sep="")
+ } else {
+ funout(gettextf("Not implemented for objectBilan = %s",objectBilan),arret=TRUE)
+ }
+ requete<-stacomirtools::connect(requete) # appel de la methode connect de l'object requeteODBC
+ object at data<-requete at query
+ return(object)
+ })
+
+#' choice method for Ref_year referential
+#'
+#' Allows the selection of year and the assignment in environment envir_stacomi
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @param object An object of class \link{Ref_year-class}
+#' @param nomassign The name to be asssigned in envir_stacomi
+#' @param funoutlabel The label that appears in funout
+#' @param titleFrame Title for the frame
+#' @param preselect The number of the year selected in the gdroplist (integer)
+#' @examples
+#' \dontrun{
+#' object=new("Ref_year")
+#' object<-charge(object)
+#' win=gwindow(title="test ref_year")
+#' group=ggroup(container=win,horizontal=FALSE)
+#' choice(object,nomassign="ref_year",funoutlabel="essai",titleFrame="essai Ref_year",preselect=1)
+#' dispose(win)
+#' }
+#' @keywords internal
+setMethod("choice",
+ signature=signature("Ref_year"),definition=function(object,
+ nomassign="ref_year",
+ funoutlabel=gettext("Year selected\n",domain="R-stacomiR"),
+ titleFrame=gettext("Year choice",domain="R-stacomiR"),
+ preselect=1){
+ if (nrow(object at data) > 0){
+ hannee=function(h,...){
+ object at annee_selectionnee<-svalue(choice)
+ assign(nomassign,object,envir_stacomi)
+ funout(funoutlabel)
+ }
+ group<-get("group",envir=envir_stacomi)
+ frame_annee<-gframe(titleFrame)
+ assign("frame_annee",frame_annee,envir=envir_stacomi)
+ add(group,frame_annee)
+ annees=object at data$year
+ choice=gdroplist(annees,container=frame_annee,handler=hannee,selected=preselect)
+ gbutton("OK", container=frame_annee,handler=hannee)
+ } else {
+ funout(gettext("Problem when loading data or no data in the database (ODBC link ?)",domain="R-stacomiR"),arret=TRUE)
+ }
+ })
+
+
+#' choice_c method for Ref_year referential from the command line
+#'
+#' The choice_c method will issue a warning if the year is not present in the database
+#' Allows the selection of year and the assignment in environment envir_stacomi
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @param object An object of class \link{Ref_year-class}
+#' @param annee The year to select, either as a character or as a numeric
+#' @param nomassign The name to be asssigned in envir_stacomi
+#' @param funoutlabel The label that appears in funout
+#' @param silent Stops messages from being displayed if silent=TRUE, default FALSE
+#' @examples
+#' \dontrun{
+#' object=new("Ref_year")
+#' object<-charge(object)
+#' win=gwindow(title="test ref_year")
+#' group=ggroup(container=win,horizontal=FALSE)
+#' choice(object,nomassign="ref_year",funoutlabel="essai",titleFrame="essai Ref_year",preselect=1)
+#' dispose(win)
+#' }
+setMethod("choice_c",
+ signature=signature("Ref_year"),definition=function(object,
+ annee,
+ nomassign="ref_year",
+ funoutlabel=gettext("Year selected\n",domain="R-stacomiR"),
+ silent=FALSE
+ ){
+ if (length(annee)>1) stop("horodate should be a vector of length 1")
+ if (class (annee)=="character") annee<-as.numeric(annee)
+ # the charge method must be performed before
+ gettext("no year",domain="R-stacomiR")
+ if ( !annee %in% object at data[,1] ) {
+
+ warning(stringr::str_c("Attention, year ",annee," is not available in the database, available years :",
+ ifelse(length(object at data$bjo_annee)==0,gettext(" none, were you lazy?",domain="R-stacomiR"),
+ stringr::str_c(object at data$bjo_annee,collapse=","))))
+ }
+ object at annee_selectionnee<-annee
+
+ assign(nomassign,object,envir_stacomi)
+ if (! silent) funout(funoutlabel)
+ return(object)
+ })
Modified: pkg/stacomir/R/interface_BilanAnnuels.r
===================================================================
--- pkg/stacomir/R/interface_BilanAnnuels.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/interface_BilanAnnuels.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -27,7 +27,7 @@
notebook <- gnotebook(container=group)
assign("notebook",notebook,envir=envir_stacomi)
size(notebook)<-c(400,300)
- # pour preselectionner une date on lui fournit l'indice de la date dans le RefAnnee. indice = 11 pour 2005
+ # pour preselectionner une date on lui fournit l'indice de la date dans le Ref_year. indice = 11 pour 2005
choice(bilanAnnuels at anneedebut,
nomassign="anneedebut",
Modified: pkg/stacomir/R/interface_BilanMigrationInterannuelle.r
===================================================================
--- pkg/stacomir/R/interface_BilanMigrationInterannuelle.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/interface_BilanMigrationInterannuelle.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -18,7 +18,7 @@
ggroupboutons<-get("ggroupboutons",envir=envir_stacomi)
add(ggroupboutons,group)
- # pour preselectionner une date on lui fournit l'indice de la date dans le RefAnnee. indice = 11 pour 2005
+ # pour preselectionner une date on lui fournit l'indice de la date dans le Ref_year. indice = 11 pour 2005
choice(bilanMigrationInterAnnuelle at anneeDebut,
nomassign="anneeDebut",
Modified: pkg/stacomir/R/interface_bilan_poids_moyen.r
===================================================================
--- pkg/stacomir/R/interface_bilan_poids_moyen.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/interface_bilan_poids_moyen.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -22,10 +22,10 @@
choice(bilPM at liste)
choice(bilPM at dc,objectBilan=NULL,is.enabled=TRUE)
choice(bilPM at anneedebut,
- nomassign="refAnneeDebut",
+ nomassign="ref_yearDebut",
titleFrame=gettext("Beginning year",domain="R-stacomiR")) #annee debut
choice(bilPM at anneefin,
- nomassign="refAnneeFin",
+ nomassign="ref_yearFin",
titleFrame=gettext("Ending year",domain="R-stacomiR"))#annee fin
aCalc=gWidgets::gaction(label=gettext("load",domain="R-stacomiR"),
icon="lines",
Modified: pkg/stacomir/R/setAs.r
===================================================================
--- pkg/stacomir/R/setAs.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/setAs.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -1,6 +1,6 @@
setAs("BilanMigration","BilanMigrationInterAnnuelle",function(from){
- anneeDebut=new("RefAnnee")
- anneeFin=new("RefAnnee")
+ anneeDebut=new("Ref_year")
+ anneeFin=new("Ref_year")
anneeDebut at annee_selectionnee=min(getAnnees(from at pasDeTemps))
anneeFin at annee_selectionnee=max(getAnnees(from at pasDeTemps))
bilanMigrationInterAnnuelle=new("BilanMigrationInterAnnuelle")
Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/stacomi.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -522,7 +522,7 @@
#utils::globalVariables(c("win","group","nbligne","ggrouptotal","ggrouptotal1","gSortie",
# "col.sortie","ggroupboutons","ggroupboutonsbas","groupdate","groupdc","graphes",
# "frame_annee","frame_check","frame_choice","frame_par","frame_parqual","frame_parquan",
-# "frame_std","frame_tax","frame_annee","frame_check","frame_choice","refAnnee",
+# "frame_std","frame_tax","frame_annee","frame_check","frame_choice","ref_year",
# "logw","bilan_stades_pigm","usrname","usrpwd","notebook","values","ind","progress_bar","progres"))
# Progressbar
utils::globalVariables(c("progres"))
Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r 2017-06-17 20:16:18 UTC (rev 399)
+++ pkg/stacomir/R/utilitaires.r 2017-06-18 18:36:42 UTC (rev 400)
@@ -27,7 +27,7 @@
dispose(win)
}
if (exists("envir_stacomi")){
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/stacomir -r 400
More information about the Stacomir-commits
mailing list