Search in sources :

Example 6 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class WReport method getPrintFormats.

/**
	 * 	Get the Print Formats for the table.
	 *  Fill the list and the popup menu
	 * 	@param AD_Table_ID table
	 *  @param invoker component to display popup (optional)
	 */
private void getPrintFormats(int AD_Table_ID) {
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    RowSet rowSet = MPrintFormat.getAccessiblePrintFormats(AD_Table_ID, -1, null);
    KeyNamePair pp = null;
    try {
        while (rowSet.next()) {
            pp = new KeyNamePair(rowSet.getInt(1), rowSet.getString(2));
            if (rowSet.getInt(3) == AD_Client_ID) {
                m_list.add(pp);
            }
        }
    } catch (SQLException e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    //	No Format exists - create it
    if (m_list.size() == 0) {
        if (pp == null)
            //	calls launch
            createNewFormat(AD_Table_ID);
        else
            // copies the last format. What if there were several?
            copyFormat(pp.getKey(), AD_Client_ID);
    } else //	One Format exists or no invoker - show it
    if (m_list.size() == 1)
        launchReport((KeyNamePair) m_list.get(0));
    else
        //	Multiple Formats exist - show selection
        //	below button
        showPopup();
}
Also used : SQLException(java.sql.SQLException) RowSet(javax.sql.RowSet) KeyNamePair(org.compiere.util.KeyNamePair)

Example 7 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class SimulatedPickList method print.

/**
	 * Print result generate for this report
	 */
void print() throws Exception {
    // Base Language
    Language language = Language.getLoginLanguage();
    MPrintFormat pf = null;
    int pfid = 0;
    // get print format for client, else copy system to client
    RowSet pfrs = MPrintFormat.getAccessiblePrintFormats(MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName), -1, null);
    pfrs.next();
    pfid = pfrs.getInt("AD_PrintFormat_ID");
    if (pfrs.getInt("AD_Client_ID") != 0)
        pf = MPrintFormat.get(getCtx(), pfid, false);
    else
        pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
    pfrs.close();
    if (pf == null)
        raiseError("Error: ", "No Print Format");
    pf.setLanguage(language);
    pf.setTranslationLanguage(language);
    // query
    MQuery query = new MQuery(X_RV_PP_Product_BOMLine_Storage_TableName);
    query.addRestriction(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID, MQuery.EQUAL, AD_PInstance_ID, getParamenterName(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID), getParamenterInfo(X_T_BOMLine.COLUMNNAME_AD_PInstance_ID));
    query.addRestriction(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID, MQuery.EQUAL, p_M_Warehouse_ID, getParamenterName(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID), getParamenterInfo(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID));
    query.addRestriction(X_T_BOMLine.COLUMNNAME_M_Warehouse_ID, MQuery.EQUAL, p_M_Warehouse_ID, getParamenterName("DateTrx"), getParamenterInfo("DateTrx"));
    PrintInfo info = new PrintInfo(X_RV_PP_Product_BOMLine_Storage_TableName, MTable.getTable_ID(X_RV_PP_Product_BOMLine_Storage_TableName), getRecord_ID());
    ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
    ReportCtl.preview(re);
    // records are deleted when process ends
    while (re.getView().isDisplayable()) {
        Env.sleep(1);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) Language(org.compiere.util.Language) RowSet(javax.sql.RowSet) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo)

Example 8 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class PrintBOM method print.

/**
	 * Print result generate for this report
	 */
void print() throws Exception {
    // Base Language
    Language language = Language.getLoginLanguage();
    MPrintFormat pf = null;
    int pfid = 0;
    // get print format for client, else copy system to client  
    RowSet pfrs = MPrintFormat.getAccessiblePrintFormats(X_RV_PP_Product_BOMLine_Table_ID, -1, null);
    pfrs.next();
    pfid = pfrs.getInt("AD_PrintFormat_ID");
    if (pfrs.getInt("AD_Client_ID") != 0)
        pf = MPrintFormat.get(getCtx(), pfid, false);
    else
        pf = MPrintFormat.copyToClient(getCtx(), pfid, getAD_Client_ID());
    pfrs.close();
    if (pf == null)
        raiseError("Error: ", "No Print Format");
    pf.setLanguage(language);
    pf.setTranslationLanguage(language);
    // query
    MQuery query = MQuery.get(getCtx(), AD_PInstance_ID, X_RV_PP_Product_BOMLine_Table_Name);
    query.addRestriction("AD_PInstance_ID", MQuery.EQUAL, AD_PInstance_ID);
    PrintInfo info = new PrintInfo(X_RV_PP_Product_BOMLine_Table_Name, X_RV_PP_Product_BOMLine_Table_ID, getRecord_ID());
    ReportEngine re = new ReportEngine(getCtx(), pf, query, info);
    ReportCtl.preview(re);
    // records are deleted when process ends 
    while (re.getView().isDisplayable()) {
        Env.sleep(1);
    }
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) ReportEngine(org.compiere.print.ReportEngine) Language(org.compiere.util.Language) RowSet(javax.sql.RowSet) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo)

Example 9 with RowSet

use of javax.sql.RowSet in project adempiere by adempiere.

the class DB method getRowSet.

//	commit
/**
	 * 	Get Row Set.
	 * 	When a Rowset is closed, it also closes the underlying connection.
	 * 	If the created RowSet is transfered by RMI, closing it makes no difference
	 *	@param sql sql
	 *	@param local local RowSet (own connection)
	 *	@return row set or null
	 */
public static RowSet getRowSet(String sql) {
    // Bugfix Gunther Hoppe, 02.09.2005, vpj-cd e-evolution
    // praneet - giving issues with mysql, doing a quick fix for now
    CStatementVO info;
    if (DB.isOracle() || DB.isPostgreSQL())
        info = new CStatementVO(RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, DB.getDatabase().convertStatement(sql));
    else
        info = new CStatementVO(RowSet.TYPE_SCROLL_INSENSITIVE, RowSet.CONCUR_READ_ONLY, sql);
    //dete fix convert statement
    CPreparedStatement stmt = ProxyFactory.newCPreparedStatement(info);
    RowSet retValue = stmt.getRowSet();
    close(stmt);
    return retValue;
}
Also used : RowSet(javax.sql.RowSet)

Example 10 with RowSet

use of javax.sql.RowSet in project jdk8u_jdk by JetBrains.

the class JoinRowSetTests method joinRowSetTests0003.

/*
     * Join two CachedRowSets specifying a column index to join against
     */
@Test(dataProvider = "createCachedRowSetsToUse")
public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1) throws Exception {
    try (JoinRowSet jrs = newInstance()) {
        RowSet[] rowsets = { crs, crs1 };
        int[] joinCols = { COFFEES_JOIN_COLUMN_INDEX, SUPPLIERS_JOIN_COLUMN_INDEX };
        jrs.addRowSet(rowsets, joinCols);
        validateResults(jrs);
        crs.close();
        crs1.close();
    }
}
Also used : JoinRowSet(javax.sql.rowset.JoinRowSet) JoinRowSet(javax.sql.rowset.JoinRowSet) WebRowSet(javax.sql.rowset.WebRowSet) CachedRowSet(javax.sql.rowset.CachedRowSet) RowSet(javax.sql.RowSet) Test(org.testng.annotations.Test)

Aggregations

RowSet (javax.sql.RowSet)19 SQLException (java.sql.SQLException)8 CCachedRowSet (org.compiere.util.CCachedRowSet)7 ResultSet (java.sql.ResultSet)3 PreparedStatement (java.sql.PreparedStatement)2 Timestamp (java.sql.Timestamp)2 Properties (java.util.Properties)2 CachedRowSet (javax.sql.rowset.CachedRowSet)2 JoinRowSet (javax.sql.rowset.JoinRowSet)2 WebRowSet (javax.sql.rowset.WebRowSet)2 DBException (org.adempiere.exceptions.DBException)2 MQuery (org.compiere.model.MQuery)2 PrintInfo (org.compiere.model.PrintInfo)2 MPrintFormat (org.compiere.print.MPrintFormat)2 ReportEngine (org.compiere.print.ReportEngine)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Language (org.compiere.util.Language)2 Test (org.testng.annotations.Test)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 BigDecimal (java.math.BigDecimal)1