Examples of DynaProperty


Examples of org.apache.commons.beanutils.DynaProperty

    // from the metadata
    Class clazz = Object.class;
    if (className != null) {
      clazz = loadClass(className);
    }
    return new DynaProperty(name, clazz);

  }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

    List fieldNames = fieldsToSelect;
    if ( fieldNames == null )
      fieldNames = modelEntity.getAllFieldNames();
    int n = fieldNames.size();
    for (int i = 0; i < n; i++) {
      DynaProperty dynaProperty = createDynaProperty(genericValue.getDelegator(), modelEntity, (String) fieldNames.get(i));
      if (dynaProperty != null) {
          list.add(dynaProperty);
      }
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

            DynaProperty[] props = new DynaProperty[_columnsToProperties.size()];
            int            idx   = 0;

            for (Iterator it = _columnsToProperties.values().iterator(); it.hasNext(); idx++)
            {
                props[idx] = new DynaProperty((String)it.next());
            }
            _dynaClass = new BasicDynaClass("result", BasicDynaBean.class, props);
        }
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

    for (Iterator ii = inputs.iterator(); ii.hasNext();)
    {
      oneInput = (ResponseElementDynaBean) ii.next();

      Object defValue = oneInput.get("defaultValue");
      DynaProperty dp = null;

      if (defValue != null)
      {
        dp = new DynaProperty((String) oneInput.get("name"), oneInput.get("defaultValue").getClass());
      }
      else
      {
        try
        {
          dp = new DynaProperty((String) oneInput.get("name"), Class.forName("java.lang.String"));
        }
        catch (ClassNotFoundException e)
        {
          throw new ClientException("Cannot create String dynaproperty", e);
        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

          {
            throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
          }

          DynaProperty[] props = dc.getDynaProperties();
          DynaProperty oneProp = null;

          if (log.isDebugEnabled())
          {
            // They are not available in Struts Dynaform objects.
            for (final Enumeration enumeration = this.hreq.getParameterNames(); enumeration
                    .hasMoreElements();)
            {
              // get parameter name
              // Get paramater values...
              // See if present in form.
              final String name = (String) enumeration.nextElement();

              try
              {
                for (int idx = 0;; idx++)
                {
                  final Object value = df.get(name, idx);

                  log.debug("Array Access Parameter/Value/Index: " + name + '/' + value + '/' + idx);
                }
              }
              catch (Exception e)
              {
                log.debug("Exception: " + e);
                log.debug("No more values for: " + name);
              }
            }

            for (final Enumeration enumeration = hreq.getParameterNames(); enumeration.hasMoreElements();)
            {
              final String name = (String) enumeration.nextElement();
              final String[] values = hreq.getParameterValues(name);

              log.debug("Servlet Parameter name: " + name);
              log.debug("Number of values: " + values.length);

              for (int idx = 0; idx < values.length; idx++)
              {
                log.debug("Idx/Value: " + idx + '/' + values[idx]);
              }
            }

            log.debug("# of properties: " + props.length);
          }

          for (int i = 0; i < props.length; i++)
          {
            oneProp = props[i];

            String oneName = oneProp.getName();
            final Object value = df.get(oneName);

            log.debug("Getting parameter/value/type:" + oneName + '/' + value + '/'
                    + (value == null ? "null" : value.getClass().getName()));

            // TODO: Handle mapped and indexed properties here
            // getName(), getType, isIndexed(), isMapped()
            if (df.get(oneName) != null && df.get(oneName) instanceof FormFile)
            {
              log.debug("Formfile");

              FormFile fileInfo = (FormFile) df.get(oneName);

              if (fileInfo != null && fileInfo.getFileSize() > 0)
              {
                BufferedInputStream inStream = null;

                try
                {
                  inStream = new BufferedInputStream(fileInfo.getInputStream(), BUFFER_SIZE);
                }
                catch (IOException e)
                {
                  throw new ClientException(e.getMessage(), e);
                }

                // Problem - DefaultFileItem is not comprised
                // completely of serializable components.
                // final FileItem fileItem =
                // DFIF.createItem(oneName,
                // fileInfo.getContentType(), false,
                // fileInfo.getFileName());
                // So we use BinaryWrapper instead, which is
                // completely serializable
                // TODO: Reset First parameter with Context Name
                // so that this will work over distributed
                // environments(I could not find the call to get
                // it - SPD)
                final BinaryWrapper fileWrapper = new BinaryWrapper(null, hreq.getContentType(),
                        fileInfo.getFileName(), BUFFER_SIZE, null);

                try
                {
                  final long written = fileWrapper.writeFrom(inStream);

                  if (this.log.isDebugEnabled())
                  {
                    log.debug("Read/Wrote " + written + "bytes.");
                  }
                }
                catch (IOException e)
                {
                  throw new ClientException(e.getMessage(), e);
                }
                finally
                {
                  if (inStream != null)
                  {
                    try
                    {
                      inStream.close();
                    }

                    // Done Anyways, so just print for log
                    // (hopefully) and carry on.
                    catch (IOException e)
                    {
                      e.printStackTrace();
                    }
                  } // end if(inStream

                  try
                  {
                    fileWrapper.close();
                  }

                  // Done Anyways, so just print for log
                  // (hopefully) and carry on.
                  catch (IOException e)
                  {
                    e.printStackTrace();
                  }
                } // end finally

                if (log.isDebugEnabled())
                {
                  log.debug("Setting FormFile parameter/value:" + oneName + '/'
                          + fileWrapper.getName());
                }

                kreq.setParameter(oneName, fileWrapper);
              } // end if (fileInfo!= null..
            } // end if(df.get(oneName)!=null
            else if (df.get(oneName) != null && df.get(oneName) instanceof java.io.Serializable)
            {
              if (log.isDebugEnabled())
              {
                log.debug("Setting FormField parameter/value:" + oneName + '/' + df.get(oneName));
              }

              // TODO: Fix this.
              // BUG # 880906 Need to get value(s) directly from
              // request.
              final String[] values = hreq.getParameterValues(oneName);

              if (values.length < 1)
              {
                log.debug("No values, so setting value=null");
                kreq.setParameter(oneName, null);
              }
              else if (values.length == 1)
              {
                log.debug("One value, saving as string");
                kreq.setParameter(oneName, values[1]);
              }
              else
              {
                // More than one value in this list, so send the
                // entire array
                log.debug("Many values, saving as array");
                kreq.setParameter(oneName, values);
              }
            } // end else if(df.get(oneName)!=null...instanceof
            // Serializable

            log.debug("Name/Value written to request: " + oneName);
          } // end for
        }
        else
        {
          // isMultipart == false - Just a regular dynaform
          log.debug("Standard Dyna Form...");

          // Populate the model parameters from the form
          DynaActionForm df = (DynaActionForm) form;
          DynaClass dc = df.getDynaClass();

          if (dc == null)
          {
            throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
          }

          DynaProperty[] props = dc.getDynaProperties();
          DynaProperty oneProp = null;

          for (int i = 0; i < props.length; i++)
          {
            oneProp = props[i];

            String oneName = oneProp.getName();
            final Object value = df.get(oneName);

            if (log.isDebugEnabled())
            {
              log.debug("Getting parameter/value/type:" + oneName + '/' + value + '/'
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

    for (Iterator ii = inputs.iterator(); ii.hasNext();)
    {
      oneInput = (ResponseElementDynaBean) ii.next();

      Object defValue = oneInput.get("defaultValue");
      DynaProperty dp = null;

      if (defValue != null)
      {
        dp = new DynaProperty((String) oneInput.get("name"), oneInput.get("defaultValue").getClass());
      }
      else
      {
        try
        {
          dp = new DynaProperty((String) oneInput.get("name"), Class.forName("java.lang.String"));
        }
        catch (ClassNotFoundException e)
        {
          throw new ClientException("Cannot create String dynaproperty", e);
        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

            //--- quikdraw: This should probably throw an exception, but which one?
            break;
        }

        DynaProperty fieldProp = new DynaProperty(oneFieldName, Class.forName(typeClass));

        props[propCount++] = fieldProp;
      }

      return new BasicDynaClass(pe.getName(), Class
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

      {
        totalPropCount = totalPropCount + 4;
      }

      DynaProperty[] props = new DynaProperty[totalPropCount];
      DynaProperty nameProp = new DynaProperty("name", Class.forName("java.lang.String"));

      props[propCount++] = nameProp;

      DynaProperty typeProp = new DynaProperty("type", Class.forName("java.lang.String"));

      props[propCount++] = typeProp;

      DynaProperty nested = new DynaProperty("nested", allNested.getClass());

      props[propCount++] = nested;

      /*if (allNested.size() > 0) {
          ResponseElement nestedElement = null;
          for (Iterator in = allNested.iterator(); in.hasNext();) {
              nestedElement = (ResponseElement) in.next();
              DynaProperty nestedProp =
                  new DynaProperty(
                      nestedElement.getName(),
                      Class.forName(
                          "de.iritgo.aktera.clients.ResponseElementDynaBean"));
              props[propCount++] = nestedProp;
          }
      } */
      DynaProperty attribProp = new DynaProperty("attributes", Class
              .forName("org.apache.commons.beanutils.BasicDynaBean"));

      props[propCount++] = attribProp;

      /*   if (attributes.size() > 0) {
             Object attribVal = null;
             String oneKey = null;
             for (Iterator in = attributes.keySet().iterator();
                 in.hasNext();
                 ) {
                 oneKey = (String) in.next();
                 attribVal = attributes.get(oneKey);
                 DynaProperty nestedProp =
                     new DynaProperty(oneKey, attribVal.getClass());
                 props[propCount++] = nestedProp;
             }
         } */

      /**
       * If the element is an Input, create properties appropriate to an Input
       */
      if (re instanceof Input)
      {
        Input i = (Input) re;
        Object defValue = i.getDefaultValue();
        DynaProperty defProp = null;

        if (defValue != null)
        {
          defProp = new DynaProperty("defaultValue", i.getDefaultValue().getClass());
        }
        else
        {
          defProp = new DynaProperty("defaultValue", Class.forName("java.lang.String"));
        }

        props[propCount++] = defProp;

        /**
         * We only have an attribute of "validValues" if the set of valid values
         * for this input is not empty. The actual validValues property gets
         * populated by a HashSet of dynabeans, where each bean has attributes
         * name and label
         */
        Map valids = i.getValidValues();

        if (valids.size() > 0)
        {
          DynaProperty validsProp = new DynaProperty("validValues", Class.forName("java.util.TreeSet"));

          props[propCount++] = validsProp;
        }

        DynaProperty labelProp = new DynaProperty("label", Class.forName("java.lang.String"));

        props[propCount++] = labelProp;
      }

      if (re instanceof Output)
      {
        Output o = (Output) re;
        Object content = o.getContent();
        DynaProperty contentProp = null;

        if (content != null)
        {
          contentProp = new DynaProperty("content", content.getClass());
        }
        else
        {
          contentProp = new DynaProperty("content", Class.forName("java.lang.String"));
        }

        props[propCount++] = contentProp;
      }

      if (re instanceof Command)
      {
        Command c = (Command) re;

        DynaProperty modelProp = new DynaProperty("model", Class.forName("java.lang.String"));

        props[propCount++] = modelProp;

        DynaProperty beanProp = new DynaProperty("bean", Class.forName("java.lang.String"));

        props[propCount++] = beanProp;

        DynaProperty labelProp = new DynaProperty("label", Class.forName("java.lang.String"));

        props[propCount++] = labelProp;

        Map params = c.getParameters();
        DynaProperty paramsProp = new DynaProperty("parameters", params.getClass());

        props[propCount++] = paramsProp;
      }

      return new BasicDynaClass(re.getName(), Class.forName("de.iritgo.aktera.clients.ResponseElementDynaBean"),
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

          oneAttribName = (String) io.next();
          oneAttribValue = attributes.get(oneAttribName);

          if (oneAttribValue == null)
          {
            dattr[j++] = new DynaProperty(oneAttribName, Class.forName("java.lang.String"));
          }
          else
          {
            if (oneAttribValue instanceof ResponseElement)
            {
              dattr[j++] = new DynaProperty(oneAttribName, Class
                      .forName("de.iritgo.aktera.clients.ResponseElementDynaBean"));
            }
            else
            {
              dattr[j++] = new DynaProperty(oneAttribName, oneAttribValue.getClass());
            }
          }
        }

        DynaClass bdattr = new BasicDynaClass(re.getName() + "_attributes", Class
                .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), dattr);

        DynaBean oneAttrBean = bdattr.newInstance();

        for (Iterator io = attributes.keySet().iterator(); io.hasNext();)
        {
          oneAttribName = (String) io.next();
          oneAttribValue = attributes.get(oneAttribName);

          if (oneAttribValue instanceof ResponseElement)
          {
            oneAttrBean.set(oneAttribName, new ResponseElementDynaBean((ResponseElement) oneAttribValue));
          }
          else
          {
            oneAttrBean.set(oneAttribName, oneAttribValue);
          }
        }

        set("attributes", oneAttrBean);
      }
      else
      {
        DynaClass bdattr = new BasicDynaClass(re.getName() + "_attributes", Class
                .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), new DynaProperty[0]);
        BasicDynaBean oneAttrBean = (BasicDynaBean) bdattr.newInstance();

        set("attributes", oneAttrBean);
      }

      if (re instanceof Input)
      {
        set("type", "input");

        Input i = (Input) re;

        set("defaultValue", i.getDefaultValue());

        Map valids = i.getValidValues();

        if (valids.size() > 0)
        {
          BeanComparator bc = new BeanComparator("value");
          TreeSet options = new TreeSet(bc);
          DynaProperty[] dpopts = new DynaProperty[2];

          dpopts[0] = new DynaProperty("value", Class.forName("java.lang.String"));
          dpopts[1] = new DynaProperty("label", Class.forName("java.lang.String"));

          DynaClass bdopt = new BasicDynaClass("validValues", Class
                  .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), dpopts);
          Object oneOpt = null;
          Object oneLabelObj = null;
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

  {
//  Force an exception if the property does not exist
     // (BeanUtils.setProperty() silently returns in this case)
     if (top instanceof DynaBean)
     {
       DynaProperty desc =((DynaBean) top).getDynaClass().getDynaProperty(actualName);
       if (desc == null)
       {
         throw new NoSuchMethodException(
           "Bean has no property named " + actualName);
       }
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.