Search in sources :

Example 6 with About

use of eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About 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)

Example 7 with About

use of eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About in project hale by halestudio.

the class OmlRdfReader method getOMLRelation.

/**
 * Converts from the JAXB-Based RelationType to the OML Relation
 *
 * @param relation
 * @return
 */
private Relation getOMLRelation(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.RelationType relationType) {
    Relation relation = null;
    IAbout about = null;
    List<FeatureClass> features = null;
    if (relationType != null) {
        if (relationType.getAbout() != null) {
            about = new About(relationType.getAbout());
        }
        relation = new Relation(about);
        // set label list
        if (relation.getLabel() != null) {
            relation.setLabel(relationType.getLabel());
        }
        // set transformation
        if (relationType.getTransf() != null) {
            relation.setTransformation(getTransformation(relationType.getTransf()));
        }
        // set Range Restriction
        if (relationType.getRangeRestriction() != null) {
            features = new ArrayList<FeatureClass>();
            features.add(getRangeRestriction(relationType.getRangeRestriction()));
            relation.setRangeRestriction(features);
        }
        // set Domain Restriction
        if (relationType.getDomainRestriction() != null) {
            features = new ArrayList<FeatureClass>();
            features.add(getDomainRestriction(relationType.getDomainRestriction()));
            relation.setDomainRestriction(features);
        }
    }
    return relation;
}
Also used : Relation(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Relation) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) FeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Example 8 with About

use of eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About in project hale by halestudio.

the class OmlRdfReader method read.

/**
 * Unmarshalls oml-mapping to the HUMBOLDT Alignment.
 *
 * @param rdfFile path to the oml-mapping file
 * @return Alignment object
 */
public Alignment read(URL rdfFile) {
    // 1. unmarshal rdf
    JAXBContext jc;
    JAXBElement<AlignmentType> root = null;
    try {
        jc = JAXBContext.newInstance(ALIGNMENT_CONTEXT, ObjectFactory.class.getClassLoader());
        Unmarshaller u = jc.createUnmarshaller();
        // it will debug problems while unmarshalling
        u.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
        root = u.unmarshal(new StreamSource(rdfFile.openStream()), AlignmentType.class);
    /*
			 * root = u.unmarshal(new StreamSource(new File(rdfFile)),
			 * AlignmentType.class);
			 */
    } catch (Exception e) {
        throw new IllegalStateException("Failed to read alignment", e);
    }
    AlignmentType genAlignment = root.getValue();
    // 2. create humboldt alignment object and fulfill the required fields
    Alignment al = new Alignment();
    // set about
    al.setAbout(new About(UUID.randomUUID()));
    // set level
    if (genAlignment.getLevel() != null) {
        al.setLevel(genAlignment.getLevel());
    }
    // set map with cells
    if (genAlignment.getMap() != null) {
        al.setMap(getMap(genAlignment.getMap()));
    }
    // set schema1,2 containing information about ontologies1,2
    if (genAlignment.getOnto1() != null && genAlignment.getOnto1().getOntology() != null) {
        al.setSchema1(getSchema(genAlignment.getOnto1().getOntology()));
    }
    if (genAlignment.getOnto2() != null && genAlignment.getOnto2().getOntology() != null) {
        al.setSchema2(getSchema(genAlignment.getOnto2().getOntology()));
    }
    // set Value Class
    if (genAlignment.getValueClass() != null) {
        al.setValueClass(getValueClass(genAlignment.getValueClass()));
    }
    return al;
}
Also used : AlignmentType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.AlignmentType) Alignment(eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment) StreamSource(javax.xml.transform.stream.StreamSource) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Example 9 with About

use of eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About in project hale by halestudio.

the class OmlRdfReader method getEntity.

/**
 * Converts from the JAXB generated EntityType to the {@link IEntity}
 *
 * @param entity
 * @return
 */
private IEntity getEntity(JAXBElement<? extends EntityType> jaxbEntity) {
    EntityType entityType = jaxbEntity.getValue();
    // TODO allow to instantiate entity as Property, FeatureClass, Relation,
    // ComposedFeatureClass, ComposedFeatureType, composedRelation
    // instantiate entity es property
    Entity entity = null;
    IAbout about = null;
    // TODO add convertion to the RelationType if needed
    if (entityType instanceof PropertyType) {
        // make decision whether it is ComposedProperty
        if (((PropertyType) entityType).getPropertyComposition() != null) {
            PropertyCompositionType propCompType = ((PropertyType) entityType).getPropertyComposition();
            // instantiate entity as ComposedProperty
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new ComposedProperty(getOperator(propCompType.getOperator()), about);
            if (propCompType.getCollection() != null && propCompType.getCollection().getItem().size() > 0) {
                // set collection
                ((ComposedProperty) entity).setCollection(getPropertyCollection(propCompType.getCollection()));
            } else if (propCompType.getProperty() != null) {
                // set Property
                ((ComposedProperty) entity).getCollection().add(getProperty(propCompType.getProperty()));
            } else if (propCompType.getRelation() != null) {
                // set Relation
                ((ComposedProperty) entity).setRelation(getOMLRelation(propCompType.getRelation()));
            }
        // set ComposedProperty specific members
        } else {
            // instantiate entity as property
            if (entityType.getAbout() != null) {
                about = new About(entityType.getAbout());
            }
            entity = new Property(about);
        }
        // set property-specific members to the entity
        PropertyType propertyType = ((PropertyType) entityType);
        // set domainRestriction
        if (propertyType.getDomainRestriction() != null) {
            ((Property) entity).setDomainRestriction(getDomainRestriction(propertyType.getDomainRestriction()));
        }
        // set typeCondition
        if (propertyType.getTypeCondition() != null) {
            ((Property) entity).setTypeCondition(propertyType.getTypeCondition());
        }
        // set value conditions
        if (propertyType.getValueCondition() != null) {
            ((Property) entity).setValueCondition(getValueCondition(propertyType.getValueCondition()));
        }
    } else if (entityType instanceof ClassType) {
        // initiates entity as FeatureType
        ClassType cType = (ClassType) entityType;
        if (entityType.getAbout() != null) {
            about = new About(entityType.getAbout());
        }
        entity = new FeatureClass(about);
        // set attribute occurence conditions if exist
        if (cType.getAttributeOccurenceCondition() != null) {
            ((FeatureClass) entity).setAttributeOccurenceCondition(getRestrictions(cType.getAttributeOccurenceCondition()));
        }
        // set attribute type conditions if exist
        if (cType.getAttributeTypeCondition() != null) {
            ((FeatureClass) entity).setAttributeTypeCondition(getRestrictions(cType.getAttributeTypeCondition()));
        }
        // set attribute value conditions if exist
        if (cType.getAttributeValueCondition() != null) {
            ((FeatureClass) entity).setAttributeValueCondition(getRestrictions(cType.getAttributeValueCondition()));
        }
    } else {
        throw new IllegalArgumentException("Illegal entity type given");
    }
    if (entityType.getTransf() != null) {
        // set Transformation to Entity
        Transformation transformation = getTransformation(entityType.getTransf());
        entity.setTransformation(transformation);
    }
    // set About
    About eabout = new About(UUID.randomUUID());
    if (entityType.getAbout() != null) {
        eabout.setAbout(entityType.getAbout());
    }
    entity.setAbout(eabout);
    // set Labels
    if (entityType.getLabel() != null) {
        entity.setLabel(entityType.getLabel());
    }
    return entity;
}
Also used : EntityType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.EntityType) PropertyCompositionType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType) Entity(eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity) IEntity(eu.esdihumboldt.hale.io.oml.internal.model.align.IEntity) Transformation(eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) PropertyType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyType) ClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType) ValueClassType(eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType) ComposedProperty(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty) Property(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property) FeatureClass(eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Example 10 with About

use of eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About in project hale by halestudio.

the class OmlRdfReader method getSchema.

/**
 * converts from JAXB Ontology {@link OntologyType} to OML schema
 * {@link ISchema}
 *
 * @param onto Ontology
 * @return schema
 */
private ISchema getSchema(OntologyType onto) {
    // creates formalism
    // create Formalism
    Formalism formalism = null;
    if (onto.getFormalism() != null) {
        formalism = getFormalism(onto.getFormalism());
    }
    ISchema schema = new Schema(onto.getLocation(), formalism);
    // set about
    IAbout about = new About(UUID.randomUUID());
    if (onto.getAbout() != null) {
        ((About) about).setAbout(onto.getAbout());
    }
    ((Schema) schema).setAbout(about);
    // set labels
    if (onto.getLabel() != null) {
        ((Schema) schema).getLabels().addAll(onto.getLabel());
    }
    return schema;
}
Also used : ISchema(eu.esdihumboldt.hale.io.oml.internal.model.align.ISchema) Schema(eu.esdihumboldt.hale.io.oml.internal.goml.align.Schema) ISchema(eu.esdihumboldt.hale.io.oml.internal.model.align.ISchema) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout) Formalism(eu.esdihumboldt.hale.io.oml.internal.goml.align.Formalism) About(eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About) IAbout(eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)

Aggregations

About (eu.esdihumboldt.hale.io.oml.internal.goml.rdf.About)14 IAbout (eu.esdihumboldt.hale.io.oml.internal.model.rdf.IAbout)14 FeatureClass (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.FeatureClass)6 ArrayList (java.util.ArrayList)6 ClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ClassType)4 ValueClassType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.ValueClassType)4 Transformation (eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Transformation)3 ICell (eu.esdihumboldt.hale.io.oml.internal.model.align.ICell)3 Parameter (eu.esdihumboldt.hale.io.oml.internal.goml.oml.ext.Parameter)2 ComposedProperty (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.ComposedProperty)2 Property (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Property)2 Relation (eu.esdihumboldt.hale.io.oml.internal.goml.omwg.Relation)2 ISchema (eu.esdihumboldt.hale.io.oml.internal.model.align.ISchema)2 IParameter (eu.esdihumboldt.hale.io.oml.internal.model.align.ext.IParameter)2 PropertyCompositionType (eu.esdihumboldt.hale.io.oml.internal.model.generated.oml.PropertyCompositionType)2 Alignment (eu.esdihumboldt.hale.io.oml.internal.goml.align.Alignment)1 Cell (eu.esdihumboldt.hale.io.oml.internal.goml.align.Cell)1 Entity (eu.esdihumboldt.hale.io.oml.internal.goml.align.Entity)1 Formalism (eu.esdihumboldt.hale.io.oml.internal.goml.align.Formalism)1 Schema (eu.esdihumboldt.hale.io.oml.internal.goml.align.Schema)1