@Override public void parse(IParserCallback parserCallback) throws IOException { parse(parserCallback, ";"); }
@Override public final IScriptExecutor scriptExecutor() throws OrmException { return new ScriptExecutor(this); }
@Override public final ScriptExecutor scriptExecutor() throws OrmException { return new ScriptExecutorImpl(this); }
@Override public void execute(final InputStream scriptStream, final Charset charset) throws IOException, OrmException { this.logger.info("Begin script execution"); //$NON-NLS-1$ Parser parser = new StreamParser(scriptStream, true, charset); SessionParserCallback spc = new SessionParserCallback(this.session); parser.parse(spc); this.logger.info("End script execution"); //$NON-NLS-1$ }
@Override public void execute(InputStream scriptStream, Charset charset) throws IOException, OrmException { logger.info("execute", "Begin script execution"); IParser parser = new StreamParser(scriptStream, true, charset); SessionParserCallback spc = new SessionParserCallback(session); parser.parse(spc); logger.debug("execute", "End script execution"); }
@Override public void execute(InputStream scriptStream) throws IOException, OrmException { execute(scriptStream, Charset.defaultCharset()); }
private void checkend(IParserCallback parserCallback, StringBuilder StringBuilder, String line, GenericWrapper<Integer> apostrophesWrapper ) { String trimmedline = line.trim(); if ( !trimmedline.isEmpty() && !trimmedline.startsWith("--") ) { if ( line.contains(";") ) { String[] splitted = line.split(";"); int position = 0; for (int i=0 ; i<splitted.length; i++) { int apostrophes = apostrophesWrapper.getValue(); String token = splitted[i]; position += token.length() + 1; apostrophes += countApostrophes(token); apostrophesWrapper.setValue(apostrophes); if ( apostrophes % 2 == 1) { StringBuilder.append(token + ";"); } else { StringBuilder.append(token); parserCallback.parseAction(StringBuilder.toString()); StringBuilder.setLength(0); apostrophesWrapper.setValue(0); line = line.substring(position, line.length() ); checkend(parserCallback, StringBuilder, line, apostrophesWrapper); break; } } } else { StringBuilder.append(line + "\n"); } } }
private void checkend(final ParserCallback parserCallback, final StringBuilder StringBuilder, final String line, final GenericWrapper<Integer> apostrophesWrapper ) { String trimmedline = line.trim(); if ( !trimmedline.isEmpty() && !trimmedline.startsWith("--") ) { //$NON-NLS-1$ if ( line.contains(";") ) { //$NON-NLS-1$ String tempLine = line; String[] splitted = tempLine.split(";"); //$NON-NLS-1$ int position = 0; for (String token : splitted) { int apostrophes = apostrophesWrapper.getValue(); position += token.length() + 1; apostrophes += countApostrophes(token); apostrophesWrapper.setValue(apostrophes); if ( (apostrophes % 2) == 1) { StringBuilder.append(token + ";"); //$NON-NLS-1$ } else { StringBuilder.append(token); parserCallback.parseAction(StringBuilder.toString()); StringBuilder.setLength(0); apostrophesWrapper.setValue(0); tempLine = tempLine.substring(position, tempLine.length() ); checkend(parserCallback, StringBuilder, tempLine, apostrophesWrapper); break; } } } else { StringBuilder.append(line + "\n"); //$NON-NLS-1$ } } }
private boolean findStatement(IParserCallback parserCallback, BufferedReader bufferedReader) throws IOException { StringBuilder StringBuilder = new StringBuilder(); String line = null; GenericWrapper<Integer> apostrophes = new GenericWrapper<Integer>(0); while (true) { if ( ! ((line = bufferedReader.readLine()) != null )) { return false; } checkend(parserCallback, StringBuilder, line, apostrophes); } }
@Override public void parse(IParserCallback parserCallback, String spearatorSymbol) throws IOException { InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; try { inputStreamReader = new InputStreamReader(inputStream, charset ); bufferedReader = new BufferedReader(inputStreamReader); findStatement(parserCallback, bufferedReader); } finally { if (bufferedReader!=null) bufferedReader.close(); if (inputStreamReader!=null) inputStreamReader.close(); if (closeInputStream && inputStream!=null) inputStream.close(); } }
@Override public void execute(final InputStream scriptStream) throws IOException, OrmException { this.execute(scriptStream, Charset.defaultCharset()); }
private void executeScript(JPO jpOrm) throws Exception { final Session session = jpOrm.session(); final ITransaction tx = session.transaction(); final IScriptExecutor scriptExecutor = session.scriptExecutor(); final InputStream scriptStream = new FileInputStream(filename); scriptExecutor.execute(scriptStream); tx.commit(); }
@Override public void execute(String script) throws OrmException { Charset charset = Charset.defaultCharset(); InputStream is = new ByteArrayInputStream(script.getBytes(charset)); try { execute(is, charset); } catch (IOException e) { throw new OrmException(e); } }
@Override public void parse(final ParserCallback parserCallback) throws IOException { parse(parserCallback, ";"); //$NON-NLS-1$ }
private boolean findStatement(final ParserCallback parserCallback, final BufferedReader bufferedReader) throws IOException { StringBuilder StringBuilder = new StringBuilder(); String line = null; GenericWrapper<Integer> apostrophes = new GenericWrapper<Integer>(0); while (true) { if ( ! ((line = bufferedReader.readLine()) != null )) { return false; } checkend(parserCallback, StringBuilder, line, apostrophes); } }
@Override public void parse(final ParserCallback parserCallback, final String spearatorSymbol) throws IOException { InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; try { inputStreamReader = new InputStreamReader(inputStream, charset ); bufferedReader = new BufferedReader(inputStreamReader); findStatement(parserCallback, bufferedReader); } finally { if (bufferedReader!=null) { bufferedReader.close(); } if (inputStreamReader!=null) { inputStreamReader.close(); } if (closeInputStream && (inputStream!=null)) { inputStream.close(); } } }
@Override public void execute(final String script) throws OrmException { Charset charset = Charset.defaultCharset(); InputStream is = new ByteArrayInputStream(script.getBytes(charset)); try { this.execute(is, charset); } catch (IOException e) { throw new OrmException(e); } }
public static void init(SessionProvider sessionProvider, String createScriptFileName, String dropScriptFileName, Dialect dialect, GeneratorStrategy generatorStrategy) throws Exception { BaseTestShared.generatorStrategy = generatorStrategy; BaseTestShared.sessionProvider = sessionProvider; BaseTestShared.dialect = dialect; assertNotNull(sessionProvider); final JPO jpOrm = new JPOrm(sessionProvider, dialect, generatorStrategy); final Session session = jpOrm.session(); final ITransaction tx = session.transaction(); final IScriptExecutor scriptExecutor = session.scriptExecutor(); try { scriptExecutor.execute(new FileInputStream(dropScriptFileName)); } catch (final Exception e) {} scriptExecutor.execute(new FileInputStream(createScriptFileName)); tx.commit(); INITIALISED = true; }
@Override public Void doInTransaction(final Session session) { final ScriptExecutor scriptExecutor = session.scriptExecutor(); try { scriptExecutor.execute(getClass().getResourceAsStream("/sql/derby_create_db.sql")); //$NON-NLS-1$ } catch (Exception e) { throw new RuntimeException(e); } return null; }
private void executeScript(final JPO jpOrm) throws Exception { final Session session = jpOrm.session(); final Transaction tx = session.transaction(); final ScriptExecutor scriptExecutor = session.scriptExecutor(); final InputStream scriptStream = new FileInputStream(this.filename); scriptExecutor.execute(scriptStream); tx.commit(); }