Package org.jdbf.engine.basic

Examples of org.jdbf.engine.basic.ObjectMapped


     */
    public ObjectMapped getUnmarshallObject(String xml)
        throws UnmarshallException{
       
        ConfigurationImpl child;
        ObjectMapped om = null;
        logger.log(Level.INFO,Messages.message("Unmarshaller.unmarshall"));
        try{
      byte [] byteArray = xml.getBytes();
      ConfigurationImpl conf = (ConfigurationImpl)
            ConfigurationBuilder.build (
                new ByteArrayInputStream(byteArray)
            );
           
      child = (ConfigurationImpl) conf.getConfiguration("class-name");     
            logger.log(Level.FINEST,"tag class-name " + child.getValue());
      Class classFor = Class.forName(child.getValue());
      om = (ObjectMapped) classFor.newInstance();
      child = (ConfigurationImpl) conf.getConfiguration("repository-name");
            logger.log(Level.FINEST,"tag repository-name " + child.getValue());
      om.setRepositoryViewName(child.getValue());
      Iterator iter = conf.getConfigurations("attributes");     
     
            while (iter.hasNext()){
        child = (ConfigurationImpl) iter.next();
        Iterator iterChild = child.getConfigurations("attribute");       
        while (iterChild.hasNext()) {
          conf = (ConfigurationImpl) iterChild.next();
          child = (ConfigurationImpl) conf.getConfiguration("name");
          String name = child.getValue();
                    logger.log(Level.FINEST,"tag name " + name);
          child = (ConfigurationImpl) conf.getConfiguration("value");
          String value = child.getValue();
                    logger.log(Level.FINEST,"tag value " + value);
          /*
           * Bug fixing 957296 (Gmartone)
           */
          if(name.equals("OID"))
            om.setOID(value);
          else
          /*
           * End bug fixing 957296 (Gmartone)
           */
          ReflectionManager.setValueByName(om,name,value);
        }
      }
      }
      catch(Exception e){
          logger.throwing(CLASS_NAME,"getUnmarshallObject()",
                        new UnmarshallException("unmarshal.unmarshalFail",
                            om.getClassName()));

      throw new UnmarshallException("unmarshal.unmarshalFail",
                      om.getClassName()
                     );
      }
      return om;   
    }
View Full Code Here


     */
    public static ObjectMapped createBean(String name, HashMap props)
      throws MappingException {

    Class oBeanClass = null;
        ObjectMapped oBean = null;
        Method oMethod = null;

        String sProp;
 
 
View Full Code Here

        props.put("repositoryViewName", beanDesc.getRepositoryViewName());

        //loop ResultSet
        while (results.next()) {

            ObjectMapped map =
                ReflectionManager.createBean(beanDesc.getClassName(), props);
            ResultSetMetaData metaData = results.getMetaData();
            //get values from ResultSet
            for (int i = 0; i < itemDesc.size(); i++) {
                int columnIndex = i + 1;
                ItemDescriptor item = (ItemDescriptor) itemDesc.get(i);
                String propertyName = item.getPropertyName();

                String columnTableName = item.getColumnTableName();

                if (columnTableName
                    .equals(metaData.getColumnName(columnIndex))) {

                    Object propertyValue = results.getObject(columnTableName);

                    Object[] params = { propertyName, propertyValue };
                    logger.log(
                        Level.FINEST,
                        Messages.format("Statement.value", params));
                    if (propertyValue == null) {
                        propertyValue = Types.getDefault(item.getDataType());
                    }
                    else {
                        if (!propertyName.equals("OID")) {

                            Object obj = null;
                            Class toClass =
                                ReflectionManager.getPropertyType(
                                    map,
                                    propertyName);
                            Class fromClass = propertyValue.getClass();

                            propertyValue =
                                convertValue(
                                    propertyName,
                                    propertyValue,
                                    map,
                                    item,
                                    fromClass,
                                    toClass);
                        }
                    }

                    /*
                     * OID is inherited fields and it cannot
                     * be setted by ReflectionManager directly
                     */
                    if (propertyName.equals("OID")) {
                        map.setOID(propertyValue);
                    }
                    else
                        map =
                            view.setPropertyValue(
                                map,
                                propertyName,
                                propertyValue);

                }

            }
            logger.log(Level.FINEST, Messages.message(map.toString()));
            res.add(map);
        }
        results.close();

        return res;
View Full Code Here

TOP

Related Classes of org.jdbf.engine.basic.ObjectMapped

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.