use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class CSVFormatter method start.
@Override
public void start(String nm) throws ProcessingException {
try {
buildSchema();
createOutputStreams();
writer = new CsvMapWriter(fio, CsvPreference.EXCEL_PREFERENCE);
writer.writeHeader(header);
} catch (Exception err) {
throw new ProcessingException("Failed to launch", err);
}
}
use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class GISDataFormatter method start.
/**
* Start output.
*/
@Override
public void start(String containerName) throws ProcessingException {
/**
* apply default GIS data model
*/
if (this.gisDataModel == null) {
setGisDataModel();
}
try {
createOutputStreams();
} catch (Exception create_err) {
throw new ProcessingException(create_err);
}
DocumentStart ds = new DocumentStart(doc_type);
this.os.write(ds);
this.os.write(gisDataModel.getSchema());
ContainerStart containerStart = new ContainerStart();
containerStart.setType("Folder");
containerStart.setName(containerName);
this.os.write(containerStart);
}
use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class BasicGeoTemporalProcessing method createFormatter.
/**
* The default formatter
*/
public static AbstractFormatter createFormatter(String outputFormat, Parameters plist) throws IOException, ProcessingException {
if (plist.isdefault) {
throw new ProcessingException("Caller is required to use non-default Parameters; " + "\nat least set the output options, folder, jobname, etc.");
}
AbstractFormatter formatter = (AbstractFormatter) FormatterFactory.getInstance(outputFormat);
if (formatter == null) {
throw new ProcessingException("Wrong formatter?");
}
formatter.setParameters(plist);
formatter.setOutputFilename(plist.getJobName() + formatter.outputExtension);
return formatter;
}
use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class BasicGeoTemporalProcessing method setup.
/** Ideally you should separate your one-time initialization steps, configuring your extractors
* apart from the repetitive steps of setting up Jobs and Inputs. Outputs you might setup once
* for the entire JVM session, or it may be something you do periodically. In summary:
*
* configure separately:
* a) extractors, converters
* b) job inputs and parameters
* c) output formatters
* d) other resources, e.g., filters
*/
public void setup(String inFile, List<String> outFormats, String outFile, String tempDir) throws ConfigException, ProcessingException, IOException {
params.isdefault = false;
if (!validateParameters(inFile, outFormats, outFile, tempDir, params)) {
throw new ProcessingException("VALIDATION ERRORS: " + runnerMessage.toString());
}
// If you are dead-sure you want only coordinates from text, then just use XCoord.
// Otherwise SimpleGeocoder does both coords + names.
//
//XCoord xcoord = new XCoord();
//xcoord.configure();
//this.addExtractor(xcoord);
// Testing only
params.tag_places = true;
params.tag_coordinates = true;
params.output_countries = false;
PlaceGeocoder geocoder = new PlaceGeocoder();
geocoder.enablePersonNameMatching(true);
geocoder.setParameters(params);
geocoder.configure();
this.addExtractor(geocoder);
XTemporal xtemp = new XTemporal();
xtemp.configure();
this.addExtractor(xtemp);
converter = new XText();
converter.enableHTMLScrubber(false);
converter.enableSaving(true);
converter.enableOverwrite(false);
converter.setConversionListener(this);
//
if (tempDir != null) {
converter.getPathManager().setConversionCache(tempDir);
} else {
converter.enableSaving(false);
}
try {
converter.setup();
} catch (IOException ioerr) {
throw new ConfigException("Document converter could not start", ioerr);
}
this.params.inputFile = inFile.trim();
this.params.outputFile = outFile.trim();
if (outFormats != null) {
for (String fmt : outFormats) {
params.addOutputFormat(fmt);
AbstractFormatter formatter = createFormatter(fmt, params);
formatter.overwrite = overwriteOutput;
this.addFormatter(formatter);
//if (formatter instanceof CSVFormatter) {
// formatter.addField(OpenSextantSchema.FILEPATH.getName());
// formatter.addField(OpenSextantSchema.MATCH_TEXT.getName());
// }
formatter.start(params.getJobName());
}
}
}
use of org.opensextant.processing.ProcessingException in project Xponents by OpenSextant.
the class TweetGeocoder method createFormatter.
/**
* The default formatter
*/
public static GISDataFormatter createFormatter(String outputFormat, Parameters p) throws IOException, ProcessingException {
if (p.isdefault) {
throw new ProcessingException("Caller is required to use non-default Parameters; " + "\nat least set the output options, folder, jobname, etc.");
}
GISDataFormatter formatter = (GISDataFormatter) FormatterFactory.getInstance(outputFormat);
if (formatter == null) {
throw new ProcessingException("Wrong formatter?");
}
formatter.setParameters(p);
// formatter.setOutputDir(params.outputDir);
formatter.setOutputFilename(p.getJobName() + formatter.outputExtension);
return formatter;
}
Aggregations