use of eu.esdihumboldt.hale.common.align.model.Alignment in project hale by halestudio.
the class TestUtil method loadAlignment.
/**
* Loads the specified alignment. Assumes that its base alignments don't
* need a location update.
*
* @param location the URI specifying the location of the alignment
* @param sourceTypes the source type index
* @param targetTypes the target type index
* @return the loaded alignment
* @throws Exception if the alignment or other resources could not be loaded
*/
public static Alignment loadAlignment(final URI location, Schema sourceTypes, Schema targetTypes) throws Exception {
DefaultInputSupplier input = new DefaultInputSupplier(location);
IOReporter report = new DefaultIOReporter(new Locatable() {
@Override
public URI getLocation() {
return location;
}
}, "Load alignment", AlignmentIO.ACTION_LOAD_ALIGNMENT, true);
Alignment alignment;
try {
alignment = CastorAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null));
} catch (Exception e) {
alignment = JaxbAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null), null, null);
}
assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
return alignment;
}
use of eu.esdihumboldt.hale.common.align.model.Alignment in project hale by halestudio.
the class AbstractDefaultFunctionService method getPropertyFunctions.
@Override
public Collection<? extends PropertyFunctionDefinition> getPropertyFunctions() {
Collection<? extends PropertyFunctionDefinition> functions = super.getPropertyFunctions();
Alignment al = getCurrentAlignment();
if (al != null) {
List<PropertyFunctionDefinition> cfs = new ArrayList<>();
for (CustomPropertyFunction cf : al.getAllCustomPropertyFunctions().values()) {
cfs.add(new AlignmentFunctionDescriptor(cf.getDescriptor()));
}
cfs.addAll(functions);
functions = cfs;
}
return functions;
}
use of eu.esdihumboldt.hale.common.align.model.Alignment in project hale by halestudio.
the class AbstractDefaultFunctionService method getPropertyFunctions.
@Override
public Collection<? extends PropertyFunctionDefinition> getPropertyFunctions(String categoryId) {
Collection<? extends PropertyFunctionDefinition> functions = super.getPropertyFunctions(categoryId);
Alignment al = getCurrentAlignment();
if (al != null) {
List<PropertyFunctionDefinition> cfs = new ArrayList<>();
for (CustomPropertyFunction cf : al.getAllCustomPropertyFunctions().values()) {
PropertyFunctionDefinition descriptor = cf.getDescriptor();
if (Objects.equal(categoryId, descriptor.getCategoryId())) {
cfs.add(new AlignmentFunctionDescriptor(descriptor));
}
}
cfs.addAll(functions);
functions = cfs;
}
return functions;
}
use of eu.esdihumboldt.hale.common.align.model.Alignment in project hale by halestudio.
the class AlignmentView method updateRelation.
/**
* Update the selected type relation to a cell that is related to the given
* schema selection.
*
* @param selection the schema selection
*/
private void updateRelation(SchemaSelection selection) {
Cell typeCell = sourceTargetSelector.getSelectedCell();
if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) && associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
// type cell is associated with source and target, don't change
return;
}
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
Alignment alignment = as.getAlignment();
// find type cell associated with both source and target
for (Cell cell : alignment.getTypeCells()) {
if ((associatedWithType(cell.getSource(), selection.getSourceItems())) && associatedWithType(cell.getTarget(), selection.getTargetItems())) {
// typeRelations.setSelection(new StructuredSelection(cell));
sourceTargetSelector.setSelection(new StructuredSelection(cell));
return;
}
}
if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) || associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
// type cell is associated with source or target, don't change
return;
}
// find type cell associated with source or target
for (Cell cell : alignment.getTypeCells()) {
if ((associatedWithType(cell.getSource(), selection.getSourceItems())) || associatedWithType(cell.getTarget(), selection.getTargetItems())) {
sourceTargetSelector.setSelection(new StructuredSelection(cell));
// typeRelations.setSelection(new StructuredSelection(cell));
return;
}
}
}
use of eu.esdihumboldt.hale.common.align.model.Alignment in project hale by halestudio.
the class FeatureChainingConfigurationPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
if (firstShow) {
for (ChainPage page : pages) page.dispose();
pages.clear();
AlignmentService alignmentService = HaleUI.getServiceProvider().getService(AlignmentService.class);
Alignment alignment = alignmentService.getAlignment();
int pageIdx = 0;
Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
for (Cell typeCell : typeCells) {
if (AppSchemaMappingUtils.isJoin(typeCell)) {
JoinParameter joinParameter = getJoinParameter(typeCell);
List<JoinCondition> conditions = getSortedJoinConditions(joinParameter);
TypeEntityDefinition joinTarget = getTargetType(typeCell).getDefinition();
for (int i = 0; i < joinParameter.getTypes().size() - 1; i++) {
ChainPage chainPage = new ChainPage(pageIdx, typeCell.getId(), i, joinParameter.getTypes(), conditions, joinTarget);
chainPage.setWizard(getWizard());
pages.add(chainPage);
pageIdx++;
}
}
}
}
setPageComplete(true);
if (!goingBack) {
getContainer().showPage(getNextPage());
} else {
getContainer().showPage(getPreviousPage());
}
}
Aggregations