Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>5.1.1</version>
<version>5.5.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ private void setCorrectType(Collection<AbstractEntity> entities) {
}

private void postParsing(OWLOntology loadedOntology, VowlData vowlData, OWLOntologyManager manager) {
vowlData.fixProperties();
setCorrectType(vowlData.getEntityMap().values());
parseAnnotations(vowlData, manager);
fillDomainRanges(vowlData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void visit(VowlThing vowlThing) {
Map<String, Object> attributes = new HashMap<>();

addCommonFields(vowlThing, object, attributes);
attributes.remove("baseIri");
attributes.put("iri", VowlThing.GENERIC_THING_IRI.toString());

_class.add(object);
Expand Down Expand Up @@ -171,14 +172,17 @@ public void visit(VowlDatatype vowlDatatype) {
AbstractDatatype reference = vowlData.getDatatypeForIri(((DatatypeReference) vowlDatatype).getReferencedIri());
Map<String, Object> object = new HashMap<>();
Map<String, Object> attributes = new HashMap<>();
String iri = reference.getIri().toString();

object.put("id", vowlData.getIdForEntity(vowlDatatype));
object.put("type", reference.getType());

attributes.put("id", vowlData.getIdForEntity(vowlDatatype));
attributes.put("label", getLabelsFromAnnotations(reference.getAnnotations().getLabels()));
attributes.put("iri", reference.getIri().toString());
attributes.put("baseIri", reference.getBaseIri().toString());
attributes.put("iri", iri);

if(!iri.equals(VowlLiteral.LITERAL_IRI))
attributes.put("baseIri", reference.getBaseIri().toString());

_class.add(object);
classAttribute.add(attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
*
Expand Down Expand Up @@ -72,6 +73,8 @@ public void export(Exporter exporter) throws Exception {
}

protected void processHeader(VowlData vowlData) {
Set<String> ignoreOther = Stream.of("title", "versionInfo", "creator")
.collect(Collectors.toCollection(HashSet::new));
OntologyInformation ontologyInformation = vowlData.getOntologyInformation();
header.put("languages", vowlData.getLanguages());
header.put("baseIris", vowlData.getBaseIris().stream().map(IRI::toString).collect(Collectors.toSet()));
Expand All @@ -83,14 +86,17 @@ protected void processHeader(VowlData vowlData) {
header.put("description", JsonGeneratorVisitorImpl.getLabelsFromAnnotations(ontologyInformation.getAnnotations().getDescription()));
header.put("labels", JsonGeneratorVisitorImpl.getLabelsFromAnnotations(ontologyInformation.getAnnotations().getLabels()));
header.put("comments", JsonGeneratorVisitorImpl.getLabelsFromAnnotations(ontologyInformation.getAnnotations().getComments()));
header.put("other", ontologyInformation.getAnnotations().getIdentifierToAnnotation());
header.put("other", ontologyInformation.getAnnotations().getIdentifierToAnnotation().entrySet().stream()
.filter(x -> !ignoreOther.contains(x.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));

Map<String, String> map = vowlData.getPrefixMap();
// adding prefix list to that thing;
for (Map.Entry<String,String> entry : map.entrySet()) {
String pr=entry.getKey();
pr= pr.substring(0, pr.length() - 1);
prefixList.put(pr,entry.getValue());
String pr=entry.getKey();
pr= pr.substring(0, pr.length() - 1);
if(!pr.isEmpty())
prefixList.put(pr,entry.getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,37 @@ public IRI generate() {
return IRI.create(iriPrefix + generations++);
}
}

/**
* owlapi creates both ObjectProperty and DatatypeProperty from Properties
* with only type DatatypeProperty and InverseFunctionalProperty.
* The resulting file is different depending on the type that is
* created first (not deterministic).
* Check if an ObjectProperty has no range and if a DatatypeProperty with the same iri
* exists, reinsert it to force it into the EntityMap.
*/
public void fixProperties() {
Iterator<Entry<IRI, VowlObjectProperty>> it = objectPropertyMap.entrySet().iterator();
while (it.hasNext()) {
Entry<IRI, VowlObjectProperty> pair = it.next();
VowlObjectProperty P = pair.getValue();
Set<IRI> R = P.getRanges();
VowlDatatypeProperty D = null;
if(R.size() == 0) {
try {
D = getDatatypePropertyForIri(pair.getKey());
if(D != null) {
for(IRI domain : P.getDomains())
D.addDomain(domain);
addDatatypeProperty(D);
it.remove();
}
} catch (Exception e) {

}
}
}
}
}

class AllEntityMap<K, V extends AbstractEntity> extends HashMap<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.uni_stuttgart.vis.vowl.owl2vowl.model.AbstractVowlObject;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.annotation.Annotation;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.data.VowlData;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.entities.nodes.datatypes.VowlLiteral;
import de.uni_stuttgart.vis.vowl.owl2vowl.parser.helper.IriFormatText;
import org.semanticweb.owlapi.model.OWLOntologyManager;

Expand All @@ -30,9 +31,12 @@ public void parse(AbstractVowlObject vowlObject) {
protected void parseForEntity(AbstractVowlObject entity) {
entity.accept(new AnnotationVisitor(vowlData, manager));

String iriLabel = IriFormatText.cutQuote(IriFormatText.extractNameFromIRI(entity.getIri().toString()));
Annotation iriAnnotationLabel = new Annotation("label", iriLabel);
iriAnnotationLabel.setLanguage(Vowl_Lang.LANG_DEFAULT);
entity.getAnnotations().addLabel(iriAnnotationLabel);
String iri = entity.getIri().toString();
if(!iri.equals(VowlLiteral.LITERAL_IRI)) {
String iriLabel = IriFormatText.cutQuote(IriFormatText.extractNameFromIRI(iri));
Annotation iriAnnotationLabel = new Annotation("label", iriLabel);
iriAnnotationLabel.setLanguage(Vowl_Lang.LANG_DEFAULT);
entity.getAnnotations().addLabel(iriAnnotationLabel);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void visit(TypeOfProperty typeOfProperty) {

private void classBehaviour(AbstractProperty property) {
if (property.getDomains().isEmpty() && property.getRanges().isEmpty()) {
if (!property.getReferencedIris().isEmpty()) {
if (!property.getReferencedIris().isEmpty() && property.getInverse() == null) {
property.setExportToJson(false);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public void visit(OWLInverseObjectPropertiesAxiom axiom) {
OWLObjectProperty baseProperty = secondProperty.asOWLObjectProperty();

AbstractProperty inverseVowlProp = vowlData.getPropertyForIri(inverseProperty.getIRI());
AbstractProperty baseVowlProp = vowlData.getPropertyForIri(baseProperty.getIRI());
inverseVowlProp.addInverse(baseProperty.getIRI());
baseVowlProp.addInverse(inverseProperty.getIRI());
}

@Override
Expand Down