@Override public boolean isCompatibleWith(IKnowledge type) { return NS.isClass(type); }
KIMClassificationObserver(IObservableSemantics observable) { if (!NS.isClass(observable)) { throw new KlabRuntimeException("cannot create a classification observer from non-class knowledge"); } this.observable = observable; classification = new Classification(observable.getType()); }
if (NS.isClass(observer)) {
private static IConcept getContextType(IKnowledge concept, boolean recurse) { if (!(concept instanceof IConcept)) { return null; } IConcept ret = null; if (recurse && (NS.isAttribute(concept) || NS.isRealm(concept) || NS.isClass(concept) || NS.isConfiguration(concept))) { IConcept described = getDescribedQuality((IConcept) concept); ret = described == null ? null : getContextType(described, false); } else if (recurse && (NS.isIdentity(concept) || NS.isProcess(concept))) { Collection<IConcept> described = getApplicableObservables(concept); ret = described.size() > 0 ? NS.getLeastGeneralCommonConcept(described) : null; } else { Collection<IConcept> cls = OWL .getRestrictedClasses((IConcept) concept, KLAB .p(NS.HAS_CONTEXT_PROPERTY)); ret = cls.isEmpty() ? null : cls.iterator().next(); } if (ret == null && NS.isObservable(concept)) { IConcept inherent = getInherentType(concept); if (inherent != null) { ret = getContextType(inherent, false); } } return ret; }
if (NS.isClass(trait)) { return trait;
/** * Make a default model from an observable. Only works for class/trait and for direct * observers. If direct, select an instantiator. * * @param context * @param oob * @return a new model */ public static IModel makeModel(KIMScope context, KIMObservableSemantics oob) { if (NS.isDirect(oob)) { return new KIMModel(context.getNamespace(), oob); } else if (NS.isClass(oob)) { KIMClassificationObserver co = new KIMClassificationObserver(oob); oob.setObserver(co); co.namespace = context.getNamespace(); return new KIMModel(co); } else { context.error("models can only be created without specifications for direct observables or classes/traits", oob .getFirstLineNumber()); } return null; }
/** * TODO use reasoner for better resolution of physical properties etc. * * @param observable * @return observation type */ public static IConcept getObservationTypeFor(IConcept observable) { if (observable.is(KLAB.c(CORE_PHYSICAL_PROPERTY))) { return KLAB.c(MEASUREMENT); } else if (observable.is(KLAB.c(CORE_PREFERENCE_VALUE))) { return KLAB.c(RANKING); } else if (isClass(observable) || isTrait(observable)) { return KLAB.c(CLASSIFICATION); } else if (isObject(observable)) { return KLAB.c(DIRECT_OBSERVATION); } return KLAB.c(INDIRECT_OBSERVATION); }
if (NS.isClass(original)) { if (original.isAbstract() || NS.isBaseDeclaration(original)) { return original;
if (NS.isClass(model)) {
boolean isQualitySpace = isClass(c);
if (NS.isClass(k)) { Collection<IConcept> exposed = Traits.getExposedTraits(k); if (exposed.isEmpty()) {
&& !(NS.isTrait(coreConcept) || NS.isClass(coreConcept))) { context.error("only traits and classes can use the 'describes' clause, to define qualities they summarize or their context of application", lineNumber(statement));
.getType(), lineNumber(statement.getConcept()), NS.isQuality(obs)); } else if (!(NS.isClass(obs) || NS.isTrait(obs)) && !NS.isDirect(obs)) {