Package com.google.refine.importing.ImportingManager

Examples of com.google.refine.importing.ImportingManager.Format


            String format = parameters.getProperty("format");
           
            // If a format is specified, it might still be wrong, so we need
            // to check if we have a parser for it. If not, null it out.
            if (format != null && !format.isEmpty()) {
                Format formatRecord = ImportingManager.formatToRecord.get(format);
                if (formatRecord == null || formatRecord.parser == null) {
                    format = null;
                }
            }
           
            // If we don't have a format specified, try to guess it.
            if (format == null || format.isEmpty()) {
                // Use legacy parameters to guess the format.
                if ("false".equals(parameters.getProperty("split-into-columns"))) {
                    format = "text/line-based";
                } else if (",".equals(parameters.getProperty("separator")) ||
                           "\\t".equals(parameters.getProperty("separator"))) {
                    format = "text/line-based/*sv";
                } else {
                    JSONArray rankedFormats = JSONUtilities.getArray(config, "rankedFormats");
                    if (rankedFormats != null && rankedFormats.length() > 0) {
                        format = rankedFormats.getString(0);
                    }
                }
               
                if (format == null || format.isEmpty()) {
                    // If we have failed in guessing, default to something simple.
                    format = "text/line-based";
                }
            }
           
            JSONObject optionObj = null;
            String optionsString = request.getParameter("options");
            if (optionsString != null && !optionsString.isEmpty()) {
                optionObj = ParsingUtilities.evaluateJsonStringToObject(optionsString);
            } else {
                Format formatRecord = ImportingManager.formatToRecord.get(format);
                optionObj = formatRecord.parser.createParserUIInitializationData(
                    job, ImportingUtilities.getSelectedFileRecords(job), format);
            }
            adjustLegacyOptions(format, parameters, optionObj);
           
View Full Code Here


        boolean download = bestFormat == null ? true :
            ImportingManager.formatToRecord.get(bestFormat).download;
       
        List<String> formats = new ArrayList<String>(ImportingManager.formatToRecord.keySet().size());
        for (String format : ImportingManager.formatToRecord.keySet()) {
            Format record = ImportingManager.formatToRecord.get(format);
            if (record.uiClass != null && record.parser != null && record.download == download) {
                formats.add(format);
                formatToSegments.put(format, format.split("/"));
            }
        }
View Full Code Here

        }
        return results;
    }
   
    static public void previewParse(ImportingJob job, String format, JSONObject optionObj, List<Exception> exceptions) {
        Format record = ImportingManager.formatToRecord.get(format);
        if (record == null || record.parser == null) {
            // TODO: what to do?
            return;
        }
       
View Full Code Here

            final ImportingJob job,
            final String format,
            final JSONObject optionObj,
            final List<Exception> exceptions,
            boolean synchronous) {
        final Format record = ImportingManager.formatToRecord.get(format);
        if (record == null || record.parser == null) {
            // TODO: what to do?
            return -1;
        }
       
View Full Code Here

            HttpUtilities.respond(response, "error", "No such import job");
            return;
        }
       
        String format = request.getParameter("format");
        Format formatRecord = ImportingManager.formatToRecord.get(format);
        if (formatRecord != null && formatRecord.parser != null) {
            JSONObject options = formatRecord.parser.createParserUIInitializationData(
                    job, ImportingUtilities.getSelectedFileRecords(job), format);
            JSONObject result = new JSONObject();
            JSONUtilities.safePut(result, "status", "ok");
View Full Code Here

TOP

Related Classes of com.google.refine.importing.ImportingManager.Format

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.