[Stacomir-commits] r189 - in pkg/stacomir: . R examples/01_BilanMigrationMult examples/02_BilanMigration inst/config inst/tests/testthat man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 4 22:06:20 CEST 2016


Author: briand
Date: 2016-09-04 22:06:19 +0200 (Sun, 04 Sep 2016)
New Revision: 189

Modified:
   pkg/stacomir/NAMESPACE
   pkg/stacomir/R/BilanMigration.r
   pkg/stacomir/R/RefMsg.r
   pkg/stacomir/R/fn_EcritBilanJournalier.r
   pkg/stacomir/R/fn_EcritBilanMensuel.r
   pkg/stacomir/R/fungraph.r
   pkg/stacomir/R/funstat.r
   pkg/stacomir/R/stacomi.r
   pkg/stacomir/R/utilitaires.r
   pkg/stacomir/examples/01_BilanMigrationMult/bilanMigrationMult_Arzal.R
   pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R
   pkg/stacomir/inst/config/generate_data.R
   pkg/stacomir/inst/config/stacomi_manual_launch.r
   pkg/stacomir/inst/tests/testthat/test-00stacomir.R
   pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R
   pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
   pkg/stacomir/man/BilanMigration-class.Rd
   pkg/stacomir/man/BilanMigrationMult-class.Rd
   pkg/stacomir/man/createmessage-RefMsg-method.Rd
   pkg/stacomir/man/husr.Rd
   pkg/stacomir/man/plot-BilanMigration-ANY-method.Rd
   pkg/stacomir/man/stacomi.Rd
Log:
Writing daily bilan and monthly bilan.

Modified: pkg/stacomir/NAMESPACE
===================================================================
--- pkg/stacomir/NAMESPACE	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/NAMESPACE	2016-09-04 20:06:19 UTC (rev 189)
@@ -48,6 +48,7 @@
 exportMethods(supprime)
 import(Hmisc)
 import(RColorBrewer)
+import(RGtk2)
 import(RODBC)
 import(RPostgreSQL)
 import(gWidgets)

Modified: pkg/stacomir/R/BilanMigration.r
===================================================================
--- pkg/stacomir/R/BilanMigration.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/BilanMigration.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -264,7 +264,8 @@
 #' 		\item{plot.type="multiple"}{Method to overlay graphs for BilanMigrationMult (multiple dc/taxa/stage in the same plot)}
 #' }
 #' @note When plotting the "standard" plot, the user will be prompted to "write" the daily migration and monthly migration in the database.
-#' these entries are necessary to run the Interannual Migration class.
+#' these entries are necessary to run the Interannual Migration class. If the stacomi has been launched with database_expected=FALSE,
+#' then no entry will be written to the database
 #' @param x An object of class BilanMigrationMult
 #' @param y From the formals but missing
 #' @param plot.type One of "standard","step". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or 
@@ -346,7 +347,8 @@
 					###########################################""
 					# Writes the daily bilan in the database
 					#########################################
-					fn_EcritBilanJournalier(bilanMigration)
+					database_expected<-get("database_expected",envir=envir_stacomi)
+					if (database_expected) fn_EcritBilanJournalier(bilanMigration,silent)
 				} # end is.null(data)
 				
 				#§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

Modified: pkg/stacomir/R/RefMsg.r
===================================================================
--- pkg/stacomir/R/RefMsg.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/RefMsg.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -49,15 +49,15 @@
 
 #' createmessage method for RefMsg referential objects 
 #' @param ojbect An objet of class RefMsg
-#' @param pre_launch_test Default to TRUE, if FALSE, no database connection is expected and the messages will be loaded from msg dataset within the package
+#' @param database_expected Default to TRUE, if FALSE, no database connection is expected and the messages will be loaded from msg dataset within the package
 #' @return An S4 object of class RefMsg
 #' @note When coming from the database, doublequotes are now escaped with an antislash (/"), those at the beginning and end are left as doublequotes, 
 #' the others are single quote when they are to be pasted within the text as code example. The remainder "c("a","b","c") are rebuilt into vectors by the function
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
 #' @keywords internal
-setMethod("createmessage",signature=signature("RefMsg"),definition=function(object,pre_launch_test) {
-			if (pre_launch_test){
+setMethod("createmessage",signature=signature("RefMsg"),definition=function(object,database_expected) {
+			if (database_expected){
 				#object=new("RefMsg")
 				object<-charge(object)
 				object<-charge_avec_filtre(object,lang=get("lang",envir=envir_stacomi))
@@ -114,7 +114,7 @@
 				}
 				msg<-create_vector(msg)
 				assign("msg",msg,envir=envir_stacomi)
-			} else	{ # !pre_launch_test
+			} else	{ # !database_expected
 				utils::data("msg")
 				assign("msg",msg,envir=envir_stacomi)
 			}

Modified: pkg/stacomir/R/fn_EcritBilanJournalier.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -5,28 +5,40 @@
 #' the function fn_EcritBilanJournalier
 #' 
 #' @param bilanMigration an object of class \code{\linkS4class{BilanMigration}}
+#' @param silent : TRUE to avoid messages
 #' @note the user is asked whether or not he wants to overwrite data, if no
 #' data are present in the database, the import is done anyway
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples 
+#' \dontrun{
+#' stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE) 
+#' data("bM_Arzal")
+#' bM_Arzal<-calcule(bM_Arzal)
+#' fn_EcritBilanJournalier(bilanMigration=bM_Arzal,silent=FALSE)
+#' }
 #' @export
-fn_EcritBilanJournalier<-function(bilanMigration){
+fn_EcritBilanJournalier<-function(bilanMigration,silent){
 	# voir essai_table_bilanJournalier.sql pour le format du tableau
 	# je cherche les colonnes que je ne veux pas retenir
-	data=bilanMigration at data	
-	jour_dans_lannee_non_nuls=strftime(bilanMigration at time.sequence,'%Y-%m-%d %H:%M:%S')[data$Effectif_total!=0]
+	if (class(bilanMigration)!="BilanMigration") stop("the bilanMigration should be of class BilanMigration")
+	if (class(silent)!="logical") stop("the silent argument should be a logical")
+	dc=as.numeric(bilanMigration at dc@dc_selectionne)[1]
+	data=bilanMigration at calcdata[[stringr::str_c("dc_",dc)]][["data"]]
+	jour_dans_lannee_non_nuls=data$debut_pas
 	data=data[data$Effectif_total!=0,]
-	col_a_retirer=match(c("No.pas","type_de_quantite"),colnames(data))
+	col_a_retirer=match(c("No.pas","type_de_quantite","debut_pas","fin_pas"),colnames(data))
 	data=data[,-col_a_retirer]
-	data$"Taux_d_echappement"[data$Taux_d_echappement==-1]<-NA 
+	data$taux_d_echappement[data$taux_d_echappement==-1]<-NA 
 	data$coe_valeur_coefficient[data$"coe_valeur_coefficient"==1]<-NA 
-	peuventpaszero=match(c("Taux_d_echappement","coe_valeur_coefficient"),colnames(data))
+	peuventpaszero=match(c("taux_d_echappement","coe_valeur_coefficient"),colnames(data))
 	data[,-peuventpaszero][data[,-peuventpaszero]==0]<-NA
-	t_bilanmigrationjournalier_bjo=cbind(bilanMigration at dc@dc_selectionne,
+	t_bilanmigrationjournalier_bjo=cbind(
+			bilanMigration at dc@dc_selectionne,
 			bilanMigration at taxons@data$tax_code,
 			bilanMigration at stades@data$std_code,
-			unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y")),
-			rep(jour_dans_lannee_non_nuls,ncol(data)),
-			utils::stack(data),  
+			unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y")), # une valeur
+			rep(as.character(jour_dans_lannee_non_nuls),ncol(data[,c("MESURE","CALCULE","EXPERT","PONCTUEL","Effectif_total","taux_d_echappement","coe_valeur_coefficient")])),
+			utils::stack(data[,c("MESURE","CALCULE","EXPERT","PONCTUEL","Effectif_total","taux_d_echappement","coe_valeur_coefficient")]),  
 			format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
 			substr(toupper(get("sch",envir=envir_stacomi)),1,nchar(toupper(get("sch",envir=envir_stacomi)))-1)
 	)
@@ -76,8 +88,8 @@
 		} # end for
 		funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanJournalier.5,"\n"))
 		# si l'utilisateur accepte de remplacer les valeurs
-		dispose(progres)
 		odbcClose(requete at connection)
+		gtkWidgetDestroy(progres)
 		# ecriture egalement du bilan mensuel
 		taxon= as.character(bilanMigration at taxons@data$tax_nom_latin)
 		stade= as.character(bilanMigration at stades@data$std_libelle)
@@ -126,13 +138,13 @@
 					"('",paste(t_bilanmigrationjournalier_bjo[i,],collapse="','"),"');",sep="")
 			requete<-stacomirtools::connect(requete)   
 		} # end for
-		dispose(progres)
 		RODBC::odbcClose(requete at connection)
 		funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanJournalier.5,"\n"))
 		taxon= as.character(bilanMigration at taxons@data$tax_nom_latin)
 		stade= as.character(bilanMigration at stades@data$std_libelle)
 		DC=as.numeric(bilanMigration at dc@dc_selectionne)	
-		resum=funstat(tableau=bilanMigration at data,time.sequence=bilanMigration at time.sequence,taxon,stade,DC)
+		tableau<-bilanMigration at calcdata[[stringr::str_c("dc_",DC)]][["data"]]
+		resum=funstat(tableau=tableau,time.sequence=tableau$debut_pas,taxon,stade,DC,silent=silent)
 		fn_EcritBilanMensuel(bilanMigration,resum)
 	} # end else
 } # end function

Modified: pkg/stacomir/R/fn_EcritBilanMensuel.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanMensuel.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/fn_EcritBilanMensuel.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -1,6 +1,7 @@
 #' This writes monthly data in t_bilanmensuel_mens table
 #' 
-#' Launched by fun_EcritBilanJournalier
+#' @note This function is launched by fun_EcritBilanJournalier, the resum 
+#' dataset is created by the \link{funstat} function
 #' 
 #' 
 #' @param bilanMigration an object of class \code{\linkS4class{BilanMigration}}
@@ -8,14 +9,15 @@
 #' @export
 fn_EcritBilanMensuel<-function(bilanMigration,resum){
 	# voir essai_table_bilanmensuel.sql pour le format du tableau
+	# below not the most elegant way to do it but efficient
+	
 	t_bilanmigrationmensuel_bme=stacomirtools::killfactor(
 			cbind(bilanMigration at dc@dc_selectionne,
 					bilanMigration at taxons@data$tax_code,
 					bilanMigration at stades@data$std_code,
-					unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y")),
-					rep(rownames(resum),12),
-					# stack re-ordonne les tab de donnees !
-					stack(resum,select=c(1:13)),  
+					unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y")), # une valeur
+					rep(rownames(resum),(ncol(resum)-2)), # nb of month except columns bilan and label
+					stack(resum,select=c(2:(ncol(resum)-1))),# stack re-ordonne les tab de donnees !  
 					format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
 					substr(toupper(get("sch",envir=envir_stacomi)),1,nchar(toupper(get("sch",envir=envir_stacomi)))-1)
 			)

Modified: pkg/stacomir/R/fungraph.r
===================================================================
--- pkg/stacomir/R/fungraph.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/fungraph.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -355,7 +355,6 @@
 	graphics::par("mar"=c(4, 4, 1, 2) + 0.1)
 	tableau$mois=factor(months(tableau$debut_pas,abbreviate=TRUE),
 			levels=unique(months(tableau$debut_pas,abbreviate=TRUE)))
-
 	tableaum<-reshape2::melt(data=tableau[,c("MESURE","CALCULE","EXPERT","PONCTUEL","mois")],							
 							id.vars=c("mois"),
 							measure.vars=c("MESURE","CALCULE","EXPERT","PONCTUEL"),

Modified: pkg/stacomir/R/funstat.r
===================================================================
--- pkg/stacomir/R/funstat.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/funstat.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -9,8 +9,9 @@
 #' @param DC  The counting device
 #' @param silent Message displayed or not
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @export
 funstat=function(tableau,time.sequence,taxon,stade,DC,silent){
-	funout(get("msg",envir=envir_stacomi)$funstat.1)
+	if (!silent) funout(get("msg",envir=envir_stacomi)$funstat.1)
 	mois=strftime(as.POSIXlt(time.sequence),"%m")
 	moislab=unique(mois)
 	annee=unique(strftime(as.POSIXlt(time.sequence),"%Y"))

Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/stacomi.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -87,7 +87,7 @@
 
 
 #' Internal function, tests the connection and if it works loads the stacomi interface
-#' @note \code{gr_interface} is copied by stacomi into envir_stacomi. Same for \code{pre_launch_test}
+#' @note \code{gr_interface} is copied by stacomi into envir_stacomi. Same for \code{database_expected}
 #' 
 #' @param h A handler
 #' @param ... Other arguments
@@ -96,10 +96,10 @@
 	baseODBC<-get("baseODBC",envir=envir_stacomi)
 	# assigned when passing through stacomi
 	gr_interface<-get("gr_interface",envir_stacomi) # logical true or false
-	pre_launch_test<-get("pre_launch_test",envir_stacomi) # logical true or false
+	database_expected<-get("database_expected",envir_stacomi) # logical true or false
 	login_window<-get("login_window",envir_stacomi) # logical true or false
 	# test de la connection
-	if (login_window & gr_interface&pre_launch_test){	
+	if (login_window & gr_interface&database_expected){	
 			baseODBC[2]<-svalue(usrname)
 			baseODBC[3]<-svalue(usrpwd)
 			assign("sch",paste(baseODBC[2],".",sep=""),envir=envir_stacomi)
@@ -112,7 +112,7 @@
 		# we dispose loginwindow
 	
 	
-	if (pre_launch_test){
+	if (database_expected){
 		con=new("ConnectionODBC")
 		con at baseODBC=get("baseODBC",envir=envir_stacomi)
 		e=expression(con<-connect(con))
@@ -129,7 +129,7 @@
 	#############################
 	# second test to check that the database is working well
 	############################
-	if (pre_launch_test){
+	if (database_expected){
 		if (test) { # il existe un lien ODBC mais qui pointe peut etre ailleurs
 			requete=new("RequeteODBC")
 			requete at baseODBC<-get("baseODBC",envir=envir_stacomi)
@@ -181,7 +181,7 @@
 					handler=hgmessage)
 		} # end else test (else == the test didn't pass, we have to change the name and password	
 	} else {
-		# here : pre_launch_test=FALSE
+		# here : database_expected=FALSE
 		# we don't want to check the connection at all...
 		if (gr_interface){
 			interface_graphique()
@@ -213,26 +213,27 @@
 #' 			the program will skip the login window and use calcmig values for user (\code{uid}) and password(\code{pwd}) as a default.}
 #'      \item{tests for connection}{ Test for the existence of a calcmig.csv file, and then the existence of the file
 #' 			\code{usr.tr_taxon_tax} where usr is the username extracted from calcmig. These tests are only done if 
-#' 			\code{pre_launch_test=TRUE}. If the test don't pass, then the user is prompted for a "login window" even if argument
+#' 			\code{database_expected=TRUE}. If the test don't pass, then the user is prompted for a "login window" even if argument
 #' 			\code{login_window} was set to \code{FALSE} at launch.}
 #'       \item{graphical interface}{ When either, previous tests have been run successfully, or the value for
-#'          \code{pre_launch_test=FALSE} the program will launch. If \code{graphical_interface} is \code{TRUE}, the program will use
+#'          \code{database_expected=FALSE} the program will launch. If \code{graphical_interface} is \code{TRUE}, the program will use
 #'          a graphical interface \code{\link{interface_graphique}} to build the graphical interface, otherwise the program is expected to run
 #' 			through the command line.}
 #'  }
-#' When \code{pre_launch_test=FALSE} a connection to the database is not expected. Therefore test are run by calling examples object stored in Rdata.
+#' When \code{database_expected=FALSE} a connection to the database is not expected. Therefore test are run by calling examples object stored in Rdata.
 #'  And also messages are downloaded from the database in several languages. These are loaded from the data directory of the package instead, and
 #' are only avalaible in english. 
 #' 
 #' @param gr_interface Boolean, if \code{TRUE} the program will launch the graphical interface
 #' @param login_window Boolean, if \code{TRUE} a login window will be displayed asking the user to specify
 #' user name.
-#' @param pre_launch_test Boolean, if \code{TRUE} pre launch tests will be run to test the connection validity
-#' @usage stacomi(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE)
+#' @param database_expected Boolean, if \code{TRUE} pre launch tests will be run to test the connection validity
+#' @usage stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
 #' @import stringr
 #' @import RColorBrewer
 #' @import gWidgets
 #' @import gWidgetsRGtk2
+#' @import RGtk2
 #' @import ggplot2
 #' @import RPostgreSQL
 #' @import sqldf
@@ -240,6 +241,7 @@
 #' @import stacomirtools
 #' @import RODBC
 #' @import Hmisc
+#' @import RGtk2
 #' @importFrom intervals Intervals
 #' @importFrom intervals closed<-
 #' @importFrom intervals interval_overlap
@@ -273,15 +275,15 @@
 #' 	stacomi(login_window=FALSE)
 #' }  
 #' #launch stacomi without connection to the database
-#' stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+#' stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 #' @export
-stacomi=function(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE){
+stacomi=function(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE){
 	# first loading of connection and odbc info using chargexml()
 	envir_stacomi <- new.env(parent = emptyenv())
 	assign("envir_stacomi",envir_stacomi,.GlobalEnv)
 	# trois variables passées à interface graphique via envir_stacomi :
 	assign("gr_interface",gr_interface,envir=envir_stacomi)	
-	assign("pre_launch_test",pre_launch_test,envir=envir_stacomi)
+	assign("database_expected",database_expected,envir=envir_stacomi)
 	assign("login_window",login_window,envir=envir_stacomi)
    # the first messages are necessary for the first access to the database, they are in French
 	msg<-messages()
@@ -300,7 +302,7 @@
 	assign("sch",paste(baseODBC[2],".",sep=""),envir=envir_stacomi)
 	
 	refMsg=new("RefMsg")
-	createmessage(refMsg,pre_launch_test)
+	createmessage(refMsg,database_expected)
 	
 	msg=get("msg",envir=envir_stacomi)
 	#libraries()
@@ -311,7 +313,7 @@
 			sqldf.RPostgreSQL.port = sqldf.options["sqldf.port"])
 	# loginWindow, will call the husr handler
 	# user login
-	if (gr_interface&login_window&pre_launch_test){
+	if (gr_interface&login_window&database_expected){
 		logw <- gWidgets::gwindow(msg$interface_graphique_log.1, 
 				name="log",
 				parent=c(0,0),

Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/R/utilitaires.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -219,7 +219,7 @@
 #'dispose(progres)
 #' }
 mygtkProgressBar<-function(title,progress_text,width=400,height=50,pulse=TRUE){
-	.dialog <- RGtk2::gtkDialog(title=title, NULL, NULL,
+	.dialog <- gWidgetsRGtk2::gtkDialog(title=title, NULL, NULL,
 			"gtk-close", RGtk2::GtkResponseType["none"],
 			show = FALSE)
 	assign("progres",.dialog,envir=envir_stacomi)

Modified: pkg/stacomir/examples/01_BilanMigrationMult/bilanMigrationMult_Arzal.R
===================================================================
--- pkg/stacomir/examples/01_BilanMigrationMult/bilanMigrationMult_Arzal.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/examples/01_BilanMigrationMult/bilanMigrationMult_Arzal.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -1,6 +1,6 @@
 library(stacomiR)
 
-stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE) 
+stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE) 
 ## launches the application in the command line
 ## here an example of loading
 ## not run as the program is possibly not installed
@@ -8,7 +8,7 @@
 \dontrun{
 	stacomi(gr_interface=FALSE,
 			login_window=FALSE,
-			pre_launch_test=FALSE)	
+			database_expected=FALSE)	
 	bMM_Arzal=new("BilanMigrationMult")
 	bMM_Arzal=choice_c(bMM_Arzal,
 			dc=c(5,6,12),

Modified: pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R
===================================================================
--- pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -1,6 +1,6 @@
 library(stacomiR)
 
-stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE) 
+stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE) 
 ## launches the application in the command line
 ## here an example of loading
 ## not run as the program is possibly not installed
@@ -8,7 +8,7 @@
 \dontrun{
 	stacomi(gr_interface=FALSE,
 			login_window=FALSE,
-			pre_launch_test=FALSE)	
+			database_expected=FALSE)	
 	bM_Arzal=new("BilanMigration")
 	bM_Arzal=choice_c(bM_Arzal,
 			dc=5,
@@ -30,6 +30,8 @@
 bM_Arzal<-calcule(bM_Arzal)
 #Individual plot for all DC (standard), taxon and stage where data present
 #silent argument to stop all messages
+# this will also write daily and monthly migration balance to the database,
+# but only if stacomi has been run with argument : database_expected=FALSE
 plot(bM_Arzal,plot.type="standard",silent=TRUE)
 
 #cumulated migration at the station (all stages and DC grouped)

Modified: pkg/stacomir/inst/config/generate_data.R
===================================================================
--- pkg/stacomir/inst/config/generate_data.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/inst/config/generate_data.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -6,7 +6,7 @@
 source ("F:/workspace/stacomir/pkg/stacomir/inst/config/stacomi_manual_launch.r")
 assign("lang","English",envir=envir_stacomi)	
 refMsg=new("RefMsg")
-createmessage(refMsg,pre_launch_test=TRUE)
+createmessage(refMsg,database_expected=TRUE)
 msg=get("msg",envir=envir_stacomi)
 devtools::use_data(msg,internal=FALSE,overwrite=TRUE)
 
@@ -42,7 +42,7 @@
 
 stacomi(gr_interface=FALSE,
 		login_window=FALSE,
-		pre_launch_test=FALSE)	
+		database_expected=FALSE)	
 bM_Arzal=new("BilanMigration")
 bM_Arzal=choice_c(bM_Arzal,
 		dc=5,

Modified: pkg/stacomir/inst/config/stacomi_manual_launch.r
===================================================================
--- pkg/stacomir/inst/config/stacomi_manual_launch.r	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/inst/config/stacomi_manual_launch.r	2016-09-04 20:06:19 UTC (rev 189)
@@ -100,6 +100,6 @@
 # interface_BilanEspeces dans BilanEspeces
 setwd("F:/workspace/stacomir/pkg/stacomir")
 data("msg")
- stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+ stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 
 

Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -76,7 +76,7 @@
 
 test_that("Test that working environment is created",{
 			require(stacomiR)
-			stacomi(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE)
+			stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
 			expect_true(exists("envir_stacomi"))
 			dispose(logw)
 			rm("envir_stacomi",envir =.GlobalEnv)
@@ -84,15 +84,15 @@
 
 test_that("Test that gWidget loginwindow is loaded ",{
 			require(stacomiR)
-			stacomi(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE)
+			stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
 			expect_true(exists("logw"))
 			dispose(logw)
 			rm("envir_stacomi",envir =.GlobalEnv)
 })
 
-test_that("Test that gWidget gr_interface is loaded, without pre_launch_test, nor login window",{
+test_that("Test that gWidget gr_interface is loaded, without database_expected, nor login window",{
 			require(stacomiR)
-			stacomi(gr_interface=TRUE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=TRUE,login_window=FALSE,database_expected=FALSE)
 			expect_true(exists("win"))
 			dispose(win)
 			rm("envir_stacomi",envir =.GlobalEnv)
@@ -100,7 +100,7 @@
 
 test_that("gWidget gr_interface is loaded, with pre launch_test, but without login window",{
 			require(stacomiR)
-			stacomi(gr_interface=TRUE,login_window=FALSE,pre_launch_test=TRUE)
+			stacomi(gr_interface=TRUE,login_window=FALSE,database_expected=TRUE)
 			expect_true(exists("win"))
 			dispose(win)
 			rm("envir_stacomi",envir =.GlobalEnv)
@@ -127,7 +127,7 @@
 			object<-createmessage(object,TRUE)	
 			msgbase<-get("msg",envir=envir_stacomi)
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			msg<-get("msg",envir=envir_stacomi)
 			# objects should have the same length but different languages
 			expect_identical(length(msg),length(msgbase))

Modified: pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -1,7 +1,7 @@
 context("BilanMigrationMult")
 test_that("Test an instance of bilanMigrationMult",{
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			bilanMigrationMult<-new("BilanMigrationMult")
 			options(warn = 2)
 			bilanMigrationMult<-choice_c(bilanMigrationMult,
@@ -16,7 +16,7 @@
 ## This test check that the code above works with numeric and a different formating for date
 test_that("Test another instance of bilanMigrationMult",{
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			bilanMigrationMult<-new("BilanMigrationMult")
 			options(warn = 2)
 			bilanMigrationMult<-choice_c(bilanMigrationMult,
@@ -31,7 +31,7 @@
 test_that("Tests one instance with error (dc does not exist)",
 		{
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			bilanMigrationMult<-new("BilanMigrationMult")
 			options(warn = 2)
 			expect_error(choice_c(bilanMigrationMult,
@@ -45,7 +45,7 @@
 test_that("Tests one instance with error (dc does not exist)",
 		{
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			bilanMigrationMult<-new("BilanMigrationMult")
 			options(warn = 2)
 			expect_error(choice_c(bilanMigrationMult,

Modified: pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2016-09-04 20:06:19 UTC (rev 189)
@@ -1,7 +1,7 @@
 context("BilanMigration")
 test_that("Test an instance of bilanMigration",{
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			# overriding user schema to point to iav
 			baseODBC<-get("baseODBC",envir=envir_stacomi)
 			baseODBC[c(2,3)]<-rep("iav",2)
@@ -26,7 +26,7 @@
 test_that("Test connect method",{
 			stacomi(gr_interface=FALSE,
 					login_window=FALSE,
-					pre_launch_test=FALSE)	
+					database_expected=FALSE)	
 			# overriding user schema
 			baseODBC<-get("baseODBC",envir=envir_stacomi)
 			baseODBC[c(2,3)]<-rep("iav",2)

Modified: pkg/stacomir/man/BilanMigration-class.Rd
===================================================================
--- pkg/stacomir/man/BilanMigration-class.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/BilanMigration-class.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -34,7 +34,7 @@
 \examples{
 library(stacomiR)
 
-stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE) 
+stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE) 
 ## launches the application in the command line
 ## here an example of loading
 ## not run as the program is possibly not installed
@@ -42,7 +42,7 @@
 \dontrun{
 	stacomi(gr_interface=FALSE,
 			login_window=FALSE,
-			pre_launch_test=FALSE)	
+			database_expected=FALSE)	
 	bM_Arzal=new("BilanMigration")
 	bM_Arzal=choice_c(bM_Arzal,
 			dc=5,

Modified: pkg/stacomir/man/BilanMigrationMult-class.Rd
===================================================================
--- pkg/stacomir/man/BilanMigrationMult-class.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/BilanMigrationMult-class.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -45,7 +45,7 @@
 \examples{
 library(stacomiR)
 
-stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=FALSE) 
+stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE) 
 ## launches the application in the command line
 ## here an example of loading
 ## not run as the program is possibly not installed
@@ -53,7 +53,7 @@
 \dontrun{
 	stacomi(gr_interface=FALSE,
 			login_window=FALSE,
-			pre_launch_test=FALSE)	
+			database_expected=FALSE)	
 	bMM_Arzal=new("BilanMigrationMult")
 	bMM_Arzal=choice_c(bMM_Arzal,
 			dc=c(5,6,12),

Modified: pkg/stacomir/man/createmessage-RefMsg-method.Rd
===================================================================
--- pkg/stacomir/man/createmessage-RefMsg-method.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/createmessage-RefMsg-method.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -5,10 +5,10 @@
 \alias{createmessage,RefMsg-method}
 \title{createmessage method for RefMsg referential objects}
 \usage{
-\S4method{createmessage}{RefMsg}(object, pre_launch_test)
+\S4method{createmessage}{RefMsg}(object, database_expected)
 }
 \arguments{
-\item{pre_launch_test}{Default to TRUE, if FALSE, no database connection is expected and the messages will be loaded from msg dataset within the package}
+\item{database_expected}{Default to TRUE, if FALSE, no database connection is expected and the messages will be loaded from msg dataset within the package}
 
 \item{ojbect}{An objet of class RefMsg}
 }

Modified: pkg/stacomir/man/husr.Rd
===================================================================
--- pkg/stacomir/man/husr.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/husr.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -15,7 +15,7 @@
 Internal function, tests the connection and if it works loads the stacomi interface
 }
 \note{
-\code{gr_interface} is copied by stacomi into envir_stacomi. Same for \code{pre_launch_test}
+\code{gr_interface} is copied by stacomi into envir_stacomi. Same for \code{database_expected}
 }
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}

Modified: pkg/stacomir/man/plot-BilanMigration-ANY-method.Rd
===================================================================
--- pkg/stacomir/man/plot-BilanMigration-ANY-method.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/plot-BilanMigration-ANY-method.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -3,7 +3,7 @@
 \docType{methods}
 \name{plot,BilanMigration,ANY-method}
 \alias{plot,BilanMigration,ANY-method}
-\title{Plots of various type for BilanMigration}
+\title{Plots of various type for BilanMigration, and performs writing to the database of daily values.}
 \usage{
 \S4method{plot}{BilanMigration,ANY}(x, y, plot.type = "standard",
   silent = FALSE, ...)
@@ -26,6 +26,10 @@
 		\item{plot.type="multiple"}{Method to overlay graphs for BilanMigrationMult (multiple dc/taxa/stage in the same plot)}
 }
 }
+\note{
+When plotting the "standard" plot, the user will be prompted to "write" the daily migration and monthly migration in the database.
+these entries are necessary to run the Interannual Migration class.
+}
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 }

Modified: pkg/stacomir/man/stacomi.Rd
===================================================================
--- pkg/stacomir/man/stacomi.Rd	2016-09-01 19:39:15 UTC (rev 188)
+++ pkg/stacomir/man/stacomi.Rd	2016-09-04 20:06:19 UTC (rev 189)
@@ -5,7 +5,7 @@
 \title{Function that loads the loginwindow, tests connection, and then destroys the
 window}
 \usage{
-stacomi(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE)
+stacomi(gr_interface=TRUE,login_window=TRUE,database_expected=TRUE)
 }
 \arguments{
 \item{gr_interface}{Boolean, if \code{TRUE} the program will launch the graphical interface}
@@ -13,7 +13,7 @@
 \item{login_window}{Boolean, if \code{TRUE} a login window will be displayed asking the user to specify
 user name.}
 
-\item{pre_launch_test}{Boolean, if \code{TRUE} pre launch tests will be run to test the connection validity}
+\item{database_expected}{Boolean, if \code{TRUE} pre launch tests will be run to test the connection validity}
 }
 \description{
 Function that loads the loginwindow, tests connection, and then destroys the
@@ -28,14 +28,14 @@
 			the program will skip the login window and use calcmig values for user (\code{uid}) and password(\code{pwd}) as a default.}
      \item{tests for connection}{ Test for the existence of a calcmig.csv file, and then the existence of the file
 			\code{usr.tr_taxon_tax} where usr is the username extracted from calcmig. These tests are only done if 
-			\code{pre_launch_test=TRUE}. If the test don't pass, then the user is prompted for a "login window" even if argument
+			\code{database_expected=TRUE}. If the test don't pass, then the user is prompted for a "login window" even if argument
 			\code{login_window} was set to \code{FALSE} at launch.}
       \item{graphical interface}{ When either, previous tests have been run successfully, or the value for
-         \code{pre_launch_test=FALSE} the program will launch. If \code{graphical_interface} is \code{TRUE}, the program will use
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/stacomir -r 189


More information about the Stacomir-commits mailing list