use of org.jkiss.dbeaver.ext.oracle.model.OracleObjectPersistAction in project dbeaver by dbeaver.
the class CompileHandler method compileUnit.
public static boolean compileUnit(DBRProgressMonitor monitor, DBCCompileLog compileLog, OracleSourceObject unit) throws DBCException {
final DBEPersistAction[] compileActions = unit.getCompileActions();
if (ArrayUtils.isEmpty(compileActions)) {
return true;
}
try (JDBCSession session = DBUtils.openUtilSession(monitor, unit.getDataSource(), "Compile '" + unit.getName() + "'")) {
boolean success = true;
for (DBEPersistAction action : compileActions) {
final String script = action.getScript();
compileLog.trace(script);
if (monitor.isCanceled()) {
break;
}
try {
try (DBCStatement dbStat = session.prepareStatement(DBCStatementType.QUERY, script, false, false, false)) {
action.beforeExecute(session);
dbStat.executeStatement();
}
action.afterExecute(session, null);
} catch (DBCException e) {
action.afterExecute(session, e);
throw e;
}
if (action instanceof OracleObjectPersistAction) {
if (!logObjectErrors(session, compileLog, unit, ((OracleObjectPersistAction) action).getObjectType())) {
success = false;
}
}
}
final DBSObjectState oldState = unit.getObjectState();
unit.refreshObjectState(monitor);
if (unit.getObjectState() != oldState) {
unit.getDataSource().getContainer().fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, unit));
}
return success;
}
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleObjectPersistAction in project dbeaver by serge-rider.
the class CompileHandler method compileUnit.
public static boolean compileUnit(DBRProgressMonitor monitor, DBCCompileLog compileLog, OracleSourceObject unit) throws DBCException {
final DBEPersistAction[] compileActions = unit.getCompileActions();
if (ArrayUtils.isEmpty(compileActions)) {
return true;
}
try (JDBCSession session = DBUtils.openUtilSession(monitor, unit.getDataSource(), "Compile '" + unit.getName() + "'")) {
boolean success = true;
for (DBEPersistAction action : compileActions) {
final String script = action.getScript();
compileLog.trace(script);
if (monitor.isCanceled()) {
break;
}
try {
try (DBCStatement dbStat = session.prepareStatement(DBCStatementType.QUERY, script, false, false, false)) {
dbStat.executeStatement();
}
action.handleExecute(session, null);
} catch (DBCException e) {
action.handleExecute(session, e);
throw e;
}
if (action instanceof OracleObjectPersistAction) {
if (!logObjectErrors(session, compileLog, unit, ((OracleObjectPersistAction) action).getObjectType())) {
success = false;
}
}
}
final DBSObjectState oldState = unit.getObjectState();
unit.refreshObjectState(monitor);
if (unit.getObjectState() != oldState) {
unit.getDataSource().getContainer().fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, unit));
}
return success;
}
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleObjectPersistAction in project dbeaver by serge-rider.
the class JobRunHandler method runJob.
public static boolean runJob(DBRProgressMonitor monitor, DBCCompileLog compileLog, OracleSchedulerJob job) throws DBCException {
final DBEPersistAction[] compileActions = job.getRunActions();
if (ArrayUtils.isEmpty(compileActions)) {
return true;
}
try (JDBCSession session = DBUtils.openUtilSession(monitor, job, "Run '" + job.getName() + "'")) {
boolean success = true;
for (DBEPersistAction action : compileActions) {
final String script = action.getScript();
compileLog.trace(script);
if (monitor.isCanceled()) {
break;
}
try {
try (DBCStatement dbStat = session.prepareStatement(DBCStatementType.SCRIPT, script, false, false, false)) {
action.beforeExecute(session);
dbStat.executeStatement();
}
action.afterExecute(session, null);
} catch (DBCException e) {
action.afterExecute(session, e);
throw e;
}
if (action instanceof OracleObjectPersistAction) {
if (!logObjectErrors(session, compileLog, job, ((OracleObjectPersistAction) action).getObjectType())) {
success = false;
}
}
}
final DBSObjectState oldState = job.getObjectState();
job.refreshObjectState(monitor);
if (job.getObjectState() != oldState) {
job.getDataSource().getContainer().fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, job));
}
return success;
}
}
use of org.jkiss.dbeaver.ext.oracle.model.OracleObjectPersistAction in project dbeaver by serge-rider.
the class CompileHandler method compileUnit.
public static boolean compileUnit(DBRProgressMonitor monitor, DBCCompileLog compileLog, OracleSourceObject unit) throws DBCException {
final DBEPersistAction[] compileActions = unit.getCompileActions(monitor);
if (ArrayUtils.isEmpty(compileActions)) {
throw new DBCException("No compile actions associated with " + unit.getSourceType().name());
}
try (JDBCSession session = DBUtils.openUtilSession(monitor, unit, "Compile '" + unit.getName() + "'")) {
boolean success = true;
for (DBEPersistAction action : compileActions) {
final String script = action.getScript();
compileLog.trace(script);
if (monitor.isCanceled()) {
break;
}
try {
try (DBCStatement dbStat = session.prepareStatement(DBCStatementType.QUERY, script, false, false, false)) {
action.beforeExecute(session);
dbStat.executeStatement();
}
action.afterExecute(session, null);
} catch (DBCException e) {
action.afterExecute(session, e);
throw e;
}
if (action instanceof OracleObjectPersistAction) {
if (!logObjectErrors(session, compileLog, unit, ((OracleObjectPersistAction) action).getObjectType())) {
success = false;
}
}
}
final DBSObjectState oldState = unit.getObjectState();
unit.refreshObjectState(monitor);
if (unit.getObjectState() != oldState) {
unit.getDataSource().getContainer().fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, unit));
}
return success;
}
}
Aggregations