Examples of GenericList


Examples of com.adobe.acs.commons.genericlists.GenericList

        adapterFactory = new GenericListAdapterFactory();
    }

    @Test
    public void test_that_adapting_page_with_correct_template_returns_directly() {
        GenericList list = adapterFactory.getAdapter(listPage, GenericList.class);
        assertNotNull(list);
        List<Item> items = list.getItems();
        assertNotNull(items);
        assertEquals(2, items.size());
        assertEquals("titleone", items.get(0).getTitle());
        assertEquals("valueone", items.get(0).getValue());
    }
View Full Code Here

Examples of com.adobe.acs.commons.genericlists.GenericList

                    }
                });
            }
        });

        GenericList section = adaptToGenericList(wrongPage);
        assertNull(section);
    }
View Full Code Here

Examples of com.adobe.acs.commons.genericlists.GenericList

            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>());
            }
        });

        GenericList section = adaptToGenericList(wrongPage);
        assertNull(section);
    }
View Full Code Here

Examples of com.adobe.acs.commons.genericlists.GenericList

    public void test_i18n_titles() {
        Locale french = new Locale("fr");
        Locale swissFrench = new Locale("fr", "ch");
        Locale franceFrench = new Locale("fr", "fr");
       
        GenericList list = adapterFactory.getAdapter(listPage, GenericList.class);
        assertNotNull(list);
        List<Item> items = list.getItems();
        assertNotNull(items);
        assertEquals(2, items.size());
        assertEquals("titleone", items.get(0).getTitle(french));
        assertEquals("titleone", items.get(0).getTitle(swissFrench));
        assertEquals("titleone", items.get(0).getTitle(franceFrench));
View Full Code Here

Examples of com.adobe.acs.commons.genericlists.GenericList

            String fullListPath = LIST_ROOT + listPath;
            Page listPage = resourceResolver.adaptTo(PageManager.class).getPage(fullListPath);
            if (listPage == null) {
                return null;
            } else {
                GenericList list = listPage.adaptTo(GenericList.class);
                if (list == null) {
                    return null;
                } else {
                    ResourceMetadata rm = new ResourceMetadata();
                    rm.setResolutionPath(path);
View Full Code Here

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

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

      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

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

    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

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

   */
  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

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

      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
TOP
Copyright © 2018 www.massapi.com. 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.