Example usage for org.hibernate ScrollableResults get

List of usage examples for org.hibernate ScrollableResults get

Introduction

In this page you can find the example usage for org.hibernate ScrollableResults get.

Prototype

Object[] get();

Source Link

Document

Get the current row of results.

Usage

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getSoftwareComplianceSummaryReport(Account pAccount, String remoteUser, String lsName,
        PrintWriter pPrintWriter, boolean pbCustomerOwnedCustomerManagedSearchChecked,
        boolean pbCustomerOwnedIBMManagedSearchChecked, boolean pbIBMOwnedIBMManagedSearchChecked,
        boolean pbIBMO3rdMSearchChecked, boolean pbCustO3rdMSearchChecked, boolean pbIBMOibmMSWCOSearchChecked,
        boolean pbCustOibmMSWCOSearchChecked, boolean pbTitlesNotSpecifiedInContractScopeSearchChecked,
        boolean pbSelectAllChecked) throws HibernateException, Exception {
    if (pbSelectAllChecked) {
        pbCustomerOwnedCustomerManagedSearchChecked = true;
        pbCustomerOwnedIBMManagedSearchChecked = true;
        pbIBMOwnedIBMManagedSearchChecked = true;
        pbIBMO3rdMSearchChecked = true;/*from   w w w .j a  v  a 2s  .  co m*/
        pbCustO3rdMSearchChecked = true;
        pbIBMOibmMSWCOSearchChecked = true;
        pbCustOibmMSWCOSearchChecked = true;
        pbTitlesNotSpecifiedInContractScopeSearchChecked = true;
    }
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(
            "CALL EAADMIN.SwComplianceSum(:customerId, :customerOwnedCustomerManaged, :customerOwnedIBMManaged, :ibmOwnedIBMManaged, :ibmOwned3RDManaged, :customerOwned3RDManaged, :ibmOwnedIbmManagedSWConsumBased, :custOwnedIbmManagedSWConsumBased, :titlesNotSpecifiedInContractScope)")
            .setLong("customerId", pAccount.getId())
            .setInteger("customerOwnedCustomerManaged", pbCustomerOwnedCustomerManagedSearchChecked ? 1 : 0)
            .setInteger("customerOwnedIBMManaged", pbCustomerOwnedIBMManagedSearchChecked ? 1 : 0)
            .setInteger("ibmOwnedIBMManaged", pbIBMOwnedIBMManagedSearchChecked ? 1 : 0)
            .setInteger("ibmOwned3RDManaged", pbIBMO3rdMSearchChecked ? 1 : 0)
            .setInteger("customerOwned3RDManaged", pbCustO3rdMSearchChecked ? 1 : 0)
            .setInteger("ibmOwnedIbmManagedSWConsumBased", pbIBMOibmMSWCOSearchChecked ? 1 : 0)
            .setInteger("custOwnedIbmManagedSWConsumBased", pbCustOibmMSWCOSearchChecked ? 1 : 0)
            .setInteger("titlesNotSpecifiedInContractScope",
                    pbTitlesNotSpecifiedInContractScopeSearchChecked ? 1 : 0)
            .scroll(ScrollMode.FORWARD_ONLY);

    printHeader(SOFTWARE_COMPLIANCE_SUMMARY_REPORT_NAME, pAccount.getAccount(),
            SOFTWARE_COMPLIANCE_SUMMARY_COLUMN_HEADERS, pPrintWriter);
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }
    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getSoftwareLparBaselineReport(Account pAccount, String remoteUser, String lsName,
        PrintWriter pPrintWriter) throws HibernateException, Exception {
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate())
            .createSQLQuery("SELECT SL.Name AS SL_Name" + ", SL.Bios_Serial"
                    + ", COALESCE ( hle.Processor_Count,0)" + ", SL.ScanTime"
                    + ", CASE LENGTH(RTRIM(COALESCE(CHAR(HSC.Id), ''))) WHEN 0 THEN 'No' ELSE 'Yes' END"
                    + ", H.Serial" + ", MT.Name AS MT_Name" + ", MT.Type " + "FROM EAADMIN.Software_Lpar SL "
                    + "LEFT OUTER JOIN EAADMIN.HW_SW_Composite HSC ON HSC.Software_Lpar_Id = SL.Id "
                    + "LEFT OUTER JOIN EAADMIN.Hardware_Lpar HL ON HL.Id = HSC.Hardware_Lpar_Id "
                    + "LEFT OUTER JOIN EAADMIN.Hardware H ON H.Id = HL.Hardware_Id "
                    + "LEFT OUTER JOIN EAADMIN.Machine_Type MT ON MT.Id = H.Machine_Type_Id "
                    + "LEFT OUTER JOIN EAADMIN.Hardware_lpar_eff hle on ( hle.hardware_lpar_id=hl.id and hle.status = 'ACTIVE' )"
                    + " WHERE SL.Customer_Id = :customerId AND SL.Status = 'ACTIVE' " + " ORDER BY SL.Name ASC")
            .setLong("customerId", pAccount.getId()).scroll(ScrollMode.FORWARD_ONLY);

    printHeader(SOFTWARE_LPAR_BASELINE_REPORT_NAME, pAccount.getAccount(),
            SOFTWARE_LPAR_BASELINE_COLUMN_HEADERS, pPrintWriter);
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }//from   ww  w .ja  va 2 s . c  o  m
    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getSoftwareVarianceReport(Account pAccount, String remoteUser, String lsName,
        PrintWriter pPrintWriter) throws HibernateException, Exception {
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(
            "SELECT S.Software_Name, COUNT(IS.Software_Id), CAST(NULL AS VARCHAR(256)) FROM EAADMIN.Software S, EAADMIN.Installed_Software IS, EAADMIN.Software_Lpar SL WHERE S.Software_Id = IS.Software_Id AND S.Status = 'ACTIVE' AND S.Level = 'LICENSABLE' AND IS.Discrepancy_Type_Id IN (1, 2, 4) AND IS.Status = 'ACTIVE' AND IS.Software_Lpar_Id = SL.Id AND NOT EXISTS (SELECT SF.Software_Id FROM EAADMIN.Schedule_F SF, EAADMIN.Status S2 WHERE SF.Customer_Id = :customerId AND SF.Software_Name = S.Software_Name AND S2.Id = SF.Status_Id AND S2.Description = 'ACTIVE') AND SL.Customer_Id = :customerId GROUP BY S.Software_Name UNION SELECT SF.Software_Name, CAST(0 AS INTEGER), SF.Software_Title FROM EAADMIN.Schedule_F SF, EAADMIN.Status S2 WHERE SF.Customer_Id = :customerId AND S2.Id = SF.Status_Id AND S2.Description = 'ACTIVE' AND NOT EXISTS (SELECT S3.Software_Id FROM EAADMIN.Software S3, EAADMIN.Installed_Software IS, EAADMIN.Software_Lpar SL WHERE S3.Software_Name = SF.Software_Name AND S3.Software_Id = IS.Software_Id AND S3.Status = 'ACTIVE' AND S3.Level = 'LICENSABLE' AND IS.Discrepancy_Type_Id IN (1, 2, 4) AND IS.Status = 'ACTIVE' AND IS.Software_Lpar_Id = SL.Id AND SL.Customer_Id = :customerId) ORDER BY Software_Name")
            .setLong("customerId", pAccount.getId()).scroll(ScrollMode.FORWARD_ONLY);

    printHeader(SOFTWARE_VARIANCE_REPORT_NAME, null, SOFTWARE_VARIANCE_REPORT_COLUMN_HEADERS, pPrintWriter);
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }//w w  w. java2s.  c  o  m
    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getWorkstationAccountsReport(String remoteUser, String lsName, PrintWriter pPrintWriter)
        throws HibernateException, Exception {
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(
            "SELECT C.Account_Number, C.Customer_Name, CT.Customer_Type_Name, G.Name AS G_Name, R.Name AS R_Name, CC.Name AS CC_Name, S.Sector_Name, COUNT(H.Id), H.Hardware_Status FROM EAADMIN.Customer C, EAADMIN.Customer_Type CT, EAADMIN.Country_Code CC, EAADMIN.Region R, EAADMIN.Geography G, EAADMIN.Sector S, EAADMIN.Hardware H, EAADMIN.Machine_Type MT WHERE C.Status = 'ACTIVE' AND C.Customer_Type_Id = CT.Customer_Type_Id AND CT.Customer_Type_Name LIKE '%WORKSTATION%' AND G.Id = R.Geography_Id AND R.Id = CC.Region_Id AND CC.Id = C.Country_Code_Id AND S.Sector_Id = C.Sector_Id AND H.Customer_Id = C.Customer_Id AND H.Status = 'ACTIVE' AND MT.Id = H.Machine_Type_Id AND MT.Type != 'WORKSTATION' GROUP BY C.Account_Number, C.Customer_Name, CT.Customer_Type_Name, G.Name, R.Name, CC.Name, S.Sector_Name, H.Hardware_Status ORDER BY C.Account_Number, H.Hardware_Status")
            .scroll(ScrollMode.FORWARD_ONLY);

    printHeader(WORKSTATION_ACCOUNTS_REPORT_NAME, null, WORKSTATION_ACCOUNTS_REPORT_COLUMN_HEADERS,
            pPrintWriter);//from  www  . j ava 2 s .  co  m
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }
    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Override
@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getPriorityISVSWReport(PrintWriter pPrintWriter) {
    printHeader(PRIORITY_ISV_SW_REPORT_NAME, null, PRIORITY_ISV_SW_REPORT_COLUMN_HEADERS, pPrintWriter);
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(
            "SELECT mf.NAME, isv.LEVEL, case when isv.LEVEL = 'GLOBAL' then 'ALL' else cus.CUSTOMER_NAME end as CUSTOMER_NAME, cus.ACCOUNT_NUMBER, isv.EVIDENCE_LOCATION, st.DESCRIPTION, isv.BUSINESS_JUSTIFICATION,isv.REMOTE_USER, isv.RECORD_TIME from EAADMIN.PRIORITY_ISV_SW isv inner join EAADMIN.MANUFACTURER mf on isv.MANUFACTURER_ID = mf.ID inner join EAADMIN.STATUS st on isv.STATUS_ID = st.ID left outer join EAADMIN.CUSTOMER cus on isv.CUSTOMER_ID = cus.CUSTOMER_ID")
            .scroll(ScrollMode.FORWARD_ONLY);
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }// w w w.  jav a 2s.  c  o  m

    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getScheduleFReport(Account account, PrintWriter pPrintWriter) {
    StringBuffer sql = new StringBuffer();
    sql.append(//  w ww .j  a  v  a2  s.c o m
            "select sf.Level,sf.hw_Owner,sf.hostname,sf.serial,sf.Machine_Type, c.account_number,sf.software_title,sf.software_name,sf.manufacturer,sc.description as Scope,sf.sw_financial_resp,so.description as Source,sf.source_location,st.description as Status,sf.business_justification")
            .append(" from eaadmin.schedule_f sf,eaadmin.scope sc, eaadmin.status st,eaadmin.source so,eaadmin.customer c ")
            .append(" where sc.id=sf.scope_id and st.id=sf.status_id and so.id=sf.source_id and c.customer_id=sf.customer_id and")
            .append(" c.customer_id=").append(account.getId());

    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(sql.toString())
            .scroll(ScrollMode.FORWARD_ONLY);

    pPrintWriter.println(outputData(SCHEDULE_F_REPORT_COLUMN_HEADERS));
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }

    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getNonInstanceBasedSWReport(PrintWriter pPrintWriter) {
    // TODO Auto-generated method stub
    printHeader(NON_INSTANCE_REPORT_NAME, null, NON_INSTANCE_REPORT_COLUMN_HEADERS, pPrintWriter);
    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(
            "SELECT sw.SOFTWARE_NAME, mf.NAME, non.RESTRICTION, ct.DESCRIPTION as ctDesc, CASE non.BASE_ONLY WHEN 1 THEN 'Y' ELSE 'N' END, st.DESCRIPTION as stDesc, non.REMOTE_USER, non.RECORD_TIME FROM EAADMIN.NON_INSTANCE non, EAADMIN.SOFTWARE sw, EAADMIN.MANUFACTURER mf, EAADMIN.CAPACITY_TYPE ct, EAADMIN.STATUS st WHERE non.SOFTWARE_ID = sw.SOFTWARE_ID AND non.MANUFACTURER_ID = mf.ID AND non.CAPACITY_TYPE_CODE = ct.CODE AND non.STATUS_ID = st.ID")
            .scroll(ScrollMode.FORWARD_ONLY);
    while (lsrReport.next()) {
        pPrintWriter.println(outputData(lsrReport.get()));
    }// www .j  av a2 s . c  o m

    lsrReport.close();
}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Override
@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getAlertHardwareCfgDataReport(Account pAccount, String remoteUser, String lsName, HSSFWorkbook phwb,
        OutputStream pOutputStream) throws HibernateException, Exception {

    AlertType alertType = (AlertType) getEntityManager().createNamedQuery("getAlertTypeByCode")
            .setParameter("code", "HWCFGDTA").getSingleResult();

    StringBuffer sb = new StringBuffer(
            "SELECT CASE WHEN VA.Alert_Age > 90 THEN 'Red' WHEN VA.Alert_Age > 45 THEN 'Yellow' ELSE 'Green' END, ");
    sb.append(//  ww  w  .  j  a  v a2  s . com
            "H.Serial, MT.Name, H.processor_manufacturer, H.MAST_PROCESSOR_TYPE, H.PROCESSOR_MODEL, H.NBR_CORES_PER_CHIP, H.CHIPS, ")
            .append("H.PROCESSOR_COUNT, H.NBR_OF_CHIPS_MAX, H.CPU_GARTNER_MIPS, H.CPU_MIPS, H.CPU_MSU, ")
            .append("VA.Creation_Time, VA.Alert_Age, MT.Type, VA.Remote_User, VA.Comments, VA.Record_Time,AC.name as ac_name, ")
            .append("CC.target_date,CC.owner as cc_owner,CC.record_time as cc_record_time,CC.remote_user as cc_remote_user, CC.id as cc_id ")
            .append("FROM EAADMIN.V_Alerts VA, EAADMIN.Hardware H, EAADMIN.Machine_Type MT, EAADMIN.cause_code CC, EAADMIN.alert_cause AC ")
            .append("WHERE VA.Customer_Id = :customerId AND VA.Type = 'HWCFGDTA' AND VA.Open = 1 AND H.Id = VA.FK_Id AND MT.Id = H.Machine_Type_Id ")
            .append("and VA.id=CC.alert_id and CC.alert_type_id= :alertTypeId and CC.alert_cause_id=AC.id ORDER BY H.Serial ASC ");

    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(sb.toString())
            .setLong("customerId", pAccount.getId()).setInteger("alertTypeId", alertType.getId().intValue())
            .scroll(ScrollMode.FORWARD_ONLY);

    HSSFSheet sheet = phwb.createSheet("Alert Hardware Config " + pAccount.getAccount() + " Report");
    printHeader(ALERT_HARDWARE_CFGDATA_REPORT_NAME, pAccount.getAccount(),
            ALERT_HARDWARE_CFGDATA_REPORT_COLUMN_HEADERS, sheet);
    int i = 3;
    while (lsrReport.next()) {
        int k = 1;
        if (i > 65535) {
            k++;
            sheet = phwb.createSheet("Alert Hardware Config " + pAccount.getAccount() + " Report" + k);
            i = 1;
        }
        HSSFRow row = sheet.createRow((int) i);
        outputData(lsrReport.get(), row);
        i++;
    }

    @SuppressWarnings("unchecked")
    Iterator<Object[]> vCauseCodeSummary = getEntityManager()
            .createNamedQuery("getValidCauseCodesByAlertTypeId").setParameter("alertTypeId", alertType.getId())
            .getResultList().iterator();
    HSSFSheet sheet_2 = phwb.createSheet("Valid Cause Codes");
    HSSFRow rowhead0 = sheet_2.createRow((int) 0);
    outputData(ALERT_VALID_CAUSE_CODE_HEADERS, rowhead0);
    int j = 1;
    while (vCauseCodeSummary.hasNext()) {
        HSSFRow row = sheet_2.createRow((int) j);
        outputData(vCauseCodeSummary.next(), row);
        j++;
    }
    phwb.write(pOutputStream);

}

From source file:com.ibm.asset.trails.service.impl.ReportServiceImpl.java

License:Open Source License

@Override
@Transactional(readOnly = false, propagation = Propagation.NOT_SUPPORTED)
public void getAlertUnlicensed(Account pAccount, String remoteUser, String lsName, HSSFWorkbook phwb,
        OutputStream pOutputStream, String type, String code, String reportName, String sheetName)
        throws HibernateException, Exception {

    AlertType alertType = (AlertType) getEntityManager().createNamedQuery("getAlertTypeByCode")
            .setParameter("code", code).getSingleResult();

    StringBuffer sb = new StringBuffer(unlicensedAlertQuery);

    ScrollableResults lsrReport = ((Session) getEntityManager().getDelegate()).createSQLQuery(sb.toString())
            .setLong("customerId", pAccount.getId()).setParameter("type", type).setParameter("code", code)
            .scroll(ScrollMode.FORWARD_ONLY);

    HSSFSheet sheet = phwb.createSheet(sheetName + " " + pAccount.getAccount() + " Report");
    printHeader(reportName, pAccount.getAccount(), UNLICENSED_GROUP_COLUMN_HEADERS, sheet);
    int i = 3;//from ww  w  .  j  av a2s .c om
    while (lsrReport.next()) {
        int k = 1;
        if (i > 65535) {
            k++;
            sheet = phwb.createSheet("Alert Contract Scope " + pAccount.getAccount() + " Report" + k);
            i = 1;
        }
        HSSFRow row = sheet.createRow((int) i);
        outputData(lsrReport.get(), row);
        i++;
    }

    @SuppressWarnings("unchecked")
    Iterator<Object[]> vCauseCodeSummary = getEntityManager()
            .createNamedQuery("getValidCauseCodesByAlertTypeId").setParameter("alertTypeId", alertType.getId())
            .getResultList().iterator();

    HSSFSheet sheet_2 = phwb.createSheet("Valid Cause Codes");
    HSSFRow rowhead0 = sheet_2.createRow((int) 0);
    outputData(ALERT_VALID_CAUSE_CODE_HEADERS, rowhead0);
    int j = 1;
    while (vCauseCodeSummary.hasNext()) {
        HSSFRow row = sheet_2.createRow((int) j);
        outputData(vCauseCodeSummary.next(), row);
        j++;
    }
    phwb.write(pOutputStream);

}

From source file:com.ibm.ea.bravo.report.MainframeScan.java

public void execute(String[] args, HttpServletRequest request) {
    ScrollableResults list = null;

    try {//w w  w  .jav a 2s .  com

        // get the report

        Session session = DelegateReport.getSession();

        list = session.getNamedQuery("mainFrameScanReport").scroll();

        // get the output writer
        PrintWriter os = new PrintWriter(outputStream, true);

        os.println(Constants.CONFIDENTIAL);

        // output the header
        os.println(tsv(HEADER));

        // output the report
        while (list.next()) {
            os.println(tsv(list.get()));
        }
        os.close();
        DelegateReport.closeSession(session);

    } catch (Exception e) {
        logger.error(e);
    }
}