diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..e527956
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..30b8cca
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ DatabasesResourcesManager
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/cfg/ALog.properties b/cfg/ALog.properties
new file mode 100644
index 0000000..875385d
--- /dev/null
+++ b/cfg/ALog.properties
@@ -0,0 +1,24 @@
+#### Use two appenders, one to log to console, another to log to a file
+#log4j.rootCategory= R
+
+#### Second appender writes to a file
+#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#log4j.appender.stdout.Threshold=trace
+#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.stdout.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %p %t %c - %m%n
+
+log4j.logger.AnalysisLogger=TRACE,AR
+log4j.appender.AR=org.apache.log4j.RollingFileAppender
+log4j.appender.AR.Threshold=trace
+log4j.appender.AR.File=./Analysis.log
+log4j.appender.AR.MaxFileSize=50000KB
+log4j.appender.AR.MaxBackupIndex=2
+log4j.appender.AR.layout=org.apache.log4j.PatternLayout
+log4j.appender.AR.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %p %t %c - %m%n
+
+#### Third appender writes to a file
+log4j.logger.org.hibernate=H
+log4j.appender.H=org.apache.log4j.AsyncAppender
+log4j.appender.H.Threshold=OFF
+log4j.appender.H.layout=org.apache.log4j.PatternLayout
+log4j.appender.H.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %p %t %c - %m%n
diff --git a/cfg/DestinationDBHibernate.cfg.out.xml b/cfg/DestinationDBHibernate.cfg.out.xml
new file mode 100644
index 0000000..e69de29
diff --git a/cfg/DestinationDBHibernate.cfg.xml b/cfg/DestinationDBHibernate.cfg.xml
new file mode 100644
index 0000000..90d87a9
--- /dev/null
+++ b/cfg/DestinationDBHibernate.cfg.xml
@@ -0,0 +1,18 @@
+
+
+
+ com.mysql.jdbc.Driver
+ org.hibernate.connection.C3P0ConnectionProvider
+ jdbc:mysql://146.48.87.169/timeseries
+ root
+ test
+
+ org.hibernate.dialect.MySQLDialect
+ org.hibernate.transaction.JDBCTransactionFactory
+ 0
+ 1
+ 0
+ 1
+ thread
+
+
\ No newline at end of file
diff --git a/cfg/HibernateConfigurationMySQL.cfg.xml b/cfg/HibernateConfigurationMySQL.cfg.xml
new file mode 100644
index 0000000..c5b646e
--- /dev/null
+++ b/cfg/HibernateConfigurationMySQL.cfg.xml
@@ -0,0 +1,18 @@
+
+
+
+ com.mysql.jdbc.Driver
+ org.hibernate.connection.C3P0ConnectionProvider
+ jdbc:mysql://146.48.87.169/col2oct2010
+ root
+ test
+
+ org.hibernate.dialect.MySQLDialect
+ org.hibernate.transaction.JDBCTransactionFactory
+ 0
+ 1
+ 0
+ 1
+ thread
+
+
\ No newline at end of file
diff --git a/cfg/HibernateConfigurationPostgres.cfg.xml b/cfg/HibernateConfigurationPostgres.cfg.xml
new file mode 100644
index 0000000..80a0435
--- /dev/null
+++ b/cfg/HibernateConfigurationPostgres.cfg.xml
@@ -0,0 +1,19 @@
+
+
+
+ org.postgresql.Driver
+ org.hibernate.connection.C3P0ConnectionProvider
+ jdbc:postgresql://statistical-manager.d.d4science.research-infrastructures.eu/testdb
+ utente
+ d4science
+
+ org.hibernate.dialect.PostgreSQLDialect
+ org.hibernate.transaction.JDBCTransactionFactory
+ public
+ 0
+ 1
+ 0
+ 1
+ thread
+
+
\ No newline at end of file
diff --git a/cfg/HibernateConfigurationPostgres1.cfg.xml b/cfg/HibernateConfigurationPostgres1.cfg.xml
new file mode 100644
index 0000000..97da43e
--- /dev/null
+++ b/cfg/HibernateConfigurationPostgres1.cfg.xml
@@ -0,0 +1,19 @@
+
+
+
+ org.postgresql.Driver
+ org.hibernate.connection.C3P0ConnectionProvider
+ jdbc:postgresql://dbtest.research-infrastructures.eu/aquamapsorgupdated
+ utente
+ d4science
+
+ org.hibernate.dialect.PostgreSQLDialect
+ org.hibernate.transaction.JDBCTransactionFactory
+ public
+ 0
+ 1
+ 0
+ 1
+ thread
+
+
\ No newline at end of file
diff --git a/cfg/algorithms.properties b/cfg/algorithms.properties
new file mode 100644
index 0000000..fdf28d7
--- /dev/null
+++ b/cfg/algorithms.properties
@@ -0,0 +1,13 @@
+AQUAMAPS_SUITABLE=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsSuitable
+AQUAMAPS_NATIVE=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsNative
+AQUAMAPS_NATIVE_2050=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsNative2050
+AQUAMAPS_SUITABLE_2050=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsSuitable2050
+AQUAMAPS_NATIVE_NEURALNETWORK=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsNN
+AQUAMAPS_SUITABLE_NEURALNETWORK=org.gcube.dataanalysis.ecoengine.spatialdistributions.AquamapsNNSuitable
+FEED_FORWARD_A_N_N_DISTRIBUTION=org.gcube.dataanalysis.ecoengine.spatialdistributions.FeedForwardNeuralNetworkDistribution
+LWR=org.gcube.dataanalysis.executor.nodes.algorithms.LWR
+BIONYM_BIODIV=org.gcube.dataanalysis.executor.nodes.transducers.bionym.BionymBiodiv
+BIONYM=org.gcube.dataanalysis.executor.nodes.transducers.bionym.BionymFlexibleWorkflowTransducer
+OCCURRENCES_MERGER=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceMergingNode
+OCCURRENCES_INTERSECTOR=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceIntersectionNode
+OCCURRENCES_SUBTRACTION=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceSubtractionNode
\ No newline at end of file
diff --git a/cfg/clusterers.properties b/cfg/clusterers.properties
new file mode 100644
index 0000000..f9321de
--- /dev/null
+++ b/cfg/clusterers.properties
@@ -0,0 +1,4 @@
+DBSCAN=org.gcube.dataanalysis.ecoengine.clustering.DBScan
+LOF=org.gcube.dataanalysis.ecoengine.clustering.LOF
+KMEANS=org.gcube.dataanalysis.ecoengine.clustering.KMeans
+XMEANS=org.gcube.dataanalysis.ecoengine.clustering.XMeansWrapper
\ No newline at end of file
diff --git a/cfg/evaluators.properties b/cfg/evaluators.properties
new file mode 100644
index 0000000..9d7a554
--- /dev/null
+++ b/cfg/evaluators.properties
@@ -0,0 +1,4 @@
+MAPS_COMPARISON=org.gcube.dataanalysis.geo.algorithms.MapsComparator
+DISCREPANCY_ANALYSIS=org.gcube.dataanalysis.ecoengine.evaluation.DiscrepancyAnalysis
+QUALITY_ANALYSIS=org.gcube.dataanalysis.ecoengine.evaluation.DistributionQualityAnalysis
+HRS=org.gcube.dataanalysis.ecoengine.evaluation.HabitatRepresentativeness
\ No newline at end of file
diff --git a/cfg/generators.properties b/cfg/generators.properties
new file mode 100644
index 0000000..2907162
--- /dev/null
+++ b/cfg/generators.properties
@@ -0,0 +1,3 @@
+LOCAL_WITH_DATABASE=org.gcube.dataanalysis.ecoengine.processing.LocalSplitGenerator
+SIMPLE_LOCAL=org.gcube.dataanalysis.ecoengine.processing.LocalSimpleSplitGenerator
+D4SCIENCE=org.gcube.dataanalysis.executor.generators.D4ScienceDistributedProcessing
\ No newline at end of file
diff --git a/cfg/modelers.properties b/cfg/modelers.properties
new file mode 100644
index 0000000..d5c652e
--- /dev/null
+++ b/cfg/modelers.properties
@@ -0,0 +1 @@
+HSPEN_MODELER=org.gcube.dataanalysis.ecoengine.modeling.SimpleModeler
\ No newline at end of file
diff --git a/cfg/models.properties b/cfg/models.properties
new file mode 100644
index 0000000..1e54f69
--- /dev/null
+++ b/cfg/models.properties
@@ -0,0 +1,4 @@
+HSPEN=org.gcube.dataanalysis.ecoengine.models.ModelHSPEN
+AQUAMAPSNN=org.gcube.dataanalysis.ecoengine.models.ModelAquamapsNN
+FEED_FORWARD_ANN=org.gcube.dataanalysis.ecoengine.models.FeedForwardNN
+#FEED_FORWARD_ANN_FILE=org.gcube.dataanalysis.ecoengine.models.testing.FeedForwardNNFile
\ No newline at end of file
diff --git a/cfg/nodealgorithms.properties b/cfg/nodealgorithms.properties
new file mode 100644
index 0000000..700df1d
--- /dev/null
+++ b/cfg/nodealgorithms.properties
@@ -0,0 +1,10 @@
+AQUAMAPS_SUITABLE=org.gcube.dataanalysis.executor.nodes.algorithms.AquamapsSuitableNode
+AQUAMAPS_NATIVE=org.gcube.dataanalysis.executor.nodes.algorithms.AquamapsNativeNode
+AQUAMAPS_NATIVE_2050=org.gcube.dataanalysis.executor.nodes.algorithms.AquamapsNative2050Node
+AQUAMAPS_SUITABLE_2050=org.gcube.dataanalysis.executor.nodes.algorithms.AquamapsSuitable2050Node
+OCCURRENCES_MERGER=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceMergingNode
+OCCURRENCES_INTERSECTOR=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceIntersectionNode
+OCCURRENCES_SUBTRACTION=org.gcube.dataanalysis.executor.nodes.transducers.OccurrenceSubtractionNode
+LWR=org.gcube.dataanalysis.executor.nodes.algorithms.LWR
+BIONYM_BIODIV=org.gcube.dataanalysis.executor.nodes.transducers.bionym.BionymBiodiv
+BIONYM=org.gcube.dataanalysis.executor.nodes.transducers.bionym.BionymFlexibleWorkflowTransducer
\ No newline at end of file
diff --git a/cfg/operators.xml b/cfg/operators.xml
new file mode 100644
index 0000000..3f39339
--- /dev/null
+++ b/cfg/operators.xml
@@ -0,0 +1,2620 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cfg/table.txt b/cfg/table.txt
new file mode 100644
index 0000000..e69de29
diff --git a/cfg/transducerers.properties b/cfg/transducerers.properties
new file mode 100644
index 0000000..34dcbb2
--- /dev/null
+++ b/cfg/transducerers.properties
@@ -0,0 +1,36 @@
+BIOCLIMATE_HSPEC=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHSPECTransducer
+BIOCLIMATE_HCAF=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHCAFTransducer
+BIOCLIMATE_HSPEN=org.gcube.dataanalysis.ecoengine.transducers.BioClimateHSPENTransducer
+HCAF_INTERPOLATION=org.gcube.dataanalysis.ecoengine.transducers.InterpolationTransducer
+HCAF_FILTER=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.HcafFilter
+HSPEN_FILTER=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.HspenFilter
+ABSENCE_CELLS_FROM_AQUAMAPS=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.MarineAbsencePointsFromAquamapsDistribution
+PRESENCE_CELLS_GENERATION=org.gcube.dataanalysis.ecoengine.transducers.simplequeryexecutors.MarinePresencePoints
+OCCURRENCES_MERGER=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsMerger
+OCCURRENCES_INTERSECTOR=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsIntersector
+OCCURRENCES_MARINE_TERRESTRIAL=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsInSeaOnEarth
+OCCURRENCES_DUPLICATES_DELETER=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsDuplicatesDeleter
+OCCURRENCES_SUBTRACTION=org.gcube.dataanalysis.ecoengine.transducers.OccurrencePointsSubtraction
+FIN_TAXA_MATCH=org.gcube.dataanalysis.fin.taxamatch.TaxaMatchTransducer
+OBIS_MOST_OBSERVED_SPECIES=org.gcube.dataanalysis.trendylyzeralgorithms.AbsoluteSpeciesBarChartsAlgorithm
+OBIS_SINGLE_SPECIES_DISTRIBUTION_PER_AREA=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsAreaBarChart
+OBIS_SPECIES_OBSERVATIONS_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerYear
+OBIS_MOST_OBSERVED_TAXA=org.gcube.dataanalysis.trendylyzeralgorithms.TaxaObservationsBarChartAlgorithm
+OBIS_TAXA_OBSERVATIONS_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.TaxaObservationsPerYearLineChart
+OBIS_SPECIES_OBSERVATIONS_PER_LME_AREA=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerLMEAreaPerYearLineChart
+OBIS_SPECIES_OBSERVATIONS_PER_MEOW_AREA=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerMEOWAreaPerYearLineChart
+MOST_OBSERVED_SPECIES=org.gcube.dataanalysis.trendylyzeralgorithms.AbsoluteSpeciesBarChartsAlgorithm
+SPECIES_OBSERVATIONS_TREND_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerYear
+MOST_OBSERVED_TAXA=org.gcube.dataanalysis.trendylyzeralgorithms.TaxaObservationsBarChartAlgorithm
+TAXONOMY_OBSERVATIONS_TREND_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.TaxaObservationsPerYearLineChart
+SPECIES_OBSERVATIONS_PER_AREA=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsAreaBarChart
+SPECIES_OBSERVATION_LME_AREA_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerLMEAreaPerYearLineChart
+SPECIES_OBSERVATION_MEOW_AREA_PER_YEAR=org.gcube.dataanalysis.trendylyzeralgorithms.SpeciesObservationsPerMEOWAreaPerYearLineChart
+GET_TAXA_ALGORITHM=org.gcube.dataanalysis.JobSMspd.TaxaProcedure
+GET_OCCURRENCES_ALGORITHM=org.gcube.dataanalysis.JobSMspd.OccurencesProcedure
+FIN_GSAY_MATCH=org.gcube.dataanalysis.fin.gsay.GSAYTransducer
+POINTS_TO_MAP=org.gcube.dataanalysis.geo.algorithms.PointsMapsCreator
+POLYGONS_TO_MAP=org.gcube.dataanalysis.geo.algorithms.PolygonMapsCreator
+SPECIES_MAP_FROM_CSQUARES=org.gcube.dataanalysis.geo.algorithms.SpeciesDistributionsMapsCreatorFromCsquares
+SPECIES_MAP_FROM_POINTS=org.gcube.dataanalysis.geo.algorithms.SpeciesDistributionsMapsCreatorFromPoints
+BIONYM_LOCAL=org.gcube.dataanalysis.executor.nodes.transducers.bionym.BionymLocalTransducer
\ No newline at end of file
diff --git a/cfg/userperspective.properties b/cfg/userperspective.properties
new file mode 100644
index 0000000..0e32d0f
--- /dev/null
+++ b/cfg/userperspective.properties
@@ -0,0 +1,18 @@
+ANOMALIES_DETECTION=DBSCAN,LOF,KMEANS,XMEANS
+CLASSIFICATION=FEED_FORWARD_A_N_N_DISTRIBUTION
+CLIMATE=BIOCLIMATE_HSPEC,BIOCLIMATE_HCAF,BIOCLIMATE_HSPEN,HCAF_INTERPOLATION
+CORRELATION_ANALYSIS=HRS
+DATA_CLUSTERING=DBSCAN,LOF,KMEANS,XMEANS
+FILTERING=HCAF_FILTER,HSPEN_FILTER
+FUNCTION_SIMULATION=FEED_FORWARD_A_N_N_DISTRIBUTION
+OCCURRENCES=ABSENCE_CELLS_FROM_AQUAMAPS,PRESENCE_CELLS_GENERATION,OCCURRENCES_MERGER,OCCURRENCES_INTERSECTOR,OCCURRENCES_MARINE_TERRESTRIAL,OCCURRENCES_DUPLICATES_DELETER,OCCURRENCES_SUBTRACTION
+PERFORMANCES_EVALUATION=QUALITY_ANALYSIS,DISCREPANCY_ANALYSIS
+SPECIES_SIMULATION=AQUAMAPS_SUITABLE,AQUAMAPS_NATIVE,AQUAMAPS_NATIVE_2050,AQUAMAPS_SUITABLE_2050,AQUAMAPS_NATIVE_NEURALNETWORK,AQUAMAPS_SUITABLE_NEURALNETWORK
+TRAINING=HSPEN,AQUAMAPSNN,FEED_FORWARD_ANN
+TIME_SERIES=HCAF_INTERPOLATION
+TAXA=FIN_TAXA_MATCH,BIONYM,BIONYM_BIODIV,BIONYM_LOCAL,FIN_GSAY_MATCH
+MAPS=MAPS_COMPARISON,DISCREPANCY_ANALYSIS,POINTS_TO_MAP,POLYGONS_TO_MAP,SPECIES_MAP_FROM_CSQUARES,SPECIES_MAP_FROM_POINTS
+BAYESIAN_METHODS=LWR,FEED_FORWARD_A_N_N_DISTRIBUTION
+OBIS_OBSERVATIONS_SPECIES_DATA=MOST_OBSERVED_SPECIES,MOST_OBSERVED_TAXA,SPECIES_OBSERVATIONS_PER_AREA
+OBIS_OBSERVATIONS_TRENDS=SPECIES_OBSERVATIONS_TREND_PER_YEAR,TAXONOMY_OBSERVATIONS_TREND_PER_YEAR,SPECIES_OBSERVATION_MEOW_AREA_PER_YEAR,SPECIES_OBSERVATION_LME_AREA_PER_YEAR
+SPD_PROCEDURES=GET_TAXA_ALGORITHM,GET_OCCURRENCES_ALGORITHM
\ No newline at end of file
diff --git a/files/SmartSampleOnTable.txt b/files/SmartSampleOnTable.txt
new file mode 100644
index 0000000..1c0329f
--- /dev/null
+++ b/files/SmartSampleOnTable.txt
@@ -0,0 +1,100 @@
+3712:100:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3214:110:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3803:237:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1215:476:3,5889,6272,6065,73.92,24.7,0.45,29.31,19.41,9.9,,34.93,,35.07,34.79,,252,0,0,0,0,0
+1701:131:1,1854,2090,1961,46.78,5.32,0.57,10.62,1.51,9.11,-0.96,35.04,,35.11,34.97,34.9099,369,4.7E-4,0,0,0,0
+1208:383:3,0,0,0,,,,,,,,,,,,,0,,,,,
+7007:384:4,0,0,0,,,,,,,,,,,,,0,,,,,
+7509:237:3,0,0,0,,,,,,,,,,,,,0,,,,,
+7012:360:2,3589,4357,4099,91.46,27.66,0.47,29.31,25.82,3.49,1.46,34.22,,34.6,33.91,34.6926,304,0,0,0,0,0
+7008:455:3,1523,2841,2032,373.74,28.16,0.54,30.93,26.11,4.82,2.31,32.62,,33.21,31.66,34.6493,325,0,0,0,0,0
+7806:114:4,0,600,369,179.81,-1.79,0,-1.54,-1.79,0.25,,30.45,,31.36,28.8,,169,0.88,0.95,0.78,0.84,0.94
+3000:215:4,1333,3759,3360,393.52,26.43,0.45,29.62,22.16,7.46,2.46,34.34,,35.53,33.29,34.8958,701,0,0,0,0,0
+5708:466:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3114:123:1,0,163,10,21.79,26.99,0.39,29.59,23.8,5.79,26.99,34.93,,35.58,34.15,34.8772,547,0,0,0,0,0
+5213:392:3,4125,4339,4197,33.44,21.53,0.44,26.26,17.8,8.46,1.49,35.37,,35.64,34.99,34.6944,136,0,0,0,0,0
+3608:229:2,3914,4276,4089,63.4,-1,0.1,1.37,-1.79,3.16,-0.26,33.81,,34.18,33.61,34.6651,304,0.33,0.05,0.64,0.61,0.01
+3005:114:2,4168,4777,4590,79.03,28.22,0.23,30.76,25.35,5.41,1.34,35.33,,35.48,35.14,34.7173,376,0,0,0,0,0
+1616:228:1,0,0,0,,,,,,,,,,,,,0,,,,,
+7611:495:4,0,0,0,,,,,,,,,,,,,0,,,,,
+7215:218:4,819,4520,2642,1134.08,25.38,0.3,27.73,23.36,4.37,1.72,35,,35.11,34.84,34.6492,227,0,0,0,0,0
+7213:384:2,3825,4712,4419,180.49,20.31,0.41,23.63,17.74,5.89,1.56,34.79,,35.13,34.65,34.6861,229,0,0,0,0,0
+1707:350:1,31,185,80,46.54,-1.67,0.13,0.64,-1.79,2.43,-1.34,29.53,,31.29,26.14,34.1963,521,0.69,0.95,0.44,0.39,0.96
+3512:123:2,4065,4637,4319,121.94,4.79,0.29,7.48,2.46,5.02,0.18,33.94,,34.08,33.8,34.6884,293,9.667e-,0,0,0,0
+5306:475:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3014:353:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1317:110:1,5391,5686,5527,54.8,21.65,0.43,27.17,16.48,10.69,1.5,34.78,,34.99,34.56,34.6963,324,0,0,0,0,0
+7500:496:3,140,1029,372,199.17,10.06,0.23,13.8,7.6,6.2,8.53,35.22,,35.27,35.18,35.3121,619,0,0,0,0,0
+3613:489:4,0,0,0,,,,,,,,,,,,,0,,,,,
+5015:489:2,3549,5818,4716,610.91,29.02,0.38,30.11,27.67,2.44,1.26,35.51,,35.76,35.19,34.7055,279,0,0,0,0,0
+1400:248:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1003:144:2,0,0,0,,,,,,,,,,,,,0,,,,,
+1700:476:3,1560,2640,2125,197.33,0.22,0.91,4.57,-1.79,6.36,-0.97,34.58,,34.9,34.24,34.9096,484,0.00157,0.00333,0,0,0
+1101:360:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3710:238:1,0,0,0,,,,,,,,,,,,,0,,,,,
+1109:219:2,0,114,59,32.51,28.95,0.27,30.98,27.11,3.87,28.55,31.6,,32.61,29.1,32.7094,828,0,0,0,0,0
+3005:206:3,4431,5008,4648,87.6,28.48,0.25,30.77,26.25,4.52,1.35,35.33,,35.49,35.07,34.7162,357,0,0,0,0,0
+7514:475:1,3730,4019,3853,41.42,7.96,0.43,15.67,3.7,11.97,1.47,32.35,,32.65,31.8,34.696,438,4.9E-4,0,0,0,0
+5304:475:2,5086,5177,5122,20.48,17.57,0.33,22.38,13.7,8.68,0.22,35.5,,35.89,35.12,34.6691,380,0,0,0,0,0
+3512:495:1,4615,4673,4634,13.29,1.11,0.26,4.12,-1.72,5.84,-0.2,33.92,,34.08,33.8,34.6847,215,4.0E-5,0,0,0,0
+5606:499:2,0,541,207,120.54,-1.76,0.07,-0.43,-1.79,1.36,-0.06,32.06,,32.4,31.54,34.4431,342,0.6,0.33,0.65,0.71,0.69
+3717:457:4,475,623,513,42.39,-1.79,0.01,-1.63,-1.79,0.16,-0.06,34.32,,34.5,34.24,34.7085,716,0.56,0.66,0.83,0.7,0.02
+3511:374:1,4512,4614,4550,15.01,1.71,0.3,4.44,-1.1,5.54,-0.11,33.95,,34.03,33.85,34.6796,210,9.667e-,0,0,0,0
+7406:495:4,197,369,300,44.07,4.47,0.87,15.02,-1.79,16.81,,29.5,,30.96,27.95,,182,0.1,0.11,0,0.01,0.27
+7511:465:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3107:103:3,4647,5465,5120,148.99,27.55,0.26,29.95,24.84,5.11,1.42,34.57,,35.06,34.12,34.715,273,0,0,0,0,0
+3317:495:3,0,27,13,9.05,15.9,0.48,20.66,12.53,8.13,15.19,35,,35.24,34.81,34.9984,101,0,0,0,0,0
+5806:468:4,0,0,0,,,,,,,,,,,,,0,,,,,
+3312:144:2,8,3740,1665,1441.75,17.63,0.34,21.02,14.85,6.17,2.51,35.75,,35.95,35.58,34.6496,557,0,0,0,0,0
+1202:360:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3801:351:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5505:371:3,2999,4241,3957,262.49,1.72,0.43,5.13,-1.51,6.64,0.03,33.99,,34.18,33.93,34.6731,265,0.01,0,0.03,0.01,0
+5509:216:4,4492,4979,4686,82.95,7.16,0.29,10.07,4.95,5.12,0.71,34.17,,34.22,34.11,34.7095,237,0,0,0,0,0
+1109:381:4,1921,2197,2041,49.84,28.08,0.3,30.62,24.75,5.87,2.69,30.67,,32.45,27.11,34.8055,701,0,0,0,0,0
+3715:476:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5706:390:1,1,1,1,0,-1.79,0,-1.78,-1.79,0.01,-1.38,34.49,,34.79,33.9,34.4578,0,1.5,1.5,1.5,1.5,1.5
+3305:206:4,3639,5326,4596,418.01,21.2,0.21,25.3,18,7.3,0.96,35.51,,35.6,35.4,34.7139,203,0,0,0,0,0
+5805:392:4,0,0,0,,,,,,,,,,,,,0,,,,,
+7200:226:3,0,0,0,,,,,,,,,,,,,0,,,,,
+3201:111:2,1142,2372,1695,307.26,18.2,0.34,22.52,15.27,7.25,3.33,35.29,,35.41,35.18,34.8833,180,0,0,0,0,0
+7003:372:4,2569,5496,4368,560.13,27.31,0.27,28.93,24.91,4.02,2.39,35.85,,36.12,35.49,34.9086,374,0,0,0,0,0
+3317:111:3,2672,4221,3383,339.74,19.89,0.42,23.91,17.04,6.87,1.86,35.79,,35.98,35.71,34.6866,321,0,0,0,0,0
+1313:373:2,300,1902,1376,307.88,17.07,0.58,27.99,9.06,18.93,0.16,33.88,,34.34,33,34.0637,525,0,0,0,0,0
+5015:496:4,1828,5706,5026,962.02,28.95,0.37,30.13,27.51,2.62,1.29,35.56,,35.79,35.19,34.7062,238,0,0,0,0,0
+5012:468:3,4236,4770,4565,101.81,26.93,0.53,29.99,24.99,5,1.46,35.52,,35.76,35.27,34.694,311,0,0,0,0,0
+5408:478:1,3831,4264,4081,90.62,8.82,0.35,11.9,6.3,5.6,0.89,33.96,,34.08,33.7,34.7117,226,0,0,0,0,0
+3206:456:2,3674,4807,4145,218.76,23.36,0.29,27.46,20.13,7.33,1.56,35.43,,35.56,35.26,34.7224,184,0,0,0,0,0
+1807:239:1,2630,3163,2925,147.72,-1.79,0,-1.78,-1.79,0.01,-0.78,31.19,,32.81,27.81,34.9295,0,0.93,0.98,0.89,0.87,0.96
+5608:130:2,4406,4617,4522,59.01,1.2,0.46,5.31,-1.39,6.7,0.46,33.89,,33.98,33.71,34.6962,170,0.00688,0,0.01,0.00666,0
+7209:458:2,0,0,0,,,,,,,,,,,,,0,,,,,
+7515:235:1,3936,4506,4302,105.49,7.16,0.4,13.88,3.18,10.7,1.51,32.55,,32.8,31.49,34.6837,491,6.7E-4,0,0,0,0
+3406:475:3,1256,2363,1969,270.64,4.79,0.36,8.43,2.49,5.94,1.7,33.86,,34.03,33.72,34.722,297,0,0,0,0,0
+1411:237:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1303:381:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3316:350:1,2366,4360,3305,506.59,19.16,0.38,24.43,15.73,8.7,1.28,35.7,,35.86,35.59,34.7234,374,0,0,0,0,0
+3417:132:1,0,0,0,,,,,,,,,,,,,0,,,,,
+7205:363:4,4699,6127,5466,334.74,25.31,0.2,28.84,22.24,6.6,2.11,36.98,,37.16,36.85,34.854,197,0,0,0,0,0
+5313:384:3,4921,5181,5027,52.25,15.12,0.35,19.63,11.63,8,1.26,34.41,,34.55,34.28,34.7122,262,0,0,0,0,0
+5417:248:1,411,1060,665,207.1,12.63,0.49,17.62,9.14,8.48,5.83,34.59,,34.74,34.26,34.3562,797,0,0,0,0,0
+5804:207:3,0,1,1,0,-1.79,0,-1.78,-1.79,0.01,,34.5,,34.77,34.06,,106,1.5,1.5,1.5,1.5,1.5
+7401:111:4,2738,4691,3679,499,16.44,0.34,20.57,13.05,7.52,2.63,35.81,,35.89,35.7,34.9243,541,0,0,0,0,0
+3312:100:2,0,0,0,,,,,,,,,,,,,0,,,,,
+1704:134:1,308,363,333,11.13,0.78,0.54,7.11,-1.79,8.9,-0.88,34.68,,34.84,34.47,34.9043,421,0.04,0.12,0.01,0,0.02
+7306:102:1,4584,5254,5003,128.8,23.88,0.22,28.88,19.53,9.35,2.24,36.62,,36.72,36.47,34.8884,252,0,0,0,0,0
+1315:465:3,5619,5801,5714,46.45,18.71,0.6,27.24,12.16,15.08,1.55,34.46,,34.64,34.26,34.693,424,0,0,0,0,0
+5417:394:3,5248,5536,5351,53.39,10.28,0.4,14.15,7.32,6.83,1.21,34.45,,34.71,34.34,34.7159,383,0,0,0,0,0
+5617:468:2,2942,3608,3293,209.01,-1.13,0.15,2.22,-1.79,4.01,0.09,34.02,,34.2,33.76,34.6875,261,0.34,0.04,0.6,0.66,0.05
+1012:362:4,326,4077,2526,1093.78,28.86,0.12,30.1,27.25,2.85,3.58,33.88,,34.29,33.36,34.5877,616,0,0,0,0,0
+1014:238:4,3404,5093,4312,372.23,29.41,0.22,30.24,28.21,2.03,1.53,34.38,,34.77,34.09,34.6879,247,0,0,0,0,0
+3708:373:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1407:486:4,0,0,0,,,,,,,,,,,,,0,,,,,
+7109:374:4,0,0,0,,,,,,,,,,,,,0,,,,,
+5109:468:3,3645,4184,3924,121.58,22.85,0.34,25.17,20.54,4.63,1.83,35.89,,36.2,35.58,34.6884,256,0,0,0,0,0
+3408:216:4,2439,2964,2707,95.29,12.37,0.33,15.67,10,5.67,2,34.78,,34.99,34.57,34.7453,389,0,0,0,0,0
+7113:374:4,4989,5295,5141,64.43,24.61,0.42,27.21,21.73,5.48,1.45,34.46,,34.72,34.18,34.6938,247,0,0,0,0,0
+7510:495:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3510:392:2,4090,4586,4384,64.91,0.02,0.29,2.8,-1.79,4.59,-0.15,33.95,,34.08,33.81,34.6813,219,0.02,0,0.01,0.06,0
+1817:488:3,1387,3509,2297,642.94,-1.79,0,-1.78,-1.79,0.01,-0.52,31.15,,31.74,30.65,34.951,0,1,1,1,1,1
+1207:353:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5512:206:4,3797,4078,3933,51.68,7.98,0.42,11.7,6.23,5.47,1.4,34.33,,34.41,34.2,34.7207,319,0,0,0,0,0
+1804:476:1,2846,3866,3433,308.99,-1.79,0,-1.78,-1.79,0.01,-0.6,31.95,,32.67,31.28,34.9552,0,0.94,0.98,0.93,0.9,0.97
diff --git a/files/table.txt b/files/table.txt
new file mode 100644
index 0000000..063ad74
--- /dev/null
+++ b/files/table.txt
@@ -0,0 +1,100 @@
+3214:370:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1514:228:3,1080,1320,1217,49.45,3.95,0.46,14.12,-1.79,15.91,2.3,32.66,,32.95,32.3,34.4143,572,0.1,0.21,0,0,0.2
+3302:459:4,4485,4698,4627,48.74,20.55,0.28,24,17.58,6.42,1.21,35.47,,35.52,35.35,34.7433,635,0,0,0,0,0
+5511:245:2,3156,3347,3278,32.85,6.24,0.49,9.43,4.32,5.11,1.29,34.17,,34.25,34.06,34.7168,283,0,0,0,0,0
+1007:456:4,2277,2607,2441,75.86,28.6,0.3,30.92,27.34,3.58,2.06,34.67,,35.43,33.71,34.7468,697,0,0,0,0,0
+5006:134:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1602:238:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3102:393:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3307:102:2,3521,4511,3866,182.68,20.17,0.3,24.72,16.23,8.49,1.12,35.77,,35.98,35.67,34.7112,170,0,0,0,0,0
+5716:248:4,3280,3498,3417,51.34,-1.79,0,-1.78,-1.79,0.01,0.31,34,,34.31,33.79,34.7005,388,0.75,0.81,0.93,0.91,0.39
+3706:111:4,0,0,0,,,,,,,,,,,,,0,,,,,
+3100:228:4,4469,4750,4598,77.81,23.32,0.47,28.18,18.91,9.27,2.39,35.9,,36.37,34.76,34.8874,662,0,0,0,0,0
+3802:142:2,0,0,0,,,,,,,,,,,,,0,,,,,
+7217:394:2,5097,5464,5317,67.82,22.27,0.5,27.24,17.19,10.05,1.55,35.1,,35.34,34.93,34.6917,267,0,0,0,0,0
+7115:458:3,4413,6028,5527,238.07,26.16,0.35,27.89,24.23,3.66,1.43,34.62,,34.96,34.44,34.6986,203,0,0,0,0,0
+3115:468:1,2646,3449,3112,197.07,27.13,0.37,29.63,24.39,5.24,1.88,35.07,,35.28,34.82,34.698,253,0,0,0,0,0
+1810:235:3,2370,3650,3427,342.62,-1.79,0,-1.78,-1.79,0.01,-0.71,30.63,,32.43,28.69,34.939,0,0.93,0.98,0.89,0.88,0.97
+3815:351:3,0,0,0,,,,,,,,,,,,,0,,,,,
+7512:458:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5605:218:1,570,5146,2644,1252.42,-0.53,0.3,2.35,-1.79,4.14,0.43,33.88,,34.04,33.61,34.6985,220,0.05,0.00333,0.13,0.08,0
+1603:133:1,0,0,0,,,,,,,,,,,,,0,,,,,
+1110:465:2,0,0,0,,,,,,,,,,,,,0,,,,,
+5005:238:4,0,0,0,,,,,,,,,,,,,0,,,,,
+3711:114:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1600:104:1,271,304,288,6.96,9.48,0.39,17.71,5.12,12.59,6.97,33.4,,34.06,32.13,35.1901,862,0.01,0.02,0,0,0.03
+7111:468:1,3034,4116,3825,202.95,25.98,0.31,28.57,23.68,4.89,1.5,34.17,,34.44,33.81,34.6885,332,0,0,0,0,0
+5313:134:4,4413,4800,4604,87.77,18.5,0.39,23.68,14.94,8.74,1.3,34.99,,35.26,34.76,34.7075,179,0,0,0,0,0
+7810:363:1,1596,2076,1832,188.49,-1.79,0,-1.78,-1.79,0.01,-0.4,30.94,,31.19,30.55,34.9299,0,0.97,0.99,0.96,0.95,0.99
+1717:352:1,97,180,138,22.07,-1.79,0,-1.76,-1.79,0.03,-1.04,29.35,,30.13,28.53,33.4049,0,0.92,0.97,0.84,0.87,0.97
+3404:382:3,3887,4494,4191,162.59,4.78,0.36,7.19,2.47,4.72,0.43,33.9,,34.12,33.77,34.651,322,8.25,0,0,0,0
+7515:476:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1709:123:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5205:114:1,0,0,0,,,,,,,,,,,,,0,,,,,
+7006:112:1,0,0,0,,,,,,,,,,,,,0,,,,,
+3513:487:1,4294,4692,4475,90.74,1.95,0.28,4.89,-0.32,5.21,-0.05,33.82,,33.91,33.72,34.6773,206,1.3E-4,0,0,0,0
+3102:370:2,0,0,0,,,,,,,,,,,,,0,,,,,
+5613:247:1,4237,4904,4573,173.63,-0.9,0.42,2.01,-1.79,3.8,0.24,33.92,,34.07,33.63,34.7061,165,0.2,0,0.21,0.51,0.06
+3517:352:2,5068,5548,5372,62.83,6.65,0.34,9.58,4.95,4.63,0.96,34.14,,34.39,33.95,34.707,287,0,0,0,0,0
+5201:103:2,2807,4255,3603,327.26,23.47,0.35,26.85,20.99,5.86,2.23,36.64,,36.79,36.46,34.8601,155,0,0,0,0,0
+3710:457:2,0,0,0,,,,,,,,,,,,,0,,,,,
+7406:350:4,0,131,21,29.77,6.73,0.33,18.93,-1.54,20.47,4.47,30.64,,31.26,29.89,30.8745,130,0.06,0.13,0,0.00487,0.13
+1602:382:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3208:392:3,4032,4337,4168,62.46,20.3,0.31,24.85,16.45,8.4,1.36,35.78,,36.03,35.67,34.7223,166,0,0,0,0,0
+1004:382:3,0,0,0,,,,,,,,,,,,,0,,,,,
+1406:372:3,0,0,0,,,,,,,,,,,,,0,,,,,
+3504:102:2,3980,4204,4075,52.37,3.06,0.28,5.55,1.2,4.35,0.2,33.95,,34.07,33.87,34.6437,348,2.667e-,0,0,0,0
+1316:124:4,6183,6290,6262,15.09,21.37,0.5,27.11,16.29,10.82,,34.67,,34.85,34.54,,376,0,0,0,0,0
+1603:487:3,0,121,68,30.23,3.98,0.6,10.49,-1.73,12.22,3.01,34.93,,35.2,34.75,34.6867,633,0.01,0.02,0.01,0.02,0.02
+3717:497:2,1,1,1,0,-1.79,0,-1.78,-1.79,0.01,-1.45,34.31,,34.54,33.98,34.3521,661,1.5,1.5,1.5,1.5,1.5
+3111:380:2,4117,5047,4532,218.35,26.05,0.43,29.54,23.3,6.24,1.18,34.79,,35.01,34.6,34.7135,255,0,0,0,0,0
+7503:228:2,2978,3873,3569,175.58,8.44,0.66,14.13,4.87,9.26,2.64,34.71,,34.9,34.44,34.9337,629,0,0,0,0,0
+3312:237:2,3,862,344,269.72,17.86,0.29,21.21,14.9,6.31,11.84,35.81,,36.04,35.56,35.1271,622,0,0,0,0,0
+1604:100:4,0,0,0,,,,,,,,,,,,,0,,,,,
+5805:207:1,1,1,1,0,-1.79,0,-1.78,-1.79,0.01,-1.3,34.64,,34.92,34.24,34.6741,0,1.5,1.5,1.5,1.5,1.5
+3808:486:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1113:111:4,5468,6222,5905,126.52,28.77,0.26,30.48,26.93,3.55,,34.21,,34.43,34.01,,194,0,0,0,0,0
+5504:459:4,3503,4373,3978,241.42,3.39,0.47,6.6,-0.19,6.79,0.32,33.99,,34.09,33.86,34.6805,311,6.833e-,0,0,0,0
+3015:478:1,0,2301,880,817.09,29.26,0.34,30.5,27.3,3.2,4.84,34.63,,35.06,34.22,34.5298,392,0,0,0,0,0
+7001:487:4,1974,4794,4251,503.36,27.47,0.34,29.33,24.24,5.09,2.3,35.12,,35.77,34.45,34.8818,548,0,0,0,0,0
+1202:469:2,0,0,0,,,,,,,,,,,,,0,,,,,
+3809:143:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1303:123:3,1226,1584,1385,89.6,21.98,0.31,28.4,16.09,12.31,13.63,39.09,,39.29,38.84,38.7163,317,0,0,0,0,0
+5406:102:2,0,0,0,,,,,,,,,,,,,0,,,,,
+5116:228:4,5100,5258,5181,27.52,28.82,0.29,30.09,27.09,3,1.09,35.3,,35.76,34.9,34.7102,207,0,0,0,0,0
+7305:380:2,5152,5443,5393,34.25,21.41,0.25,27.56,17.45,10.11,2.27,36.15,,36.31,35.84,34.8778,374,0,0,0,0,0
+3709:226:4,0,0,0,,,,,,,,,,,,,0,,,,,
+1808:133:3,3273,3484,3392,55.93,-1.79,0,-1.78,-1.79,0.01,-0.7,30.72,,32.6,27.39,34.9412,0,0.93,0.98,0.89,0.88,0.96
+7807:248:3,1171,1276,1199,25.78,-1.79,0,-1.78,-1.79,0.01,-0.19,30.52,,31.41,29.24,34.9273,0,0.98,0.99,0.96,0.97,0.99
+7710:225:3,0,44,11,13.03,-1.79,0.02,-1.29,-1.79,0.5,-0.84,30.95,,37.68,27.2,31.0727,49,0.82,0.91,0.69,0.79,0.89
+7312:371:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5212:122:1,3115,3815,3527,187.11,25.03,0.25,27.63,22.24,5.39,1.7,36.44,,36.68,36.14,34.6819,127,0,0,0,0,0
+5410:465:2,3154,3727,3575,83.87,9.48,0.32,13.08,6.87,6.21,1.35,34.12,,34.22,34.02,34.7125,245,0,0,0,0,0
+3610:372:3,0,0,0,,,,,,,,,,,,,0,,,,,
+3010:103:2,0,64,10,9.18,29.1,0.35,31.21,27.1,4.11,29.11,29.87,,31.57,27.72,30.2693,183,0,0,0,0,0
+3204:144:4,0,0,0,,,,,,,,,,,,,0,,,,,
+3109:487:3,5178,5741,5503,75.15,24.94,0.38,27.5,22.65,4.85,1.17,34.71,,34.99,34.53,34.7109,218,0,0,0,0,0
+5416:218:3,4236,4744,4580,91.81,14.1,0.54,19.23,10.43,8.8,0.89,34.84,,34.91,34.66,34.706,371,0,0,0,0,0
+3217:218:1,3375,4010,3710,141.95,25.18,0.39,28.43,21.84,6.59,1.85,35.39,,35.59,35.19,34.6822,301,0,0,0,0,0
+5706:110:2,0,37,19,9.76,-1.79,0,-1.78,-1.79,0.01,-1.62,34.16,,34.61,33.2,34.2117,210,0.88,0.89,0.89,0.87,0.88
+7708:110:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5107:225:2,0,0,0,,,,,,,,,,,,,0,,,,,
+7015:140:1,4730,5183,5003,78.85,27.81,0.64,29.86,24.94,4.92,1.43,34.81,,34.88,34.71,34.695,357,0,0,0,0,0
+3009:477:1,4152,5179,4685,222.74,28.49,0.38,30.45,25.89,4.56,1.17,34.09,,34.38,33.62,34.7137,274,0,0,0,0,0
+3414:478:4,1057,1673,1340,169.31,10.41,0.43,13.23,8.46,4.77,3.29,34.61,,34.8,34.36,34.429,393,0,0,0,0,0
+7200:142:3,0,0,0,,,,,,,,,,,,,0,,,,,
+5314:364:1,4516,5384,4890,166.04,16.27,0.32,21.4,13,8.4,1.2,34.74,,34.87,34.57,34.7034,246,0,0,0,0,0
+7306:390:1,4322,5333,5132,137.96,21.54,0.37,27.23,16.05,11.18,2.28,35.67,,36.09,35.35,34.8922,495,0,0,0,0,0
+5700:390:3,0,0,0,,,,,,,,,,,,,0,,,,,
+3106:485:3,2042,3309,2699,250.96,25.62,0.28,28.86,22.75,6.11,1.86,34.85,,35.16,34.67,34.7201,203,0,0,0,0,0
+5707:371:4,1,1,1,0,-1.79,0,-1.78,-1.79,0.01,-1.7,33.9,,34.25,33.5,33.4427,0,1.5,1.5,1.5,1.5,1.5
+7602:123:2,1285,1531,1359,56.7,8.32,0.32,12.4,5.81,6.59,3.78,35.25,,35.33,35.14,34.9939,441,0,0,0,0,0
+3712:390:1,0,0,0,,,,,,,,,,,,,0,,,,,
+1412:372:4,0,0,0,,,,,,,,,,,,,0,,,,,
+5700:217:2,0,103,43,29.45,-1.78,0.01,-1.55,-1.79,0.24,-1.72,34.11,,34.56,33.45,34.2757,187,1.5,1.5,1.5,1.5,1.5
+1616:102:1,0,69,55,17.46,2.82,0.37,12.45,-1.79,14.24,0.41,32.36,,33,31.51,32.7001,908,0.34,0.53,0.03,0.08,0.7
+7501:361:2,2571,2809,2668,54.47,11.33,0.26,15.48,9.1,6.38,3.08,35.34,,35.42,35.27,34.9611,501,0,0,0,0,0
+5413:495:4,4357,4747,4546,92.09,8.74,0.44,12.57,6.41,6.16,1.28,34.33,,34.51,34.19,34.7173,281,0,0,0,0,0
+1007:485:1,1563,2842,2458,320.42,28.53,0.29,31.05,26.28,4.77,2.07,34.54,,35.09,33.44,34.7277,907,0,0,0,0,0
+7114:229:2,5187,5440,5317,54.71,26.63,0.34,28.64,24.51,4.13,1.47,34.36,,34.68,34.04,34.6959,248,0,0,0,0,0
+7414:101:3,4582,4876,4718,53.09,14.79,0.75,21.34,9.31,12.03,1.54,33.32,,33.43,33.06,34.6921,430,0,0,0,0,0
diff --git a/log.txt b/log.txt
new file mode 100644
index 0000000..04a9dc3
--- /dev/null
+++ b/log.txt
@@ -0,0 +1,44 @@
+0 [main] INFO org.gcube.common.scope.impl.ScopeProviderScanner - using scope provider org.gcube.common.scope.impl.DefaultScopeProvider@685e95ae
+633 [main] INFO org.gcube.common.scan.DefaultScanner - matched 13 resources from 62 urls in 313 ms
+653 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/d4science.servicemap
+682 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/vo1.servicemap
+683 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/openbio.servicemap
+685 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/cnr.servicemap
+687 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/testing.servicemap
+689 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/gcube.servicemap
+690 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/farm.servicemap
+692 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/isti.servicemap
+694 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/gcubeapps.servicemap
+696 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/ecosystem.servicemap
+697 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/securevo.servicemap
+699 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/devsec.servicemap
+701 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/devnext.servicemap
+879 [main] INFO org.gcube.common.clients.stubs.jaxws.StubFactory - fetching wsdl for XQueryAccessService at http://dlib01.isti.cnr.it:8080/wsrf/services/gcube/informationsystem/collector/XQueryAccess?wsdl
+1420 [main] INFO org.gcube.resources.discovery.icclient.ICClient - executing query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RuntimeResource')//Document/Data/ic:Profile/Resource where ($resource/Profile/Category/text() eq 'Database') return $resource
+1497 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ScopeHandler@1c7c0f04
+1498 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.TargetServiceHandler@16bc6a12
+1499 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ClientInfoHandler@2f1c7c32
+1500 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.LegacyWSAddressingHandler@281de7b2
+1624 [main] INFO org.gcube.resources.discovery.icclient.ICClient - executed query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RuntimeResource')//Document/Data/ic:Profile/Resource where ($resource/Profile/Category/text() eq 'Database') return $resource in 204 ms
+0 [main] INFO org.gcube.common.scope.impl.ScopeProviderScanner - using scope provider org.gcube.common.scope.impl.DefaultScopeProvider@3c22d5b5
+508 [main] INFO org.gcube.common.scan.DefaultScanner - matched 13 resources from 62 urls in 314 ms
+529 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/d4science.servicemap
+557 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/vo1.servicemap
+559 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/openbio.servicemap
+560 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/cnr.servicemap
+562 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/testing.servicemap
+564 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/gcube.servicemap
+566 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/farm.servicemap
+568 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/isti.servicemap
+570 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/gcubeapps.servicemap
+572 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/ecosystem.servicemap
+574 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/securevo.servicemap
+576 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/devsec.servicemap
+578 [main] INFO org.gcube.common.scope.impl.ServiceMapScanner - loading jar:file:/home/loredana/.m2/repository/org/gcube/core/common-scope-maps/1.0.2-SNAPSHOT/common-scope-maps-1.0.2-SNAPSHOT.jar!/devnext.servicemap
+717 [main] INFO org.gcube.common.clients.stubs.jaxws.StubFactory - fetching wsdl for XQueryAccessService at http://dlib01.isti.cnr.it:8080/wsrf/services/gcube/informationsystem/collector/XQueryAccess?wsdl
+892 [main] INFO org.gcube.resources.discovery.icclient.ICClient - executing query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RuntimeResource')//Document/Data/ic:Profile/Resource where ($resource/Profile/Category/text() eq 'Database') return $resource
+926 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ScopeHandler@3d48392b
+927 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.TargetServiceHandler@657189ad
+928 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.ClientInfoHandler@45f2a7e9
+929 [main] INFO org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry - loaded call handler org.gcube.common.clients.stubs.jaxws.handlers.LegacyWSAddressingHandler@5eb85400
+1022 [main] INFO org.gcube.resources.discovery.icclient.ICClient - executed query declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; for $resource in collection('/db/Profiles/RuntimeResource')//Document/Data/ic:Profile/Resource where ($resource/Profile/Category/text() eq 'Database') return $resource in 130 ms
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..84097f9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,147 @@
+
+ 4.0.0
+
+ org.gcube.dataanalysis
+ 1.0.0-SNAPSHOT
+
+
+ org.gcube.tools
+ maven-parent
+ 1.0.0
+
+
+
+ org.gcube.contentmanagement
+ storage-manager-core
+ [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+
+
+
+ org.gcube.core
+ common-scope-maps
+ [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ provided
+
+
+ org.gcube.resources.discovery
+ ic-client
+ [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ provided
+
+
+
+
+ org.gcube.contentmanagement
+ storage-manager-wrapper
+ [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ provided
+
+
+
+ junit
+ junit
+ 4.11
+
+
+ org.gcube.core
+ common-scope
+ [1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ provided
+
+
+
+ org.gcube.resources
+ common-gcore-resources
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+ provided
+
+
+
+
+ org.gcube.core
+ common-encryption
+ [1.0.1-SNAPSHOT,3.0.0-SNAPSHOT)
+ provided
+
+
+
+ org.gcube.dataanalysis
+ ecological-engine
+ [1.7.2-SNAPSHOT,1.8.0-SNAPSHOT)
+
+
+ postgresql
+ postgresql
+
+
+
+
+
+
+
+
+
+
+
+ com.mysql
+ mysql-connector
+ 5.1.7
+
+
+
+ postgresql
+ postgresql
+ 9.1-901-1.jdbc4
+
+
+ org.gcube.resources.discovery
+ discovery-client
+ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
+
+
+
+ rapidminer-custom
+ swissql-api
+ 1.0.0
+
+
+
+
+
+
+
+
+
+
+
+
+ dnet-deps
+ dnet-deps
+ http://maven.research-infrastructures.eu/nexus/content/repositories/dnet-deps//
+
+
+
+
+
+
+ maven-assembly-plugin
+
+
+ jar-with-dependencies
+
+
+
+
+ package
+
+ single
+
+
+
+
+
+
+ databases-resources-manager
+
diff --git a/src/main/java/org/gcube/dataanalysis/databases/access/DatabasesDiscoverer.java b/src/main/java/org/gcube/dataanalysis/databases/access/DatabasesDiscoverer.java
new file mode 100644
index 0000000..6e73f60
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/access/DatabasesDiscoverer.java
@@ -0,0 +1,37 @@
+package org.gcube.dataanalysis.databases.access;
+
+import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
+import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
+
+import java.util.List;
+
+import org.gcube.common.resources.gcore.ServiceEndpoint;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+import org.gcube.resources.discovery.client.api.DiscoveryClient;
+import org.gcube.resources.discovery.client.api.DiscoveryException;
+import org.gcube.resources.discovery.client.api.InvalidResultException;
+import org.gcube.resources.discovery.client.queries.impl.XQuery;
+
+
+/** Class that allows to discover databases submitting a query to the IS.
+ * It retrieves a list of DBResource object */
+public class DatabasesDiscoverer extends ResourceDiscoverer{
+
+ public DatabasesDiscoverer(){
+
+
+ }
+
+ /** Method that performs the discovery process of database resources */
+ public List discover() throws IllegalStateException, DiscoveryException, InvalidResultException{
+
+ XQuery query = queryFor(ServiceEndpoint.class);
+ query.addCondition("$resource/Profile/Category/text() eq 'Database'");
+
+ DiscoveryClient discovery = clientFor(DBResource.class);
+ List resources = discovery.submit(query);
+
+ return resources;
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/access/ResourceDiscoverer.java b/src/main/java/org/gcube/dataanalysis/databases/access/ResourceDiscoverer.java
new file mode 100644
index 0000000..5dcdf96
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/access/ResourceDiscoverer.java
@@ -0,0 +1,13 @@
+package org.gcube.dataanalysis.databases.access;
+
+import java.util.List;
+
+import org.gcube.dataanalysis.databases.resources.DBResource;
+
+/** Class that allows to discover generic resources submitting a query to the IS.
+ * It retrieves a list of DBResource objects. */
+public abstract class ResourceDiscoverer {
+
+
+ public abstract List discover();
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/accessold/AddressesDiscoverer.java b/src/main/java/org/gcube/dataanalysis/databases/accessold/AddressesDiscoverer.java
new file mode 100644
index 0000000..b81ceec
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/accessold/AddressesDiscoverer.java
@@ -0,0 +1,63 @@
+package org.gcube.dataanalysis.databases.accessold;
+
+import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
+import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.gcube.common.resources.gcore.ServiceEndpoint;
+import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+import org.gcube.resources.discovery.client.api.DiscoveryClient;
+import org.gcube.resources.discovery.client.queries.impl.XQuery;
+
+/**
+ * Class that, allowing to set a scope and to submit a query to the IS, recover
+ * a list of url for each DBResource object
+ */
+
+public class AddressesDiscoverer {
+
+ /** Method to set the scope */
+ public void setScope(String scope) {
+
+ ScopeProvider.instance.set(scope);
+
+ }
+
+ /** Method to recover the url's list */
+ public List retrieveAddress(String Category) {
+
+ List addresses = new ArrayList();
+
+ XQuery query = queryFor(ServiceEndpoint.class);
+ query.addCondition("$resource/Profile/Category/text() eq '" + Category
+ + "'");
+
+ DiscoveryClient submitop = clientFor(DBResource.class);
+ List access = submitop.submit(query);
+
+ // System.out.println("size resource: "+access.size());
+
+ int APsize = 0;
+ String address = "";
+
+ for (int i = 0; i < access.size(); i++) {
+
+ APsize = access.get(i).getAccessPoints().size();
+
+ for (int j = 0; j < APsize; j++) {
+
+ address = access.get(i).getAccessPoints().get(j).address();
+ addresses.add(address);
+
+ }
+
+ }
+
+ return addresses;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/accessold/DatabasesDiscoverer.java b/src/main/java/org/gcube/dataanalysis/databases/accessold/DatabasesDiscoverer.java
new file mode 100644
index 0000000..0e7df88
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/accessold/DatabasesDiscoverer.java
@@ -0,0 +1,38 @@
+package org.gcube.dataanalysis.databases.accessold;
+
+import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
+import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
+
+import java.util.List;
+
+import org.gcube.common.resources.gcore.ServiceEndpoint;
+import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+import org.gcube.resources.discovery.client.api.DiscoveryClient;
+import org.gcube.resources.discovery.client.queries.impl.XQuery;
+
+
+/** Class that allows to discover databases submitting a query to the IS and given a certain scope.
+ * It retrieves a list of DBResource object */
+public class DatabasesDiscoverer extends ResourceDiscoverer{
+
+ public DatabasesDiscoverer(){
+
+
+ }
+
+ /** Method that performs the discovery process of database resources */
+ public List discovery(String scope) {
+
+ ScopeProvider.instance.set(scope);
+
+ XQuery query = queryFor(ServiceEndpoint.class);
+ query.addCondition("$resource/Profile/Category/text() eq 'Database'");
+
+ DiscoveryClient discovery = clientFor(DBResource.class);
+ List resources = discovery.submit(query);
+
+ return resources;
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/accessold/ResourceDiscoverer.java b/src/main/java/org/gcube/dataanalysis/databases/accessold/ResourceDiscoverer.java
new file mode 100644
index 0000000..c04b047
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/accessold/ResourceDiscoverer.java
@@ -0,0 +1,15 @@
+package org.gcube.dataanalysis.databases.accessold;
+
+import java.util.List;
+
+import org.gcube.dataanalysis.databases.resources.DBResource;
+
+/** Class that allows to discover generic resources submitting a query to the IS and given a certain scope.
+ * It retrieves a list of DBResource objects. */
+public abstract class ResourceDiscoverer {
+
+
+ public abstract List discovery(String scope);
+
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/converter/SqlDialectConverter.java b/src/main/java/org/gcube/dataanalysis/databases/converter/SqlDialectConverter.java
new file mode 100644
index 0000000..dd3e88a
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/converter/SqlDialectConverter.java
@@ -0,0 +1,36 @@
+package org.gcube.dataanalysis.databases.converter;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+
+import com.adventnet.swissqlapi.SwisSQLAPI;
+import com.adventnet.swissqlapi.sql.exception.ConvertException;
+import com.adventnet.swissqlapi.sql.parser.ParseException;
+
+/**
+ * Class that allows to convert a query specifying a sql dialect by means of a SwisSQL API
+ */
+public class SqlDialectConverter {
+
+ private SwisSQLAPI obj;
+
+ // Constructor
+ public SqlDialectConverter(String query) {
+
+ obj = new SwisSQLAPI(query);
+
+ }
+
+ public String convert(int dialect) throws ParseException, ConvertException {
+
+ String queryConverted = null;
+
+ queryConverted = obj.convert(dialect);
+
+ AnalysisLogger.getLogger().debug(
+ "In SqlDialectConverter-> query converted: " + queryConverted);
+
+ return queryConverted;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/lexer/LexicalAnalyzer.java b/src/main/java/org/gcube/dataanalysis/databases/lexer/LexicalAnalyzer.java
new file mode 100644
index 0000000..342b871
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/lexer/LexicalAnalyzer.java
@@ -0,0 +1,203 @@
+package org.gcube.dataanalysis.databases.lexer;
+
+import java.util.ArrayList;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+
+/**
+ * Class that allows to filter queries no read-only compliant by means of a
+ * lexical analysis
+ */
+public class LexicalAnalyzer {
+
+ private ArrayList BlackList = new ArrayList(); // Keywords'
+
+ // blacklist
+
+ // Method that performs the lexical analysis
+ public boolean analyze(String query) throws Exception {
+
+ boolean NotAllowed = false;
+
+ // building the keywords' blacklist
+ // the following keywords are common for MySQL and PostgreSQL databases.
+
+ BlackList.add("INSERT");
+ BlackList.add("DELETEÂ ");
+ BlackList.add("UPDATEÂ ");
+ BlackList.add("CREATE");
+ BlackList.add("ALTER");
+ BlackList.add("DROP");
+ BlackList.add("GRANT");
+ BlackList.add("REVOKE");
+ BlackList.add("TRUNCATE");
+
+ BlackList.add("DO");
+ BlackList.add("START TRANSACTION");
+ BlackList.add("COMMIT");
+ BlackList.add("BEGIN");
+ BlackList.add("ROLLBACK");
+ BlackList.add("SET");
+ BlackList.add("SAVEPOINT");
+ BlackList.add("RELEASE SAVEPOINT");
+ BlackList.add("LOCK");
+
+ BlackList.add("DECLARE");
+ BlackList.add("PREPARE");
+ BlackList.add("FETCH");
+ // BlackList.add("EXPLAIN");
+ BlackList.add("ANALYZE");
+ BlackList.add("EXECUTE");
+ BlackList.add("SHOW");
+ BlackList.add("RESET");
+
+ String queryParsed = null;
+
+ int NumOfBlackList = BlackList.size();
+
+ AnalysisLogger.getLogger().debug(
+ "LexicalAnalyzer->blacklist size: " + NumOfBlackList);
+
+ // System.out.println("size blacklist: " + NumOfBlackList);
+
+ // parse the query using the regular expressions
+ queryParsed = LexicalAnalyzer.parseRegularExpressions(query);
+
+ // check if the query contains a word defined in the blacklist
+ NotAllowed = check(queryParsed);
+
+ AnalysisLogger.getLogger().debug(
+ "LexicalAnalyzer->query not allowed: " + NotAllowed);
+
+ if (NotAllowed == true) {
+
+ throw new Exception("Only read-only queries are allowed");
+
+ }
+
+ return NotAllowed;
+
+ }
+
+ // Method that checks if the query contains a word defined in the blacklist
+ public boolean check(String query) {
+
+ boolean NotAllowed = false;
+
+ check_tokens: for (int j = 0; j < BlackList.size(); j++) {
+
+ // System.out.println("BlackList word: " + BlackList.get(j));
+
+ // keyword check with regex regular expression
+
+ String Keyword = BlackList.get(j);
+
+ String regex = ".*\\b" + Keyword.replaceAll(" +", "[ ]\\+")
+ + "\\b.*";
+
+ if (query.toUpperCase().matches(regex)) {
+
+ NotAllowed = true;
+
+ break check_tokens;
+
+ }
+
+ // if (Keyword.contains(" ")) {
+ //
+ // String[] arrayKeyword = Keyword.split(" ");
+ //
+ // int i;
+ // // boolean notContained = false;
+ //
+ // String Regex = "";
+ // String regexKeyword = regexKeyword = ".*\\b" + arrayKeyword[0]
+ // + "\\s*";
+ // Regex = regexKeyword;
+ //
+ // for (i = 1; i < arrayKeyword.length; i++) {
+ //
+ // if (i == arrayKeyword.length - 1) {
+ //
+ // Regex = Regex + arrayKeyword[i] + "\\b.*";
+ //
+ // } else {
+ //
+ // Regex = Regex + arrayKeyword[i] + "\\s*";
+ //
+ // }
+ //
+ // }
+ //
+ // if (query.toUpperCase().matches(Regex)) {
+ //
+ // // notContained = true;
+ //
+ // AnalysisLogger.getLogger().debug(
+ // "LexicalAnalyzer-> : the query contains the word in the blacklist "
+ // + BlackList.get(j));
+ //
+ // NotAllowed = true;
+ //
+ // break check_tokens;
+ //
+ // }
+ //
+ // } else {
+ //
+ // String regexKeyword = ".*\\b" + BlackList.get(j) + "\\b.*";
+ //
+ // if (query.toUpperCase().matches(regexKeyword)) {
+ //
+ // AnalysisLogger.getLogger().debug(
+ // "LexicalAnalyzer-> : the query contains the word in the blacklist "
+ // + BlackList.get(j));
+ //
+ // NotAllowed = true;
+ //
+ // break check_tokens;
+ //
+ // }
+ //
+ // }
+
+ }
+
+ return NotAllowed;
+
+ }
+
+ public ArrayList getBlackList() {
+
+ return BlackList;
+
+ }
+
+ private static String parseRegularExpressions(String phrase) {
+
+ // replacement of the punctuation characters
+ // String todelete = "[\\]\\[!#$%&()*+,./:;<=>?@\\^_{|}~-]";
+ String todelete = "[\\]\\[!#$%&()*+,./:;<=>?@\\^{|}~-]";
+ phrase = phrase.replaceAll(todelete, " ");
+ phrase = phrase.replaceAll("[ ]+", " ");
+
+ AnalysisLogger.getLogger().debug(
+ "LexicalAnalyzer-> : replacing query " + phrase);
+
+ // elimination by means of a replacement of the word enclosed in '',
+ // "",``
+ String apex = "'.*'";
+ phrase = phrase.replaceAll(apex, "");
+ String apex2 = "\".*\"";
+ phrase = phrase.replaceAll(apex2, "");
+ String apex3 = "`.*`";
+ phrase = phrase.replaceAll(apex3, "");
+
+ AnalysisLogger.getLogger().debug(
+ "LexicalAnalyzer-> : parsed string " + phrase);
+
+ return phrase;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/lexer/MySQLLexicalAnalyzer.java b/src/main/java/org/gcube/dataanalysis/databases/lexer/MySQLLexicalAnalyzer.java
new file mode 100644
index 0000000..180cdb7
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/lexer/MySQLLexicalAnalyzer.java
@@ -0,0 +1,56 @@
+package org.gcube.dataanalysis.databases.lexer;
+
+import java.util.ArrayList;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+
+/**
+ * Class that allows to filter queries no read-only compliant considering the
+ * MySQL database and by means of a lexical analysis
+ */
+
+public class MySQLLexicalAnalyzer extends LexicalAnalyzer {
+
+
+
+ public MySQLLexicalAnalyzer() {
+
+ ArrayList BlackList = new ArrayList(); // Keywords' blacklist
+ BlackList = super.getBlackList();
+
+ updateBlackList(BlackList);
+
+ }
+
+ // update the keywords' blacklist
+ private void updateBlackList(ArrayList BlackList) {
+
+ // Mysql's keywords
+ BlackList.add("RENAME");
+ BlackList.add("REPLACE");
+ BlackList.add("LOAD DATA INFILE");
+ BlackList.add("CALL");
+ BlackList.add("HANDLER");
+ BlackList.add("UNLOCK");
+ BlackList.add("DEALLOCATE PREPARE");
+ BlackList.add("OPEN");
+ BlackList.add("CLOSE");
+ BlackList.add("BACKUP");
+ BlackList.add("CHECK");
+ BlackList.add("CHECKSUM");
+ BlackList.add("OPTIMIZE");
+ BlackList.add("REPAIR");
+ BlackList.add("RESTORE");
+ BlackList.add("CACHE");
+ BlackList.add("FLUSH");
+ BlackList.add("KILL");
+ BlackList.add("LOAD INDEX INTO CACHE");
+ BlackList.add("PURGE BINARY LOGS");
+// BlackList.add("RESET");
+
+ AnalysisLogger.getLogger().debug(
+ "MySQLLexicalAnalyzer->: blacklist updated");
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/lexer/PostgresLexicalAnalyzer.java b/src/main/java/org/gcube/dataanalysis/databases/lexer/PostgresLexicalAnalyzer.java
new file mode 100644
index 0000000..13db1b3
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/lexer/PostgresLexicalAnalyzer.java
@@ -0,0 +1,67 @@
+package org.gcube.dataanalysis.databases.lexer;
+
+import java.util.ArrayList;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+
+/**
+ * Class that allows to filter queries no read-only compliant considering the
+ * Postgres database and by means of a lexical analysis
+ */
+public class PostgresLexicalAnalyzer extends LexicalAnalyzer {
+
+// private ArrayList BlackList = new ArrayList(); // Keywords'
+
+ // blacklist
+
+ public PostgresLexicalAnalyzer() {
+ ArrayList BlackList = new ArrayList(); // Keywords' blacklist
+ BlackList = super.getBlackList();
+
+ updateBlackList(BlackList);
+
+ }
+
+ // update the keywords' blacklist
+ private void updateBlackList(ArrayList BlackList) {
+
+ // Keywords'
+ // blacklist
+
+ BlackList.add("COPY");
+ BlackList.add("COMMENT");
+ BlackList.add("SELECT INTO");
+ BlackList.add("UNLISTEN");
+ BlackList.add("VACUUM");
+ BlackList.add("VALUES");
+ BlackList.add("SECURITY LABEL");
+ BlackList.add("REASSIGN OWNED");
+ BlackList.add("ABORT");
+ BlackList.add("CHECKPOINT");
+ BlackList.add("CLOSE");
+ BlackList.add("CLUSTER");
+ BlackList.add("DEALLOCATE");
+ BlackList.add("DISCARD");
+ BlackList.add("END");
+ BlackList.add("LISTEN");
+ BlackList.add("LOAD");
+ BlackList.add("MOVE");
+ BlackList.add("NOTIFY");
+ BlackList.add("REFRESH MATERIALIZED VIEW");
+ BlackList.add("REINDEX");
+// BlackList.add("RESET");
+
+ // BlackList.add("SET ROLE");
+
+ // BlackList.add("SET SESSION AUTHORIZATION");
+
+ // BlackList.add("SET TRANSACTION");
+
+ // BlackList.add("SET CONSTRAINTS");
+
+ AnalysisLogger.getLogger().debug(
+ "PostgresLexicalAnalyzer->: blacklist updated");
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/resources/DBResource.java b/src/main/java/org/gcube/dataanalysis/databases/resources/DBResource.java
new file mode 100644
index 0000000..77eba9d
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/resources/DBResource.java
@@ -0,0 +1,803 @@
+package org.gcube.dataanalysis.databases.resources;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.gcube.common.encryption.StringEncrypter;
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+import org.gcube.dataanalysis.databases.resources.processing.Normalizer;
+
+/** Class that describes a resource database considering information specified from the user in a xml file.
+ * Information are retrieved from the xml file Through the JAXB and the relative object is initialized */
+
+//Database Resource Description class
+@XmlRootElement(name = "Resource")
+public class DBResource {
+
+ // Variables
+ private String ResourceName;
+ private String PlatformName;
+ private String PlatformVersion;
+ private String HostedOn;
+ private String Port = null;
+ private String dbguessed = null;
+
+ @XmlElement(name = "ID")
+ private String id;
+
+ @XmlElementRef
+ private Profile profile;
+
+ // Methods
+ public String getID() {
+
+ if (id == null)
+ id = "";
+
+ return id;
+
+ }
+
+ public String getPort() {
+
+ if (Port == null) {
+
+ Port = "";
+
+ }
+
+ return Port;
+
+ }
+
+ public void setPort(String value) {
+
+ Port = value;
+
+ }
+
+ public String getResourceName() {
+
+ ResourceName = this.profile.getname().trim();
+
+ return ResourceName;
+
+ }
+
+ public String getHostedOn() {
+
+ HostedOn = this.profile.getHostedOn();
+
+ return HostedOn;
+
+ }
+
+ public String getPlatformName() {
+
+ PlatformName = this.profile.getPlatformName();
+
+ if (PlatformName.contains(" ")) {
+
+ PlatformName = PlatformName.trim();
+
+ }
+
+ return PlatformName;
+
+ }
+
+ public void setPlatformName(String name) {
+
+ this.profile.platform.name = name;
+
+ }
+
+ public String getPlatformVersion() {
+
+ PlatformVersion = this.profile.getPlatformVersion();
+
+ return PlatformVersion;
+
+ }
+
+ public void setHostedOn(String value) {
+
+ HostedOn = value;
+
+ }
+
+ public String getDBguessed() {
+
+ return dbguessed;
+
+ }
+
+ public void setDBguessed(String name) {
+
+ dbguessed = name;
+
+ }
+
+ public void normalize(int index) throws IOException{
+
+ try {
+ Normalizer.normalize(this, index);
+ } catch (IOException e) {
+
+// e.printStackTrace();
+
+ throw e;
+ }
+
+ }
+
+ public List getAccessPoints() {
+
+ List ap = this.profile.accessPoints();
+
+ return ap;
+
+ }
+
+ // Class Profile
+
+ @XmlRootElement(name = "Profile")
+ static class Profile {
+
+ @XmlElement(name = "Name")
+ private String name;
+
+ @XmlElementRef
+ private Platform platform;
+
+ @XmlElementRef
+ private Runtime runtime;
+
+ @XmlElementRef
+ private List accessPoints = new ArrayList();
+
+ public String getname() {
+ if (name == null)
+ name = "";
+
+ return name;
+ }
+
+ public List accessPoints() {
+
+ return accessPoints;
+
+ }
+
+ public String getHostedOn() {
+
+ return this.runtime.getHostedOn().trim();
+
+ }
+
+ public String getPlatformName() {
+
+ return this.platform.getName();
+
+ }
+
+ public String getPlatformVersion() {
+
+ return this.platform.getVersion();
+
+ }
+
+ }
+
+ // Class Runtime
+
+ @XmlRootElement(name = "RunTime")
+ public static class Runtime {
+
+ @XmlElement(name = "HostedOn")
+ private String hostedOn;
+
+ public String getHostedOn() {
+
+ if (hostedOn == null)
+ hostedOn = "";
+
+ return hostedOn;
+ }
+
+ }
+
+ // Class Platform
+
+ @XmlRootElement(name = "Platform")
+ public static class Platform {
+
+ private String version;
+
+ @XmlElement(name = "Name")
+ private String name;
+
+ @XmlElement(name = "Version")
+ private String Version;
+
+ @XmlElement(name = "MinorVersion")
+ private String minorVersion;
+
+ @XmlElement(name = "RevisionVersion")
+ private String revisionVersion;
+
+ public String getVersion() {
+
+ // Version's computation
+ if ((Version == null) || (Version.equals(""))) {
+
+ // Version="8";
+ // minorVersion="4";
+ // revisionVersion="0";
+
+ Version = "";
+ minorVersion = "";
+ revisionVersion = "";
+
+ version = Version + "." + minorVersion + "." + revisionVersion;
+
+ } else {
+ version = Version;
+
+ if ((minorVersion != null) && (!(minorVersion.equals("")))) {
+
+ version = version.concat(".").concat(minorVersion);
+
+ if ((revisionVersion != null)
+ && (!(revisionVersion.equals("")))) {
+
+ version = version.concat(".").concat(revisionVersion);
+
+ }
+
+ }
+
+ }
+
+ return version;
+
+ }
+
+ public String getName() {
+
+ return name;
+
+ }
+
+ }
+
+ // Class AccessPoint
+
+ @XmlRootElement(name = "AccessPoint")
+ public static class AccessPoint {
+
+ private String endpoint;
+ // private String port;
+ private String username;
+ private String password;
+ private String DatabaseName = null;
+ private String Driver = null;
+ private String Dialect = null;
+ private String MaxConnections = null;
+ private String schema = null;
+ private String tableSpaceCount = null;
+ private String tableSpacePrefix = null;
+
+ /* it contains the variables aquamapsWorldTable,aquamapsDataStore */
+ private HashMap auxiliaryProperties = new HashMap();
+
+ @XmlElementRef
+ private Interface itfce = new Interface();
+
+ @XmlElementRef
+ private AccessData accessData = new AccessData();
+
+ @XmlElementWrapper(name = "Properties")
+ @XmlElementRef
+ private List properties = new ArrayList();
+
+ @XmlElement(name = "Description")
+ private String description;
+
+ public String name() {
+
+ return itfce.endpoint().name();
+ }
+
+ public String address() {
+
+ endpoint = itfce.endpoint().address().trim();
+
+ if (endpoint == null)
+ endpoint = "";
+
+ return endpoint;
+ }
+
+ public void setUrl(String value) {
+
+ itfce.endpoint.address = value;
+ endpoint = itfce.endpoint.address.trim();
+
+ }
+
+ public String getUsername() {
+
+ username = this.accessData.username();
+
+ return username;
+
+ }
+
+ public String getPassword() throws Exception{
+
+ String pwd = this.accessData.password();
+
+ try {
+ password = StringEncrypter.getEncrypter().decrypt(pwd);
+ } catch (Exception e) {
+
+// e.printStackTrace();
+ throw e;
+
+ }
+
+ return password;
+
+ }
+
+ public String getDescription() {
+
+ if ((description == null) || (description.equals(""))) {
+
+ description = "jdbc connection url";
+
+ }
+
+ return description;
+
+ }
+
+ public String getDatabaseName() {
+
+ if (properties.size() == 0) {
+
+ Property p = new Property();
+ p.name = "dbname";
+ p.value = "";
+ properties.add(p);
+
+ return DatabaseName = "";
+
+ } else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if (((properties.get(i).name()).toLowerCase()
+ .contains("dbname"))
+ || (properties.get(i).name()).toLowerCase()
+ .contains("databasename")
+ || ((properties.get(i).name()).toLowerCase()
+ .contains("database"))) {
+ DatabaseName = properties.get(i).value();
+
+ }
+
+ }
+
+ if (DatabaseName == null) {
+
+ Property p = new Property();
+ p.name = "dbname";
+ p.value = "";
+ properties.add(p);
+
+ DatabaseName = "";
+ return DatabaseName;
+ }
+
+ }
+
+ return DatabaseName;
+
+ }
+
+ public void setDatabaseName(String value) {
+
+ DatabaseName=value;
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if (((properties.get(i).name()).toLowerCase()
+ .contains("dbname"))
+ || (properties.get(i).name()).toLowerCase().contains(
+ "databasename")
+ || ((properties.get(i).name()).toLowerCase()
+ .contains("database"))) {
+ DatabaseName = properties.get(i).setvalue(value);
+
+ AnalysisLogger.getLogger().debug(
+ "In class DBResource->setting the database's name to value : " + DatabaseName);
+
+ }
+
+ }
+
+ }
+
+ public String getDriver() {
+
+ if (properties.size() == 0) {
+
+ Property p = new Property();
+ p.name = "driver";
+ p.value = "";
+ properties.add(p);
+
+ return Driver = "";
+
+ } else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).toLowerCase().contains(
+ "driver")) {
+ Driver = properties.get(i).value();
+
+ }
+
+ }
+
+ if (Driver == null) {
+
+ Property p = new Property();
+ p.name = "driver";
+ p.value = "";
+ properties.add(p);
+
+ Driver = "";
+
+ return Driver;
+ }
+
+ }
+
+ return Driver;
+
+ }
+
+ public void SetDriver(String value) {
+
+ // Driver="org"+"."+value+"."+"Driver";
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).toLowerCase().contains("driver")) {
+ Driver = properties.get(i).setvalue(value);
+
+ AnalysisLogger.getLogger().debug(
+ "In class DBResource->setting the driver's name to value : " + Driver);
+
+ }
+
+ }
+
+ }
+
+ public String getDialect() {
+
+ if (properties.size() == 0) {
+
+ Property p = new Property();
+ p.name = "dialect";
+ p.value = "";
+ properties.add(p);
+
+ return Dialect = "";
+
+ } else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).toLowerCase().contains(
+ "dialect")) {
+ Dialect = properties.get(i).value();
+
+ }
+
+ }
+
+ if (Dialect == null) {
+
+ Property p = new Property();
+ p.name = "dialect";
+ p.value = "";
+ properties.add(p);
+
+ Dialect = "";
+
+ return Dialect;
+ }
+
+ }
+
+ return Dialect;
+
+ }
+
+ public void SetDialect(String value) {
+
+ // Driver="org"+"."+value+"."+"Driver";
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).toLowerCase()
+ .contains("dialect")) {
+
+ Dialect = properties.get(i).setvalue(value);
+
+ AnalysisLogger.getLogger().debug(
+ "In class DBResource->Setting the dialect: "
+ + Dialect);
+
+ }
+
+ }
+
+ }
+
+ public String getMaxConnections() {
+
+ /* Check if the AccessPoint object does not have a Properties section */
+ if (properties.size() == 0) {
+
+ return MaxConnections = "2";
+ }
+
+ else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).equals("maxConnection")) {
+ MaxConnections = properties.get(i).value();
+
+ }
+
+ }
+
+ if (MaxConnections == null)
+ return MaxConnections = "2";
+ else
+ return MaxConnections;
+
+ }
+
+ }
+
+ public String getSchema() {
+
+ /* Check if the AccessPoint object does not have a Properties section */
+ if (properties.size() == 0)
+ return schema = "public";
+
+ else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ //
+ if ((properties.get(i).name()).equals("schema")) {
+ schema = properties.get(i).value();
+
+ }
+
+ }
+
+ if (schema == null)
+ return schema = "public";
+ else
+ return schema;
+
+ }
+
+ }
+
+ public String getTableSpaceCount() {
+
+ /* Check if the AccessPoint object does not have a Properties section */
+ if (properties.size() == 0)
+ return tableSpaceCount = "0";
+
+ else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).equals("tableSpaceCount")) {
+ tableSpaceCount = properties.get(i).value();
+
+ }
+
+ }
+
+ if (tableSpaceCount == null)
+ return tableSpaceCount = "0";
+ else
+ return tableSpaceCount;
+
+ }
+
+ }
+
+ public String getTableSpacePrefix() {
+
+ /* Check if the AccessPoint object does not have a Properties section */
+ if (properties.size() == 0)
+ return tableSpacePrefix = "";
+
+ else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).equals("tableSpacePrefix")) {
+ tableSpacePrefix = properties.get(i).value();
+
+ }
+
+ }
+
+ if (tableSpacePrefix == null)
+ return tableSpacePrefix = "";
+ else
+ return tableSpacePrefix;
+
+ }
+
+ }
+
+ public HashMap getAuxiliaryProperties() {
+
+ String AuxiliaryProperty;
+
+ /* Check if the AccessPoint object does not have a Properties section */
+ if (properties.size() == 0)
+ return auxiliaryProperties;
+
+ else {
+
+ for (int i = 0; i < properties.size(); i++) {
+
+ if ((properties.get(i).name()).equals("aquamapsWorldTable")) {
+ AuxiliaryProperty = properties.get(i).value();
+
+ auxiliaryProperties.put("aquamapsWorldTable",
+ AuxiliaryProperty);
+
+ }
+
+ if ((properties.get(i).name()).equals("aquamapsDataStore")) {
+ AuxiliaryProperty = properties.get(i).value();
+
+ auxiliaryProperties.put("aquamapsDataStore",
+ AuxiliaryProperty);
+
+ }
+
+ }
+
+ return auxiliaryProperties;
+
+ }
+
+ }
+
+ }
+
+ // Class Interface
+ @XmlRootElement(name = "Interface")
+ public static class Interface {
+
+ @XmlElementRef
+ private Endpoint endpoint = new Endpoint();
+
+ public Endpoint endpoint() {
+ return endpoint;
+ }
+ }
+
+ // Class Endpoint
+ @XmlRootElement(name = "Endpoint")
+ public static class Endpoint {
+
+ @XmlAttribute(name = "EntryName")
+ private String name;
+
+ @XmlValue
+ private String address;
+
+ public String name() {
+ return name;
+ }
+
+ public String address() {
+
+ if (address == null)
+ address = "";
+ return address;
+ }
+
+ }
+
+ // Class AccessData
+ @XmlRootElement(name = "AccessData")
+ public static class AccessData {
+
+ @XmlElement(name = "Username")
+ private String username;
+
+ @XmlElement(name = "Password")
+ private String password;
+
+ public String username() {
+
+ if ((username == null) || (username.equals(""))) {
+
+ username = "gcube";
+
+ }
+
+ return username;
+ }
+
+ public String password() {
+
+ if ((password == null) || (password.equals(""))) {
+
+ password = "d4science";
+
+ }
+ return password;
+ }
+
+ }
+
+ // Class Property
+ @XmlRootElement(name = "Property")
+ public static class Property {
+
+ @XmlElement(name = "Name")
+ private String name;
+
+ @XmlElement(name = "Value")
+ private String value;
+
+ public String name() {
+ return name;
+ }
+
+ public String value() {
+ return value;
+ }
+
+ public String setvalue(String val) {
+
+ value = val;
+ return value;
+
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Decider.java b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Decider.java
new file mode 100644
index 0000000..aa92c16
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Decider.java
@@ -0,0 +1,503 @@
+package org.gcube.dataanalysis.databases.resources.processing;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+
+/**
+ * Class that, taking the url as input, performs a parsing process of the field
+ * Url through a tree decision
+ */
+public class Decider {
+
+ // Method that implements the tree decision to parse and build the field
+ // Url.
+ public static void decide(DBResource obj, int index) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->starting the parsing process");
+
+ String EntireUrl = "";
+
+ String[] SplitOne = null;
+
+ boolean varone = false;
+ boolean var = false;
+
+ if (obj.getAccessPoints().get(index).address().contains("//")) { // the
+ // url
+ // contains
+ // the
+ // character
+ // "//"
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->the url contains the character '//' ");
+
+ varone = true;
+
+ SplitOne = obj.getAccessPoints().get(index).address().split("//"); // Split
+ // on
+ // the
+ // node
+ // of
+ // the
+ // tree
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on '//' ");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->SplitOne's lenght: " + SplitOne.length);
+
+ // Test Print
+ for (int i = 0; i < SplitOne.length; i++) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_one: " + SplitOne[i]);
+
+ }
+
+ if (SplitOne.length > 1) { // with the split operation there is two
+ // parts on the left of "//" and on the
+ // right of "//".
+
+ // try to build the first part of the string url
+
+ // recover the url in the left part of the url
+
+ if (SplitOne[0].length() == 0) { // There is not information on
+ // the left of "//".
+ // Left Node LevelTree=2
+
+ EntireUrl = EntireUrl + "jdbc" + ":";
+
+ if (obj.getPlatformName().toLowerCase().contains("mysql")) {
+
+ EntireUrl = EntireUrl + "mysql" + ":";
+
+ } else {
+
+ EntireUrl = EntireUrl + "postgresql" + ":";
+
+ }
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->result: " + EntireUrl);
+
+ }
+
+ // Split operation on the Left Node LevelTree=2
+
+ else { // there is information on the left of "//"
+
+ // if (SplitOne[0].contains(":")){
+ String[] SplitTwo = SplitOne[0].split(":");
+
+ // System.out.println("split ':' one");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on '/'");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_two's lenght: "
+ + SplitTwo.length);
+
+ // Test Print
+ for (int i = 0; i < SplitTwo.length; i++) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_two: " + SplitTwo[i]);
+
+ }
+
+ // check on the lenght
+
+ if (SplitTwo.length == 2) { // the two strings related to
+ // "jdbc" and the driver's name
+ // are presented.
+
+ if ((obj.getPlatformName().toLowerCase()
+ .contains("postgres"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Decider->setting the url using the driver");
+
+ EntireUrl = SplitTwo[0] + ":" + "postgresql" + ":";
+ }
+ if (obj.getPlatformName().toLowerCase()
+ .contains("mysql")) {
+
+ EntireUrl = SplitTwo[0] + ":" + "mysql" + ":";
+
+ }
+
+ } else { // there is one string: or the "jdbc" or the
+ // driver's name.
+
+ if (SplitTwo[0].toLowerCase().equals("jdbc")) {
+
+ EntireUrl = "jdbc" + ":";
+
+ // if
+ // ((this.getPlatformName().toLowerCase().contains("postgres"))||(this.getPlatformName().toLowerCase().contains("postgis"))){
+
+ if ((obj.getPlatformName().toLowerCase()
+ .contains("postgres"))) {
+ EntireUrl = EntireUrl + "postgresql" + ":";
+
+ }
+
+ if (obj.getPlatformName().toLowerCase()
+ .contains("mysql")) {
+
+ EntireUrl = EntireUrl + "mysql" + ":";
+
+ }
+
+ } else { // there is the driver's name. I check the
+ // variable db, set by the method guessDB,
+ // to set the url properly.
+
+ if (obj.getPlatformName().toLowerCase()
+ .contains("postgres")) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Decider->setting the url using the driver postgres");
+
+ EntireUrl = "jdbc" + ":" + "postgresql" + ":";
+
+ }
+
+ else if (obj.getPlatformName().toLowerCase()
+ .contains("mysql")) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Decider->setting the url using the driver mysql");
+
+ EntireUrl = "jdbc" + ":" + "mysql" + ":";
+
+ }
+
+ }
+
+ }
+ // }
+
+ }
+
+ } else { // with the split operation there is one part on the left
+ // of "//".
+
+ EntireUrl = obj.getAccessPoints().get(index).address();
+
+ if ((obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("postgres"))
+ || (obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("postgis"))) {
+
+ EntireUrl = "jdbc:postgresql://";
+
+ }
+ if (obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("mysql")) {
+
+ EntireUrl = "jdbc:mysql://";
+
+ }
+
+ // the url is built using the available information.
+ EntireUrl = EntireUrl + obj.getHostedOn() + ":" + obj.getPort()
+ + "/"
+ + obj.getAccessPoints().get(index).getDatabaseName();
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->result: " + EntireUrl);
+
+ var = true;
+ }
+
+ }
+
+ if ((obj.getAccessPoints().get(index).address().contains("/"))
+ && (var == false)) { // it manages several cases. It is selected
+ // if: 1) there is only the part on the
+ // right of "//", 2) there is the entire
+ // string, 3) there is the part on the
+ // right of "/"
+
+ // System.out.println("manage '/'");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->the url contains characther '/'");
+
+ if (varone == true) { // There is the hostname, the port number or
+ // both. A split on "/" is performed to
+ // retrieve the database's name
+
+ // Split operation on the Right Node LevelTree=2
+
+ String[] SplitThree = SplitOne[1].split("/");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on '/'");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_three's lenght: "
+ + SplitThree.length);
+
+ for (int i = 0; i < SplitThree.length; i++) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_three: " + SplitThree[i]);
+
+ }
+
+ if (SplitThree[0].length() == 0) { // There are not the hostname
+ // and the port number.
+ // Left Node LevelTree= 3
+
+ EntireUrl = EntireUrl + "//" + obj.getHostedOn() + ":"
+ + obj.getPort();
+
+ } else { // Recovery host and the port number
+
+ String[] SplitFour = SplitThree[0].split(":");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on ':'");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_four's lenght: "
+ + SplitFour.length);
+
+ for (int i = 0; i < SplitFour.length; i++) {
+
+ AnalysisLogger.getLogger()
+ .debug("In class Decider->Split_four: "
+ + SplitFour[i]);
+
+ }
+
+ if (SplitFour[0].length() == 0) { // there is not the
+ // hostname.
+ // Left Node LevelTree=4
+
+ EntireUrl = EntireUrl + "//" + obj.getHostedOn();
+ } else { // there is the hostname
+ obj.setHostedOn(SplitFour[0]);
+
+ EntireUrl = EntireUrl + "//" + SplitFour[0];
+
+ }
+
+ if (SplitFour.length > 1) { // the url contains the port
+ // number too.
+
+ // the url contains the port number
+
+ obj.setPort(SplitFour[1]);
+
+ EntireUrl = EntireUrl + ":" + SplitFour[1];
+
+ } else {
+ // the url does not contain the port number
+
+ EntireUrl = EntireUrl + ":" + obj.getPort();
+
+ }
+
+ }
+
+ if (SplitThree.length > 1) { // Right Node LevelTree= 3
+ // the url contains the database's name
+
+ obj.getAccessPoints().get(index)
+ .setDatabaseName(SplitThree[1]);
+
+ EntireUrl = EntireUrl + "/" + SplitThree[1];
+
+ }
+
+ else {
+
+ // The url does not contain the database's name
+
+ EntireUrl = EntireUrl
+ + "/"
+ + obj.getAccessPoints().get(index)
+ .getDatabaseName();
+
+ }
+
+ }
+
+ else { // there is only the database's name
+
+ String[] SplitThree = obj.getAccessPoints().get(index)
+ .address().split("/");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on '/'");
+
+ obj.getAccessPoints().get(index).setDatabaseName(SplitThree[1]);
+
+ if (SplitThree[0].length() == 0) { // only the database's name
+ // is retrieved
+
+ // if
+ // ((this.getPlatformName().equals("postgres"))||(this.getPlatformName().equals("postgis"))){
+ if ((obj.getPlatformName().equals("postgres"))) {
+
+ EntireUrl = "jdbc:" + "postgresql" + ":" + "//"
+ + obj.getHostedOn() + ":" + obj.getPort() + "/"
+ + SplitThree[1];
+
+ }
+
+ if (obj.getPlatformName().toLowerCase().contains("mysql")) {
+
+ EntireUrl = "jdbc:" + "mysql" + ":" + "//"
+ + obj.getHostedOn() + ":" + obj.getPort() + "/"
+ + SplitThree[1];
+
+ }
+ }
+
+ if (SplitThree[0].length() != 0) { // on the left of "/" there
+ // are other information
+
+ String[] SplitTwo = SplitThree[0].split(":");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->split operation on ':'");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_two's lenght");
+
+ for (int i = 0; i < SplitTwo.length; i++) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Split_two: " + SplitTwo[i]);
+
+ }
+
+ // check on the lenght
+
+ if (SplitTwo.length == 2) { // The two strings "jdbc" and
+ // driver's name are presented.
+
+ // sono presenti stringa "jdbc" e "nome driver"
+
+ // *this.getAccessPoints().get(index).SetDriver(SplitTwo[1]);
+
+ if ((SplitTwo[1].toLowerCase().contains("postgres"))
+ || (SplitTwo[1].toLowerCase()
+ .contains("postgis"))) {
+
+ EntireUrl = SplitTwo[0] + ":" + "postgresql" + ":";
+ }
+ if (SplitTwo[1].toLowerCase().contains("mysql")) {
+
+ EntireUrl = SplitTwo[0] + ":" + "mysql" + ":";
+
+ }
+
+ // EntireUrl=SplitTwo[0]+":"+SplitTwo[1]+":";
+
+ // if
+ // ((this.getPlatformName().toLowerCase().contains("postgres"))||(this.getPlatformName().toLowerCase().contains("postgis"))){
+ if ((obj.getPlatformName().toLowerCase()
+ .contains("postgres"))) {
+
+ EntireUrl = EntireUrl + "//" + obj.getHostedOn()
+ + ":" + obj.getPort() + "/" + SplitThree[1];
+
+ }
+
+ if (obj.getPlatformName().toLowerCase()
+ .contains("mysql")) {
+
+ EntireUrl = EntireUrl + "//" + obj.getHostedOn()
+ + ":" + obj.getPort() + "/" + SplitThree[1];
+
+ }
+
+ } else { // only one string between "jdbc" or driver's name
+ // is presented
+
+ if (SplitTwo[0].toLowerCase().equals("jdbc")) { // the
+ // string
+ // "jdbc"
+ // is
+ // presented
+
+ EntireUrl = "jdbc" + ":";
+
+ if ((obj.getPlatformName().toLowerCase()
+ .contains("postgres"))
+ || (obj.getPlatformName().toLowerCase()
+ .contains("postgis"))) {
+
+ EntireUrl = EntireUrl + "postgresql" + ":"
+ + "//" + obj.getHostedOn() + ":"
+ + obj.getPort() + "/" + SplitThree[1];
+
+ }
+
+ if (obj.getPlatformName().toLowerCase()
+ .contains("mysql")) {
+
+ EntireUrl = EntireUrl + "mysql" + ":" + "//"
+ + obj.getHostedOn() + ":"
+ + obj.getPort() + "/" + SplitThree[1];
+
+ }
+
+ } else { // the string related to the driver's name is
+ // presented
+
+ // EntireUrl="jdbc"+":"+SplitTwo[0]+":"+"//"+this.getHostedOn()+":"+this.getPort()+"/"+SplitThree[1];;
+ // *this.getAccessPoints().get(index).SetDriver(SplitTwo[0]);
+
+ if ((obj.getDBguessed().contains("postgis"))
+ || (obj.getDBguessed().contains("postgres"))) {
+ // EntireUrl="jdbc"+":"+SplitTwo[0]+":"+"//"+this.getHostedOn()+":"+this.getPort()+"/"+SplitThree[1];}
+
+ // *this.getAccessPoints().get(index).SetDriver(SplitTwo[0]);
+
+ EntireUrl = "jdbc" + ":" + "postgresql" + ":"
+ + "//" + obj.getHostedOn() + ":"
+ + obj.getPort() + "/" + SplitThree[1];
+ }
+ if (obj.getDBguessed().contains("mysql")) {
+
+ EntireUrl = "jdbc" + ":" + "mysql" + ":" + "//"
+ + obj.getHostedOn() + ":"
+ + obj.getPort() + "/" + SplitThree[1];
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ // if(this.getAccessPoints().get(index).address().contains(":")){}
+
+ obj.getAccessPoints().get(index).setUrl(EntireUrl);
+
+ AnalysisLogger.getLogger().debug(
+ "In class Decider->Url normalized: "
+ + obj.getAccessPoints().get(index).address());
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Guesser.java b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Guesser.java
new file mode 100644
index 0000000..fba7ede
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Guesser.java
@@ -0,0 +1,361 @@
+package org.gcube.dataanalysis.databases.resources.processing;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+
+/**
+ * Class that uses as inputs the available information (platform, driver and
+ * dialect) to determine the database's type
+ */
+
+public class Guesser {
+
+ private String db = ""; // the database's type
+
+ // Method that determines the database's type using the available
+ // information as platform, driver and dialect and set these parameters to
+ // the correct values if they are not specified according to a well-formed
+ // mode.
+ public String guessDB(DBResource obj, int index) {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->starting the guess process");
+
+// String platform = "";
+
+ if ((obj.getPlatformName().trim().equals(""))
+ && (obj.getAccessPoints().get(index).getDriver().equals(""))
+ && (obj.getAccessPoints().get(index).getDialect().equals(""))
+ && (obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("mysql"))) { // it is used the 'mysql'
+ // driver's name
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the 'mysql' driver's name");
+
+ // System.out.println("Set condition default");
+
+ db = "mysql";
+
+ obj.setPort("3306");
+
+ // return db;
+
+ }
+
+ else if ((obj.getPlatformName().trim().equals(""))
+ && (obj.getAccessPoints().get(index).getDriver().equals(""))
+ && (obj.getAccessPoints().get(index).getDialect().equals(""))
+ && (obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("postgis"))) { // it is used the 'postgis'
+ // dialect's name
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the address information: "
+ + obj.getAccessPoints().get(index).address()
+ .toLowerCase());
+
+ db = "postgis";
+
+ obj.setPort("5432");
+
+ }
+
+ if ((obj.getPlatformName().trim().equals(""))
+ && (obj.getAccessPoints().get(index).getDriver().equals(""))
+ && (obj.getAccessPoints().get(index).getDialect().equals(""))
+ && (!(obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("mysql")))
+ && (!(obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("postgres")))) { // in this case there are not
+ // enough information so the
+ // database's name and the
+ // port number are set to
+ // the default values.
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number are set to the default values");
+
+ db = "postgres";
+
+ obj.setPort("5432");
+
+ }
+
+ if ((obj.getPlatformName().trim().equals(""))
+ && (obj.getAccessPoints().get(index).getDriver().equals(""))
+ && (obj.getAccessPoints().get(index).getDialect().equals(""))
+ && (obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("postgres"))) { // it is used the 'postgres'
+ // driver's name
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the address information: "
+ + obj.getAccessPoints().get(index).address()
+ .toLowerCase());
+
+ db = "postgres";
+
+ obj.setPort("5432");
+
+ }
+
+ if (((obj.getPlatformName() != ""))
+ && (obj.getPlatformName().toLowerCase().contains("mysql"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the platform's name: "
+ + obj.getPlatformName().toLowerCase());
+
+ db = "mysql";
+ obj.setPort("3306");
+
+ } else if ((obj.getAccessPoints().get(index).getDriver() != "")
+ && (obj.getAccessPoints().get(index).getDriver().toLowerCase()
+ .contains("mysql"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the driver's name: "
+ + obj.getAccessPoints().get(index).getDriver()
+ .toLowerCase());
+
+ db = "mysql";
+ obj.setPort("3306");
+ } else if ((obj.getAccessPoints().get(index).getDialect() != "")
+ && (obj.getAccessPoints().get(index).getDialect().toLowerCase()
+ .contains("mysql"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect()
+ .toLowerCase());
+
+ db = "mysql";
+ obj.setPort("3306");
+
+ }
+
+ if ((obj.getPlatformName() != "")
+ && (obj.getPlatformName().toLowerCase().contains("postgres"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the platform's name: "
+ + obj.getPlatformName().toLowerCase());
+
+ db = "postgres";
+ obj.setPort("5432");
+
+ } else if ((obj.getAccessPoints().get(index).getDriver() != "")
+ && (obj.getAccessPoints().get(index).getDriver().toLowerCase()
+ .contains("postgres"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the driver's name: "
+ + obj.getAccessPoints().get(index).getDriver()
+ .toLowerCase());
+
+ db = "postgres";
+ obj.setPort("5432");
+ } else if ((obj.getAccessPoints().get(index).getDialect() != "")
+ && (obj.getAccessPoints().get(index).getDialect().toLowerCase()
+ .contains("postgres"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect()
+ .toLowerCase());
+
+ db = "postgres";
+ obj.setPort("5432");
+
+ }
+
+ if ((obj.getPlatformName() != "")
+ && (obj.getPlatformName().toLowerCase().contains("postgis"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the platform's name: "
+ + obj.getPlatformName().toLowerCase());
+
+ db = "postgis";
+ obj.setPort("5432");
+
+ // }else if
+ // ((this.getAccessPoints().get(index).Driver.toLowerCase().contains("postgis"))&&(!(this.getAccessPoints().get(index).Driver.equals("")))){
+ } else if ((obj.getAccessPoints().get(index).getDriver() != "")
+ && (obj.getAccessPoints().get(index).getDriver().toLowerCase()
+ .contains("postgis"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the driver's name: "
+ + obj.getAccessPoints().get(index).getDriver()
+ .toLowerCase());
+
+ db = "postgis";
+ obj.setPort("5432");
+
+ // }else if
+ // ((this.getAccessPoints().get(index).getDialect()!="")&&(this.getAccessPoints().get(index).getDialect().toLowerCase().contains("postgis")))
+ // {
+ } else if ((obj.getAccessPoints().get(index).getDialect() != "")
+ && (obj.getAccessPoints().get(index).getDialect().toLowerCase()
+ .contains("postgis"))) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect()
+ .toLowerCase());
+
+ db = "postgis";
+ obj.setPort("5432");
+
+ } else if (obj.getAccessPoints().get(index).address().toLowerCase()
+ .contains("postgis")) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number determined using the address information: "
+ + obj.getAccessPoints().get(index).address()
+ .toLowerCase());
+
+ db = "postgis";
+ obj.setPort("5432");
+
+ }
+
+ if (db.equals("")) {
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->database's name and port number are set to default values because the database's type is not determined : "
+ + obj.getAccessPoints().get(index).address()
+ .toLowerCase());
+
+ db = "postgres";
+ obj.setPort("5432");
+
+ }
+
+ // 'Set' process of the platform, driver and dialect parameters
+
+ // Set Platform's name Operation
+
+ if ((db.equals("mysql")) || (db.equals("postgres"))) {
+
+ obj.setPlatformName(db);
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->setting platform's name: "
+ + obj.getPlatformName());
+
+ } else if (db.equals("postgis")) {
+
+ obj.setPlatformName("postgres");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->setting platform's name: "
+ + obj.getPlatformName());
+
+ }
+
+ // Set Driver's name Operation
+
+ if ((obj.getAccessPoints().get(index).getDriver() == "")
+ || (!(obj.getAccessPoints().get(index).getDriver()
+ .contains(".")))) {
+
+ if (db.contains("postgres")) {
+
+ obj.getAccessPoints().get(index)
+ .SetDriver("org.postgresql.Driver");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->setting driver's name: "
+ + obj.getAccessPoints().get(index).getDriver());
+
+ } else if (db.contains("postgis")) {
+
+ obj.getAccessPoints().get(index)
+ .SetDriver("org.postgresql.Driver");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->setting driver's name: "
+ + obj.getAccessPoints().get(index).getDriver());
+
+ } else if (db.contains("mysql")) {
+
+ obj.getAccessPoints().get(index)
+ .SetDriver("com.mysql.jdbc.Driver");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Guesser->setting driver's name: "
+ + obj.getAccessPoints().get(index).getDriver());
+ }
+
+ }
+
+ // Set Dialect's name operation
+ if ((obj.getAccessPoints().get(index).getDialect() == "")
+ || (!(obj.getAccessPoints().get(index).getDialect()
+ .contains(".")))) {
+
+ if (db.contains("postgres")) {
+
+ obj.getAccessPoints().get(index)
+ .SetDialect("org.hibernate.dialect.PostgreSQLDialect");
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->setting dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect());
+
+ } else if (db.contains("postgis")) {
+
+ obj.getAccessPoints()
+ .get(index)
+ .SetDialect(
+ "org.hibernatespatial.postgis.PostgisDialect");
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->setting dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect());
+
+ } else if (db.contains("mysql")) {
+
+ obj.getAccessPoints().get(index)
+ .SetDialect("org.hibernate.dialect.MySQLDialect");
+
+ AnalysisLogger
+ .getLogger()
+ .debug("In class Guesser->setting dialect's name: "
+ + obj.getAccessPoints().get(index).getDialect());
+ }
+
+ }
+
+ return db;
+
+ }
+
+ // it returns the db field of the object Guesser
+ public String getDB() {
+
+ return db;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Normalizer.java b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Normalizer.java
new file mode 100644
index 0000000..94f6310
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/resources/processing/Normalizer.java
@@ -0,0 +1,145 @@
+package org.gcube.dataanalysis.databases.resources.processing;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+import org.gcube.dataanalysis.databases.resources.DBResource;
+import org.gcube.dataanalysis.databases.resources.processing.Normalizer;
+import org.gcube.dataanalysis.databases.resources.processing.Guesser;
+
+
+/** Class that performs the normalization process using the available information specified from the user */
+
+public class Normalizer {
+
+ /* It performs the normalization process considering as input an access point field of a DBResource resource */
+ public static void normalize(DBResource obj, int index) throws IOException {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting to guess the database's type");
+
+ Guesser guess=new Guesser();
+
+ String db = guess.guessDB(obj, index);
+
+ obj.setDBguessed(db);
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting the normalization process");
+
+ // the Url contains at least the character between the "//", "/" or ":"
+ if ((obj.getAccessPoints().get(index).address().contains("//"))
+ || (obj.getAccessPoints().get(index).address().contains("/"))
+ || (obj.getAccessPoints().get(index).address().contains(":")))
+ {
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->calling the parsing process of the url");
+ Decider.decide(obj, index);
+
+ } else { // the Url does not contain none of the characters "//", "/" or
+ // ":" so there is an indecision to be managed
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting to manage an indecision");
+
+ if ((obj.getAccessPoints().get(index).address().equals(obj
+ .getHostedOn())) && (!(obj.getHostedOn().equals("")))) { /* the address is the hostname */
+
+ obj.getAccessPoints()
+ .get(index)
+ .setUrl("//"
+ + obj.getAccessPoints().get(index).address());
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting the tree decision process using the hostname");
+
+ Decider.decide(obj, index);
+
+ } else if ((!(obj.getAccessPoints().get(index).address().equals("")))
+ && (!(obj.getAccessPoints().get(index).address().equals(obj
+ .getHostedOn())) && (obj.getHostedOn().equals("")))) {
+
+ // throw new UnknownHostException("The host is unknown");
+
+ throw new UnknownHostException(
+ "the available information are not sufficient to determine the complete address: please fill the field 'Hosted On'");
+
+ } else if ((!(obj.getAccessPoints().get(index).address()
+ .equals("jdbc")))
+ && (!(obj.getAccessPoints().get(index).address()
+ .toLowerCase().toLowerCase().contains("mysql")))
+
+ && (!(obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("postgres")))
+ && (!(obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("postgis")))
+ && (!(obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains(obj.getPort())))
+ && (!(obj.getAccessPoints().get(index).address().equals("")))) { /* the address is the database's name */
+
+ obj.getAccessPoints()
+ .get(index)
+ .setUrl("/"
+ + obj.getAccessPoints().get(index).address());
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting the tree decision process using the database's name");
+
+ Decider.decide(obj, index);
+
+ } else if ((obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("postgres"))
+ || (obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("postgis"))
+ || (obj.getAccessPoints().get(index).address()
+ .toLowerCase().contains("mysql"))) { /* the address is the driver's name */
+
+ obj.getAccessPoints()
+ .get(index)
+ .setUrl("jdbc:"
+ + obj.getAccessPoints().get(index).address()
+ + "://");
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->starting the tree decision process using the driver's name");
+
+ Decider.decide(obj, index);
+
+ }
+
+ // if ((obj.getAccessPoints().get(index).address().equals(""))){
+ if ((obj.getAccessPoints().get(index).address().equals(""))) { /* the address is empty so several available information are used to build the Url */
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->managing the address null");
+
+ // Empty address management
+
+ if (!(obj.getHostedOn().equals(""))
+ && (obj.getHostedOn() != null)) { /* the hostname is used if it is not null. */
+
+// AnalysisLogger.getLogger().debug(
+// "In class Normalizer->using the hostname"
+// + obj.getHostedOn());
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->managing the address null using the hostname");
+
+ obj.getAccessPoints().get(index).setUrl(obj.getHostedOn());
+
+ AnalysisLogger.getLogger().debug(
+ "In class Normalizer->recalling the 'normalize' method");
+
+ normalize(obj, index);
+
+ }
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/sampler/RowScore.java b/src/main/java/org/gcube/dataanalysis/databases/sampler/RowScore.java
new file mode 100644
index 0000000..ea27ded
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/sampler/RowScore.java
@@ -0,0 +1,47 @@
+package org.gcube.dataanalysis.databases.sampler;
+
+/**
+ * Class that allows to describe
+ */
+public class RowScore implements Comparable {
+
+ private Object row;
+ private int score;
+
+ public RowScore(Object r, int s) {
+
+ row = r;
+ score = s;
+
+ }
+
+ // to get the row
+ public Object getRow() {
+
+ return row;
+ }
+
+ // to get the score
+ public int getScore() {
+
+ return score;
+ }
+
+ // to compare two RowScore objects in order to sort a list of this objects
+ @Override
+ public int compareTo(RowScore o) {
+ // TODO Auto-generated method stub
+
+ if (this.score > o.getScore())
+ return 1;
+
+ if (this.score == o.getScore())
+ return 0;
+
+ if (this.score < o.getScore())
+ return -1;
+
+ return 0;
+ }
+
+}
diff --git a/src/main/java/org/gcube/dataanalysis/databases/sampler/Sampler.java b/src/main/java/org/gcube/dataanalysis/databases/sampler/Sampler.java
new file mode 100644
index 0000000..7e869d9
--- /dev/null
+++ b/src/main/java/org/gcube/dataanalysis/databases/sampler/Sampler.java
@@ -0,0 +1,1286 @@
+package org.gcube.dataanalysis.databases.sampler;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.LinkedHashMap;
+import java.util.Random;
+
+import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
+import org.gcube.dataanalysis.databases.utils.ConnectionManager;
+import org.hibernate.SessionFactory;
+
+/**
+ * Class that allows to perform different types of Sample operations on a table:
+ * SampleOnTable, SmartSampleOnTable, RandomSampleOnTable
+ */
+
+public class Sampler {
+
+ // query to perform sample operation on the table
+ private static final String queryForSampleOnTablePostgres = "select %1$s from \"%2$s\" limit 100";
+ private static final String queryForSampleOnTableMysql = "select %1$s from %2$s limit 100";
+
+ // query to perform a smart sample operation randomly on the table
+ private static final String queryForSmartSampleOnTablePostgres = "select %1$s from \"%2$s\" order by random() limit 200";
+ private static final String queryForSmartSampleOnTableMysql = "select %1$s from %2$s order by rand() limit 200";
+ // private static final String queryForSmartSampleOnTablePostgres =
+ // "select * from \"%1$s\" order by random() limit 200";
+ // private static final String queryForSmartSampleOnTableMysql =
+ // "select * from %1$s order by rand() limit 200";
+
+ // query to perform a smart sample operation on the table considering the
+ // threshold
+ private static final String queryForSmartSampleWithThresholdOnTablePostgres = "select %1$s from \"%2$s\" limit 200 offset %3$s";
+ // private static final String queryForSmartSampleWithThresholdOnTableMysql
+ // = "select %1$s from %2$s limit 200 offset %3$s";
+
+ // query to perform a sample operation randomly on a table
+ // private static final String queryForRandomSampleOnTablePostgres =
+ // "select %1$s from \"%2$s\" order by random() limit 100";
+ // query to perform a smart sample operation on the table considering the
+ // threshold
+ private static final String queryForRandomSampleWithThresholdOnTablePostgres = "select %1$s from \"%2$s\" limit 100 offset %3$s";
+ private static final String queryForRandomSampleOnTableMysql = "select %1$s from %2$s order by rand() limit 100";
+ private static final String queryForRandomSampleOnTablePostgres = "select %1$s from %2$s order by random() limit 100";
+
+ // query to get columns' name
+ private static final String queryForColumnsPostgres = "SELECT column_name FROM information_schema.COLUMNS WHERE table_name ='%1$s' and table_schema='%2$s'";
+ private static final String queryForColumnsMysql = "SELECT column_name FROM information_schema.COLUMNS WHERE table_name ='%1$s' and table_schema='%2$s'";
+
+ private static final String MYSQL = "MySQL";
+ private static final String POSTGRES = "Postgres";
+
+ private List listColumns = null;
+
+ public Sampler() {
+
+ }
+
+ // retrieve the first 100 rows of a table
+ public List