Package it.eng.spago.paginator.basic.impl

Examples of it.eng.spago.paginator.basic.impl.GenericList


    SessionContainer session = requestContainer.getSessionContainer();
    String parameterFieldName = (String)request.getAttribute("parameterFieldName");
    logger.debug("parameterFieldName="+parameterFieldName);
    // define the spago paginator and list object
    PaginatorIFace paginator = new GenericPaginator();
    ListIFace list = new GenericList();
    // define variable for value column name
    String valColName = "";
    // recover lov object 
    IParameterDAO pardao = DAOFactory.getParameterDAO();
    Parameter par = pardao.loadForExecutionByParameterIDandRoleName(parId, roleName);
    ModalitiesValue modVal = par.getModalityValue();
    // get the lov provider
    String looProvider = modVal.getLovProvider();
    // get from the request the type of lov
    String typeLov = LovDetailFactory.getLovTypeCode(looProvider);
    // get the user profile
    IEngUserProfile profile = null;
    SessionContainer permanentSession = session.getPermanentContainer();
    profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
//    HttpServletRequest httpReq = (HttpServletRequest)requestContainer.getInternalRequest();
//    HttpSession httpSess = httpReq.getSession();
//    profile = (IEngUserProfile)httpSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    // based on lov type fill the spago list / paginator object / valColName
    SourceBean rowsSourceBean = null;
    if(typeLov.equalsIgnoreCase("QUERY")) {
      QueryDetail qd = QueryDetail.fromXML(looProvider);
//      if (qd.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = qd.getValueColumnName();     
      //String pool = qd.getConnectionName();
      String datasource = qd.getDataSource();
      String statement = qd.getQueryDefinition();
      // execute query
      try {
        statement = StringUtilities.substituteProfileAttributesInString(statement, profile);
        //rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), pool, statement);
        rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), datasource, statement);
      } catch (Exception e) {
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        int startIndex = stacktrace.indexOf("java.sql.");
        int endIndex = stacktrace.indexOf("\n\tat ", startIndex);
        if (endIndex == -1) endIndex = stacktrace.indexOf(" at ", startIndex);
        if (startIndex != -1 && endIndex != -1)
          response.setAttribute("errorMessage", stacktrace.substring(startIndex, endIndex));
        response.setAttribute("testExecuted", "false");
      }
    } else if(typeLov.equalsIgnoreCase("FIXED_LIST")) {
      FixedListDetail fixlistDet = FixedListDetail.fromXML(looProvider);
//      if (fixlistDet.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = fixlistDet.getValueColumnName();
      try{
        String result = fixlistDet.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
        if(!rowsSourceBean.getName().equalsIgnoreCase("ROWS")) {
          throw new Exception("The fix list is empty");
        } else if (rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG).size()==0) {
          throw new Exception("The fix list is empty");
        }
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while converting fix lov into spago list", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing fix list lov");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("SCRIPT")) {
      ScriptDetail scriptDetail = ScriptDetail.fromXML(looProvider);
//      if (scriptDetail.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = scriptDetail.getValueColumnName();
      try{
        String result = scriptDetail.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while executing the script lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing script");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("JAVA_CLASS")) {
      JavaClassDetail javaClassDetail = JavaClassDetail.fromXML(looProvider);
//      if (javaClassDetail.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = javaClassDetail.getValueColumnName();
      try{   
        String javaClassName = javaClassDetail.getJavaClassName();
        IJavaClassLov javaClassLov = (IJavaClassLov) Class.forName(javaClassName).newInstance();
          String result = javaClassLov.getValues(profile);
            rowsSourceBean = SourceBean.fromXMLString(result);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                              "getList", "Error while executing the java class lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing java class");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    }
    // fill paginator
    int count = 0;
    if(rowsSourceBean != null) {
      List rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      for (int i = 0; i < rows.size(); i++){
        paginator.addRow(rows.get(i));
        count++;
      }
    }
    paginator.setPageSize(count);
    list.setPaginator(paginator);
   
    // get all the columns name
      rowsSourceBean = list.getPaginator().getAll();
    List colNames = new ArrayList();
    List rows = null;
    if(rowsSourceBean != null) {
      rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      if((rows!=null) && (rows.size()!=0)) {
View Full Code Here


      rowSBStr += "    DESCRIPTION=\"" + (description != null ? description : "") + "\"";
      rowSBStr += "     />";
      SourceBean rowSB = SourceBean.fromXMLString(rowSBStr);
      paginator.addRow(rowSB);
    }
    ListIFace list = new GenericList();
    list.setPaginator(paginator);
    // filter the list
    String valuefilter = (String) request.getAttribute(SpagoBIConstants.VALUE_FILTER);
    if (valuefilter != null) {
      String columnfilter = (String) request
          .getAttribute(SpagoBIConstants.COLUMN_FILTER);
View Full Code Here

    if (lovResultSB != null) {
      rows = lovResultSB.getAttributeAsList("ROW");
      for (int i = 0; i < rows.size(); i++)
        paginator.addRow(rows.get(i));
    }
    list = new GenericList();
    list.setPaginator(paginator);
    return list;
  }
View Full Code Here

   */
  public ListIFace getList(SourceBean request, SourceBean response) throws Exception {
     
    // define the spago paginator and list object
    PaginatorIFace paginator = new GenericPaginator();
    ListIFace list = new GenericList();
    // recover lov object 
    RequestContainer requestContainer = getRequestContainer();
    SessionContainer session = requestContainer.getSessionContainer();
    ModalitiesValue modVal = (ModalitiesValue) session.getAttribute(SpagoBIConstants.MODALITY_VALUE_OBJECT);
    // get the lov provider
    String looProvider = modVal.getLovProvider();
    // get from the request the type of lov
    String typeLov = LovDetailFactory.getLovTypeCode(looProvider);
    // get the usser profile
    IEngUserProfile profile = null;
    profile = (IEngUserProfile)session.getAttribute(SpagoBIConstants.USER_PROFILE_FOR_TEST);
    if(profile==null) {
      SessionContainer permSess = session.getPermanentContainer();
      profile = (IEngUserProfile) permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    } else {
      session.delAttribute(SpagoBIConstants.USER_PROFILE_FOR_TEST);
    }
    // based on lov type fill the spago list and paginator object
    SourceBean rowsSourceBean = null;
    List colNames = new ArrayList();
    if(typeLov.equalsIgnoreCase("QUERY")) {
      QueryDetail qd = QueryDetail.fromXML(looProvider);
      //String pool = qd.getConnectionName();
      String datasource = qd.getDataSource();
      String statement = qd.getQueryDefinition();
      // execute query
      try {
        statement = StringUtilities.substituteProfileAttributesInString(statement, profile);
        //rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), pool, statement, colNames);
        rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), datasource, statement, colNames);
      } catch (Exception e) {
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        int startIndex = stacktrace.indexOf("java.sql.");
        int endIndex = stacktrace.indexOf("\n\tat ", startIndex);
        if (endIndex == -1) endIndex = stacktrace.indexOf(" at ", startIndex);
        if (startIndex != -1 && endIndex != -1)
          response.setAttribute("errorMessage", stacktrace.substring(startIndex, endIndex));
        response.setAttribute("testExecuted", "false");
      }
    } else if(typeLov.equalsIgnoreCase("FIXED_LIST")) {
      FixedListDetail fixlistDet = FixedListDetail.fromXML(looProvider);
      try{
        String result = fixlistDet.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
        colNames = findFirstRowAttributes(rowsSourceBean);
        if(!rowsSourceBean.getName().equalsIgnoreCase("ROWS")) {
          throw new Exception("The fix list is empty");
        } else if (rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG).size()==0) {
          throw new Exception("The fix list is empty");
        }
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while converting fix lov into spago list", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing fix list lov");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("SCRIPT")) {
      ScriptDetail scriptDetail = ScriptDetail.fromXML(looProvider);
      try{
        String result = scriptDetail.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
        colNames = findFirstRowAttributes(rowsSourceBean);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while executing the script lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing script");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("JAVA_CLASS")) {
      JavaClassDetail javaClassDetail = JavaClassDetail.fromXML(looProvider);
      try{   
        String javaClassName = javaClassDetail.getJavaClassName();
        IJavaClassLov javaClassLov = (IJavaClassLov) Class.forName(javaClassName).newInstance();
          String result = javaClassLov.getValues(profile);
            rowsSourceBean = SourceBean.fromXMLString(result);
            colNames = findFirstRowAttributes(rowsSourceBean);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                              "getList", "Error while executing the java class lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing java class");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    }
    // fill paginator
    if(rowsSourceBean != null) {
      List rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      for (int i = 0; i < rows.size(); i++)
        paginator.addRow(rows.get(i));
    }
    list.setPaginator(paginator);
   
    // build module configuration for the list
    String moduleConfigStr = "";
    moduleConfigStr += "<CONFIG>";
    moduleConfigStr += "  <QUERIES/>";
View Full Code Here

      BIObject obj = (BIObject) it.next();
      SourceBean rowSB = makeListRow(profile, obj);
      if (rowSB != null)
    paginator.addRow(rowSB);
  }
  ListIFace list = new GenericList();
  list.setPaginator(paginator);
  // filter the list
  String valuefilter = (String) request.getAttribute(SpagoBIConstants.VALUE_FILTER);
  if (valuefilter != null) {
      String columnfilter = (String) request.getAttribute(SpagoBIConstants.COLUMN_FILTER);
      String typeFilter = (String) request.getAttribute(SpagoBIConstants.TYPE_FILTER);
View Full Code Here

        }
        if (rowSB != null) paginator.addRow(rowSB);
      }
    }
   
    ListIFace list = new GenericList();
    list.setPaginator(paginator);
    logger.debug( "OUT" );
    return list;
  }
View Full Code Here

    // non esegue nessuna operazione)
    // SearchTextInList.search(request, response, pagedRows, rowsVector);
   
       
   
    ListIFace list = new GenericList();
    list.setPaginator(paginator);
    // list.addStaticData(firstData);
   
    // filter the list
    String valuefilter = (String) request.getAttribute(SpagoBIConstants.VALUE_FILTER);
//    if((valuefilter!=null) && !(valuefilter.trim().equals(""))) {
View Full Code Here

        }
        if (doesRowSatisfyCondition) break;
      }
      if (doesRowSatisfyCondition) newPaginator.addRow(row);
    }
    ListIFace newList = new GenericList();
    newList.setPaginator(newPaginator);
    return newList;
  }
View Full Code Here

        }
        return list;
      }
      if (doesRowSatisfyCondition) newPaginator.addRow(row);
    }
    ListIFace newList = new GenericList();
    newList.setPaginator(newPaginator);
    return newList;
  }
View Full Code Here

    if (rowsSourceBean != null) {
      List rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      if (rows != null && rows.size() != 0) {
        // builds list
        PaginatorIFace paginator = new GenericPaginator();
        ListIFace list = new GenericList();
        list.setPaginator(paginator);
        for (int i = 0; i < rows.size(); i++) {
          paginator.addRow(rows.get(i));
        }
        // filters for correlations
        IParameterUseDAO parusedao = DAOFactory.getParameterUseDAO();
        ParameterUse paruse = parusedao.loadByParameterIdandRole(currbiObjPar.getParID(), roleName);
        list = SelectParametersLookupModule.filterListForParametersCorrelation(paruse, request, list, new HashMap(), errorHandler);
        // gets SourceBean from filtered list
        toReturn = list.getPaginator().getAll();
      }
    }
    logger.debug("OUT");
    return toReturn;
  }
View Full Code Here

TOP

Related Classes of it.eng.spago.paginator.basic.impl.GenericList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.