Java Code Examples for org.hibernate.mapping.PersistentClass#hasDom4jRepresentation()

The following examples show how to use org.hibernate.mapping.PersistentClass#hasDom4jRepresentation() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Instantiates a EntityEntityModeToTuplizerMapping based on the given
 * entity mapping and metamodel definitions.
 *
 * @param mappedEntity The entity mapping definition.
 * @param em The entity metamodel definition.
 */
public EntityEntityModeToTuplizerMapping(PersistentClass mappedEntity, EntityMetamodel em) {
	// create our own copy of the user-supplied tuplizer impl map
	Map userSuppliedTuplizerImpls = new HashMap();
	if ( mappedEntity.getTuplizerMap() != null ) {
		userSuppliedTuplizerImpls.putAll( mappedEntity.getTuplizerMap() );
	}

	// Build the dynamic-map tuplizer...
	Tuplizer dynamicMapTuplizer = null;
	String tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.MAP );
	if ( tuplizerImpl == null ) {
		dynamicMapTuplizer = new DynamicMapEntityTuplizer( em, mappedEntity );
	}
	else {
		dynamicMapTuplizer = buildEntityTuplizer( tuplizerImpl, mappedEntity, em );
	}

	// then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available
	Tuplizer pojoTuplizer = null;
	tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.POJO );
	if ( mappedEntity.hasPojoRepresentation() ) {
		if ( tuplizerImpl == null ) {
			pojoTuplizer = new PojoEntityTuplizer( em, mappedEntity );
		}
		else {
			pojoTuplizer = buildEntityTuplizer( tuplizerImpl, mappedEntity, em );
		}
	}
	else {
		pojoTuplizer = dynamicMapTuplizer;
	}

	// then dom4j tuplizer, if dom4j representation is available
	Tuplizer dom4jTuplizer = null;
	tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.DOM4J );
	if ( mappedEntity.hasDom4jRepresentation() ) {
		if ( tuplizerImpl == null ) {
			dom4jTuplizer = new Dom4jEntityTuplizer( em, mappedEntity );
		}
		else {
			dom4jTuplizer = buildEntityTuplizer( tuplizerImpl, mappedEntity, em );
		}
	}
	else {
		dom4jTuplizer = null;
	}

	// put the "standard" tuplizers into the tuplizer map first
	if ( pojoTuplizer != null ) {
		addTuplizer( EntityMode.POJO, pojoTuplizer );
	}
	if ( dynamicMapTuplizer != null ) {
		addTuplizer( EntityMode.MAP, dynamicMapTuplizer );
	}
	if ( dom4jTuplizer != null ) {
		addTuplizer( EntityMode.DOM4J, dom4jTuplizer );
	}

	// then handle any user-defined entity modes...
	if ( !userSuppliedTuplizerImpls.isEmpty() ) {
		Iterator itr = userSuppliedTuplizerImpls.entrySet().iterator();
		while ( itr.hasNext() ) {
			Map.Entry entry = ( Map.Entry ) itr.next();
			EntityMode entityMode = ( EntityMode ) entry.getKey();
			EntityTuplizer tuplizer = buildEntityTuplizer( ( String ) entry.getValue(), mappedEntity, em );
			addTuplizer( entityMode, tuplizer );
		}
	}
}
 
Example 2
public ComponentEntityModeToTuplizerMapping(Component component) {
	PersistentClass owner = component.getOwner();

	// create our own copy of the user-supplied tuplizer impl map
	Map userSuppliedTuplizerImpls = new HashMap();
	if ( component.getTuplizerMap() != null ) {
		userSuppliedTuplizerImpls.putAll( component.getTuplizerMap() );
	}

	// Build the dynamic-map tuplizer...
	Tuplizer dynamicMapTuplizer = null;
	String tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.MAP );
	if ( tuplizerImpl == null ) {
		dynamicMapTuplizer = new DynamicMapComponentTuplizer( component );
	}
	else {
		dynamicMapTuplizer = buildComponentTuplizer( tuplizerImpl, component );
	}

	// then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available
	tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.POJO );
	Tuplizer pojoTuplizer = null;
	if ( owner.hasPojoRepresentation() && component.hasPojoRepresentation() ) {
		if ( tuplizerImpl == null ) {
			pojoTuplizer = new PojoComponentTuplizer( component );
		}
		else {
			pojoTuplizer = buildComponentTuplizer( tuplizerImpl, component );
		}
	}
	else {
		pojoTuplizer = dynamicMapTuplizer;
	}

	// then dom4j tuplizer, if dom4j representation is available
	Tuplizer dom4jTuplizer = null;
	tuplizerImpl = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.DOM4J );
	if ( owner.hasDom4jRepresentation() ) {
		if ( tuplizerImpl == null ) {
			dom4jTuplizer = new Dom4jComponentTuplizer( component );
		}
		else {
			dom4jTuplizer = buildComponentTuplizer( tuplizerImpl, component );
		}
	}
	else {
		dom4jTuplizer = null;
	}

	// put the "standard" tuplizers into the tuplizer map first
	if ( pojoTuplizer != null ) {
		addTuplizer( EntityMode.POJO, pojoTuplizer );
	}
	if ( dynamicMapTuplizer != null ) {
		addTuplizer( EntityMode.MAP, dynamicMapTuplizer );
	}
	if ( dom4jTuplizer != null ) {
		addTuplizer( EntityMode.DOM4J, dom4jTuplizer );
	}

	// then handle any user-defined entity modes...
	if ( !userSuppliedTuplizerImpls.isEmpty() ) {
		Iterator itr = userSuppliedTuplizerImpls.entrySet().iterator();
		while ( itr.hasNext() ) {
			Map.Entry entry = ( Map.Entry ) itr.next();
			EntityMode entityMode = ( EntityMode ) entry.getKey();
			ComponentTuplizer tuplizer = buildComponentTuplizer( ( String ) entry.getValue(), component );
			addTuplizer( entityMode, tuplizer );
		}
	}
}