Search in sources :

Example 6 with BaseAlignmentCell

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

the class AbstractBaseAlignmentLoader method applyModifiers.

/**
 * Apply modifiers on the alignment.
 *
 * @param alignment the alignment to work on
 * @param modifiers the modifiers to apply
 * @param prefixMapping the mapping of prefixes (see
 *            {@link #getCell(Alignment, String, String, Map, IOReporter)})
 * @param defaultPrefix the default prefix (may be <code>null</code>) (see
 *            {@link #getCell(Alignment, String, String, Map, IOReporter)})
 * @param base whether the added modifiers are from a base alignment or the
 *            main alignment
 * @param reporter the I/O reporter to report any errors to, may be
 *            <code>null</code>
 */
private void applyModifiers(Alignment alignment, Collection<M> modifiers, Map<String, String> prefixMapping, String defaultPrefix, boolean base, IOReporter reporter) {
    for (M modifier : modifiers) {
        Cell cell = getCell(alignment, getModifiedCell(modifier), defaultPrefix, prefixMapping, reporter);
        if (cell == null)
            continue;
        // disabledFor
        for (String disabledForId : getDisabledForList(modifier)) {
            Cell other = getCell(alignment, disabledForId, defaultPrefix, prefixMapping, reporter);
            if (other == null)
                continue;
            else if (!AlignmentUtil.isTypeCell(other)) {
                reporter.warn(new IOMessageImpl("A cell referenced in disable-for is not a type cell.", null));
                continue;
            } else if (!alignment.getPropertyCells(other, true, false).contains(cell)) {
                reporter.warn(new IOMessageImpl("A cell referenced in disable-for does not contain the cell that gets modified.", null));
                continue;
            }
            // so it has to be a BaseAlignmentCell
            if (base)
                ((BaseAlignmentCell) cell).setBaseDisabledFor(other, true);
            else
                ((ModifiableCell) cell).setDisabledFor(other, true);
        }
        // transformation mode
        TransformationMode mode = getTransformationMode(modifier);
        if (mode != null) {
            if (base)
                ((BaseAlignmentCell) cell).setBaseTransformationMode(mode);
            else
                ((ModifiableCell) cell).setTransformationMode(mode);
        }
    // XXX handle additional properties
    }
}
Also used : TransformationMode(eu.esdihumboldt.hale.common.align.model.TransformationMode) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) Cell(eu.esdihumboldt.hale.common.align.model.Cell) ModifiableCell(eu.esdihumboldt.hale.common.align.model.ModifiableCell) MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) BaseAlignmentCell(eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell) UnmigratedCell(eu.esdihumboldt.hale.common.align.migrate.impl.UnmigratedCell)

Aggregations

BaseAlignmentCell (eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell)6 Cell (eu.esdihumboldt.hale.common.align.model.Cell)5 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)5 ModifiableCell (eu.esdihumboldt.hale.common.align.model.ModifiableCell)4 ArrayList (java.util.ArrayList)4 DefaultCell (eu.esdihumboldt.hale.common.align.model.impl.DefaultCell)3 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)2 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)2 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)2 Property (eu.esdihumboldt.hale.common.align.model.Property)2 Type (eu.esdihumboldt.hale.common.align.model.Type)2 DefaultAlignment (eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment)2 DefaultProperty (eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)2 DefaultType (eu.esdihumboldt.hale.common.align.model.impl.DefaultType)2 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)2 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)2 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)2 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)2 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2