From c480975544d7bb518c17768c4982e8a26541307d Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Sun, 2 Dec 2007 03:33:39 +0000 Subject: [PATCH] [ 1842534 ] Grant independence to GenerateModel from AD_Process_ID http://sourceforge.net/tracker/index.php?func=detail&aid=1842534&group_id=176962&atid=879335 --- base/src/org/compiere/model/MProcess.java | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/base/src/org/compiere/model/MProcess.java b/base/src/org/compiere/model/MProcess.java index 2024c56c09..72defd54fa 100644 --- a/base/src/org/compiere/model/MProcess.java +++ b/base/src/org/compiere/model/MProcess.java @@ -21,6 +21,8 @@ import java.util.*; import java.util.logging.*; import org.adempiere.util.ProcessUtil; +import org.compiere.db.CConnection; +import org.compiere.interfaces.Server; import org.compiere.process.*; import org.compiere.util.*; @@ -413,4 +415,37 @@ public class MProcess extends X_AD_Process return success; } // afterSave + /** + * Grant independence to GenerateModel from AD_Process_ID + * @param String tableName + * @return int retValue + */ + public static int getProcess_ID(String value) { + int retValue = 0; + String SQL = "SELECT AD_Process_ID FROM AD_Process WHERE value = ?"; + try + { + if (DB.isRemoteObjects()) + { + Server server = CConnection.get().getServer(); + retValue = server.getTableID(value); + } + else + { + PreparedStatement pstmt = DB.prepareStatement(SQL, null); + pstmt.setString(1, value); + ResultSet rs = pstmt.executeQuery(); + if (rs.next()) + retValue = rs.getInt(1); + rs.close(); + pstmt.close(); + } + } + catch (Exception e) + { + retValue = -1; + } + return retValue; + } + } // MProcess