Search in sources :

Example 1 with DefaultEntityResolver

use of eu.esdihumboldt.hale.common.align.io.impl.DefaultEntityResolver in project hale by halestudio.

the class AppSchemaMappingUtils method resolvePropertyTypes.

/**
 * Goes through all chain configurations in the provided feature chaining
 * configuration and attempts to resolve all unresolved property entity
 * definitions.
 *
 * <p>
 * More specifically, resolution for a particular chain configuration is
 * attempted if {@link ChainConfiguration#getJaxbNestedTypeTarget()} returns
 * a value, while {@link ChainConfiguration#getNestedTypeTarget()} returns
 * <code>null</code>.
 * </p>
 *
 * <p>
 * Upon successful resolution,
 * {@link ChainConfiguration#setJaxbNestedTypeTarget(PropertyType)} is
 * invoked with a <code>null</code> argument, to avoid further entity
 * resolution attempts.
 * </p>
 *
 * <p>
 * A {@link DefaultEntityResolver} instance is used to resolve entities.
 * </p>
 *
 * @param featureChaining the global feature chaining configuration
 * @param types the schema to use for entity lookup
 * @param ssid the schema space identifier
 */
public static void resolvePropertyTypes(FeatureChaining featureChaining, TypeIndex types, SchemaSpaceID ssid) {
    if (featureChaining != null) {
        EntityResolver resolver = new DefaultEntityResolver();
        for (String joinCellId : featureChaining.getJoins().keySet()) {
            List<ChainConfiguration> chains = featureChaining.getChains(joinCellId);
            for (ChainConfiguration chain : chains) {
                if (chain.getNestedTypeTarget() == null && chain.getJaxbNestedTypeTarget() != null) {
                    Property resolved = resolver.resolveProperty(chain.getJaxbNestedTypeTarget(), types, ssid);
                    if (resolved != null) {
                        chain.setNestedTypeTarget(resolved.getDefinition());
                        chain.setJaxbNestedTypeTarget(null);
                    }
                }
            }
        }
    }
}
Also used : DefaultEntityResolver(eu.esdihumboldt.hale.common.align.io.impl.DefaultEntityResolver) ChainConfiguration(eu.esdihumboldt.hale.io.appschema.model.ChainConfiguration) EntityResolver(eu.esdihumboldt.hale.common.align.io.EntityResolver) DefaultEntityResolver(eu.esdihumboldt.hale.common.align.io.impl.DefaultEntityResolver) Property(eu.esdihumboldt.hale.common.align.model.Property)

Aggregations

EntityResolver (eu.esdihumboldt.hale.common.align.io.EntityResolver)1 DefaultEntityResolver (eu.esdihumboldt.hale.common.align.io.impl.DefaultEntityResolver)1 Property (eu.esdihumboldt.hale.common.align.model.Property)1 ChainConfiguration (eu.esdihumboldt.hale.io.appschema.model.ChainConfiguration)1