use of eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl in project hale by halestudio.
the class CastorAlignmentReader method loadAlignment.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected MutableAlignment loadAlignment(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Load hale alignment", ProgressIndicator.UNKNOWN);
InputStream in = getSource().getInput();
MutableAlignment alignment = null;
try {
alignment = CastorAlignmentIO.load(in, reporter, getSourceSchema(), getTargetSchema(), getPathUpdater());
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
return alignment;
} finally {
in.close();
}
progress.end();
reporter.setSuccess(true);
return alignment;
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl in project hale by halestudio.
the class CastorAlignmentWriter method execute.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Save hale alignment", ProgressIndicator.UNKNOWN);
PathUpdate pathUpdate = new PathUpdate(getProjectLocation(), getTarget().getLocation());
OutputStream out = getTarget().getOutput();
try {
CastorAlignmentIO.save(getAlignment(), out, pathUpdate);
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
return reporter;
} finally {
out.close();
}
progress.end();
reporter.setSuccess(true);
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl in project hale by halestudio.
the class JaxbAlignmentWriter method execute.
/**
* @see AbstractIOProvider#execute(ProgressIndicator, IOReporter)
*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
progress.begin("Save hale alignment", ProgressIndicator.UNKNOWN);
PathUpdate pathUpdate = new PathUpdate(getProjectLocation(), getTarget().getLocation());
AlignmentType alignment;
try {
alignment = JaxbAlignmentIO.convert(getAlignment(), reporter, pathUpdate);
} catch (Exception e) {
reporter.error(new IOMessageImpl("Error converting alignment to XML model", e));
reporter.setSuccess(false);
return reporter;
}
OutputStream out = getTarget().getOutput();
try {
JaxbAlignmentIO.save(alignment, reporter, out);
} catch (Exception e) {
reporter.error(new IOMessageImpl(e.getMessage(), e));
reporter.setSuccess(false);
return reporter;
} finally {
out.close();
}
progress.end();
reporter.setSuccess(true);
return reporter;
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl 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
}
}
use of eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl in project hale by halestudio.
the class CellBean method createCell.
/**
* Create a cell based on the information in the cell bean if possible.
* Otherwise a corresponding error message should be added to the report.
*
* @param reporter the I/O reporter to report any errors to, may be
* <code>null</code>
* @param sourceTypes the source types to use for resolving definition
* references
* @param targetTypes the target types to use for resolving definition
* references
* @return the created cell or <code>null</code>
*/
public MutableCell createCell(IOReporter reporter, TypeIndex sourceTypes, TypeIndex targetTypes) {
MutableCell cell = new DefaultCell();
cell.setTransformationIdentifier(getTransformationIdentifier());
if (transformationParameters != null && !transformationParameters.isEmpty()) {
ListMultimap<String, ParameterValue> parameters = ArrayListMultimap.create();
for (ParameterValueBean param : transformationParameters) {
parameters.put(param.getName(), param.createParameterValue());
}
cell.setTransformationParameters(parameters);
}
cell.setId(id);
try {
cell.setSource(createEntities(source, sourceTypes, SchemaSpaceID.SOURCE));
cell.setTarget(createEntities(target, targetTypes, SchemaSpaceID.TARGET));
} catch (Throwable e) {
reporter.error(new IOMessageImpl("Could not create cell", e));
return null;
}
return cell;
}
Aggregations