use of eu.esdihumboldt.hale.io.oml.internal.model.align.ICell in project hale by halestudio.
the class OmlRdfGenerator method getMaps.
/**
* Converts from List of ICell to the List of Map
*
* @param map
* @return
*/
private Collection<? extends Map> getMaps(List<ICell> map) {
ArrayList<Map> maps = new ArrayList<Map>(map.size());
Iterator<?> iterator = map.iterator();
Map jMap;
ICell cell;
while (iterator.hasNext()) {
cell = (ICell) iterator.next();
if (cell != null) {
jMap = new Map();
jMap.setCell(getCellType(cell));
maps.add(jMap);
}
}
return maps;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ICell in project hale by halestudio.
the class OmlRdfReader method getMap.
/**
* @param map List of the generated maps, containing cell{@link CellType}
* and String about
* @return List of Cells {@link Cell}
*/
private List<ICell> getMap(List<Map> maps) {
List<ICell> cells = new ArrayList<ICell>(maps.size());
Cell cell;
Map map;
Iterator<Map> iterator = maps.iterator();
while (iterator.hasNext()) {
map = iterator.next();
if (map.getCell() != null) {
cell = getCell(map.getCell());
cells.add(cell);
}
}
return cells;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ICell 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();
}
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ICell in project hale by halestudio.
the class Alignment method deepCopy.
/**
* Create a deep copy of the alignment.
*
* @return a copy of the alignment
*/
public Alignment deepCopy() {
Alignment result = new Alignment();
result.setAbout(new About(this.getAbout().getAbout()));
result.setLevel(this.getLevel());
Schema schema1 = new Schema(this.level, (Formalism) this.getSchema1().getFormalism());
schema1.setAbout(new About(this.getSchema1().getAbout().getAbout()));
result.setSchema1(schema1);
Schema schema2 = new Schema(this.level, (Formalism) this.getSchema2().getFormalism());
schema2.setAbout(new About(this.getSchema2().getAbout().getAbout()));
result.setSchema2(schema2);
List<ICell> cells = new ArrayList<ICell>();
for (ICell cell : this.getMap()) {
cells.add(((Cell) cell).deepCopy());
}
result.setMap(cells);
return result;
}
use of eu.esdihumboldt.hale.io.oml.internal.model.align.ICell in project hale by halestudio.
the class Cell method deepCopy.
public ICell deepCopy() {
Cell result = new Cell();
result.setAbout(new About(this.getAbout().getAbout()));
result.setEntity1(((Entity) this.getEntity1()).deepCopy());
result.setEntity2(((Entity) this.getEntity2()).deepCopy());
List<String> newLabels = new ArrayList<String>();
for (String label : this.getLabel()) {
newLabels.add(label);
}
result.setLabel(newLabels);
result.setMeasure(this.getMeasure());
// not yet deep
result.setRelation(this.getRelation());
return result;
}
Aggregations