use of org.jkiss.dbeaver.model.DBPEvent 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.model.DBPEvent in project dbeaver by serge-rider.
the class OracleUtils method normalizeSourceName.
public static String normalizeSourceName(OracleSourceObject object, boolean body) {
try {
String source = body ? ((DBPScriptObjectExt) object).getExtendedDefinitionText(null) : object.getObjectDefinitionText(null);
if (source == null) {
return null;
}
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(object.getSourceType() + (body ? "\\s+BODY" : "") + "\\s(\\s*)([\\w$\\.]+)[\\s\\(]+", java.util.regex.Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(source);
if (matcher.find()) {
String objectName = matcher.group(2);
if (objectName.indexOf('.') == -1) {
if (!objectName.equalsIgnoreCase(object.getName())) {
object.setName(DBObjectNameCaseTransformer.transformObjectName(object, objectName));
object.getDataSource().getContainer().fireEvent(new DBPEvent(DBPEvent.Action.OBJECT_UPDATE, object));
}
//.substring(0, matcher.start(1)) + object.getSchema().getName() + "." + objectName + source.substring(matcher.end(2));
return source;
}
}
return source.trim();
} catch (DBException e) {
log.error(e);
return null;
}
}
Aggregations