* @throws IllegalStateException
* @since 4.0
*/
public String getShopId (JDCConnection oConn) throws SQLException,IllegalStateException {
String sGuShop = null;
DBSubset oCats = getCategories(oConn);
String sIdDomain = null;
if (DebugFile.trace) {
DebugFile.writeln("Begin Product.getShopId([JDCConnection])");
DebugFile.incIdent();
}
if (oCats.getRowCount()!=0) {
if (isNull(DB.gu_owner))
throw new IllegalStateException("Product must be fully loaded before calling getShopId()");
PreparedStatement oQury = oConn.prepareStatement("SELECT "+DB.id_domain+" FROM "+DB.k_users+" WHERE "+DB.gu_user+"=?",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (DebugFile.trace) DebugFile.writeln("Statement.executeQuery(SELECT "+DB.id_domain+" FROM "+DB.k_users+" WHERE "+DB.gu_user+"='"+getStringNull(DB.gu_owner,"null")+"'");
oQury.setString(1, getString(DB.gu_owner));
ResultSet oRSet = oQury.executeQuery();
if (oRSet.next())
sIdDomain = String.valueOf(oRSet.getInt(1));
oRSet.close();
oQury.close();
if (null==sIdDomain) throw new SQLException("User "+getString(DB.gu_owner)+" not found at "+DB.k_users+" table");
oQury = oConn.prepareStatement("SELECT "+DB.gu_shop+" FROM "+DB.k_shops+" WHERE "+DB.id_domain+"="+sIdDomain+" AND "+DB.gu_root_cat+"=?",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ListIterator oIter = new Category (oConn, oCats.getString(0,0)).browse(oConn, Category.BROWSE_UP, Category.BROWSE_TOPDOWN).listIterator();
while (oIter.hasNext() && (null==sGuShop)) {
Category oPrnt = (Category) oIter.next();
if (DebugFile.trace) DebugFile.writeln("Statement.executeQuery(SELECT "+DB.gu_shop+" FROM "+DB.k_shops+" WHERE "+DB.id_domain+"="+sIdDomain+" AND "+DB.gu_root_cat+"='"+oPrnt.getStringNull(DB.gu_category,"null")+"'");
oQury.setString(1, oPrnt.getString(DB.gu_category));
oRSet = oQury.executeQuery();