Examples of JDOClassInfoNature


Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

        ClassInfo cInfo = (ClassInfo) cInfos.get(0);
        XMLInfoNature xmlNature = new XMLInfoNature(cInfo);

        assertEquals("father", xmlNature.getNodeName());

        JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);

        assertEquals("Father", cNature.getTableName());

        List primaryKeys = cNature.getPrimaryKeys();

        assertEquals(1, primaryKeys.size());
        assertEquals("ssnr", primaryKeys.get(0));

        ///////// FieldInfo
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

//                assertNull(primaryKeys);
               
                assertEquals(0, cInfo.getFieldCount());
               
            } else if (xmlNature.getNodeName().equals("bookType")) {
                JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
               
                assertEquals("book", cNature.getTableName());
               
                List primaryKeys = cNature.getPrimaryKeys();
               
                assertEquals(1, primaryKeys.size());
                assertEquals("isbn", (String) primaryKeys.get(0));
               
                ///////// FieldInfo
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

        for (int i = 0; i < cInfos.size(); ++i) {
            ClassInfo cInfo = (ClassInfo) cInfos.get(i);
           
            assertNotNull(cInfo);
           
            JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
            XMLInfoNature xmlNature = new XMLInfoNature(cInfo);
           
            assertNotNull(cNature);
           
            if (xmlNature.getNodeName().equals("person")) {
                String tableName = cNature.getTableName();
                assertEquals("person", tableName);
               
                List primaryKeys = cNature.getPrimaryKeys();
               
                assertEquals(1, primaryKeys.size());
                assertEquals("ssn", (String) primaryKeys.get(0));
               
                assertEquals(4, cInfo.getFieldCount());
               
                FieldInfo[] fInfos = cInfo.getElementFields();
               
                assertNotNull(fInfos);
               
                for (int j = 0; j < fInfos.length; ++j) {
                    FieldInfo fInfo = fInfos[j];
                    assertNotNull(fInfo);
                    JDOFieldInfoNature fNature = new JDOFieldInfoNature(fInfo);
                    assertNotNull(fNature);
                   
                    String columnName = fNature.getColumnName();
                    String columnType = fNature.getColumnType();
                   
                    XMLInfoNature xmlFieldNature = new XMLInfoNature(fInfo);
                   
                    if (xmlFieldNature.getNodeName().equals("ssn")) {   
                        assertEquals("ssn", columnName);
                        assertEquals("bigint", columnType);
                    } else if (xmlFieldNature.getNodeName().equals("firstName")) {
                        assertEquals("firstName", columnName);
                        assertEquals("varchar", columnType);
                    } else if (xmlFieldNature.getNodeName().equals("lastName")) {
                        assertEquals("lastName", columnName);
                        assertEquals("varchar", columnType);
                    } else if (xmlFieldNature.getNodeName().equals("birthdate")) {
                        assertEquals("birthdate", columnName);
                        assertEquals("date", columnType);
                    } else {
                        fail("Unexpected FieldInfo Element encountered!");
                    }
                }
            } else if (xmlNature.getNodeName().equals("insurant")) {
                String tableName = cNature.getTableName();
                assertEquals("insurant", tableName);
               
                List primaryKeys = cNature.getPrimaryKeys();
               
                assertEquals(2, primaryKeys.size());
                assertEquals("ssn", (String) primaryKeys.get(0));
                assertEquals("policyNumber", (String) primaryKeys.get(1));
               
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

        createContructorForDefaultValueForSimpleContent(component.getAnnotated(), classInfo, sgState);
        makeMethods(component, sgState, state, jClass, baseClass);
       
        if (classInfo.hasNature(JDOClassInfoNature.class.getName())) {
            JDOClassInfoNature jdoNature = new JDOClassInfoNature(classInfo);
            if (jdoNature.getDetachable()) {
                createJdoTimestampImplementations(jClass);
            }
        }

        sgState.bindReference(jClass, classInfo);
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

        if (state.hasBoundProperties() && !enumeration) {
            createPropertyChangeMethods(jClass);
        }
       
        if (classInfo.hasNature(JDOClassInfoNature.class.getName())) {
            JDOClassInfoNature jdoNature = new JDOClassInfoNature(classInfo);
            if (jdoNature.getDetachable()) {
                createJdoTimestampImplementations(jClass);
            }
        }

        sgState.bindReference(jClass, classInfo);
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

                AppInfo appInfo = appInfos.nextElement();
                List<?> content = appInfo.getJdoContent();
                Iterator<?> it = content.iterator();
                if (it.hasNext()) {
                    cInfo.addNature(JDOClassInfoNature.class.getName());
                    JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
                    while (it.hasNext()) {
                        Object tmpObject = it.next();
                        if (tmpObject instanceof Table) {
                            Table table = (Table) tmpObject;
                            cNature.setTableName(table.getName());
                            cNature.setAccessMode(AccessMode.valueOf("shared"));
                            cNature.setDetachable(table.isDetachable());
                         // TODO: Uncomment next line as soon as Annotation Classes have been updated!
//                            cNature.setAccessMode(AccessMode.valueOf(table.getAccessMode().toString()));
                            PrimaryKey pk = table.getPrimaryKey();
                            Iterator<String> pIt = pk.iterateKey();
                            while (pIt.hasNext()) {
                                cNature.addPrimaryKey(pIt.next());
                            }
                        }
                    }
                }
            }
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

       JClass jClass               = classInfo.getJClass();
       String descriptorClassName  =
           getQualifiedJDODescriptorClassName(jClass.getName());
       JDODescriptorJClass classDesc =
           new JDODescriptorJClass(_config, descriptorClassName, jClass);
       JDOClassInfoNature cNature = new JDOClassInfoNature(classInfo);

       //-- get handle to default constructor
       JConstructor ctor   = classDesc.getConstructor(0);
       JSourceCode jsc     = ctor.getSourceCode();

       jsc = createClassInfoPart(classInfo, jsc);

       //=================
       // FieldDescriptors
       //=================

       for (int i = 0; i < classInfo.getElementFields().length; i++) {
           FieldInfo fInfo = classInfo.getElementFields()[i];
           if (checkFieldInfoNatures(fInfo)) {
              
               if (fInfo.hasNature(JDOOneToOneNature.class.getName())) {
                   jsc = createOneToOneFieldInfoPart(fInfo, jsc);
                  
               } else if (fInfo.hasNature(JDOOneToManyNature.class.getName())) {
                   jsc = createOneToManyFieldInfoPart(fInfo, jsc);
               } else {
                   jsc = createEntityFieldInfoPart(fInfo, jsc);
               }
           }
       }


       _fields = setFields(classInfo.getElementFields());
       _identities = setIdentities(cNature.getPrimaryKeys());

       jsc.add("");

       jsc.add("setFields(new FieldDescriptor[] {" + _fields + "});");
       jsc.add("setIdentities(new FieldDescriptor[] {" + _identities + "});");
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

       FieldInfo fInfo;
       ClassInfo cInfo;
       for (int i = 0; i < fInfos.length; i++) {
           fInfo = fInfos[i];
           cInfo = fInfo.getDeclaringClassInfo();
           JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
           if (cNature.getPrimaryKeys() != null) {
               if (cNature.getPrimaryKeys().contains(new XMLInfoNature(fInfo).getNodeName())) {
                   continue;
               }
           }
           if (str.equals("")) {
               str = str + new XMLInfoNature(fInfo).getNodeName() + "FieldDescr";
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

    * @return true when ClassInfo has a JDOClassNature with all required
    *              attributes properly set, false otherwise
    */
   private boolean checkClassInfoNature(final ClassInfo cInfo) {
       if (cInfo.hasNature(JDOClassInfoNature.class.getName())) {
           JDOClassInfoNature cNature = new JDOClassInfoNature(cInfo);
           if (cNature.getAccessMode() == null
                   || cNature.getPrimaryKeys() == null
                   || cNature.getPrimaryKeys().isEmpty()
                   || cNature.getTableName() == null
                   || cNature.getTableName().length() == 0) {
               return false;
           }
           return true;
       }
       return false;
View Full Code Here

Examples of org.exolab.castor.builder.info.nature.JDOClassInfoNature

    * @param jsc JSourceCode
    * @return JSourceCode created in this method
    */
   private JSourceCode createClassInfoPart(final ClassInfo classInfo, final JSourceCode jsc) {

       JDOClassInfoNature cNature = new JDOClassInfoNature(classInfo);

       jsc.add("");
      
       jsc.add("addNature(ClassDescriptorJDONature.class.getName());");
       jsc.add("ClassDescriptorJDONature jdoNature = new ClassDescriptorJDONature(this);");

       //-- set table name
       String tableName = cNature.getTableName();
       jsc.add("jdoNature.setTableName(\"" + tableName + "\");");

       //-- set corresponding Java class
       // TODO IS THERE A NEED TO CHECK THIS?!
       String className = classInfo.getJClass().getLocalName();
       if ((className != null) && (className.length() > 0)) {
           jsc.add("setJavaClass(");
           jsc.append(className);
           jsc.append(".class);");
       }

       //-- set access mode
       String accessMode = cNature.getAccessMode().getName();
       jsc.add("jdoNature.setAccessMode(AccessMode.valueOf(\"" + accessMode + "\"));");

       //-- set cache key
       // TODO IS THERE A NEED TO CHECK THIS?!
       String fullName = classInfo.getJClass().getName();
       if ((fullName != null) && (fullName.length() > 0)) {
           jsc.add("jdoNature.addCacheParam(\"name\", \"");
           jsc.append(fullName);
           jsc.append("\");");
       }

       jsc.add("");

       //-- Configure class mapping
       jsc.add("mapping.setAccess(ClassMappingAccessType.valueOf(\"");
       jsc.append(accessMode + "\"));");

       jsc.add("mapping.setAutoComplete(true);");

       // TODO IS THERE A NEED TO CHECK THIS?!
       if ((fullName != null) && (fullName.length() > 0)) {
           jsc.add("mapping.setName(\"");
           jsc.append(fullName);
           jsc.append("\");");
       }

       //-- set class choice
       jsc.add("mapping.setClassChoice(choice);");

       //-- set table
       String table = cNature.getTableName();
       jsc.add("mapTo.setTable(\"" + table + "\");");

       //-- set table mapping
       jsc.add("mapping.setMapTo(mapTo);");

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.