Examples of AtomicTypeConverter


Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

    }

    private String getStringValue(String fieldName, Object value) {
      FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor(fieldName);
      AtomicTypeConverter atomicTypeConverter = null ;
      // if the attribute is a simple field (primitive data type or wrapper class)
      if (fieldDescriptor != null)
      {
        String fieldConverterName = fieldDescriptor.getConverter();

        // if a field converter is set in the mapping, use this one
        if ( fieldConverterName != null )
        {
          atomicTypeConverter = (AtomicTypeConverter) ReflectionUtils.newInstance(fieldConverterName);
        }
        // else use a default converter in function of the attribute type
        else
        {
          atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters.get(value.getClass());
        }
      }
      // else it could be a collection (for example, it is a multivalue property)
      else
      {
        atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters.get(value.getClass());
      }
        return atomicTypeConverter.getXPathQueryValue(valueFactory, value);
    }
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

            Value[] values = new Value[objects.getSize()];
            ValueFactory valueFactory = session.getValueFactory();
            Iterator collectionIterator = objects.getIterator();
            for (int i = 0; i < objects.getSize(); i++) {
                Object fieldValue = collectionIterator.next();
                AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                    .get(fieldValue.getClass());
                //If there is no proper conversion strategy defined for a specific bean type
                //then system will make a best effort conversion strategy using UndefinedTypeConverter.
                //@author:Boni Gopalan
                if (atomicTypeConverter == null){
                  atomicTypeConverter = new UndefinedTypeConverterImpl();
                }
                values[i] = atomicTypeConverter.getValue(valueFactory, fieldValue);
            }

            parentNode.setProperty(jcrName, values);
        }
        catch(ValueFormatException vfe) {
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

        Value[] values = new Value[objects.getSize()];
        ValueFactory valueFactory = session.getValueFactory();
        int i = 0;
        for (Iterator collectionIterator = objects.getIterator(); collectionIterator.hasNext(); i++) {
            Object fieldValue = collectionIterator.next();
            AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                .get(fieldValue.getClass());
            //If there is no proper conversion strategy defined for a specific bean type
            //then system will make a best effort conversion strategy using UndefinedTypeConverter.
            //@author:Boni Gopalan
            if (atomicTypeConverter == null){
              atomicTypeConverter = new UndefinedTypeConverterImpl();
            }
           
            values[i] = atomicTypeConverter.getValue(valueFactory, fieldValue);
        }

        parentNode.setProperty(jcrName, values);
    }
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

                  + collectionDescriptor.getClassDescriptor().getClassName()
                  " because it is not a collection");
            }

            for (int i = 0; i < values.length; i++) {
                AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                    .get(elementClass);
                //If there is no proper conversion strategy defined for a specific bean type
                //then system will make a best effort conversion strategy using UndefinedTypeConverter.
                //@author:Boni Gopalan
                if (atomicTypeConverter == null){
                  atomicTypeConverter = new UndefinedTypeConverterImpl();
                }
                ((ManageableCollection) objects).addObject(atomicTypeConverter.getObject(values[i]));
            }

            return objects;
        }
        catch(ValueFormatException vfe) {
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

   
        // otherwise create the bean to set the value
        initializedBean = ReflectionUtils.newInstance(classDescriptor.getClassName());
    }

        AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, initializedBean, fieldName);
        Object fieldValue = (propValue != null) ? converter.getObject(propValue) : null;
        ReflectionUtils.setNestedProperty(initializedBean, fieldName, fieldValue);

        return initializedBean;
  }
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

        //Not sure that we have the attribute with the default value in all use cases       
        ReflectionUtils.setNestedProperty(object, fieldName, defaultValue);
        fieldValue = ReflectionUtils.getNestedProperty(object, fieldName);
       
      }
      AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, object, fieldName);
      Value value = converter.getValue(valueFactory, fieldValue);
 
      checkProperty(objectNode, fieldDescriptor, value);
      objectNode.setProperty(jcrName, value);
    }     
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

            if (!pi.hasNext()) {
                return null;
            }

            ManageableObjects objects = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);
            AtomicTypeConverter atomicTypeConverter = getAtomicTypeConverter(collectionDescriptor);

            while (pi.hasNext()) {
                Property prop = pi.nextProperty();

                // ignore protected properties here
                if (prop.getDefinition().isProtected()) {
                    continue;
                }

                // handle multvalues as a list
                Object value;
                if (prop.getDefinition().isMultiple()) {
                    List valueList = new ArrayList();
                    Value[] values = prop.getValues();
                    for (int i = 0; i < values.length; i++) {
                        valueList.add(atomicTypeConverter.getObject(values[i]));
                    }
                    value = valueList;
                } else {
                    value = atomicTypeConverter.getObject(prop.getValue());
                }

                if (objects instanceof Map) {
                    String name = prop.getName();
                    ((Map) objects).put(name, value);
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

                    prop.remove();
                }
            }
        }

        AtomicTypeConverter atomicTypeConverter = getAtomicTypeConverter(collectionDescriptor);

        try {
            Map map = (Map) objects.getObjects();
            ValueFactory valueFactory = session.getValueFactory();
            for (Iterator ei = map.entrySet().iterator(); ei.hasNext();) {
                Map.Entry entry = (Map.Entry) ei.next();
                String name = String.valueOf(entry.getKey());

                // verify the property is not an existing protected property
                if (parentNode.hasProperty(name)
                    && parentNode.getProperty(name).getDefinition().isProtected()) {
                    continue;
                }

                Object value = entry.getValue();
                if (value instanceof List) {
                    // multi value
                    List valueList = (List) value;
                    Value[] jcrValues = new Value[valueList.size()];
                    int i = 0;
                    for (Iterator vi = valueList.iterator(); vi.hasNext();) {
                        value = vi.next();
                        jcrValues[i++] = atomicTypeConverter.getValue(
                            valueFactory, value);
                    }
                    parentNode.setProperty(name, jcrValues);
                } else {
                    // single value
                    Value jcrValue = atomicTypeConverter.getValue(valueFactory,
                        value);
                    parentNode.setProperty(name, jcrValue);
                }
            }
        } catch (ValueFormatException vfe) {
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

     * @throws ObjectContentManagerException if no such type converter is registered
     */
    private AtomicTypeConverter getAtomicTypeConverter(CollectionDescriptor collectionDescriptor) {
        String elementClassName = collectionDescriptor.getElementClassName();
        Class elementClass = ReflectionUtils.forName(elementClassName);
        AtomicTypeConverter atc = (AtomicTypeConverter) atomicTypeConverters.get(elementClass);
        if (atc != null) {
            return atc;
        }

        throw new ObjectContentManagerException(
View Full Code Here

Examples of org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter

    }

    private String getStringValue(String fieldName, Object value) {
      FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor(fieldName);
      AtomicTypeConverter atomicTypeConverter = null ;
      // if the attribute is a simple field (primitive data type or wrapper class)
      if (fieldDescriptor != null)
      {
        String fieldConverterName = fieldDescriptor.getConverter();

        // if a field converter is set in the mapping, use this one
        if ( fieldConverterName != null )
        {
          atomicTypeConverter = (AtomicTypeConverter) ReflectionUtils.newInstance(fieldConverterName);
        }
        // else use a default converter in function of the attribute type
        else
        {
          atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters.get(value.getClass());
        }
      }
      // else it could be a collection (for example, it is a multivalue property)
      else
      {
        atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters.get(value.getClass());
      }
        return atomicTypeConverter.getXPathQueryValue(valueFactory, value);
    }
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.