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);
}
}
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;
}
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;
}
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;
}
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");
}
}
}
Aggregations