Ignore:
Timestamp:
Jun 15, 2015, 1:47:59 PM (9 years ago)
Author:
djay
Message:

Initial support for WPS 2.0.0 including the Dismiss extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/sqlapi.c

    r652 r654  
    227227  map *schema=getMapFromMaps(conf,"database","schema");
    228228  char *sqlQuery=(char*)malloc((strlen(schema->value)+flen+strlen(sid->value)+51+1)*sizeof(char));
    229   sprintf(sqlQuery,"UPDATE %s.services set response=$$%s$$ where uuid=$$%s$$;",schema->value,tmps,sid->value);
     229  sprintf(sqlQuery,"INSERT INTO %s.responses (content,uuid) VALUES ($$%s$$,$$%s$$);",schema->value,tmps,sid->value);
    230230  execSql(conf,sqlQuery);
    231231  cleanUpResultSet(conf);
     
    292292char* _getStatusFile(maps* conf,char* pid){
    293293  map *schema=getMapFromMaps(conf,"database","schema");
    294   char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char));
    295   sprintf(sqlQuery,"select response from %s.services where uuid=$$%s$$;",schema->value,pid);
     294  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+82+1)*sizeof(char));
     295  sprintf(sqlQuery,
     296          "select content from %s.responses where uuid=$$%s$$"
     297          " order by creation_time desc limit 1",schema->value,pid);
    296298  if( zoo_DS == NULL )
    297299    init_sql(conf);
     
    318320
    319321/**
    320  * Stop handling status repport.
     322 * Delete a service reference from the database.
    321323 *
    322324 * @param conf the map containing the setting of the main.cfg file
    323  */
    324 void unhandleStatus(maps* conf){
    325   map *sid=getMapFromMaps(conf,"lenv","usid");
    326   char *sqlQuery=(char*)malloc((strlen(sid->value)+52+1)*sizeof(char));
    327   sprintf(sqlQuery,"UPDATE services set end_time=now() where uuid=$$%s$$;",sid->value);
     325 * @param pid the service identifier (usid key from the [lenv] section)
     326 */
     327void removeService(maps* conf,char* pid){
     328  map *schema=getMapFromMaps(conf,"database","schema");
     329  char *sqlQuery=(char*)
     330    malloc((strlen(pid)+strlen(schema->value)+38+1)
     331           *sizeof(char));
     332  if( zoo_DS == NULL )
     333    init_sql(conf);
     334  sprintf(sqlQuery,
     335          "DELETE FROM %s.services where uuid=$$%s$$;",
     336          schema->value,pid);
    328337  execSql(conf,sqlQuery);
    329338  cleanUpResultSet(conf);
     
    332341}
    333342
     343/**
     344 * Stop handling status repport.
     345 *
     346 * @param conf the map containing the setting of the main.cfg file
     347 */
     348void unhandleStatus(maps* conf){
     349  map *schema=getMapFromMaps(conf,"database","schema");
     350  map *sid=getMapFromMaps(conf,"lenv","usid");
     351  map *fstate=getMapFromMaps(conf,"lenv","fstate");
     352  char *sqlQuery=(char*)malloc((strlen(sid->value)+
     353                                strlen(schema->value)+
     354                                (fstate!=NULL?
     355                                 strlen(fstate->value):
     356                                 6)
     357                                +66+1)*sizeof(char));
     358  sprintf(sqlQuery,
     359          "UPDATE %s.services set end_time=now(), fstate=$$%s$$"
     360          " where uuid=$$%s$$;",
     361          schema->value,(fstate!=NULL?fstate->value:"Failed"),sid->value);
     362  execSql(conf,sqlQuery);
     363  cleanUpResultSet(conf);
     364  close_sql(conf);
     365  end_sql();
     366}
     367
     368/**
     369 * Read the sid identifier attached of a service if any
     370 *
     371 * @param conf the maps containing the setting of the main.cfg file
     372 * @param pid the service identifier (usid key from the [lenv] section)
     373 * @return the sid value
     374 */
     375char* getStatusId(maps* conf,char* pid){
     376  map *schema=getMapFromMaps(conf,"database","schema");
     377  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char));
     378  sprintf(sqlQuery,
     379          "select osid from %s.services where uuid=$$%s$$",
     380          schema->value,pid);
     381  if( zoo_DS == NULL )
     382    init_sql(conf);
     383  execSql(conf,sqlQuery);
     384  OGRFeature  *poFeature = NULL;
     385  const char *tmp1;
     386  int hasRes=-1;
     387  while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){
     388    for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){
     389      if( poFeature->IsFieldSet( iField ) ){
     390        tmp1=zStrdup(poFeature->GetFieldAsString( iField ));
     391        hasRes=1;
     392        break;
     393      }
     394    }
     395    OGRFeature::DestroyFeature( poFeature );
     396  }
     397  if(hasRes<0)
     398    tmp1=NULL;
     399  return (char*)tmp1;
     400}
     401
     402/**
     403 * Read the Result file (.res).
     404 *
     405 * @param conf the maps containing the setting of the main.cfg file
     406 * @param pid the service identifier (usid key from the [lenv] section)
     407 */
     408void readFinalRes(maps* conf,char* pid,map* statusInfo){
     409  map *schema=getMapFromMaps(conf,"database","schema");
     410  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+58+1)*sizeof(char));
     411  sprintf(sqlQuery,
     412          "select fstate from %s.services where uuid=$$%s$$",
     413          schema->value,pid);
     414  if( zoo_DS == NULL )
     415    init_sql(conf);
     416  execSql(conf,sqlQuery);
     417  OGRFeature  *poFeature = NULL;
     418  int hasRes=-1;
     419  while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){
     420    for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){
     421      if( poFeature->IsFieldSet( iField ) ){
     422        addToMap(statusInfo,"Status",poFeature->GetFieldAsString( iField ));
     423        hasRes=1;
     424        break;
     425      }
     426    }
     427    OGRFeature::DestroyFeature( poFeature );
     428  }
     429  if(hasRes<0)
     430    addToMap(statusInfo,"Status","Failed");
     431  return;
     432}
     433
     434/**
     435 * Check if a service is running.
     436 *
     437 * @param conf the maps containing the setting of the main.cfg file
     438 * @param pid the unique service identifier (usid from the lenv section)
     439 * @return 1 in case the service is still running, 0 otherwise
     440 */
     441int isRunning(maps* conf,char* pid){
     442  int res=0;
     443  map *schema=getMapFromMaps(conf,"database","schema");
     444  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(pid)+73+1)*sizeof(char));
     445  sprintf(sqlQuery,"select count(*) as t from %s.services where uuid=$$%s$$ and end_time is null;",schema->value,pid);
     446  if( zoo_DS == NULL )
     447    init_sql(conf);
     448  execSql(conf,sqlQuery);
     449  OGRFeature  *poFeature = NULL;
     450  const char *tmp1;
     451  while( (poFeature = zoo_ResultSet->GetNextFeature()) != NULL ){
     452    for( int iField = 0; iField < poFeature->GetFieldCount(); iField++ ){
     453      if( poFeature->IsFieldSet( iField ) &&
     454          atoi(poFeature->GetFieldAsString( iField ))>0 ){
     455        res=1;
     456        break;
     457      }
     458    }
     459    OGRFeature::DestroyFeature( poFeature );
     460  }
     461  cleanUpResultSet(conf);
     462  return res;
     463}
     464
    334465#endif
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png