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

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


        return fd;
    }

    private BeanDescriptor parseBeanDescriptor() throws XmlPullParserException {
        BeanDescriptor fd = new BeanDescriptor();

        /*
         * fieldName CDATA #REQUIRED
         * jcrName CDATA #IMPLIED
         * proxy (true | false) "false"
         * autoRetrieve (true|false) "true"
         * autoUpdate (true|false) "true"
         * autoInsert (true|false) "true"
         * converter CDATA #IMPLIED
         * jcrType CDATA #IMPLIED
         * jcrAutoCreated (true | false) "false"
         * jcrMandatory (true | false) "false"
         * jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
         * jcrProtected (true | false) "false"
         * jcrSameNameSiblings (true | false) "false"
         */

        fd.setFieldName(this.getRequiredAttribute("fieldName"));
        fd.setJcrName(this.getOptionalAttribute("jcrName", fd.getFieldName()));
        fd.setProxy(this.getOptionalAttribute("proxy", false));

        fd.setAutoRetrieve(this.getOptionalAttribute("autoRetrieve", true));
        fd.setAutoUpdate(this.getOptionalAttribute("autoUpdate", true));
        fd.setAutoInsert(this.getOptionalAttribute("autoInsert", true));

        fd.setJcrType(this.getOptionalAttribute("jcrType"));
        fd.setJcrAutoCreated(this.getOptionalAttribute("jcrAutoCreated", false));
        fd.setJcrMandatory(this.getOptionalAttribute("jcrMandatory", false));
        fd.setJcrOnParentVersion(this.getOptionalAttribute("jcrOnParentVersion", "COPY"));
        fd.setJcrProtected(this.getOptionalAttribute("jcrProtected", false));
        fd.setJcrSameNameSiblings(this.getOptionalAttribute("jcrSameNameSiblings", false));

        fd.setJcrMultiple(this.getOptionalAttribute("jcrMultiple", false));

        return fd;
    }
View Full Code Here


        return fd;
    }

    private BeanDescriptor parseBeanDescriptor() throws XmlPullParserException {
        BeanDescriptor fd = new BeanDescriptor();

        /*
         * fieldName CDATA #REQUIRED
         * jcrName CDATA #IMPLIED
         * proxy (true | false) "false"
         * autoRetrieve (true|false) "true"
         * autoUpdate (true|false) "true"
         * autoInsert (true|false) "true"
         * converter CDATA #IMPLIED
         * jcrType CDATA #IMPLIED
         * jcrAutoCreated (true | false) "false"
         * jcrMandatory (true | false) "false"
         * jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
         * jcrProtected (true | false) "false"
         * jcrSameNameSiblings (true | false) "false"
         */

        fd.setFieldName(this.getRequiredAttribute("fieldName"));
        fd.setJcrName(this.getOptionalAttribute("jcrName", fd.getFieldName()));
        fd.setProxy(this.getOptionalAttribute("proxy", false));

        fd.setAutoRetrieve(this.getOptionalAttribute("autoRetrieve", true));
        fd.setAutoUpdate(this.getOptionalAttribute("autoUpdate", true));
        fd.setAutoInsert(this.getOptionalAttribute("autoInsert", true));

        fd.setJcrType(this.getOptionalAttribute("jcrType"));
        fd.setJcrAutoCreated(this.getOptionalAttribute("jcrAutoCreated", false));
        fd.setJcrMandatory(this.getOptionalAttribute("jcrMandatory", false));
        fd.setJcrOnParentVersion(this.getOptionalAttribute("jcrOnParentVersion", "COPY"));
        fd.setJcrProtected(this.getOptionalAttribute("jcrProtected", false));
        fd.setJcrSameNameSiblings(this.getOptionalAttribute("jcrSameNameSiblings", false));

        fd.setJcrMultiple(this.getOptionalAttribute("jcrMultiple", false));

        return fd;
    }
View Full Code Here

                }

                if (classDescriptor.getBeanDescriptors() != null) {
                    Iterator beanIterator = classDescriptor.getBeanDescriptors().iterator();
                    while (beanIterator.hasNext()) {
                        BeanDescriptor field = (BeanDescriptor) beanIterator.next();
                        if (this.isPropertyType(field.getJcrType())) {
                            propDefs.add(getPropertyDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        } else {
                            nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        }
                    }
                }

                if (classDescriptor.getCollectionDescriptors() != null) {
                    Iterator collectionIterator = classDescriptor.getCollectionDescriptors().iterator();
                    while (collectionIterator.hasNext()) {
                        CollectionDescriptor field = (CollectionDescriptor) collectionIterator.next();
                        if (this.isPropertyType(field.getJcrType())) {
                            propDefs.add(getPropertyDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        } else {
                            nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        }
                    }
                }

                nodeTypeDef.setPropertyDefs((PropDef[]) propDefs.toArray(new PropDef[propDefs.size()]));
View Full Code Here

        ClassDescriptor classDescriptor = new ClassDescriptor();
        classDescriptor.setClassName("test.Test10Class");
        classDescriptor.setJcrType("ocm:test10");
        classDescriptor.setJcrSuperTypes("nt:base");
       
        BeanDescriptor bean1 = new BeanDescriptor();
        bean1.setFieldName("a");
        bean1.setJcrName("a");
        bean1.setJcrType("String");
        classDescriptor.addBeanDescriptor(bean1);
       
        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test10 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test10");
View Full Code Here

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

        BeanDescriptor bean1 = new BeanDescriptor();
        bean1.setFieldName("a");
        bean1.setJcrName("a");
        bean1.setJcrType("String");        
        classDescriptor.addBeanDescriptor(bean1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test14 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test14");
View Full Code Here

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

        BeanDescriptor bean1 = new BeanDescriptor();
        bean1.setFieldName("a");
        bean1.setJcrName("b");
        bean1.setJcrType("nt:unstructured");
        classDescriptor.addBeanDescriptor(bean1);

        getJackrabbitNodeTypeManagerImpl().createSingleNodeType(session, classDescriptor);
       
        NodeType test12 = session.getWorkspace().getNodeTypeManager().getNodeType("ocm:test12");
View Full Code Here

                }

                if (classDescriptor.getBeanDescriptors() != null) {
                    Iterator beanIterator = classDescriptor.getBeanDescriptors().iterator();
                    while (beanIterator.hasNext()) {
                        BeanDescriptor field = (BeanDescriptor) beanIterator.next();
                        if (this.isPropertyType(field.getJcrType())) {
                            propDefs.add(getPropertyDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        } else {
                            nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        }
                    }
                }
               
                if (classDescriptor.getCollectionDescriptors() != null) {
                    Iterator collectionIterator = classDescriptor.getCollectionDescriptors().iterator();
                    while (collectionIterator.hasNext()) {
                        CollectionDescriptor field = (CollectionDescriptor) collectionIterator.next();
                        if (this.isPropertyType(field.getJcrType())) {
                            propDefs.add(getPropertyDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        } else {
                            nodeDefs.add(getNodeDefinition(field.getFieldName(), field, nodeTypeDef.getName()));
                        }
                    }
                }

                nodeTypeDef.setPropertyDefs((PropDef[]) propDefs.toArray(new PropDef[propDefs.size()]));
View Full Code Here

    try {
      classDescriptor = getClassDescriptor(object.getClass());
      String pathFieldName = classDescriptor.getPathFieldDescriptor().getFieldName();
      path = (String) ReflectionUtils.getNestedProperty(object, pathFieldName);
      Node node = (Node) session.getItem(path);
      BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor(attributeName);
      if (beanDescriptor != null)
      {
        this.retrieveBeanField(session, beanDescriptor, node, path, object, true);
      }
      // Check if the attribute is a collection
View Full Code Here

   */
  private void retrieveBeanFields(Session session, ClassDescriptor classDescriptor, Node node, String path, Object object,
      boolean forceToRetrieve) {
    Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
    while (beanDescriptorIterator.hasNext()) {
      BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
      this.retrieveBeanField(session, beanDescriptor, node, path, object, forceToRetrieve);
    }
  }
View Full Code Here

   * Insert Bean fields
   */
  private void insertBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) {
    Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
    while (beanDescriptorIterator.hasNext()) {
      BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();

      if (!beanDescriptor.isAutoInsert()) {
        continue;
      }

      String jcrName = beanDescriptor.getJcrName();
      Object bean = ReflectionUtils.getNestedProperty(object, beanDescriptor.getFieldName());
      if (bean != null)
      {
        String converterClassName = null;

        if (null == beanDescriptor.getConverter() || "".equals(beanDescriptor.getConverter()))
        {
          converterClassName = DEFAULT_BEAN_CONVERTER;
        }
        else
        {
          converterClassName = beanDescriptor.getConverter();
        }

        Object[] param = {this.mapper, this, this.atomicTypeConverterProvider};
        BeanConverter beanConverter = (BeanConverter) ReflectionUtils.invokeConstructor(converterClassName, param);
        beanConverter.insert(session, objectNode, beanDescriptor, mapper.getClassDescriptorByClass(bean.getClass()), bean, classDescriptor, object);
View Full Code Here

TOP

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

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.