Commit c585985e9b6dc39ef09fbfa80e2f59ed22db0c6d
1 parent
c01c26d9
Exists in
das2
Generate DAS2 data sources list
Showing
9 changed files
with
176 additions
and
51 deletions
Show diff stats
CMakeLists.txt
... | ... | @@ -199,6 +199,7 @@ add_subdirectory(src/ExternLib/Tetrahedron/elongation) |
199 | 199 | add_subdirectory(src/ExternLib/Tetrahedron/planarity) |
200 | 200 | add_subdirectory(src/ExternLib/Tetrahedron/characteristic) |
201 | 201 | add_subdirectory(src/ExternLib/gtl_lepb_calculate) |
202 | +add_subdirectory(src/das2GetListDataSourcesForAmda) | |
202 | 203 | |
203 | 204 | IF ( CSLIM_FOUND ) |
204 | 205 | add_subdirectory(test/DD_Client/CSlimFixtures) | ... | ... |
src/ParamGetImpl/DAS2Interface/AMDAPlugin.cc
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | #include "ParamGetDAS2.hh" |
28 | 28 | #include "GetDAS2Node.hh" |
29 | 29 | #include "ProcessDAS2GetTable.hh" |
30 | +#include "DAS2ServerManager.hh" | |
30 | 31 | |
31 | 32 | using namespace AMDA::Parameters; |
32 | 33 | using namespace AMDA::XMLParameterConfigurator; |
... | ... | @@ -62,6 +63,10 @@ using namespace AMDA::XMLParameterConfigurator; |
62 | 63 | ProcessFactory das2GetTableProcess = boost::factory<AMDA::DAS2Interface::ProcessDAS2GetTable*>(); |
63 | 64 | ServicesServer::getInstance()->addProcessFactory("das2_get_table", das2GetTableProcess); |
64 | 65 | ServicesServer::getInstance()->linkProcessWithPlugin("das2_get_table", pm.getCurrentPluginPath()); |
66 | + | |
67 | + std::cout << "BRE - das2_list_data_sources" << std::endl; | |
68 | + ServicesServer::getInstance()->addServiceImpl<AMDA::DAS2Interface::DAS2ListDataSourcesProcess>("das2_list_data_sources", &AMDA::DAS2Interface::generateDAS2ListDataSourcesForAmda); | |
69 | + ServicesServer::getInstance()->linkProcessWithPlugin("das2_list_data_sources", pm.getCurrentPluginPath()); | |
65 | 70 | } |
66 | 71 | |
67 | 72 | extern "C" void unregisterPlugin() | ... | ... |
src/ParamGetImpl/DAS2Interface/DAS2Server.cc
... | ... | @@ -187,7 +187,7 @@ bool DAS2Tree::writeToXMLFile(std::string& filePath, std::string& dataCenterName |
187 | 187 | if (writer == NULL) { |
188 | 188 | return false; |
189 | 189 | } |
190 | - | |
190 | + xmlTextWriterSetIndent(writer, 1); | |
191 | 191 | int rc; |
192 | 192 | rc = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", NULL); |
193 | 193 | |
... | ... | @@ -196,12 +196,6 @@ bool DAS2Tree::writeToXMLFile(std::string& filePath, std::string& dataCenterName |
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | -/* | |
200 | -<dataRoot xml:id="myRemoteData-treeRootNode"> | |
201 | - <dataCenter xml:id="MASER" name="MASER" url="https://voparis-das-maser.obspm.fr/das2/server"> | |
202 | - | |
203 | -*/ | |
204 | - | |
205 | 199 | rc = xmlTextWriterStartElement(writer, BAD_CAST "dataRoot"); |
206 | 200 | if (rc < 0) { |
207 | 201 | xmlFreeTextWriter(writer); |
... | ... | @@ -280,53 +274,15 @@ DAS2DatasetSPtr& DAS2Server::getDataset(std::string& pId) { |
280 | 274 | return _datasetMap[pId]; |
281 | 275 | } |
282 | 276 | |
283 | -DAS2Tree DAS2Server::getListDataSources() { | |
277 | +DAS2Tree DAS2Server::getListDataSources(std::string& baseName) { | |
284 | 278 | std::string url = _url; |
285 | 279 | url += "?server=list"; |
286 | 280 | std::string listSources = DAS2CWrapper::getListDataSources(url); |
287 | 281 | DAS2Tree tree(listSources); |
288 | - std::string filePath = "/home/amda_admin/AMDA/AMDA_Kernel/app-debug/base.xml"; | |
289 | - std::string baseName = "MASER"; | |
282 | + std::string filePath = baseName; | |
283 | + filePath += "_"; | |
284 | + filePath += "base.xml"; | |
290 | 285 | tree.writeToXMLFile(filePath, baseName, _url); |
291 | - /*std::istringstream lines(listSources.c_str()); | |
292 | - std::string line; | |
293 | - while (std::getline(lines, line)) { | |
294 | - boost::algorithm::trim(line); | |
295 | - if (line.empty()) | |
296 | - continue; | |
297 | - std::vector<std::string> parts; | |
298 | - boost::split(parts, line, [](char c){return c == '|';}); | |
299 | - std::string path = ""; | |
300 | - std::string description = ""; | |
301 | - if (parts.size() == 1) { | |
302 | - path = parts[0]; | |
303 | - } | |
304 | - else if (parts.size() == 2) { | |
305 | - path = parts[0]; | |
306 | - description = parts[1]; | |
307 | - | |
308 | - } | |
309 | - else | |
310 | - continue; | |
311 | - bool isLeaf = path.back() != '/'; | |
312 | - if (isLeaf) { | |
313 | - std::cout << "BRE - " << path << std::endl; | |
314 | - DAS2ParamInfo paramInfo; | |
315 | - if (!this->getDataset(path)->getDSDFInfo(paramInfo) || | |
316 | - !this->getDataset(path)->getDataInfo(paramInfo)) { | |
317 | - continue; | |
318 | - } | |
319 | - std::cout << "BRE => " << paramInfo.label << std::endl; | |
320 | - } | |
321 | - parts.clear(); | |
322 | - boost::split(parts, path, [](char c){return c == '/';}); | |
323 | - std::string currentPath = ""; | |
324 | - for (std::vector<std::string>::iterator it = parts.begin(); it != parts.end(); ++it) { | |
325 | - if (!currentPath.empty()) | |
326 | - currentPath += "/"; | |
327 | - currentPath += *it; | |
328 | - } | |
329 | - }*/ | |
330 | 286 | return tree; |
331 | 287 | } |
332 | 288 | ... | ... |
src/ParamGetImpl/DAS2Interface/DAS2Server.hh
src/ParamGetImpl/DAS2Interface/DAS2ServerManager.cc
... | ... | @@ -25,5 +25,10 @@ namespace AMDA { |
25 | 25 | } |
26 | 26 | return _das2ServerMap[pURL]; |
27 | 27 | } |
28 | + | |
29 | + bool generateDAS2ListDataSourcesForAmda(std::string& centerName, std::string& url) { | |
30 | + AMDA::DAS2Interface::DAS2ServerSPtr server = AMDA::DAS2Interface::DAS2ServerManager::getInstance()->getServer(url); | |
31 | + server->getListDataSources(centerName); | |
32 | + } | |
28 | 33 | } /* namespace DAS2Interface */ |
29 | 34 | } /* namespace AMDA */ | ... | ... |
src/ParamGetImpl/DAS2Interface/DAS2ServerManager.hh
... | ... | @@ -25,6 +25,7 @@ namespace AMDA { |
25 | 25 | public: |
26 | 26 | |
27 | 27 | typedef std::map<std::string,DAS2ServerSPtr> DAS2ServerMap; |
28 | + | |
28 | 29 | |
29 | 30 | // Design pattern |
30 | 31 | friend class Singleton<DAS2ServerManager>; |
... | ... | @@ -42,6 +43,9 @@ namespace AMDA { |
42 | 43 | DAS2ServerMap _das2ServerMap; |
43 | 44 | }; |
44 | 45 | |
46 | + typedef bool (*DAS2ListDataSourcesProcess)(std::string&, std::string&); | |
47 | + bool generateDAS2ListDataSourcesForAmda(std::string& centerName, std::string& url); | |
48 | + | |
45 | 49 | } /* namespace DAS2Interface */ |
46 | 50 | } /* namespace AMDA */ |
47 | 51 | #endif /* DAS2SERVERMANAGER_HH_ */ | ... | ... |
src/ParamGetImpl/DAS2Interface/ParamGetDAS2.cc
... | ... | @@ -52,7 +52,7 @@ TimeStamp ParamGetDAS2::init() |
52 | 52 | { |
53 | 53 | LOG4CXX_DEBUG(gLogger, "ParamGetDAS2::init"); |
54 | 54 | |
55 | - _datasetSPtr->getServer()->getListDataSources(); | |
55 | + //_datasetSPtr->getServer()->getListDataSources(); | |
56 | 56 | |
57 | 57 | if (!_datasetSPtr->getDSDFInfo(_paramInfo)) { |
58 | 58 | BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg(std::string("Cannot retrieve DSDF"))); | ... | ... |
... | ... | @@ -0,0 +1,48 @@ |
1 | + | |
2 | +PROJECT(das2GetListDataSourcesForAmda) | |
3 | + | |
4 | +include_directories( | |
5 | + ${CMAKE_HOME_DIRECTORY}/src/TimeUtil/ | |
6 | + ${CMAKE_HOME_DIRECTORY}/src/helpers/ | |
7 | + ${CMAKE_HOME_DIRECTORY}/src/Info/ | |
8 | + ${CMAKE_HOME_DIRECTORY}/src/Common/ | |
9 | + ${CMAKE_HOME_DIRECTORY}/src/Parameters/ | |
10 | + ${CMAKE_HOME_DIRECTORY}/src/PostProcessing/ | |
11 | + ${CMAKE_HOME_DIRECTORY}/src/XMLConfigurator/ | |
12 | + ${CMAKE_HOME_DIRECTORY}/src/XMLParameterConfigurator/ | |
13 | + ${CMAKE_HOME_DIRECTORY}/src/Plugins/ | |
14 | + ${CMAKE_HOME_DIRECTORY}/src/TimeTableCatalog/ | |
15 | + ${CMAKE_HOME_DIRECTORY}/src/SpiceKernel/ | |
16 | + ${DDCLIENTINCLUDE_DIR} | |
17 | + ${LOG4CXX_INCLUDE_DIR} | |
18 | + ${LIBXML2_INCLUDE_DIR} | |
19 | + ${Boost_INCLUDE_DIR} | |
20 | +) | |
21 | + | |
22 | +#Configuration de la librairie | |
23 | +file( | |
24 | + GLOB_RECURSE | |
25 | + source_files | |
26 | + ./* | |
27 | +) | |
28 | + | |
29 | +ADD_EXECUTABLE( das2GetListDataSourcesForAmda ${source_files} ) | |
30 | + | |
31 | + | |
32 | +target_link_libraries( | |
33 | + das2GetListDataSourcesForAmda | |
34 | + TimeUtil | |
35 | + AMDA_COMMON | |
36 | + ${CMAKE_THREAD_LIBS_INIT} | |
37 | + Parameters | |
38 | + ${LOG4CXX_LIBRARIES} | |
39 | + ${LIBXML2_LIBRARIES} | |
40 | + ${Boost_LIBRARIES} | |
41 | + Plugin | |
42 | + XMLParameterConfigurator | |
43 | + ParamOutputImpl | |
44 | + TimeTableCatalog | |
45 | + Info | |
46 | + SpiceKernel | |
47 | + ${DDCLIENTLIBRARY} | |
48 | +) | ... | ... |
... | ... | @@ -0,0 +1,106 @@ |
1 | +/** | |
2 | + * Main.cc | |
3 | + * Created on: 18 mar. 2016 | |
4 | + * Author: AKKA IS | |
5 | + */ | |
6 | + | |
7 | +#include <iostream> | |
8 | + | |
9 | +#include <boost/program_options.hpp> | |
10 | + | |
11 | +#include "AMDA-Kernel_Config.hh" | |
12 | +#include <Application.hh> | |
13 | + | |
14 | +// Parameters module include | |
15 | +#include "ParameterManager.hh" | |
16 | +#include "Parameter.hh" | |
17 | +#include "ParamGet.hh" | |
18 | +#include "Process.hh" | |
19 | +#include "ServicesServer.hh" | |
20 | +#include "TimeUtil.hh" | |
21 | + | |
22 | +using namespace std; | |
23 | +namespace po = boost::program_options; | |
24 | +using namespace log4cxx; | |
25 | +using namespace log4cxx::helpers; | |
26 | +using namespace AMDA::Parameters; | |
27 | + | |
28 | + | |
29 | +typedef bool (*DAS2ListDataSourcesProcess)(std::string&, std::string&); | |
30 | + | |
31 | +/** | |
32 | + * Main function | |
33 | + */ | |
34 | +int main(int argc, char *argv[]) { | |
35 | + int result = AMDA_EXIT_OK; | |
36 | + | |
37 | + /// Parse command line parameters | |
38 | + po::options_description desc("Allowed options"); | |
39 | + | |
40 | + desc.add_options() | |
41 | + ("help,h", "Produce help message") | |
42 | + ("version,v", "Program version") | |
43 | + ("center,c", po::value< string >(), "Center name") | |
44 | + ("url,u", po::value< string >(), "DAS2 entry point") | |
45 | + ; | |
46 | + | |
47 | + po::positional_options_description c, u; | |
48 | + c.add("center", -1); | |
49 | + u.add("url", -1); | |
50 | + | |
51 | + std::cout << "BRE - A" << std::endl; | |
52 | + | |
53 | + po::variables_map vm; | |
54 | + po::store(po::command_line_parser(argc, argv).options(desc).positional(c).positional(u).run(), vm); | |
55 | + po::notify(vm); | |
56 | + | |
57 | + std::cout << "BRE - B" << std::endl; | |
58 | + | |
59 | + if (vm.count("help")) { | |
60 | + cout << desc << "\n"; | |
61 | + return result; | |
62 | + } | |
63 | + | |
64 | + std::cout << "BRE - C" << std::endl; | |
65 | + if (vm.count("version")) { | |
66 | + cout << "Version: " << AMDA_Kernel_VERSION << "\n"; | |
67 | + return result; | |
68 | + } | |
69 | + | |
70 | + std::cout << "BRE - D" << std::endl; | |
71 | + if (!vm.count("center")) { | |
72 | + return result; | |
73 | + } | |
74 | + | |
75 | + std::cout << "BRE - E" << std::endl; | |
76 | + if (!vm.count("url")) { | |
77 | + return result; | |
78 | + } | |
79 | + | |
80 | + std::cout << "BRE - F" << std::endl; | |
81 | + | |
82 | + AMDA::Common::Application lMain; | |
83 | + | |
84 | + return lMain.main(argc,argv,[&](int , char **, AMDA::helpers::Properties& lProperties) -> int { | |
85 | + | |
86 | + std::cout << "BRE - G" << std::endl; | |
87 | + | |
88 | + string centerName = vm["center"].as< string >(); | |
89 | + string url = vm["url"].as< string >(); | |
90 | + | |
91 | + ServicesServer *servicesServer = ServicesServer::getInstance(); | |
92 | + | |
93 | + std::cout << "BRE - H" << std::endl; | |
94 | + | |
95 | + DAS2ListDataSourcesProcess list_data_sources = servicesServer->getService<DAS2ListDataSourcesProcess>("das2_list_data_sources"); | |
96 | + | |
97 | + std::cout << "BRE - I" << std::endl; | |
98 | + list_data_sources(centerName, url); | |
99 | + | |
100 | + std::cout << "BRE - " << list_data_sources << std::endl; | |
101 | + | |
102 | + return result; | |
103 | +}); | |
104 | + | |
105 | +} | |
106 | + | ... | ... |