Search in sources :

Example 1 with DummyEntityResolver

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

the class JaxbToAlignment method convertEntities.

private static ListMultimap<String, Pair<Entity, Entity>> convertEntities(List<NamedEntityType> namedEntities, TypeIndex types, SchemaSpaceID schemaSpace, EntityResolver resolver) {
    if (namedEntities == null || namedEntities.isEmpty()) {
        return null;
    }
    ListMultimap<String, Pair<Entity, Entity>> result = ArrayListMultimap.create();
    for (NamedEntityType namedEntity : namedEntities) {
        /**
         * Resolve entity.
         *
         * Possible results:
         * <ul>
         * <li>non-null entity - entity could be resolved</li>
         * <li>null entity - entity could not be resolved, continue</li>
         * <li>IllegalStateException - entity could not be resolved, reject
         * cell</li>
         * </ul>
         */
        // Create a dummy entity from the original XML definition
        DummyEntityResolver dummyResolver = new DummyEntityResolver();
        Entity dummyEntity = dummyResolver.resolve(namedEntity.getAbstractEntity().getValue(), types, schemaSpace);
        // Resolve the real entity
        Entity resolvedEntity = resolver.resolve(namedEntity.getAbstractEntity().getValue(), types, schemaSpace);
        if (resolvedEntity != null) {
            result.put(namedEntity.getName(), new Pair<Entity, Entity>(dummyEntity, resolvedEntity));
        }
    }
    return result;
}
Also used : NamedEntityType(eu.esdihumboldt.hale.common.align.io.impl.internal.generated.NamedEntityType) Entity(eu.esdihumboldt.hale.common.align.model.Entity) DummyEntityResolver(eu.esdihumboldt.hale.common.align.io.impl.dummy.DummyEntityResolver) Pair(eu.esdihumboldt.util.Pair)

Aggregations

DummyEntityResolver (eu.esdihumboldt.hale.common.align.io.impl.dummy.DummyEntityResolver)1 NamedEntityType (eu.esdihumboldt.hale.common.align.io.impl.internal.generated.NamedEntityType)1 Entity (eu.esdihumboldt.hale.common.align.model.Entity)1 Pair (eu.esdihumboldt.util.Pair)1