Skip to content

Commit

Permalink
URNs of modified concepts are OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferdinando Villa committed Dec 6, 2024
1 parent fa0b35c commit 02cca11
Showing 1 changed file with 6 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.integratedmodelling.klab.services.reasoner.internal;

import org.integratedmodelling.common.knowledge.ObservableImpl;
import org.integratedmodelling.common.lang.Axiom;
import org.integratedmodelling.common.lang.kim.KimConceptImpl;
import org.integratedmodelling.common.utils.Utils;
import org.integratedmodelling.klab.api.collections.Pair;
Expand All @@ -22,7 +23,6 @@
import org.integratedmodelling.klab.api.services.ResourcesService;
import org.integratedmodelling.klab.services.reasoner.ReasonerService;
import org.integratedmodelling.klab.services.reasoner.internal.CoreOntology.NS;
import org.integratedmodelling.common.lang.Axiom;
import org.integratedmodelling.klab.services.reasoner.owl.Ontology;
import org.integratedmodelling.klab.services.reasoner.owl.QualifiedName;

Expand Down Expand Up @@ -64,7 +64,7 @@ public class ObservableBuilder implements Observable.Builder {
private Unit unit;
private Currency currency;
private List<Annotation> annotations = new ArrayList<>();
private boolean isTrivial = true;
// private boolean isTrivial = true;
private KimConcept declaration;
private boolean axiomsAdded = false;
private String referenceName = null;
Expand Down Expand Up @@ -154,12 +154,6 @@ public ObservableBuilder(Observable observable, Scope scope, ReasonerService rea
this.traits.add(trait);
}

this.isTrivial =
/*this.context == null &&
* */this.adjacent == null && this.inherent == null && this.causant == null
&& this.caused == null && this.cooccurrent == null && this.goal == null && this.compresent == null
&& this.roles.isEmpty() && this.traits.isEmpty();

// these are only used if buildObservable() is called
this.unit = observable.getUnit();
this.currency = observable.getCurrency();
Expand Down Expand Up @@ -201,8 +195,6 @@ public ObservableBuilder(ObservableBuilder other) {
this.reasoner = other.reasoner;
this.defaultValue = other.defaultValue;
this.resolutionDirectives.addAll(other.resolutionDirectives);

checkTrivial();
}

// @Override
Expand All @@ -219,7 +211,6 @@ public Observable.Builder of(Concept concept) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setInherent(getDeclaration(concept));
}
isTrivial = false;
return this;
}

Expand All @@ -242,7 +233,6 @@ public Observable.Builder optional(boolean optional) {
@Override
public Observable.Builder withTemporalInherent(Concept concept) {
this.temporalInherent = concept;
isTrivial = false;
return this;
}

Expand All @@ -252,7 +242,6 @@ public Observable.Builder to(Concept concept) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setCaused(getDeclaration(concept));
}
isTrivial = false;
return this;
}

Expand All @@ -262,7 +251,6 @@ public Observable.Builder from(Concept concept) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setCausant(getDeclaration(concept));
}
isTrivial = false;
return this;
}

Expand All @@ -272,7 +260,6 @@ public Observable.Builder with(Concept concept) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setCompresent(getDeclaration(concept));
}
isTrivial = false;
return this;
}

Expand All @@ -286,7 +273,6 @@ public Observable.Builder withRole(Concept concept) {
this.declaration.getRoles().add(getDeclaration(concept));
}
this.roles.add(concept);
isTrivial = false;
return this;
}

Expand All @@ -296,7 +282,6 @@ public Observable.Builder withGoal(Concept goal) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setGoal(getDeclaration(goal));
}
isTrivial = false;
return this;
}

Expand All @@ -306,7 +291,6 @@ public Observable.Builder withCooccurrent(Concept cooccurrent) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setCooccurrent(getDeclaration(cooccurrent));
}
isTrivial = false;
return this;
}

Expand All @@ -316,15 +300,13 @@ public Observable.Builder withAdjacent(Concept adjacent) {
if (!declarationIsComplete) {
((KimConceptImpl) this.declaration).setAdjacent(getDeclaration(adjacent));
}
isTrivial = false;
return this;
}

@Override
public Observable.Builder linking(Concept source, Concept target) {
this.relationshipSource = source;
this.relationshipTarget = target;
isTrivial = false;
return this;
}

Expand Down Expand Up @@ -451,7 +433,6 @@ private void reset(Concept main, UnarySemanticOperator op) {
hasUnaryOp = true;
comparison = /*context =*/ inherent = /* classifier = downTo = */ caused = compresent = inherent =
null;
isTrivial = true;
}

@Override
Expand Down Expand Up @@ -575,9 +556,6 @@ public Observable.Builder without(Concept... concepts) {
}
ret.declaration = ((KimConceptImpl) ret.declaration).removeComponents(declarations, removedRoles);
}

ret.checkTrivial();

return ret;
}

Expand Down Expand Up @@ -653,8 +631,6 @@ public Observable.Builder withoutAny(SemanticType... concepts) {
ret.declaration = ((KimConceptImpl) ret.declaration).removeComponents(declarations, removedRoles);
}

ret.checkTrivial();

return ret;

}
Expand Down Expand Up @@ -731,17 +707,14 @@ public Observable.Builder withoutAny(Concept... concepts) {
ret.declaration = ((KimConceptImpl) ret.declaration).removeComponents(declarations, removedRoles);
}

ret.checkTrivial();

return ret;

}

void checkTrivial() {
this.isTrivial = causant == null && adjacent == null && caused == null && comparison == null
&& compresent == null /*&& context ==
null*/ && inherent == null && cooccurrent == null & goal == null
&& traits.isEmpty() && roles.isEmpty() && deferredTarget == null;
boolean isTrivial() {
return causant == null && adjacent == null && caused == null && comparison == null
&& compresent == null && inherent == null && cooccurrent == null & goal == null
&& traits.isEmpty() && roles.isEmpty() && deferredTarget == null && !hasUnaryOp;
}

@Override
Expand All @@ -757,7 +730,6 @@ public Observable.Builder withTrait(Concept... concepts) {
}
}
}
isTrivial = false;
return this;
}

Expand Down Expand Up @@ -1296,10 +1268,6 @@ public static String getCleanId(Concept main) {
return id;
}

private boolean isTrivial() {
return isTrivial;
}

public Concept getMainConcept() {
return main;
}
Expand Down

0 comments on commit 02cca11

Please sign in to comment.