Ignore:
Timestamp:
Jun 7, 2012, 10:54:31 PM (12 years ago)
Author:
djay
Message:

Add support for multiple inputs values for the same identifier.

File:
1 edited

Legend:

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

    r348 r360  
    22 * Author : Gérald FENOY
    33 *
    4  *  Copyright 2008-2011 GeoLabs SARL. All rights reserved.
     4 *  Copyright 2008-2012 GeoLabs SARL. All rights reserved.
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    9292      str[i]=toReplaceBy;
    9393  }
     94}
     95
     96/**
     97 * Create (or append to) an array valued maps
     98 * value = "["",""]"
     99 */
     100int appendMapsToMaps(maps* m,maps* mo,maps* mi,elements* elem){
     101
     102  map* tmap=getMapType(mo->content);
     103  if(tmap==NULL){
     104    tmap=getMapType(elem->defaults->content);
     105  }
     106
     107  map* testMap=getMap(elem->content,"maxOccurs");
     108  if(testMap!=NULL){
     109    if(strncasecmp(testMap->value,"unbounded",9)!=0 && atoi(testMap->value)>1){
     110      if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
     111        char emsg[1024];
     112        sprintf(emsg,_("You set maximum occurences for <%s> as %i but you tried to use it more than the limit you set. Please correct your ZCFG file or your request."),mi->name,atoi(testMap->value));
     113        errorException(m,emsg,"InternalError");
     114        return -1;
     115      }
     116    }else{
     117      if(strncasecmp(testMap->value,"unbounded",9)==0){
     118        if(addMapsArrayToMaps(&mo,mi,tmap->name)<0){
     119          char emsg[1024];
     120          map* tmpMap=getMap(mi->content,"length");
     121          sprintf(emsg,_("ZOO-Kernel was unable to load your data for %s position %s."),mi->name,tmpMap->value);
     122          errorException(m,emsg,"InternalError");
     123          return -1;
     124        }
     125      }
     126      else{
     127        char emsg[1024];
     128        sprintf(emsg,_("You set maximum occurences for <%s> to one but you tried to use it more than once. Please correct your ZCFG file or your request."),mi->name);
     129        errorException(m,emsg,"InternalError");
     130        return -1;
     131      }
     132    }
     133  }
     134  return 0;
    94135}
    95136
     
    10681109        if(request_input_real_format==NULL)
    10691110          request_input_real_format=dupMaps(&tmpmaps);
    1070         else
    1071           addMapsToMaps(&request_input_real_format,tmpmaps);
     1111        else{
     1112          maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
     1113          if(testPresence!=NULL){
     1114            elements* elem=getElements(s1->inputs,tmpmaps->name);
     1115            if(elem!=NULL){
     1116              if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
     1117                freeMaps(&m);
     1118                free(m);
     1119                free(REQUEST);
     1120                free(SERVICE_URL);
     1121                InternetCloseHandle(hInternet);
     1122                freeService(&s1);
     1123                free(s1);
     1124                return 0;
     1125              }
     1126            }
     1127          }
     1128          else
     1129            addMapsToMaps(&request_input_real_format,tmpmaps);
     1130        }
    10721131        freeMaps(&tmpmaps);
    10731132        free(tmpmaps);
     
    14791538        fflush(stderr);
    14801539#endif
    1481         addMapsToMaps(&request_input_real_format,tmpmaps);
     1540
     1541        {
     1542          maps* testPresence=getMaps(request_input_real_format,tmpmaps->name);
     1543          if(testPresence!=NULL){
     1544            elements* elem=getElements(s1->inputs,tmpmaps->name);
     1545            if(elem!=NULL){
     1546              if(appendMapsToMaps(m,request_input_real_format,tmpmaps,elem)<0){
     1547                freeMaps(&m);
     1548                free(m);
     1549                free(REQUEST);
     1550                free(SERVICE_URL);
     1551                InternetCloseHandle(hInternet);
     1552                freeService(&s1);
     1553                free(s1);
     1554                return 0;
     1555              }
     1556            }
     1557          }
     1558          else
     1559            addMapsToMaps(&request_input_real_format,tmpmaps);
     1560        }
    14821561       
    14831562#ifdef DEBUG
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