CONFIGRTDEPLOYMENTINFOQUERYDB Configure the query to retrieve real time glider deployment information. Syntax: [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGRTDEPLOYMENTINFOQUERYDB() Description: [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGRTDEPLOYMENTINFOQUERYDB() should return the SQL query to retrieve the information about glider deployments to be processed in real time. String SQL_QUERY is the query to execute. The mapping between deployment fields and data base table columns is given by the string cell array DEPLOYMENT_FIELDS. Deployment fields are described in GETDEPLOYMENTINFODB. Notes: Edit this file filling in the field mapping of your data base and the query that returns that fields for each deployment. Examples: [sql_query, deployment_fields] = configRTDeploymentInfoQueryDB() See also: GETDEPLOYMENTINFODB Authors: Joan Pau Beltran <joanpau.beltran@socib.cat>
configRTDeploymentInfoQueryDB.m
0001 function [sql_query, deployment_fields] = configRTDeploymentInfoQueryDB() 0002 %CONFIGRTDEPLOYMENTINFOQUERYDB Configure the query to retrieve real time glider deployment information. 0003 % 0004 % Syntax: 0005 % [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGRTDEPLOYMENTINFOQUERYDB() 0006 % 0007 % Description: 0008 % [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGRTDEPLOYMENTINFOQUERYDB() should 0009 % return the SQL query to retrieve the information about glider deployments 0010 % to be processed in real time. String SQL_QUERY is the query to execute. 0011 % The mapping between deployment fields and data base table columns is given 0012 % by the string cell array DEPLOYMENT_FIELDS. Deployment fields are described 0013 % in GETDEPLOYMENTINFODB. 0014 % 0015 % Notes: 0016 % Edit this file filling in the field mapping of your data base and the 0017 % query that returns that fields for each deployment. 0018 % 0019 % Examples: 0020 % [sql_query, deployment_fields] = configRTDeploymentInfoQueryDB() 0021 % 0022 % See also: 0023 % GETDEPLOYMENTINFODB 0024 % 0025 % Authors: 0026 % Joan Pau Beltran <joanpau.beltran@socib.cat> 0027 0028 % Copyright (C) 2013-2016 0029 % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 0030 % <http://www.socib.es> 0031 % 0032 % This program is free software: you can redistribute it and/or modify 0033 % it under the terms of the GNU General Public License as published by 0034 % the Free Software Foundation, either version 3 of the License, or 0035 % (at your option) any later version. 0036 % 0037 % This program is distributed in the hope that it will be useful, 0038 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0039 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0040 % GNU General Public License for more details. 0041 % 0042 % You should have received a copy of the GNU General Public License 0043 % along with this program. If not, see <http://www.gnu.org/licenses/>. 0044 0045 error(nargchk(0, 0, nargin, 'struct')); 0046 0047 % Select the deployment fields. 0048 % First column is deployment field 0049 % Second column is column in data base table. 0050 fields_map = { 0051 'deployment_id' 'deployment_id' 0052 'deployment_name' 'deployment_name' 0053 'deployment_start' 'deployment_initial_date' 0054 'deployment_end' 'deployment_end_date' 0055 'glider_name' 'platform_name' 0056 'glider_serial' 'instrument_serial' 0057 'glider_model' 'instrument_model' 0058 }; 0059 0060 deployment_fields = fields_map(:,1)'; 0061 database_fields = fields_map(:,2)'; 0062 0063 % Build the query. 0064 database_fields_str = ... 0065 [sprintf('%s, ', database_fields{1:end-1}) database_fields{end}]; 0066 sql_query = ['select ' database_fields_str ... 0067 ' from instrumentation.deployment' ... 0068 ' inner join instrumentation.instrument' ... 0069 ' on (deployment_instrument_id=instrument_id)' ... 0070 ' inner join instrumentation.instrument_type' ... 0071 ' on (instrument_instrument_type_id=instrument_type_id)' ... 0072 ' inner join instrumentation.instrument_platform' ... 0073 ' on (instrument_platform_instrument_id=instrument_id and instrument_platform_installation_date < now() and (instrument_platform_uninstallation_date is null or instrument_platform_uninstallation_date > now()))' ... 0074 ' inner join instrumentation.platform' ... 0075 ' on (instrument_platform_platform_id = platform_id)' ... 0076 ' inner join instrumentation.institution' ... 0077 ' on (deployment_institution_id=institution_id)' ... 0078 ' where (instrument_type_name~*''glider'' and deployment_initial_date < now() and deployment_finished=false);']; 0079 0080 end