Examples of MetaAttribute


Examples of org.hibernate.mapping.MetaAttribute

  /**
   * Returns all meta items as one large string.
   *
   */
  public String getMetaAsString(MetaAttributable pc, String attribute) {
    MetaAttribute c = pc.getMetaAttribute( attribute );

    return MetaAttributeHelper.getMetaAsString( c );
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

      if ( onlyInheritable & !inheritable ) {
        continue;
      }
      String name = metaNode.attributeValue( "attribute" );

      MetaAttribute meta = (MetaAttribute) map.get( name );
      MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
      if ( meta == null  ) {
        meta = new MetaAttribute( name );
        map.put( name, meta );
      } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793     
        meta = new MetaAttribute( name );       
        map.put( name, meta );       
      }     
      meta.addValue( metaNode.getText() );
    }
    return map;
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

    s.close();
  }

  public void testMeta() throws Exception {
    PersistentClass clazz = getCfg().getClassMapping( Master.class.getName() );
    MetaAttribute meta = clazz.getMetaAttribute("foo");
    assertTrue( "foo".equals( meta.getValue() ) );
    meta = clazz.getProperty("name").getMetaAttribute("bar");
    assertTrue( meta.isMultiValued() );
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

    Map m = cm.getMetaAttributes();
    assertNotNull(m);
    assertNotNull(cm.getMetaAttribute("global"));
    assertNull(cm.getMetaAttribute("globalnoinherit"));
   
    MetaAttribute metaAttribute = cm.getMetaAttribute("implements");
    assertNotNull(metaAttribute);
    assertEquals("implements", metaAttribute.getName());
    assertTrue(metaAttribute.isMultiValued());
    assertEquals(3, metaAttribute.getValues().size());
    assertEquals("java.lang.Observer",metaAttribute.getValues().get(0));
    assertEquals("java.lang.Observer",metaAttribute.getValues().get(1));
    assertEquals("org.foo.BogusVisitor",metaAttribute.getValues().get(2));
       
    /*Property property = cm.getIdentifierProperty();
    property.getMetaAttribute(null);*/
   
    Iterator propertyIterator = cm.getPropertyIterator();
    while (propertyIterator.hasNext()) {
      Property element = (Property) propertyIterator.next();
      System.out.println(element);
      Map ma = element.getMetaAttributes();
      assertNotNull(ma);
      assertNotNull(element.getMetaAttribute("global"));
      MetaAttribute metaAttribute2 = element.getMetaAttribute("implements");
      assertNotNull(metaAttribute2);
      assertNull(element.getMetaAttribute("globalnoinherit"));
           
    }
   
    Property element = cm.getProperty("component");
    Map ma = element.getMetaAttributes();
    assertNotNull(ma);
    assertNotNull(element.getMetaAttribute("global"));
    assertNotNull(element.getMetaAttribute("componentonly"));
    assertNotNull(element.getMetaAttribute("allcomponent"));
    assertNull(element.getMetaAttribute("globalnoinherit"));             
   
    MetaAttribute compimplements = element.getMetaAttribute("implements");
    assertNotNull(compimplements);
    assertEquals(compimplements.getValue(), "AnotherInterface");
   
    Property xp = ((Component)element.getValue()).getProperty( "x" );
    MetaAttribute propximplements = xp.getMetaAttribute( "implements" );
    assertNotNull(propximplements);
    assertEquals(propximplements.getValue(), "AnotherInterface");
   
   
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

  }

  // HBX-718
  public void testNonMutatedInheritance() {
    PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
    MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
   
    assertNotNull(metaAttribute);
    /*assertEquals( metaAttribute.getValues().size(), 2 );   
    assertEquals( "top level", metaAttribute.getValues().get(0) );*/
    assertEquals( "wicked level", metaAttribute.getValue() );
   
    Property property = cm.getProperty( "component" );
    MetaAttribute propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 3 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
    assertEquals( "monetaryamount level", propertyAttribute.getValue() );
   
    org.hibernate.mapping.Component component = (Component)property.getValue();
    property = component.getProperty( "x" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount x level", propertyAttribute.getValue() );
   
    property = cm.getProperty( "sortedEmployee" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 3 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
    assertEquals( "sortedemployee level", propertyAttribute.getValue() );
   
    property = cm.getProperty( "anotherSet" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 2 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );*/
    assertEquals( "wicked level", propertyAttribute.getValue() );
       
    Bag bag = (Bag) property.getValue();
    component = (Component)bag.getElement();
   
    assertEquals(4,component.getMetaAttributes().size());
   
    metaAttribute = component.getMetaAttribute( "globalmutated" );
    /*assertEquals( metaAttribute.getValues().size(), 3 );
    assertEquals( "top level", metaAttribute.getValues().get(0) );
    assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/
    assertEquals( "monetaryamount anotherSet composite level", metaAttribute.getValue() );   
   
    property = component.getProperty( "emp" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount anotherSet composite property emp level", propertyAttribute.getValue() );
   
   
    property = component.getProperty( "empinone" );
    propertyAttribute = property.getMetaAttribute( "globalmutated" );
   
    assertNotNull(propertyAttribute);
    /*assertEquals( propertyAttribute.getValues().size(), 4 );
    assertEquals( "top level", propertyAttribute.getValues().get(0) );
    assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
    assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
    assertEquals( "monetaryamount anotherSet composite property empinone level", propertyAttribute.getValue() );
   
   
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

      if ( onlyInheritable & !inheritable ) {
        continue;
      }
      String name = metaNode.attributeValue( "attribute" );

      MetaAttribute meta = (MetaAttribute) map.get( name );
      MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
      if ( meta == null  ) {
        meta = new MetaAttribute( name );
        map.put( name, meta );
      } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793     
        meta = new MetaAttribute( name );       
        map.put( name, meta );       
      }     
      meta.addValue( metaNode.getText() );
    }
    return map;
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

    assertEquals( null, c2j.getPOJOClass(base).getExtends() );
    assertEquals( "Base", c2j.getPOJOClass(sub).getExtends() );

    Map m = new HashMap();
    MetaAttribute attribute = new MetaAttribute( "extends" );
    attribute.addValue( "x" );
    attribute.addValue( "y" );
    m.put( attribute.getName(), attribute );
    attribute = new MetaAttribute( "interface" );
    attribute.addValue( "true" );
    m.put( attribute.getName(), attribute );

    sub.setMetaAttributes( m );
    assertEquals( "Base,x,y", c2j.getPOJOClass(sub).getExtends() );

    m = new HashMap();
    attribute = new MetaAttribute( "implements" );
    attribute.addValue( "intf" );
    m.put( attribute.getName(), attribute );
    base.setMetaAttributes( m );
    assertEquals( "intf,java.io.Serializable", c2j.getPOJOClass(base).getImplements() );
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

   
    TableIdentifier tableIdentifier = new TableIdentifier(null, null, "TblTest");
    Map attributes = res.tableToMetaAttributes(tableIdentifier);
    assertNotNull(attributes);
    assertEquals(attributes.size(),1);
    MetaAttribute ma = (MetaAttribute) attributes.get("use-in-test");
    assertEquals(ma.getName(), "use-in-test");
    assertEquals(ma.getValue(), "true");
       
    tableIdentifier = new TableIdentifier(settings.getDefaultCatalogName(), "Werd", "Testy");
    attributes = res.tableToMetaAttributes( tableIdentifier );
    assertNotNull(attributes);
    ma = (MetaAttribute) attributes.get( "werd-meta" );
    assertEquals(ma.getName(), "werd-meta");
    assertEquals(ma.getValues().size(), 2);       
 
    tableIdentifier = new TableIdentifier(null, "Werd", "MetaTable");
    attributes = res.tableToMetaAttributes( tableIdentifier );
    assertNotNull(attributes);
    assertEquals(2, attributes.size());
    ma = (MetaAttribute) attributes.get("specific-werd");
    assertEquals(ma.getName(), "specific-werd");
    assertEquals(ma.getValue(), "a one");
   
    ma = (MetaAttribute) attributes.get( "werd-meta" );
    assertEquals(ma.getName(), "werd-meta");
    assertEquals(1, ma.getValues().size()); // as long as no inherit this should be one
    assertEquals("value three", ma.getValue());
 
    tableIdentifier = new TableIdentifier(null, null, "Nothing");
    assertEquals(null, res.tableToMetaAttributes(tableIdentifier));
   
    assertNull(res.columnToMetaAttributes(new TableIdentifier("Nothing"), "bogus"));
    assertNull(res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "bogusColumn" ));
    attributes = res.columnToMetaAttributes( new TableIdentifier(null, "Werd", "MetaTable"), "MetaColumn" );
    assertEquals(1, attributes.size());
    ma = (MetaAttribute) attributes.get("specific-column");
    assertEquals("specific-column",ma.getName());
    assertEquals("yes a column with meta",ma.getValue());
   
  }
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

      if ( onlyInheritable & !inheritable ) {
        continue;
      }
      String name = metaNode.attributeValue( "attribute" );

      MetaAttribute meta = (MetaAttribute) map.get( name );
      MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
      if ( meta == null  ) {
        meta = new MetaAttribute( name );
        map.put( name, meta );
      } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793
        meta = new MetaAttribute( name );
        map.put( name, meta );
      }
      meta.addValue( metaNode.getText() );
    }
    return map;
View Full Code Here

Examples of org.hibernate.mapping.MetaAttribute

      if ( onlyInheritable & !inheritable ) {
        continue;
      }
      String name = metaNode.attributeValue( "attribute" );

      MetaAttribute meta = (MetaAttribute) map.get( name );
      MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
      if ( meta == null  ) {
        meta = new MetaAttribute( name );
        map.put( name, meta );
      } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793     
        meta = new MetaAttribute( name );       
        map.put( name, meta );       
      }     
      meta.addValue( metaNode.getText() );
    }
    return map;
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.