use of eu.esdihumboldt.hale.common.core.io.PathUpdate 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.core.io.PathUpdate in project hale by halestudio.
the class PathUpdateTest method testProjectSubfolder.
/**
* Extended real world example - project file in a subfolder and renamed
*/
@Test
public void testProjectSubfolder() {
String orgPath = "C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/unification/project/t1t2.hale";
String path = "C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/propmerge/project/t1t2_alt.hale";
PathUpdate update = new PathUpdate(URI.create("file:/" + orgPath), URI.create("file:/" + path));
URI file = URI.create("file:/C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/unification/t1.xsd");
String correct = "file:/C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/propmerge/t1.xsd";
String newpath = update.changePath(file).toString();
assertEquals(correct, newpath);
}
use of eu.esdihumboldt.hale.common.core.io.PathUpdate in project hale by halestudio.
the class PathUpdateTest method testSubfolder3.
/**
* Extended real world example - file in a subsubfolder
*/
@Test
public void testSubfolder3() {
String orgPath = "C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/unification/t1t2.hale";
String path = "C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/propmerge/t1t2.hale";
PathUpdate update = new PathUpdate(URI.create("file:/" + orgPath), URI.create("file:/" + path));
URI file = URI.create("file:/C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/unification/source/schemas/t1.xsd");
String correct = "file:/C:/Users/sitemple/Entwicklung/hale/cst/plugins/eu.esdihumboldt.cst.test/src/testdata/propmerge/source/schemas/t1.xsd";
String newpath = update.changePath(file).toString();
assertEquals(correct, newpath);
}
use of eu.esdihumboldt.hale.common.core.io.PathUpdate in project hale by halestudio.
the class PathUpdateTest method testSubfolder.
/**
* Extended real world example - file in a subfolder
*/
@Test
public void testSubfolder() {
PathUpdate update = new PathUpdate(URI.create("file:/C:/Users/sitemple/Entwicklung/humboldt2/_testdata/watercourse%20-%20Kopie/test.hale"), URI.create("file:/C:/Users/sitemple/Entwicklung/humboldt2/_testdata/wva2/test.hale"));
URI file = URI.create("file:/C:/Users/sitemple/Entwicklung/humboldt2/_testdata/watercourse%20-%20Kopie/inspire3/HydroPhysicalWaters.xsd");
String correct = "file:/C:/Users/sitemple/Entwicklung/humboldt2/_testdata/wva2/inspire3/HydroPhysicalWaters.xsd";
String newpath = update.changePath(file).toString();
assertEquals(correct, newpath);
}
use of eu.esdihumboldt.hale.common.core.io.PathUpdate in project hale by halestudio.
the class OmlReader method loadAlignment.
@Override
protected MutableAlignment loadAlignment(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException {
try {
progress.begin("Load ontology mapping file", ProgressIndicator.UNKNOWN);
OmlRdfReader reader = new OmlRdfReader();
Alignment alignment = reader.read(getSource().getLocation().toURL());
AlignmentBean align = new AlignmentBean();
List<CellBean> cells = new ArrayList<CellBean>();
List<ICell> map = alignment.getMap();
for (ICell cell : map) {
// create a new CellBean for each ICell
CellBean cellBean = new CellBean();
IEntity entity = cell.getEntity1();
IEntity entity2 = cell.getEntity2();
// temporary list to be copied into the CellBean
List<NamedEntityBean> temp_source = new ArrayList<NamedEntityBean>();
List<NamedEntityBean> temp_target = new ArrayList<NamedEntityBean>();
setBeanLists(entity, temp_source, getSourceSchema());
setBeanLists(entity2, temp_target, getTargetSchema());
// set source/target lists of the CellBean
cellBean.setSource(temp_source);
cellBean.setTarget(temp_target);
// check if one of the entities has a transformation
if (entity.getTransformation() != null || entity2.getTransformation() != null) {
// entity 1 if it has the transformation
if (entity.getTransformation() != null) {
setParameters(cellBean, entity, reporter, cell);
setTransformationId(cellBean, entity);
} else {
// else set parameters and transformation id from entity
// 2
setParameters(cellBean, entity2, reporter, cell);
setTransformationId(cellBean, entity2);
}
}
// add the CellBean to a list of CellBeans
cells.add(cellBean);
}
// set the cells for the alignment after the all iterations
align.setCells(cells);
MutableAlignment mutableAlignment = align.createAlignment(reporter, getSourceSchema(), getTargetSchema(), new PathUpdate(null, null));
reporter.setSuccess(true);
return mutableAlignment;
} finally {
progress.end();
}
}
Aggregations