Search in sources :

Example 1 with Entity

use of org.apache.tapestry5.integration.app1.data.Entity in project epsilon-runtime by BlackBeltTechnology.

the class EntityReferenceImpl method setTarget.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setTarget(Entity newTarget) {
    Entity oldTarget = target;
    target = newTarget;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, DataPackage.ENTITY_REFERENCE__TARGET, oldTarget, target));
}
Also used : Entity(hu.blackbelt.epsilon.runtime.model.test1.data.Entity) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 2 with Entity

use of org.apache.tapestry5.integration.app1.data.Entity in project tapestry-5 by apache.

the class HibernateSessionSourceImplTest method startup_without_packages.

@Test
public void startup_without_packages() {
    Collection<String> packageNames = CollectionFactory.newList("org.example.myapp.entities", "org.example.app0.entities");
    HibernateEntityPackageManager packageManager = newMock(HibernateEntityPackageManager.class);
    TestBase.expect(packageManager.getPackageNames()).andReturn(packageNames);
    ClasspathScannerImpl scanner = new ClasspathScannerImpl(new ClasspathURLConverterImpl());
    ClassNameLocatorImpl classNameLocator = new ClassNameLocatorImpl(scanner);
    List<HibernateConfigurer> filters = Arrays.asList(new DefaultHibernateConfigurer(true), new PackageNameHibernateConfigurer(packageManager, classNameLocator));
    replay();
    HibernateSessionSource source = new HibernateSessionSourceImpl(log, filters);
    Session session = source.create();
    Assert.assertNotNull(session);
    // make sure it found the entity in the package
    ClassMetadata meta = session.getSessionFactory().getClassMetadata(User.class);
    Assert.assertEquals(meta.getEntityName(), "org.example.app0.entities.User");
    verify();
}
Also used : ClassMetadata(org.hibernate.metadata.ClassMetadata) HibernateSessionSourceImpl(org.apache.tapestry5.hibernate.internal.HibernateSessionSourceImpl) PackageNameHibernateConfigurer(org.apache.tapestry5.hibernate.internal.PackageNameHibernateConfigurer) DefaultHibernateConfigurer(org.apache.tapestry5.hibernate.internal.DefaultHibernateConfigurer) HibernateSessionSource(org.apache.tapestry5.hibernate.HibernateSessionSource) ClasspathScannerImpl(org.apache.tapestry5.ioc.internal.services.ClasspathScannerImpl) DefaultHibernateConfigurer(org.apache.tapestry5.hibernate.internal.DefaultHibernateConfigurer) PackageNameHibernateConfigurer(org.apache.tapestry5.hibernate.internal.PackageNameHibernateConfigurer) HibernateConfigurer(org.apache.tapestry5.hibernate.HibernateConfigurer) ClasspathURLConverterImpl(org.apache.tapestry5.ioc.internal.services.ClasspathURLConverterImpl) ClassNameLocatorImpl(org.apache.tapestry5.ioc.internal.services.ClassNameLocatorImpl) HibernateEntityPackageManager(org.apache.tapestry5.hibernate.HibernateEntityPackageManager) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 3 with Entity

use of org.apache.tapestry5.integration.app1.data.Entity in project tapestry-5 by apache.

the class EntityPersistentFieldStrategyTest method transient_entity.

public void transient_entity() {
    SampleEntity entity = new SampleEntity();
    Session session = newMock(Session.class);
    EntityPersistentFieldStrategy strategy = new EntityPersistentFieldStrategy(session, null);
    expect(session.contains(entity)).andReturn(false);
    replay();
    Object persisted = strategy.convertApplicationValueToPersisted(entity);
    assert persisted instanceof SessionRestorable;
    Object restored = strategy.convertPersistedToApplicationValue(persisted);
    assertSame(entity, restored);
    verify();
}
Also used : EntityPersistentFieldStrategy(org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy) SessionRestorable(org.apache.tapestry5.hibernate.web.internal.SessionRestorable) Session(org.hibernate.Session)

Example 4 with Entity

use of org.apache.tapestry5.integration.app1.data.Entity in project tapestry-5 by apache.

the class EntityPersistentFieldStrategyTest method persistent_entity.

public void persistent_entity() {
    SampleEntity entity = new SampleEntity();
    SampleEntity restoredEntity = new SampleEntity();
    Session session = newMock(Session.class);
    EntityPersistentFieldStrategy strategy = new EntityPersistentFieldStrategy(session, null);
    expect(session.contains(entity)).andReturn(true);
    expect(session.getEntityName(entity)).andReturn("SampleEntity");
    expect(session.getIdentifier(entity)).andReturn(42);
    expect(session.get("SampleEntity", 42)).andReturn(restoredEntity);
    replay();
    Object persisted = strategy.convertApplicationValueToPersisted(entity);
    assert persisted instanceof SessionRestorable;
    Object restored = strategy.convertPersistedToApplicationValue(persisted);
    assertSame(restored, restoredEntity);
    verify();
}
Also used : EntityPersistentFieldStrategy(org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy) SessionRestorable(org.apache.tapestry5.hibernate.web.internal.SessionRestorable) Session(org.hibernate.Session)

Example 5 with Entity

use of org.apache.tapestry5.integration.app1.data.Entity in project tapestry-5 by apache.

the class DefaultOpenApiDescriptionGenerator method generateSchemas.

private void generateSchemas(JSONObject documentation) {
    if (!entities.isEmpty()) {
        JSONObject components = new JSONObject();
        JSONObject schemas = new JSONObject();
        for (Class<?> entity : entities) {
            typeDescriber.describeSchema(entity, schemas);
        }
        components.put("schemas", schemas);
        documentation.put("components", components);
    }
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject)

Aggregations

Session (org.hibernate.Session)7 Test (org.testng.annotations.Test)5 HibernateEntityValueEncoder (org.apache.tapestry5.hibernate.web.internal.HibernateEntityValueEncoder)4 EntityPersistentFieldStrategy (org.apache.tapestry5.hibernate.web.internal.EntityPersistentFieldStrategy)3 Entity (org.apache.tapestry5.integration.app1.data.Entity)3 JSONObject (org.apache.tapestry5.json.JSONObject)3 ValueEncoderFactory (org.apache.tapestry5.services.ValueEncoderFactory)3 Logger (org.slf4j.Logger)3 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 Metamodel (javax.persistence.metamodel.Metamodel)2 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)2 SessionRestorable (org.apache.tapestry5.hibernate.web.internal.SessionRestorable)2 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)2 Entity (hu.blackbelt.epsilon.runtime.model.test1.data.Entity)1 BeanInfo (java.beans.BeanInfo)1 IntrospectionException (java.beans.IntrospectionException)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EntityType (javax.persistence.metamodel.EntityType)1