Package com.pv.mf.db.mock.metadata

Examples of com.pv.mf.db.mock.metadata.ColumnRelationshipMetadata


               String name = null;
               if(method.isAnnotationPresent(Column.class)) {
                  name = (method.getAnnotation(Column.class)).name();
               }
              
               ColumnRelationshipMetadata column = findColumnMetadata(
                     metadata, method);
               if(column == null) {
                  column = new ColumnRelationshipMetadata();
               }
               updateColumn(metadata, column, method, name);
               saveSetter(metadata, column, method, name);
              
               //determine relation
               Relationship relationship = null;
               if(ann instanceof OneToOne) {
                  relationship = Relationship.ONE_TO_ONE;
               }
               else if(ann instanceof OneToMany) {
                  relationship = Relationship.ONE_TO_MANY;
                  column.setMappedBy(((OneToMany) ann).mappedBy());
               }
               else {
                  relationship = Relationship.NONE;
               }
              
View Full Code Here


   protected void setRelatedMocks(Object mockObj, boolean ignoreNulls,
         IClassDbMetadata classMetadata) {
      for (Map.Entry<Method, ColumnRelationshipMetadata> relationColumn :
            classMetadata.getColumnsByRelationship().entrySet()) {
        
         ColumnRelationshipMetadata columnMetadata = relationColumn.getValue();
         Relationship relationship = columnMetadata.getRelationship();
        
         Class<?> relatedType;
         IClassDbMetadata relatedClassMetadata;
         Object relatedMockObj;
         switch (relationship) {
            case ONE_TO_ONE:
               /*
                * Get the type and create a mock object from it.
                */
               relatedType = columnMetadata.getType();
               relatedClassMetadata =
                  getAnnotationManager().getClassMetadata(relatedType);
               relatedMockObj = mock(relatedType, ignoreNulls,
                     relationship);
              
               //add table
               getQuery().addTable(relatedClassMetadata.getPrimaryTable());
              
               //match identity columns
               addMatchedCriteriaSetter(
                     relatedClassMetadata.getIdentityColumn(),
                     classMetadata.getIdentityColumn(), ignoreNulls);
              
               //add child mock
               if(columnMetadata.hasSetter()) {
                  try {
                     columnMetadata.getSetterMethod().invoke(mockObj, relatedMockObj);
                     getController().clearLastInvocation();
                  } catch (IllegalArgumentException exp) {
                     LOG.error(exp.getMessage());
                     LOG.debug("Details :", exp);
                  }
                  catch (IllegalAccessException exp) {}
                  catch (InvocationTargetException exp) {}
               }
               else {
                  LOG.error("Could not find setter for relationship");
               }
               break;
            case ONE_TO_MANY:
//               /*
//                * Get the type and create a mock object from it.
//                */
               relatedType = columnMetadata.getReturnTypeInfo()
                  .getGenericArgumentType();
               relatedClassMetadata =
                  getAnnotationManager().getClassMetadata(relatedType);
//               relatedMockObj = mock(relatedType, ignoreNulls,
//                     relationship);
              
               //add table
               getQuery().addTable(relatedClassMetadata.getPrimaryTable());
              
               //match identity columns
               addMatchedCriteriaSetter(
                     relatedClassMetadata.getColumns().get(columnMetadata.getMappedBy()),
                     classMetadata.getIdentityColumn(),
                     ignoreNulls);
              
//               //add child mock
//               if(columnMetadata.hasSetter()) {
View Full Code Here

   protected void setRelatedMocks(Object mockObj,
         IClassDbMetadata classMetadata) {
      for (Map.Entry<Method, ColumnRelationshipMetadata> relationColumn :
            classMetadata.getColumnsByRelationship().entrySet()) {
        
         ColumnRelationshipMetadata columnMetadata = relationColumn.getValue();
        
         //TODO add differently for the relationship
        
         /*
          * Get the type and create a mock object from it.
          */
         Class<?> relatedType = columnMetadata.getType();
         Object relatedMockObj = mock(relatedType,
               columnMetadata.getRelationship());
        
         if(columnMetadata.hasSetter()) {
            try {
               columnMetadata.getSetterMethod().invoke(mockObj, relatedMockObj);
            } catch (IllegalArgumentException exp) {}
            catch (IllegalAccessException exp) {}
            catch (InvocationTargetException exp) {}
         }
         else {
View Full Code Here

TOP

Related Classes of com.pv.mf.db.mock.metadata.ColumnRelationshipMetadata

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.