30 if( m_xmlFiles.size() == 1 && m_writeDBfile )
32 std::size_t
found = m_xmlFiles[0].find_last_of(
'/');
33 m_outFileInName = m_xmlFiles[0].substr(
found+1);
35 else if ( m_writeDBfile )
ATH_MSG_ERROR(
"writing data base files currently only supported if just a single input XML is given!");
37 m_outFileName =
"Out.AmdcOracle.AM." + m_outFileType +
"temp.data";
38 m_outPREsqlName =
"Out.AmdcOracle.AM." + m_outFileType +
".PREsql";
40 if (m_DBFileName.empty()) {
41 m_DBFileName =
"Generated_" + m_outFileType +
"_pool.txt";
44 static std::once_flag
init;
45 std::call_once (
init, [&]()
53 return StatusCode::SUCCESS;
68 controller->ParseFiles();
73 std::string AGDDfile = theHelper.
GetAGDD(m_dumpAGDD, m_outFileType, m_DBFileName);
74 controller->ParseString(AGDDfile);
80 controller->PrintSections();
83 controller->UseGeoModelDetector(
"Muon");
84 controller->BuildAll();
92 ATH_MSG_ERROR(
"something went wrong building the RO geometry!!! ");
93 return StatusCode::FAILURE;
99 ATH_MSG_INFO(
"\t-- attempting to write output to "<< m_outFileName );
100 if( !m_outFileName.empty() )
102 if(!controller->WriteAGDDtoDBFile( m_outFileName ))
104 ATH_MSG_ERROR(
"\t-- something went wrong during writing AGDD file - crashing" );
105 return StatusCode::FAILURE;
108 ATH_MSG_INFO(
"\t-- AGDD successfully dumped to "<< m_outFileName);
110 if( !WritePREsqlFile() )
112 ATH_MSG_ERROR(
"\t-- something went wrong during writing PREsql file - crashing" );
113 return StatusCode::FAILURE;
116 ATH_MSG_INFO(
"\t-- AGDD successfully wrote PREsql file "<< m_outPREsqlName);
120 ATH_MSG_ERROR(
"\t-- no output file name provided - crashing " );
121 return StatusCode::FAILURE;
127 return StatusCode::SUCCESS;
133 std::ifstream
outfile(
m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary);
135 std::vector<std::string> newoutfilelines;
136 std::string outfileline;
137 while( getline(
outfile, outfileline) )
138 if( outfileline !=
"\n" && outfileline !=
"\r" && !outfileline.empty() )
140 const auto strBegin = outfileline.find_first_not_of(
" \t");
141 const auto strEnd = outfileline.find_last_not_of(
" \t");
142 const auto strRange = strEnd - strBegin + 1;
143 if (strBegin != std::string::npos) outfileline = outfileline.substr(strBegin, strRange);
144 newoutfilelines.push_back(outfileline);
149 for(
auto it = newoutfilelines.begin();
it != newoutfilelines.end(); ++
it)
151 if(
it != newoutfilelines.begin()) newoutfile <<
"\n";
169 std::ofstream prefile;
171 prefile <<
"insert into NSWD_data (\n";
172 prefile <<
"NSWD_data_id,\n";
173 prefile <<
"ACTVERS,\n";
174 prefile <<
"ACTVNAME,\n";
175 prefile <<
"ALGVERS,\n";
176 prefile <<
"ALGVNAME,\n";
177 prefile <<
"PASVERS,\n";
178 prefile <<
"PASVNAME,\n";
179 prefile <<
"FORMAT,\n";
180 prefile <<
"FNAME,\n";
181 prefile <<
"LENNSW,\n";
182 prefile <<
"NLINE,\n";
184 prefile <<
") values (XXX_DATA_ID_KOUNTER,\n";
189 prefile <<
"empty_clob()\n";
191 prefile <<
"insert into NSWD_data2tag values (XXX_DATA2TAG_KOUNTER,XXX_DATA_ID_KOUNTER);\n";
192 prefile <<
"DECLARE\n";
193 prefile <<
" lobloc CLOB;\n";
194 prefile <<
" req utl_http.req;\n";
195 prefile <<
" resp utl_http.resp;\n";
196 prefile <<
" text VARCHAR2(32767);\n";
197 prefile <<
" amount INTEGER(10) := 0;\n";
198 prefile <<
" offset INTEGER(10) := 0;\n";
199 prefile <<
" TRUE BOOLEAN;\n";
200 prefile <<
"BEGIN\n";
201 prefile <<
" SELECT data INTO lobloc\n";
202 prefile <<
" FROM NSWD_data\n";
203 prefile <<
" WHERE NSWD_data_id = XXX_DATA_ID_KOUNTER FOR UPDATE;\n";
204 prefile <<
" offset := DBMS_LOB.GETLENGTH(lobloc)+2;\n";
205 prefile <<
" req := utl_http.begin_request(\n";
206 prefile <<
" 'WEB_ADDRESS_FOR_TEMP_DATA_FILENSWDtemp.data');\n";
207 prefile <<
" resp := utl_http.get_response(req);\n";
208 prefile <<
" LOOP\n";
209 prefile <<
" text := ' ';\n";
210 prefile <<
" UTL_HTTP.READ_TEXT(resp, text, NULL);\n";
211 prefile <<
" /* DBMS_OUTPUT.PUT_LINE(text); */\n";
212 prefile <<
" amount := length(text);\n";
213 prefile <<
" DBMS_LOB.WRITEAPPEND(lobloc,amount,text);\n";
214 prefile <<
" END LOOP;\n";
215 prefile <<
" utl_http.end_response(resp);\n";
216 prefile <<
" EXCEPTION\n";
217 prefile <<
" WHEN utl_http.end_of_body\n";
218 prefile <<
" THEN utl_http.end_response(resp);\n";