[Stacomir-commits] r175 - in pkg/stacomir: . R inst inst/config inst/tests inst/tests/testthat man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 23 11:58:47 CEST 2016


Author: briand
Date: 2016-08-23 11:58:46 +0200 (Tue, 23 Aug 2016)
New Revision: 175

Added:
   pkg/stacomir/inst/tests/
   pkg/stacomir/inst/tests/testthat/
Removed:
   pkg/stacomir/inst/test/
   pkg/stacomir/inst/tests/test-00stacomirbaseconnection.R
   pkg/stacomir/inst/tests/test-BilanMigrationMult.R
Modified:
   pkg/stacomir/NAMESPACE
   pkg/stacomir/R/RefMsg.r
   pkg/stacomir/R/stacomi.r
   pkg/stacomir/R/utilitaires.r
   pkg/stacomir/inst/config/testthat.R
   pkg/stacomir/inst/tests/testthat/test-00stacomir.R
   pkg/stacomir/man/chargecsv.Rd
   pkg/stacomir/man/createmessage-RefMsg-method.Rd
   pkg/stacomir/man/envir_stacomi.Rd
   pkg/stacomir/man/funout.Rd
   pkg/stacomir/man/husr.Rd
Log:


Modified: pkg/stacomir/NAMESPACE
===================================================================
--- pkg/stacomir/NAMESPACE	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/NAMESPACE	2016-08-23 09:58:46 UTC (rev 175)
@@ -3,6 +3,7 @@
 export(chargecsv)
 export(fun_bilanMigrationMult)
 export(fun_bilanMigrationMult_Overlaps)
+export(fun_char_spe)
 export(fun_weight_conversion)
 export(funbarchartDC)
 export(funbarchartDF)
@@ -26,6 +27,7 @@
 export(interface_BilanEspeces)
 export(messages)
 export(stacomi)
+export(vector_to_listsql)
 exportClasses(BilanConditionEnv)
 exportClasses(BilanEspeces)
 exportClasses(BilanFonctionnementDC)
@@ -43,6 +45,7 @@
 exportMethods(charge_avec_filtre)
 exportMethods(choice_c)
 exportMethods(connect)
+exportMethods(createmessage)
 exportMethods(cumplot)
 exportMethods(plot1)
 exportMethods(print)

Modified: pkg/stacomir/R/RefMsg.r
===================================================================
--- pkg/stacomir/R/RefMsg.r	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/R/RefMsg.r	2016-08-23 09:58:46 UTC (rev 175)
@@ -56,6 +56,8 @@
 #' @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){
 				#object=new("RefMsg")

Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/R/stacomi.r	2016-08-23 09:58:46 UTC (rev 175)
@@ -89,32 +89,31 @@
 #' 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}
 #' 
-#' @param h a handler
-#' @param ... 
+#' @param h A handler
+#' @param ... Other arguments
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-
 husr=function(h,...){
 	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
+	login_window<-get("login_window",envir_stacomi) # logical true or false
 	# test de la connection
-	if (login_window){
-		con=new("ConnectionODBC")
-		if (gr_interface){
+	if (login_window & gr_interface&pre_launch_test){	
 			baseODBC[2]<-svalue(usrname)
 			baseODBC[3]<-svalue(usrpwd)
+			assign("sch",paste(baseODBC[2],".",sep=""),envir=envir_stacomi)
+			assign("baseODBC",baseODBC,envir=envir_stacomi)
 		} else {
-			# we take default values from calmig
-			# nothing is happening there
+			# nothing sch and baseODBC have been assigned from default value in stacomi()	
 		}
-		assign("sch",paste(baseODBC[2],".",sep=""),envir=envir_stacomi)
-		assign("baseODBC",baseODBC,envir=envir_stacomi)
-		con at baseODBC=get("baseODBC",envir=envir_stacomi)
+		
 		# we dispose loginwindow
-		if (exists("logw")) dispose(logw)
-	}
+	
+	
 	if (pre_launch_test){
+		con=new("ConnectionODBC")
+		con at baseODBC=get("baseODBC",envir=envir_stacomi)
 		e=expression(con<-connect(con))
 		con=tryCatch(eval(e),error=get("msg",envir=envir_stacomi)$interface_graphique_log.7) #finally=odbcClose(con at connection)clause inutile car si �a plante la connection n'est pas ouverte
 		test<-con at etat==get("msg",envir=envir_stacomi)$ConnectionODBC.6
@@ -282,20 +281,26 @@
 #' @export
 stacomi=function(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE){
 	# first loading of connection and odbc info using chargexml()
+	envir_stacomi <<- new.env(parent = emptyenv())
 	assign("gr_interface",gr_interface,envir=envir_stacomi)	
 	assign("pre_launch_test",pre_launch_test,envir=envir_stacomi)
-	# the first messages are necessary for the first access to the database, they are in French
-	envir_stacomi <- new.env(parent = emptyenv())
+	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()
 	mylinks=chargecsv()
 	baseODBC=mylinks[["baseODBC"]]
 	datawd=mylinks[["datawd"]]
 	lang=mylinks[["lang"]]	
 	sqldf.options=mylinks[["sqldf.options"]]	
+	# values assigned in the envir_stacomi
 	assign("lang",lang,envir=envir_stacomi)	
-	assign("baseODBC",baseODBC,envir=envir_stacomi)
 	assign("datawd",datawd,envir=envir_stacomi)
 	assign("sqldf.options",sqldf.options,envir=envir_stacomi)
+	
+	# the following values may be overridden later in husr()
+	assign("baseODBC",baseODBC,envir=envir_stacomi)
+	assign("sch",paste(baseODBC[2],".",sep=""),envir=envir_stacomi)
+	
 	refMsg=new("RefMsg")
 	createmessage(refMsg,pre_launch_test)
 	

Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/R/utilitaires.r	2016-08-23 09:58:46 UTC (rev 175)
@@ -237,6 +237,7 @@
 #' @param text a text string which might contain no utf8 characters
 #' @return text
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @export
 fun_char_spe<-function(text){
 	text=gsub("\u00e9","e",text) #é
 	text=gsub("\u00e8","e",text) #è
@@ -258,6 +259,7 @@
 #' @param wash Should the console be cleared after displaying the message
 #' @return nblignes Assigned in .Global
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @keywords internal
 funout<-function(text,arret=FALSE,wash=FALSE){
 	if (exists("gSortie")) {
 		if (wash) dispose(gSortie)
@@ -281,18 +283,21 @@
 #' files/stacomi/calcmig.csv file
 #' 
 #' be sure to configure your odbc link to the
-#' database, the name is the name of the first column of the calcmig.csv file
-#' uid, pwd are identifier and password to connect to the database, they should
-#' correspond to your own schema in the database pgwd, is the path to the R
-#' source if you plan not to use the compiler but develop from source
-#' https://r-forge.r-project.org/scm/?group_id=1019 datawd, is the the
+#' database, the name is the name of the first column of the calcmig.csv file. 
+#' 	\code{uid}, \code{pwd} are identifier and password to connect to the database, they should
+#' correspond to your own schema in the database. \code{pgwd} is the path to the R
+#' source if you plan not to use the compiler but run manually using inst/config/stacomi_manual_launch.R for development.\cr
+#' 	\code{datawd}, is the the
 #' directory where you want to place the outputs, mostly tables, from the
 #' program, default to ~//CalcmigData lang, is either one of French, English or
 #' Spanish
+#' 	other fields correspond to sqldf options.
+#' @note A version of the calcmig.csv is packaged in the config directory of the stacomiR library.
 #' 
 #' @return a list with the datawd place and the baseODBC vector
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @export
+#' @keywords internal
 chargecsv=function(){ 
 	#library(XML)  # chargement du package XML
 	options(guiToolkit = "RGtk2")
@@ -341,6 +346,7 @@
 #' @param vect a character vector
 #' @return listsql a list of value
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @export
 vector_to_listsql<-function(vect)
 {
 	

Modified: pkg/stacomir/inst/config/testthat.R
===================================================================
--- pkg/stacomir/inst/config/testthat.R	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/inst/config/testthat.R	2016-08-23 09:58:46 UTC (rev 175)
@@ -1,4 +1,4 @@
 require(testthat)
-test_dir("F:/workspace/stacomir/pkg/stacomir/inst/test/testthat")
+test_dir("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat")
 
 

Deleted: pkg/stacomir/inst/tests/test-00stacomirbaseconnection.R
===================================================================
--- pkg/stacomir/inst/test/test-00stacomirbaseconnection.R	2016-08-19 19:56:13 UTC (rev 164)
+++ pkg/stacomir/inst/tests/test-00stacomirbaseconnection.R	2016-08-23 09:58:46 UTC (rev 175)
@@ -1,32 +0,0 @@
-# Author: cedric.briand
-###############################################################################
-
-
-context("stacomi base connection")
-
-test_that("existence du fichier csv",{
-		filecsv<-"C:/Program Files/stacomi/calcmig.csv";
-		expect_equivalent(file.access(filecsv,0),0)
-	}
-
-)
-
-test_that("Teste que le lien ODBC existe et a la bonne longueur",{
-			result<-chargecsv();
-			expect_equal(length(result),3)
-			expect_equal(length(result$baseODBC),3)
-			expect_equal(length(result$sqldf),3)
-		})
-
-test_that("Teste que l'environnement de travail est bien cr��",{
-			expect_true(exists("envir_stacomi"))
-		})
-
-
-
-test_that("Teste la m�thode charge les messages de r�f�rence",
-		{
-			object=new("RefMsg")
-			object<-charge(object)	
-			expect_true(nrow(object at messager)>0)
-		})
\ No newline at end of file

Deleted: pkg/stacomir/inst/tests/test-BilanMigrationMult.R
===================================================================
--- pkg/stacomir/inst/test/test-BilanMigrationMult.R	2016-08-19 19:56:13 UTC (rev 164)
+++ pkg/stacomir/inst/tests/test-BilanMigrationMult.R	2016-08-23 09:58:46 UTC (rev 175)
@@ -1,37 +0,0 @@
-# Author: cedric.briand
-###############################################################################
-
-context("BilanMigrationMult")
-test_that("Teste une instance de bilanMigrationMult",{
-			bilanMigrationMult<-new("BilanMigrationMult")
-			bilanMigrationMult<-load(bilanMigrationMult,
-					dc=c(6,7),
-					taxons=c("Anguilla anguilla","Salmo salar"),
-					stades=c("AGG","AGJ","CIV"),
-					datedebut="2012-01-01",
-					datefin="2012-12-31")
-			expect_s4_class(bilanMigrationMult,
-					"BilanMigrationMult")})
-test_that("Teste une autre instance de bilanMigrationMult",{
-			bilanMigrationMult<-new("BilanMigrationMult")
-			bilanMigrationMult<-load(bilanMigrationMult,
-					dc=c(6,7),
-					taxons=c(2038,2220),
-					stades=c("AGG","AGJ","CIV"),
-					datedebut="2012-01-01",
-					datefin="31/12/2012")
-			expect_s4_class(bilanMigrationMult,
-					"BilanMigrationMult")})
-test_that("Teste une une instance avec erreur (dc n'existe pas)",
-		{
-			bilanMigrationMult<-new("BilanMigrationMult")
-			expect_error(load(bilanMigrationMult,
-							dc=c(6,70),
-							taxons=c("Anguilla anguilla","Salmo salar"),
-							stades=c("AGG","AGJ","CIV"),
-							datedebut="2012-01-01",
-							datefin="31/12/2012"))
-		})
-
-
-

Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/test/testthat/test-00stacomir.R	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R	2016-08-23 09:58:46 UTC (rev 175)
@@ -27,6 +27,7 @@
 
 test_that("Test that stacomirtools connects",{
 	require(stacomiR)
+	envir_stacomi <<- new.env(parent = emptyenv())
 	msg<-messages()
 	mylinks=chargecsv()
 	baseODBC=mylinks[["baseODBC"]]	
@@ -34,18 +35,18 @@
 	con at baseODBC=baseODBC
 	con<-connect(con)
 	expect_is(connect(con),'ConnectionODBC')
-	expect_equal(con at etat,"connected")
+	expect_equal(con at etat,NULL)
 	odbcCloseAll()
 })
 
 test_that("Test that positive count for nrow(ref.tr_taxon_tax)",{
 			require(stacomiR)
-			
+			envir_stacomi <<- new.env(parent = emptyenv())
 			msg<-messages()
 			mylinks=chargecsv()
 			baseODBC=mylinks[["baseODBC"]]	
 			requete=new("RequeteODBC")
-			requete at baseODBC<-get("baseODBC",envir=envir_stacomi)
+			requete at baseODBC<-baseODBC
 			requete at sql="select count(*) from ref.tr_taxon_tax"
 			requete<-stacomirtools::connect(requete)
 			expect_true(as.numeric(requete at query)>0)	
@@ -54,12 +55,13 @@
 
 test_that("Tests positive count for sch.t_operation_ope",{
 			require(stacomiR)
+			envir_stacomi <<- new.env(parent = emptyenv())
 			msg<-messages()
 			mylinks=chargecsv()
 			baseODBC=mylinks[["baseODBC"]]	
 			sch<-paste(baseODBC[2],".",sep="")
 			requete=new("RequeteODBC")
-			requete at baseODBC<-get("baseODBC",envir=envir_stacomi)			
+			requete at baseODBC<-baseODBC	
 			requete at sql=paste("select count(*) from ",sch,"t_operation_ope",sep="")
 			requete<-stacomirtools::connect(requete)
 			expect_true(as.numeric(requete at query)>0)	
@@ -71,6 +73,7 @@
 
 test_that("Test that working environment is created",{
 			require(stacomiR)
+			stacomi(gr_interface=TRUE,login_window=TRUE,pre_launch_test=TRUE)
 			expect_true(exists("envir_stacomi"))
 		})
 
@@ -110,7 +113,7 @@
 			object<-createmessage(object,TRUE)	
 			msgbase<-get("msg",envir=envir_stacomi)
 			require(stacomiR)
-			stacomi(gr_interface=FALSE,pre_launch_test=FALSE)
+			stacomi(gr_interface=FALSE,login_window=FALSE,pre_launch_test=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/man/chargecsv.Rd
===================================================================
--- pkg/stacomir/man/chargecsv.Rd	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/man/chargecsv.Rd	2016-08-23 09:58:46 UTC (rev 175)
@@ -12,16 +12,21 @@
 }
 \description{
 be sure to configure your odbc link to the
-database, the name is the name of the first column of the calcmig.csv file
-uid, pwd are identifier and password to connect to the database, they should
-correspond to your own schema in the database pgwd, is the path to the R
-source if you plan not to use the compiler but develop from source
-https://r-forge.r-project.org/scm/?group_id=1019 datawd, is the the
+database, the name is the name of the first column of the calcmig.csv file. 
+	\code{uid}, \code{pwd} are identifier and password to connect to the database, they should
+correspond to your own schema in the database. \code{pgwd} is the path to the R
+source if you plan not to use the compiler but run manually using inst/config/stacomi_manual_launch.R for development.\cr
+	\code{datawd}, is the the
 directory where you want to place the outputs, mostly tables, from the
 program, default to ~//CalcmigData lang, is either one of French, English or
 Spanish
+	other fields correspond to sqldf options.
 }
+\note{
+A version of the calcmig.csv is packaged in the config directory of the stacomiR library.
+}
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 }
+\keyword{internal}
 

Modified: pkg/stacomir/man/createmessage-RefMsg-method.Rd
===================================================================
--- pkg/stacomir/man/createmessage-RefMsg-method.Rd	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/man/createmessage-RefMsg-method.Rd	2016-08-23 09:58:46 UTC (rev 175)
@@ -23,4 +23,5 @@
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 }
+\keyword{internal}
 

Modified: pkg/stacomir/man/envir_stacomi.Rd
===================================================================
--- pkg/stacomir/man/envir_stacomi.Rd	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/man/envir_stacomi.Rd	2016-08-23 09:58:46 UTC (rev 175)
@@ -5,7 +5,7 @@
 \alias{envir_stacomi}
 \title{Environment where most objects from the package are stored and then loaded
 by the charge method}
-\format{An object of class \code{environment} of length 0.}
+\format{An object of class \code{environment} of length 10.}
 \usage{
 envir_stacomi
 }

Modified: pkg/stacomir/man/funout.Rd
===================================================================
--- pkg/stacomir/man/funout.Rd	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/man/funout.Rd	2016-08-23 09:58:46 UTC (rev 175)
@@ -23,4 +23,5 @@
 \author{
 Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 }
+\keyword{internal}
 

Modified: pkg/stacomir/man/husr.Rd
===================================================================
--- pkg/stacomir/man/husr.Rd	2016-08-23 08:20:45 UTC (rev 174)
+++ pkg/stacomir/man/husr.Rd	2016-08-23 09:58:46 UTC (rev 175)
@@ -7,9 +7,9 @@
 husr(h, ...)
 }
 \arguments{
-\item{h}{a handler}
+\item{h}{A handler}
 
-\item{...}{}
+\item{...}{Other arguments}
 }
 \description{
 Internal function, tests the connection and if it works loads the stacomi interface



More information about the Stacomir-commits mailing list