Search in sources :

Example 1 with ICell

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;
}
Also used : ArrayList(java.util.ArrayList) Map(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.AlignmentType.Map) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)

Example 2 with ICell

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;
}
Also used : ArrayList(java.util.ArrayList) Cell(eu.esdihumboldt.hale.io.oml.internal.goml.align.Cell) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell) Map(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.AlignmentType.Map) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)

Example 3 with ICell

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();
    }
}
Also used : IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) ArrayList(java.util.ArrayList) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell) MutableAlignment(eu.esdihumboldt.hale.common.align.model.MutableAlignment) Alignment(eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment) CellBean(eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean) NamedEntityBean(eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean) AlignmentBean(eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentBean) PathUpdate(eu.esdihumboldt.hale.common.core.io.PathUpdate) OmlRdfReader(eu.esdihumboldt.hale.io.oml.internal.goml.oml.io.OmlRdfReader)

Example 4 with ICell

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;
}
Also used : IAlignment(eu.esdihumboldt.hale.io.oml.internal.model.align.IAlignment) ISchema(eu.esdihumboldt.hale.io.oml.internal.model.align.ISchema) ArrayList(java.util.ArrayList) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)

Example 5 with ICell

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;
}
Also used : ArrayList(java.util.ArrayList) ICell(eu.esdihumboldt.hale.io.oml.internal.model.align.ICell) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About)

Aggregations

ICell (eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)5 ArrayList (java.util.ArrayList)5 About (eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About)2 Map (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.AlignmentType.Map)2 IAbout (eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)2 AlignmentBean (eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentBean)1 CellBean (eu.esdihumboldt.hale.common.align.io.impl.internal.CellBean)1 NamedEntityBean (eu.esdihumboldt.hale.common.align.io.impl.internal.NamedEntityBean)1 MutableAlignment (eu.esdihumboldt.hale.common.align.model.MutableAlignment)1 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)1 Alignment (eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment)1 Cell (eu.esdihumboldt.hale.io.oml.internal.goml.align.Cell)1 OmlRdfReader (eu.esdihumboldt.hale.io.oml.internal.goml.oml.io.OmlRdfReader)1 IAlignment (eu.esdihumboldt.hale.io.oml.internal.model.align.IAlignment)1 IEntity (eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity)1 ISchema (eu.esdihumboldt.hale.io.oml.internal.model.align.ISchema)1