Package org.apache.jackrabbit.ocm.mapper.model

Examples of org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor


                Object object = collectionIterator.next();
        if (object != null)
        {
          ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(object.getClass());

          FieldDescriptor fieldDescriptor = classDescriptor.getUuidFieldDescriptor();
          if (fieldDescriptor == null)
          {
            throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : "
                                  + classDescriptor.getClassName());
          }

          String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
          values[i] = valueFactory.createValue(uuid, PropertyType.REFERENCE);
        }
            }

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


                String key = (String) keyIterator.next();
                Object object = map.get(key);
                if (object != null) {
                    ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(object.getClass());

                    FieldDescriptor fieldDescriptor = classDescriptor.getUuidFieldDescriptor();
                    if (fieldDescriptor == null) {
                        throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : "
                                + classDescriptor.getClassName());
                    }

                    String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
                    values[i] = valueFactory.createValue(MapReferenceValueEncoder.encodeKeyAndReference(key, uuid), PropertyType.STRING);
                }
            }

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


  private void addFieldDescriptor(ClassDescriptor classDescriptor, String fieldName, Field fieldAnnotation)
  {

    FieldDescriptor fieldDescriptor = new FieldDescriptor();
    fieldDescriptor.setFieldName(fieldName);
    if ((fieldAnnotation.jcrName() != null) && (!fieldAnnotation.jcrName().equals("")))
    {
      fieldDescriptor.setJcrName(fieldAnnotation.jcrName());
    }
    else
    {
      fieldDescriptor.setJcrName(fieldName);
    }
    fieldDescriptor.setId(fieldAnnotation.id());
    fieldDescriptor.setPath(fieldAnnotation.path());
    fieldDescriptor.setUuid(fieldAnnotation.uuid());

    // It is not possible to set a null value into an annotation attribute.
    // If the converter == Object.class, it should be considered as null
    if (! fieldAnnotation.converter().equals(Object.class))
    {
        fieldDescriptor.setConverter(fieldAnnotation.converter().getName());
    }

    // It is not possible to set a null value into an annotation attribute.
    // If the jcrDefaultValue value is an empty string => it should be considered as null
    if ((fieldAnnotation.jcrDefaultValue() != null) && (!fieldAnnotation.jcrDefaultValue().equals("")))
    {
         fieldDescriptor.setJcrDefaultValue(fieldAnnotation.jcrDefaultValue());
    }

    // It is not possible to set a null value into an annotation attribute.
    // If the jcrValueConstraints value is an empty string => it should be considered as null
    if ((fieldAnnotation.jcrValueConstraints() != null) && (!fieldAnnotation.jcrValueConstraints().equals("")))
    {
         fieldDescriptor.setJcrValueConstraints(fieldAnnotation.jcrValueConstraints());
    }

    // It is not possible to set a null value into an annotation attribute.
    // If the jcrProperty value is an empty string => it should be considered as null
    if ((fieldAnnotation.jcrType() != null) && (!fieldAnnotation.jcrType().equals("")))
    {
        fieldDescriptor.setJcrType(fieldAnnotation.jcrType());
    }

    fieldDescriptor.setJcrAutoCreated(fieldAnnotation.jcrAutoCreated());
    fieldDescriptor.setJcrMandatory(fieldAnnotation.jcrMandatory());
    fieldDescriptor.setJcrOnParentVersion(fieldAnnotation.jcrOnParentVersion());
    fieldDescriptor.setJcrProtected(fieldAnnotation.jcrProtected());
    fieldDescriptor.setJcrMultiple(fieldAnnotation.jcrMultiple());

    //fieldDescriptor.setJcrType(value)
    classDescriptor.addFieldDescriptor(fieldDescriptor);
  }
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.TestClass");
        classDescriptor.setJcrType("ocm:test2");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("ocm:a");
        field1.setJcrType("String");
        field1.setJcrAutoCreated(true);
        field1.setJcrMandatory(true);
        field1.setJcrMultiple(true);
        classDescriptor.addFieldDescriptor(field1);

        FieldDescriptor field2 = new FieldDescriptor();
        field2.setFieldName("b");
        field2.setJcrName("ocm:b");
        field2.setJcrType("Long");
        field1.setJcrAutoCreated(false);
        field1.setJcrMandatory(true);
        field1.setJcrMultiple(false);
        classDescriptor.addFieldDescriptor(field2);
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test3Class");
        classDescriptor.setJcrType("test3");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);

        NodeType test3 = session.getWorkspace().getNodeTypeManager().getNodeType("test3");
View Full Code Here

    {
        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test4Class");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);

        NodeType test4 = session.getWorkspace().getNodeTypeManager().getNodeType("test.Test4Class");
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test5Class");
        classDescriptor.setJcrType("ocm:test5");
        classDescriptor.setJcrSuperTypes("ocm:test2");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("abc");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);

        NodeType test5 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test5");
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test6Class");
        classDescriptor.setJcrType("nt:test3");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        boolean failed = false;

        try
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test6Class");
        classDescriptor.setJcrType("ocm:test6");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("ocm:a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        FieldDescriptor field2 = new FieldDescriptor();
        field2.setFieldName("b");
        field2.setJcrName("ocm:b");
        field2.setJcrType("Long");
        classDescriptor.addFieldDescriptor(field2);

        ClassDescriptor classDescriptor2 = new ClassDescriptor();
        classDescriptor2.setClassName("test.Test7Class");
        classDescriptor2.setJcrType("ocm:test7");
        classDescriptor2.setJcrSuperTypes("nt:base");

        FieldDescriptor field3 = new FieldDescriptor();
        field3.setFieldName("a");
        field3.setJcrName("ocm:a");
        field3.setJcrType("String");
        classDescriptor2.addFieldDescriptor(field3);

        FieldDescriptor field4 = new FieldDescriptor();
        field4.setFieldName("b");
        field4.setJcrName("ocm:b");
        field4.setJcrType("Long");
        classDescriptor2.addFieldDescriptor(field4);

        ClassDescriptor[] classDescriptorArray = new ClassDescriptor[2];
        classDescriptorArray[0] = classDescriptor;
        classDescriptorArray[1] = classDescriptor2;
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test8Class");
        classDescriptor.setJcrType("ocm:test8");
        classDescriptor.setJcrSuperTypes("nt:base");

        FieldDescriptor field1 = new FieldDescriptor();
        field1.setFieldName("a");
        field1.setJcrName("a");
        field1.setJcrType("String");
        classDescriptor.addFieldDescriptor(field1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);

        NodeType test8 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test8");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor

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.