List of usage examples for org.apache.commons.io FileUtils copyFileToDirectory
public static void copyFileToDirectory(File srcFile, File destDir) throws IOException
From source file:es.bsc.servicess.ide.PackagingUtils.java
/** Copy runtime files for a package of Orchestration Elements. * @param runtime Path to the runtime installation * @param lib Package lib folder/*from w ww . ja v a 2s .com*/ * @throws CoreException */ private static void copyOrchestrationRuntimeFiles(String runtime, IFolder lib) throws CoreException { File lib_dir = new File(runtime + "/lib"); File web_inf_lib = lib.getLocation().toFile(); List<File> dirs = getRuntimeLibrariesDirs(lib_dir); for (File d : dirs) { if (d.isDirectory()) { Iterator<File> fi = FileUtils.iterateFiles(d, new String[] { "jar" }, false); while (fi.hasNext()) { File f = fi.next(); if (!isFileInDiscardList(f)) { try { // System.out.println("Trying to copy File "+ // f.getAbsolutePath()); FileUtils.copyFileToDirectory(f, web_inf_lib); log.debug(" File copied " + f.getAbsolutePath()); } catch (IOException e) { log.error("File " + f.getAbsolutePath() + "could not be copied to " + web_inf_lib.getAbsolutePath(), e); } } } } else log.warn("File " + d.getAbsolutePath() + "is not a directory"); } }
From source file:es.bsc.servicess.ide.PackagingUtils.java
/** Copy JaxWS libraries to the front-end package * @param lib front-end package library folder *//*from w ww . java 2 s .c om*/ private static void copyJaxWSLibraries(IFolder lib) { File web_inf_lib = lib.getLocation().toFile(); Bundle b = Platform.getBundle(BUNDLE_NAME); try { // TODO: Check if correct when installed String s = FileLocator.getBundleFile(b).getAbsolutePath() + "/lib/jaxws/"; File d = new File(s); if (d.isDirectory()) { Iterator<File> fi = FileUtils.iterateFiles(d, new String[] { "jar" }, false); while (fi.hasNext()) { File f = fi.next(); try { FileUtils.copyFileToDirectory(f, web_inf_lib); } catch (IOException e) { log.error("File " + f.getAbsolutePath() + "could not be copied to " + web_inf_lib.getAbsolutePath(), e); } } } else { log.warn("File " + d.getAbsolutePath() + " is not a directory"); } } catch (IOException e) { log.error("Failing to locate bundle file", e); e.printStackTrace(); } }
From source file:es.bsc.servicess.ide.PackagingUtils.java
/** Copy files to a folder * @param origins Files to copy// ww w . ja v a 2 s.c o m * @param destination Destination folder * @throws CoreException */ public static void copyFilesToDir(String[] origins, String destination) throws CoreException { File d = new File(destination); if (d.isDirectory()) { for (String s : origins) { File f = new File(s); try { FileUtils.copyFileToDirectory(f, d); } catch (IOException e) { log.error("File " + f.getAbsolutePath() + "could not be copied to " + d.getAbsolutePath(), e); e.printStackTrace(); throw (new JavaModelException(e, 0)); } } } else { throw (new JavaModelException(new Exception(destination + " is not a directory"), 0)); } }
From source file:com.thoughtworks.go.config.CachedGoConfigIntegrationTest.java
private void checkInPartial(String partial, File externalConfigRepo) throws IOException { ClassPathResource resource = new ClassPathResource(partial); if (resource.getFile().isDirectory()) { FileUtils.copyDirectory(resource.getFile(), externalConfigRepo); } else {/*w w w.ja va 2 s. co m*/ FileUtils.copyFileToDirectory(resource.getFile(), externalConfigRepo); } gitAddDotAndCommit(externalConfigRepo); }
From source file:com.maxl.java.aips2sqlite.RealExpertInfo.java
public void process() { // Get stop words first getStopWords();/*from ww w . java 2 s. co m*/ // Extract EPha SwissmedicNo5 to ATC map extractSwissmedicNo5ToAtcMap(); // Extract package information (this is the heavy-duty bit) extractPackageInfo(); // Extract Swiss DRG information extractSwissDRGInfo(); try { // Load CSS file: used only for self-contained xml files String amiko_style_v1_str = FileOps.readCSSfromFile(Constants.FILE_STYLE_CSS_BASE + "v1.css"); // Create error report file ParseReport parse_errors = null; if (CmlOptions.GENERATE_REPORTS == true) { parse_errors = new ParseReport(Constants.FILE_PARSE_REPORT, CmlOptions.DB_LANGUAGE, "html"); if (CmlOptions.DB_LANGUAGE.equals("de")) parse_errors.addHtmlHeader("Schweizer Arzneimittel-Kompendium", Constants.FI_DB_VERSION); else if (CmlOptions.DB_LANGUAGE.equals("fr")) parse_errors.addHtmlHeader("Compendium des Mdicaments Suisse", Constants.FI_DB_VERSION); } // Create indications report file BufferedWriter bw_indications = null; Map<String, String> tm_indications = new TreeMap<String, String>(); if (CmlOptions.INDICATIONS_REPORT == true) { ParseReport indications_report = new ParseReport(Constants.FILE_INDICATIONS_REPORT, CmlOptions.DB_LANGUAGE, "txt"); bw_indications = indications_report.getBWriter(); } /* * Add pseudo Fachinfos to SQLite database */ int tot_pseudo_counter = 0; if (CmlOptions.ADD_PSEUDO_FI == true) { PseudoExpertInfo pseudo_fi = new PseudoExpertInfo(m_sql_db, CmlOptions.DB_LANGUAGE, m_map_products); // Process tot_pseudo_counter = pseudo_fi.process(); System.out.println(""); } /* * Add real Fachinfos to SQLite database */ // Initialize counters for different languages int med_counter = 0; int tot_med_counter = 0; int missing_regnr_str = 0; int missing_pack_info = 0; int missing_atc_code = 0; int errors = 0; String fi_complete_xml = ""; // First pass is always with DB_LANGUAGE set to German! (most complete information) // The file dumped in ./reports is fed to AllDown.java to generate a multilingual ATC code / ATC class file, e.g. German - French Set<String> atccode_set = new TreeSet<String>(); // Treemap for owner error report (sorted by key) TreeMap<String, ArrayList<String>> tm_owner_error = new TreeMap<String, ArrayList<String>>(); HtmlUtils html_utils = null; System.out.println("Processing real Fachinfos..."); for (MedicalInformations.MedicalInformation m : m_med_list) { // --> Read FACHINFOS! <-- if (m.getLang().equals(CmlOptions.DB_LANGUAGE) && m.getType().equals("fi")) { // Database contains less than 5000 medis - this is a safe upperbound! if (tot_med_counter < 5000) { // Trim titles of leading and trailing spaces m.setTitle(m.getTitle().trim()); // Extract section titles and section ids MedicalInformations.MedicalInformation.Sections med_sections = m.getSections(); List<MedicalInformations.MedicalInformation.Sections.Section> med_section_list = med_sections .getSection(); String ids_str = ""; String titles_str = ""; for (MedicalInformations.MedicalInformation.Sections.Section s : med_section_list) { ids_str += (s.getId() + ","); titles_str += (s.getTitle() + ";"); } Document doc = Jsoup.parse(m.getContent()); doc.outputSettings().escapeMode(EscapeMode.xhtml); html_utils = new HtmlUtils(m.getContent()); html_utils.setLanguage(CmlOptions.DB_LANGUAGE); html_utils.clean(); // Extract registration number (swissmedic no5) String regnr_str = ""; if (CmlOptions.DB_LANGUAGE.equals("de")) regnr_str = html_utils.extractRegNrDE(m.getTitle()); else if (CmlOptions.DB_LANGUAGE.equals("fr")) regnr_str = html_utils.extractRegNrFR(m.getTitle()); // Pattern matcher for regnr command line option, (?s) searches across multiple lines Pattern regnr_pattern = Pattern.compile("(?s).*\\b" + CmlOptions.OPT_MED_REGNR); if (m.getTitle().toLowerCase().startsWith(CmlOptions.OPT_MED_TITLE.toLowerCase()) && regnr_pattern.matcher(regnr_str).find() && m.getAuthHolder().toLowerCase() .startsWith(CmlOptions.OPT_MED_OWNER.toLowerCase())) { System.out.println(tot_med_counter + " - " + m.getTitle() + ": " + regnr_str); if (regnr_str.isEmpty()) { errors++; if (CmlOptions.GENERATE_REPORTS == true) { parse_errors.append("<p style=\"color:#ff0099\">ERROR " + errors + ": reg. nr. could not be parsed in AIPS.xml (swissmedic) - " + m.getTitle() + " (" + regnr_str + ")</p>"); // Add to owner errors ArrayList<String> error = tm_owner_error.get(m.getAuthHolder()); if (error == null) error = new ArrayList<String>(); error.add(m.getTitle() + ";regnr"); tm_owner_error.put(m.getAuthHolder(), error); } missing_regnr_str++; regnr_str = ""; } // Associate ATC classes and subclasses (atc_map) String atc_class_str = ""; String atc_description_str = ""; // This bit is necessary because the ATC Code in the AIPS DB is broken sometimes String atc_code_str = ""; boolean atc_error_found = false; // Use EPha ATC Codes, AIPS is fallback solution String authNrs = m.getAuthNrs(); if (authNrs != null) { // Deal with multi-swissmedic no5 case String regnrs[] = authNrs.split(","); // Use set to avoid duplicate ATC codes Set<String> regnrs_set = new LinkedHashSet<>(); // Loop through EPha ATC codes for (String r : regnrs) { regnrs_set.add(m_smn5_atc_map.get(r.trim())); } // Iterate through set and format nicely for (String r : regnrs_set) { if (atc_code_str == null || atc_code_str.isEmpty()) atc_code_str = r; else atc_code_str += "," + r; } } else atc_error_found = true; // Notify any other problem with the EPha ATC codes if (atc_code_str == null || atc_code_str.isEmpty()) atc_error_found = true; // Fallback solution if (atc_error_found == true) { if (m.getAtcCode() != null && !m.getAtcCode().equals("n.a.") && m.getAtcCode().length() > 1) { atc_code_str = m.getAtcCode(); atc_code_str = atc_code_str.replaceAll("–", "("); atc_code_str = atc_code_str.replaceAll("Code", "").replaceAll("ATC", "") .replaceAll(" ", "").replaceAll("\\(.*", "").replaceAll("/", ",") .replaceAll("[^A-Za-z0-9,]", ""); if (atc_code_str.charAt(1) == 'O') { // E.g. Ascosal Brausetabletten atc_code_str = atc_code_str.substring(0, 1) + '0' + atc_code_str.substring(2); } if (atc_code_str.length() > 7) { if (atc_code_str.charAt(7) != ',' || atc_code_str.length() != 15) atc_code_str = atc_code_str.substring(0, 7); } } else { // Work backwards using m_atc_map and m.getSubstances() String substances = m.getSubstances(); if (substances != null) { if (m_atc_map.containsValue(substances)) { for (Map.Entry<String, String> entry : m_atc_map.entrySet()) { if (entry.getValue().equals(substances)) { atc_code_str = entry.getKey(); } } } } } atc_error_found = false; } // Now let's clean the m.getSubstances() String substances = m.getSubstances(); if ((substances == null || substances.length() < 3) && atc_code_str != null) { substances = m_atc_map.get(atc_code_str); } // Set clean substances m.setSubstances(substances); // Set clean ATC Code m.setAtcCode(atc_code_str); // System.out.println("ATC -> " + atc_code_str + ": " + substances); if (atc_code_str != null) { // \\s -> whitespace character, short for [ \t\n\x0b\r\f] // atc_code_str = atc_code_str.replaceAll("\\s",""); // Take "leave" of the tree (most precise classification) String a = m_atc_map.get(atc_code_str); if (a != null) { atc_description_str = a; atccode_set.add(atc_code_str + ": " + a); } else { // Case: ATC1,ATC2 if (atc_code_str.length() == 15) { String[] codes = atc_code_str.split(","); if (codes.length > 1) { String a1 = m_atc_map.get(codes[0]); if (a1 == null) { atc_error_found = true; a1 = "k.A."; } String a2 = m_atc_map.get(codes[1]); if (a2 == null) { atc_error_found = true; a2 = "k.A."; } atc_description_str = a1 + "," + a2; } } else if (m.getSubstances() != null) { // Fallback in case nothing else works atc_description_str = m.getSubstances(); // Work backwards using m_atc_map and m.getSubstances(), change ATC code if (atc_description_str != null) { if (m_atc_map.containsValue(atc_description_str)) { for (Map.Entry<String, String> entry : m_atc_map.entrySet()) { if (entry.getValue().equals(atc_description_str)) { m.setAtcCode(entry.getKey()); } } } } } else { atc_error_found = true; if (CmlOptions.DB_LANGUAGE.equals("de")) atc_description_str = "k.A."; else if (CmlOptions.DB_LANGUAGE.equals("fr")) atc_description_str = "n.s."; } } // Read out only two levels (L1, L3, L4, L5) for (int i = 1; i < 6; i++) { if (i != 2) { String atc_key = ""; if (i <= atc_code_str.length()) atc_key = atc_code_str.substring(0, i); char sep = (i >= 4) ? '#' : ';'; // #-separator between L4 and L5 if (atc_key != null) { String c = m_atc_map.get(atc_key); if (c != null) { atccode_set.add(atc_key + ": " + c); atc_class_str += (c + sep); } else { atc_class_str += sep; } } else { atc_class_str += sep; } } } // System.out.println("atc class = " + atc_class_str); // If DRG medication, add to atc_description_str ArrayList<String> drg = m_swiss_drg_info.get(atc_code_str); if (drg != null) { atc_description_str += (";DRG"); } } if (atc_error_found) { errors++; if (CmlOptions.GENERATE_REPORTS) { parse_errors.append("<p style=\"color:#0000bb\">ERROR " + errors + ": Broken or missing ATC-Code-Tag in AIPS.xml (Swissmedic) or ATC index (Wido) - " + m.getTitle() + " (" + regnr_str + ")</p>"); // Add to owner errors ArrayList<String> error = tm_owner_error.get(m.getAuthHolder()); if (error == null) error = new ArrayList<String>(); error.add(m.getTitle() + ";atccode"); tm_owner_error.put(m.getAuthHolder(), error); } System.err.println(">> ERROR: " + tot_med_counter + " - no ATC-Code found in the XML-Tag \"atcCode\" - (" + regnr_str + ") " + m.getTitle()); missing_atc_code++; } // Additional info stored in add_info_map String add_info_str = ";"; List<String> rnr_list = Arrays.asList(regnr_str.split("\\s*, \\s*")); if (rnr_list.size() > 0) add_info_str = m_add_info_map.get(rnr_list.get(0)); // Sanitize html String html_sanitized = ""; // First check for bad boys (version=1! but actually version>1!) if (!m.getVersion().equals("1") || m.getContent().substring(0, 20).contains("xml")) { for (int i = 1; i < 22; ++i) { html_sanitized += html_utils.sanitizeSection(i, m.getTitle(), m.getAuthHolder(), CmlOptions.DB_LANGUAGE); } html_sanitized = "<div id=\"monographie\">" + html_sanitized + "</div>"; } else { html_sanitized = m.getContent(); } // Add author number html_sanitized = html_sanitized.replaceAll("<div id=\"monographie\">", "<div id=\"monographie\" name=\"" + m.getAuthNrs() + "\">"); // Add Footer, timestamp in RFC822 format DateFormat dateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.getDefault()); Date date = new Date(); String footer_str = "<p class=\"footer\">Auto-generated by <a href=\"https://github.com/zdavatz/aips2sqlite\">aips2sqlite</a> on " + dateFormat.format(date) + "</p>"; // html_sanitized += footer_str; html_sanitized = html_sanitized.replaceAll("</div>$", footer_str + "</div>"); // Extract section indications String section_indications = ""; if (CmlOptions.DB_LANGUAGE.equals("de")) { String sstr1 = "Indikationen/Anwendungsmglichkeiten"; String sstr2 = "Dosierung/Anwendung"; if (html_sanitized.contains(sstr1) && html_sanitized.contains(sstr2)) { int idx1 = html_sanitized.indexOf(sstr1) + sstr1.length(); int idx2 = html_sanitized.substring(idx1, html_sanitized.length()) .indexOf(sstr2); try { section_indications = html_sanitized.substring(idx1, idx1 + idx2); } catch (StringIndexOutOfBoundsException e) { e.printStackTrace(); } } } else if (CmlOptions.DB_LANGUAGE.equals("fr")) { String sstr1 = "Indications/Possibilits demploi"; String sstr2 = "Posologie/Mode demploi"; html_sanitized = html_sanitized.replaceAll("Indications/Possibilits d'emploi", sstr1); html_sanitized = html_sanitized.replaceAll("Posologie/Mode d'emploi", sstr2); html_sanitized = html_sanitized.replaceAll("Indications/possibilits demploi", sstr1); html_sanitized = html_sanitized.replaceAll("Posologie/mode demploi", sstr2); if (html_sanitized.contains(sstr1) && html_sanitized.contains(sstr2)) { int idx1 = html_sanitized.indexOf(sstr1) + sstr1.length(); int idx2 = html_sanitized.substring(idx1, html_sanitized.length()) .indexOf(sstr2); try { section_indications = html_sanitized.substring(idx1, idx1 + idx2); } catch (StringIndexOutOfBoundsException e) { e.printStackTrace(); } } } // Remove all p's, div's, span's and sup's section_indications = section_indications.replaceAll("\\<p.*?\\>", "") .replaceAll("</p>", ""); section_indications = section_indications.replaceAll("\\<div.*?\\>", "") .replaceAll("</div>", ""); section_indications = section_indications.replaceAll("\\<span.*?\\>", "") .replaceAll("</span>", ""); section_indications = section_indications.replaceAll("\\<sup.*?\\>", "") .replaceAll("</sup>", ""); // System.out.println(section_indications); if (CmlOptions.DB_LANGUAGE.equals("fr")) { // Remove apostrophes section_indications = section_indications.replaceAll("l'", "") .replaceAll("d'", ""); section_indications = section_indications.replaceAll("l", "").replaceAll("d", ""); } // Remove all URLs section_indications = section_indications.replaceAll( "\\b(http|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]", ""); // Remove list of type a) b) c) ... 1) 2) ... section_indications = section_indications.replaceAll("^\\w\\)", ""); // Remove numbers, commas, semicolons, parentheses, etc. section_indications = section_indications.replaceAll("[^A-Za-z\\xC0-\\xFF- ]", ""); // Generate long list of keywords LinkedList<String> wordsAsList = new LinkedList<String>( Arrays.asList(section_indications.split("\\s+"))); // Remove stop words Iterator<String> wordIterator = wordsAsList.iterator(); while (wordIterator.hasNext()) { // Note: This assumes there are no null entries in the list and all stopwords are stored in lower case String word = wordIterator.next().trim().toLowerCase(); if (word.length() < 3 || m.getTitle().toLowerCase().contains(word) || m_stop_words_hash.contains(word)) wordIterator.remove(); } section_indications = ""; for (String w : wordsAsList) { // Remove any leading dash or hyphen if (w.startsWith("-")) w = w.substring(1); section_indications += (w + ";"); if (CmlOptions.INDICATIONS_REPORT == true) { // Add to map (key->value), word = key, value = how many times used // Is word w already stored in treemap? String t_str = tm_indications.get(w); if (t_str == null) { t_str = m.getTitle(); tm_indications.put(w, t_str); } else { t_str += (", " + m.getTitle()); tm_indications.put(w, t_str); } } } /* * Update section "Packungen", generate packungen string for shopping cart, and extract therapeutisches index */ List<String> mTyIndex_list = new ArrayList<String>(); m_list_of_packages.clear(); m_list_of_eancodes.clear(); String mContent_str = updateSectionPackungen(m.getTitle(), m.getAtcCode(), m_package_info, regnr_str, html_sanitized, mTyIndex_list); m.setContent(mContent_str); // Check if mPackSection_str is empty AND command line option PLAIN is not active if (CmlOptions.PLAIN == false && m_pack_info_str.isEmpty()) { errors++; if (CmlOptions.GENERATE_REPORTS) { parse_errors.append("<p style=\"color:#bb0000\">ERROR " + errors + ": SwissmedicNo5 not found in Packungen.xls (Swissmedic) - " + m.getTitle() + " (" + regnr_str + ")</p>"); // Add to owner errors ArrayList<String> error = tm_owner_error.get(m.getAuthHolder()); if (error == null) error = new ArrayList<String>(); error.add(m.getTitle() + ";swissmedic5"); tm_owner_error.put(m.getAuthHolder(), error); } System.err.println(">> ERROR: " + tot_med_counter + " - SwissmedicNo5 not found in Swissmedic Packungen.xls - (" + regnr_str + ") " + m.getTitle()); missing_pack_info++; } // Fix problem with wrong div class in original Swissmedic file if (CmlOptions.DB_LANGUAGE.equals("de")) { m.setStyle(m.getStyle().replaceAll("untertitel", "untertitle")); m.setStyle(m.getStyle().replaceAll("untertitel1", "untertitle1")); } // Correct formatting error introduced by Swissmedic m.setAuthHolder(m.getAuthHolder().replaceAll("&", "&")); // Check if substances str has a '$a' and change it to '&alpha' if (m.getSubstances() != null) m.setSubstances(m.getSubstances().replaceAll("\\$a", "α")); if (CmlOptions.XML_FILE == true) { if (!regnr_str.isEmpty()) { // Generate and add hash code String html_str_no_timestamp = mContent_str .replaceAll("<p class=\"footer\">.*?</p>", ""); String hash_code = html_utils.calcHashCode(html_str_no_timestamp); // Add header to html file mContent_str = mContent_str.replaceAll("<head>", "<head>" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" name=\"fi_" + hash_code + "\"/>" + "<style>" + amiko_style_v1_str + "</style>"); // Note: the following line is not necessary! // m.setContent(mContent_str); // Add header to xml file String xml_str = html_utils.convertHtmlToXml("fi", m.getTitle(), mContent_str, regnr_str); xml_str = html_utils.addHeaderToXml("singlefi", xml_str); fi_complete_xml += (xml_str + "\n"); // Write to html and xml files to disk String name = m.getTitle(); // Replace all "Sonderzeichen" name = name.replaceAll("[^a-zA-Z0-9]+", "_"); if (CmlOptions.DB_LANGUAGE.equals("de")) { FileOps.writeToFile(mContent_str, Constants.FI_FILE_XML_BASE + "fi_de_html/", name + "_fi_de.html"); FileOps.writeToFile(xml_str, Constants.FI_FILE_XML_BASE + "fi_de_xml/", name + "_fi_de.xml"); } else if (CmlOptions.DB_LANGUAGE.equals("fr")) { FileOps.writeToFile(mContent_str, Constants.FI_FILE_XML_BASE + "fi_fr_html/", name + "_fi_fr.html"); FileOps.writeToFile(xml_str, Constants.FI_FILE_XML_BASE + "fi_fr_xml/", name + "_fi_fr.xml"); } } } int customer_id = 0; // Is the customer paying? If yes add customer id // str1.toLowerCase().contains(str2.toLowerCase()) if (m.getAuthHolder().toLowerCase().contains("desitin")) customer_id = 1; /* / HERE GO THE OTHER PAYING CUSTOMERS (increment customer_id respectively) */ // Extract (O)riginal / (G)enerika info String orggen_str = ""; if (add_info_str != null) { List<String> ai_list = Arrays.asList(add_info_str.split("\\s*;\\s*")); if (ai_list != null) { if (!ai_list.get(0).isEmpty()) orggen_str = ai_list.get(0); } } // @maxl: 25.04.2015 -> set orggen_str to nil (we are using add_info_str for group names now...) orggen_str = ""; /* * Add medis, titles and ids to database */ String packages_str = ""; for (String s : m_list_of_packages) packages_str += s; String eancodes_str = ""; for (String e : m_list_of_eancodes) eancodes_str += (e + ", "); if (!eancodes_str.isEmpty() && eancodes_str.length() > 2) eancodes_str = eancodes_str.substring(0, eancodes_str.length() - 2); m_sql_db.addExpertDB(m, packages_str, regnr_str, ids_str, titles_str, atc_description_str, atc_class_str, m_pack_info_str, orggen_str, customer_id, mTyIndex_list, section_indications); m_sql_db.addProductDB(m, packages_str, eancodes_str, m_pack_info_str); med_counter++; } } tot_med_counter++; } } System.out.println(); System.out.println("--------------------------------------------"); System.out.println("Total number of real Fachinfos: " + m_med_list.size()); System.out.println("Number of FI with package information: " + tot_med_counter); System.out.println("Number of FI in generated database: " + med_counter); System.out.println("Number of errors in db: " + errors); System.out.println("Number of missing reg. nr. (min): " + missing_regnr_str); System.out.println("Number of missing pack info: " + missing_pack_info); System.out.println("Number of missing atc codes: " + missing_atc_code); System.out.println("--------------------------------------------"); System.out.println("Total number of pseudo Fachinfos: " + tot_pseudo_counter); System.out.println("--------------------------------------------"); if (CmlOptions.XML_FILE == true) { fi_complete_xml = html_utils.addHeaderToXml("kompendium", fi_complete_xml); // Write kompendium xml file to disk if (CmlOptions.DB_LANGUAGE.equals("de")) { FileOps.writeToFile(fi_complete_xml, Constants.FI_FILE_XML_BASE, "fi_de.xml"); if (CmlOptions.ZIP_BIG_FILES) FileOps.zipToFile(Constants.FI_FILE_XML_BASE, "fi_de.xml"); } else if (CmlOptions.DB_LANGUAGE.equals("fr")) { FileOps.writeToFile(fi_complete_xml, Constants.FI_FILE_XML_BASE, "fi_fr.xml"); if (CmlOptions.ZIP_BIG_FILES) FileOps.zipToFile(Constants.FI_FILE_XML_BASE, "fi_fr.xml"); } // Copy stylesheet file to ./fis/ folders try { File src = new File(Constants.FILE_STYLE_CSS_BASE + "v1.css"); File dst_de = new File(Constants.FI_FILE_XML_BASE + "fi_de_html/"); File dst_fr = new File(Constants.FI_FILE_XML_BASE + "fi_fr_html/"); if (src.exists()) { if (dst_de.exists()) FileUtils.copyFileToDirectory(src, dst_de); if (dst_fr.exists()) FileUtils.copyFileToDirectory(src, dst_fr); } } catch (IOException e) { // TODO: Unhandled! } } if (CmlOptions.GENERATE_REPORTS == true) { parse_errors.append("<br/>"); parse_errors .append("<p>Number of medications with package information: " + tot_med_counter + "</p>"); parse_errors.append("<p>Number of medications in generated database: " + med_counter + "</p>"); parse_errors.append("<p>Number of errors in database: " + errors + "</p>"); parse_errors.append("<p>Number of missing registration number: " + missing_regnr_str + "</p>"); parse_errors.append("<p>Number of missing package info: " + missing_pack_info + "</p>"); parse_errors.append("<p>Number of missing atc codes: " + missing_atc_code + "</p>"); parse_errors.append("<br/>"); // Write and close report file parse_errors.writeHtmlToFile(); parse_errors.getBWriter().close(); // Write owner error report to file ParseReport owner_errors = new ParseReport(Constants.FILE_OWNER_REPORT, CmlOptions.DB_LANGUAGE, "html"); String report_style_str = FileOps.readCSSfromFile(Constants.FILE_REPORT_CSS_BASE + ".css"); owner_errors.addStyleSheet(report_style_str); if (CmlOptions.DB_LANGUAGE.equals("de")) owner_errors.addHtmlHeader("Schweizer Arzneimittel-Kompendium", Constants.FI_DB_VERSION); else if (CmlOptions.DB_LANGUAGE.equals("fr")) owner_errors.addHtmlHeader("Compendium des Mdicaments Suisse", Constants.FI_DB_VERSION); owner_errors.append(owner_errors.treemapToHtmlTable(tm_owner_error)); owner_errors.writeHtmlToFile(); owner_errors.getBWriter().close(); // Dump to console... /* for (Map.Entry<String, ArrayList<String>> entry : tm_owner_error.entrySet()) { String author = entry.getKey(); ArrayList<String> list = entry.getValue(); for (String error : list) System.out.println(author + " -> " + error); } */ } if (CmlOptions.INDICATIONS_REPORT == true) { // Dump everything to file bw_indications.write("Total number of words: " + tm_indications.size() + "\n\n"); for (Map.Entry<String, String> entry : tm_indications.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); bw_indications.write(key + " [" + value + "]\n"); } bw_indications.close(); } if (CmlOptions.DB_LANGUAGE.equals("de")) { // Dump set to file, currently we do this only for German File atccodes_file = new File("./output/atc_codes_used_set.txt"); if (!atccodes_file.exists()) { atccodes_file.getParentFile().mkdirs(); atccodes_file.createNewFile(); } FileWriter fwriter = new FileWriter(atccodes_file.getAbsoluteFile()); BufferedWriter bwriter = new BufferedWriter(fwriter); Iterator<String> set_iterator = atccode_set.iterator(); while (set_iterator.hasNext()) { bwriter.write(set_iterator.next() + "\n"); } bwriter.close(); } System.out.println(""); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.photon.phresco.framework.impl.SCMManagerImpl.java
private void splitDotPhrescoContents(ApplicationInfo appInfo, File tempPhrescoFile, String phrescoRepoUrl, String srcRepoUrl, String testRepoUrl, String srcWorkspaceName, String phrWorkspaceName, String testWorkspaceName) throws PhrescoException { try {// w w w .j a v a 2 s .c o m String appDirName = appInfo.getAppDirName(); String appHome = Utility.getProjectHome() + appDirName + File.separator; List<ModuleInfo> modules = appInfo.getModules(); if (CollectionUtils.isNotEmpty(modules)) { for (ModuleInfo module : modules) { String moduleAppInfoPath = appHome + module.getCode() + File.separator + Constants.DOT_PHRESCO_FOLDER + File.separator + PROJECT_INFO; ApplicationInfo moduleAppInfo = getApplicationInfo(moduleAppInfoPath); File tempDest = new File(tempPhrescoFile, module.getCode()); tempDest.mkdirs(); File phrescoSrc = new File( appHome + module.getCode() + File.separator + Constants.DOT_PHRESCO_FOLDER); FileUtils.copyDirectoryToDirectory(phrescoSrc, tempDest); String phrescoPomFile = moduleAppInfo.getPhrescoPomFile(); if (StringUtils.isNotEmpty(phrescoPomFile)) { File phrescoPomSrc = new File(appHome + module.getCode() + File.separator + phrescoPomFile); File phrescoPomDest = new File(tempDest, phrescoPomFile); FileUtils.copyFileToDirectory(phrescoPomSrc, tempDest); updatePomProperties(appInfo, moduleAppInfo.getAppDirName(), phrescoPomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } } } tempPhrescoFile.mkdirs(); File phrescoSrc = new File(appHome + Constants.DOT_PHRESCO_FOLDER); FileUtils.copyDirectoryToDirectory(phrescoSrc, tempPhrescoFile); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { File phrescoPomSrc = new File(appHome + appInfo.getPhrescoPomFile()); FileUtils.copyFileToDirectory(phrescoPomSrc, tempPhrescoFile); } updatePomProperties(appInfo, "", new File(tempPhrescoFile, PHR_POM_XML), phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } catch (Exception e) { throw new PhrescoException(e); } }
From source file:com.dell.asm.asmcore.asmmanager.util.ServiceTemplateUtil.java
/** * Copy attachment to template directory * @param templateId// w w w . j a v a2 s . c o m * @param attachmentFile */ public static void addOrReplaceAttachment(String templateId, File attachmentFile) { ensureTemplateAttachmentsFolderExists(); Path tempFolder = Paths.get(TEMPLATE_ATTACHMENT_DIR + templateId); if (!Files.exists(tempFolder)) { try { Files.createDirectory(tempFolder); } catch (IOException e) { LOGGER.error("Cannot create attachment directory for template: " + templateId, e); throw new AsmManagerRuntimeException("Cannot create directory: " + tempFolder); } } Path existingAttachment = Paths .get(TEMPLATE_ATTACHMENT_DIR + templateId + File.separator + attachmentFile.getName()); if (Files.exists(existingAttachment)) { FileUtils.deleteQuietly(existingAttachment.toFile()); } try { FileUtils.copyFileToDirectory(attachmentFile, tempFolder.toFile()); } catch (IOException e) { LOGGER.error("Cannot copy attachment " + attachmentFile.getName() + " to the directory for template: " + templateId, e); throw new AsmManagerRuntimeException( "Cannot copy template attachment " + attachmentFile.getName() + " to " + tempFolder); } }
From source file:Form.Principal.java
private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked // TODO add your handling code here: if (editando == false) { File Ruta = new File("Imagenes/Fotos Perfil/"); JFileChooser Examinar = new JFileChooser(); FileNameExtensionFilter Filtro = new FileNameExtensionFilter("Image", "png", "jpg"); Examinar.addChoosableFileFilter(Filtro); Examinar.setAcceptAllFileFilterUsed(false); Examinar.setFileFilter(Filtro);// w w w .ja v a2 s . co m int Estatus = Examinar.showOpenDialog(this); if (Estatus == JFileChooser.APPROVE_OPTION) { File Origen = Examinar.getSelectedFile(); String Extension = FilenameUtils.getExtension(Origen.getPath()); File Copia = new File(Variables.getIdUsuario() + "." + Extension); try { FileUtils.copyFile(Origen, Copia); FileUtils.copyFileToDirectory(Copia, Ruta); if (Extension.equals("png")) { File jpg = new File("Imagenes/Fotos Perfil/" + Variables.idUsuario + ".jpg"); if (jpg.exists()) { jpg.delete(); } } if (Extension.equals("jpg")) { File png = new File("Imagenes/Fotos Perfil/" + Variables.idUsuario + ".png"); if (png.exists()) { png.delete(); } } Copia.delete(); } catch (IOException e) { e.printStackTrace(); } } else if (Estatus == JFileChooser.CANCEL_OPTION) { System.out.println("Cancelar"); } PerfilUsuario(Variables.idUsuario); } }
From source file:com.ah.ui.actions.monitor.MapsAction.java
private String makeXMLBgImages2Tar(final String mapName, final String time_suffix, String destFilePath, Set<String> imageNames) throws IOException { if (!(null == imageNames || imageNames.isEmpty())) { final String seperator = "/"; final String ext = ".tar"; String tarFolderPath = getTarFileRealPath(time_suffix); File tarFolder = new File(tarFolderPath); if (!tarFolder.exists()) { tarFolder.mkdirs();/* ww w . jav a2 s .com*/ } // copy the background images to subfolder 'bgImages' under tar // folder if (null != getDomain()) { String imagepath = BeTopoModuleUtil.getRealTopoBgImagePath(getDomain().getDomainName()); for (String imageName : imageNames) { FileUtils.copyFileToDirectory(new File(imagepath + seperator + imageName), new File(tarFolder, "bgImages")); } } final File xmlFile = new File(destFilePath); FileUtils.copyFileToDirectory(xmlFile, tarFolder); final String destTarFilePath = tarFolder.getParentFile().getAbsolutePath() + seperator + mapName + "_" + time_suffix + ext; if (new TarArchive().create(tarFolderPath, destTarFilePath)) { // copy tar file to xml folder final File tarFile = new File(destTarFilePath); FileUtils.copyFileToDirectory(tarFile, xmlFile.getParentFile()); // delete files under /tmp/tar FileUtils.deleteQuietly(tarFolder); FileUtils.deleteQuietly(tarFile); return tarFile.getName(); } } return null; }
From source file:edu.stanford.epad.epadws.queries.DefaultEpadOperations.java
@Override public int createSystemTemplate(String username, File templateFile, String sessionID) throws Exception { projectOperations.createEventLog(username, null, null, null, null, null, null, "CREATE SYSTEM TEMPLATE", templateFile.getName());//from ww w . ja v a2s. co m if (!EPADFileUtils.isValidXml(templateFile, EPADConfig.templateXSDPath)) throw new Exception("Invalid Template file:" + templateFile.getName()); FileUtils.copyFileToDirectory(templateFile, new File(EPADConfig.getEPADWebServerTemplatesDir())); return HttpServletResponse.SC_OK; }