Search in sources :

Example 21 with Entity

use of eu.esdihumboldt.hale.common.align.model.Entity in project hale by halestudio.

the class AssignFromCollectorExplanation method customizeBinding.

@Override
protected void customizeBinding(Map<String, Object> binding, Cell cell, boolean html, ServiceProvider provider, Locale locale) {
    // Default values for all bindings
    binding.put("_constraintsEvaluated", false);
    binding.put("_hasValue", false);
    binding.put("_isReference", false);
    Entity entity = CellUtil.getFirstEntity(cell.getTarget());
    if (entity != null && entity.getDefinition().getDefinition() instanceof PropertyDefinition) {
        PropertyDefinition resultProperty = (PropertyDefinition) entity.getDefinition().getDefinition();
        TypeDefinition resultPropertyType = resultProperty.getPropertyType();
        boolean isReference = resultProperty.getConstraint(Reference.class).isReference();
        binding.put("_isReference", isReference);
        // determine this.
        if (isReference) {
            binding.put("_hasValue", true);
        } else {
            boolean hasValue = resultPropertyType.getConstraint(HasValueFlag.class).isEnabled();
            binding.put("_hasValue", hasValue);
        }
        binding.put("_constraintsEvaluated", true);
    }
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) Reference(eu.esdihumboldt.hale.common.schema.model.constraint.property.Reference) HasValueFlag(eu.esdihumboldt.hale.common.schema.model.constraint.type.HasValueFlag) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 22 with Entity

use of eu.esdihumboldt.hale.common.align.model.Entity in project hale by halestudio.

the class InlineExplanation method getExplanation.

@Override
protected String getExplanation(Cell cell, boolean html, ServiceProvider services, Locale locale) {
    Entity source = CellUtil.getFirstEntity(cell.getSource());
    TypeEntityDefinition sourceType = getPropertyType(source);
    Entity target = CellUtil.getFirstEntity(cell.getTarget());
    TypeEntityDefinition targetType = getPropertyType(target);
    if (sourceType != null && targetType != null) {
        String retypeName = (html) ? ("<i>Retype</i>") : ("Retype");
        String text = getMessage("main", locale);
        return MessageFormat.format(text, formatEntity(source, html, true, locale), formatEntity(target, html, true, locale), formatEntity(sourceType, html, true, locale), formatEntity(targetType, html, true, locale), retypeName);
    }
    return null;
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)

Example 23 with Entity

use of eu.esdihumboldt.hale.common.align.model.Entity in project hale by halestudio.

the class MergeMigrator method updateCell.

@Override
public MutableCell updateCell(Cell originalCell, AlignmentMigration migration, MigrationOptions options, SimpleLog log) {
    MutableCell result = super.updateCell(originalCell, migration, options, log);
    SimpleLog cellLog = SimpleLog.all(log, new CellLog(result, CELL_LOG_CATEGORY));
    if (options.updateSource() && originalCell.getSource() != null) {
        Entity sourceType = CellUtil.getFirstEntity(originalCell.getSource());
        if (sourceType != null) {
            TypeDefinition sourceDef = sourceType.getDefinition().getType();
            ListMultimap<String, ParameterValue> modParams = ArrayListMultimap.create(result.getTransformationParameters());
            for (String property : PROPERTY_PATH_PARAMETERS) {
                updateProperties(modParams, migration, sourceDef, property, cellLog);
            }
            result.setTransformationParameters(modParams);
        }
    }
    return result;
}
Also used : SimpleLog(eu.esdihumboldt.hale.common.core.report.SimpleLog) Entity(eu.esdihumboldt.hale.common.align.model.Entity) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) ParameterValue(eu.esdihumboldt.hale.common.align.model.ParameterValue) CellLog(eu.esdihumboldt.hale.common.align.model.annotations.messages.CellLog) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 24 with Entity

use of eu.esdihumboldt.hale.common.align.model.Entity in project hale by halestudio.

the class MergeUtil method getKeyPropertyDefinitions.

/**
 * Get the {@link PropertyEntityDefinition} paths for all key properties of
 * a merge.<br>
 * <br>
 * <b>Subproperties are not yet supported to be part of a merge key.
 * Therefore, the inner lists will contain only a single property for the
 * time being.</b>
 *
 * @param cell Mapping cell of the merge
 * @return <code>PropertyEntityDefinition</code> paths for all key
 *         properties of the merge
 */
public static List<PropertyEntityDefinition> getKeyPropertyDefinitions(Cell cell) {
    List<PropertyEntityDefinition> result = new ArrayList<>();
    List<List<QName>> mergeProperties = MergeUtil.getProperties(cell.getTransformationParameters(), MergeFunction.PARAMETER_PROPERTY);
    for (Entity sourceEntity : cell.getSource().values()) {
        PropertyEntityDefinition keyProperty = null;
        for (List<QName> mergePropertyPath : mergeProperties) {
            // TODO Only root property is considered for now
            // If the propertyPath can consist of more than one element,
            // make sure to construct the PropertyEntityDefinition
            // accordingly
            QName root = mergePropertyPath.get(0);
            for (PropertyEntityDefinition property : AlignmentUtil.getChildrenWithoutContexts(sourceEntity)) {
                if (property.getDefinition().getName().equals(root)) {
                    keyProperty = property;
                    break;
                }
            }
            if (keyProperty != null) {
                result.add(keyProperty);
            }
        }
    }
    return result;
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 25 with Entity

use of eu.esdihumboldt.hale.common.align.model.Entity in project hale by halestudio.

the class DefaultAlignment method internalAddToMaps.

/**
 * Add a cell to the internal indexes, based on the given associated
 * entities.
 *
 * @param entities the cell entities (usually either source or target)
 * @param cell the cell to add
 */
private void internalAddToMaps(ListMultimap<String, ? extends Entity> entities, Cell cell) {
    if (entities == null) {
        return;
    }
    for (Entity entity : entities.values()) {
        EntityDefinition entityDef = entity.getDefinition();
        cellsPerEntity.put(entityDef, cell);
        switch(entityDef.getSchemaSpace()) {
            case TARGET:
                cellsPerTargetType.put(entityDef.getType(), cell);
                break;
            case SOURCE:
                cellsPerSourceType.put(entityDef.getType(), cell);
                break;
            default:
                throw new IllegalStateException("Entity definition with illegal schema space encountered");
        }
    }
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition)

Aggregations

Entity (eu.esdihumboldt.hale.common.align.model.Entity)64 Cell (eu.esdihumboldt.hale.common.align.model.Cell)25 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)21 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)14 ArrayList (java.util.ArrayList)12 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)9 ParameterValue (eu.esdihumboldt.hale.common.align.model.ParameterValue)9 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)9 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)9 List (java.util.List)9 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)8 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)7 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)6 HashSet (java.util.HashSet)6 Locale (java.util.Locale)6 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)5 FunctionDefinition (eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition)4 CellUtil (eu.esdihumboldt.hale.common.align.model.CellUtil)4 CellLog (eu.esdihumboldt.hale.common.align.model.annotations.messages.CellLog)4 AbstractCellExplanation (eu.esdihumboldt.hale.common.align.model.impl.AbstractCellExplanation)4