public void initialize() throws ThinklabException { /* link and initialize knowledge repository */ knowledgeRepository.initialize(); /* see if the preferences override the thinklab core ontology URL */ String cont = LocalConfiguration.getProperties() .getProperty("thinklab.ontology.core", DEFAULT_CORE_ONTOLOGY); URL tco = Thinklab.get().getResourceURL(cont); knowledgeRepository.refreshOntology(tco, MiscUtilities.getNameFromURL(cont), true); /* initialize types before we register plugins */ initializeThinklabTypes(); /* initialize default blacklists */ String blk = LocalConfiguration.getProperties().getProperty(IGNORE_PROPERTY_PROPERTY); if (blk != null) { String[] bk = blk.trim().split(","); for (String s : bk) { KnowledgeManager.get().blacklistProperty(s); } } blk = LocalConfiguration.getProperties().getProperty(IGNORE_CONCEPT_PROPERTY); if (blk != null) { String[] bk = blk.trim().split(","); for (String s : bk) { KnowledgeManager.get().blacklistConcept(s); } } commandManager = new CommandManager(); Thinklab.get().logger().info("knowledge manager initialized successfully"); }
private void initializeThinklabTypes() throws ThinklabValidationException { Properties p = LocalConfiguration.getProperties(); // TODO all this stuff should be left to a specified plugin if installed, and done this way // only as a last resort. Also plugin properties should be used. /* store references to commonly used concepts. These come from system config, defaulted to core IMA ontology. */ try { integerTypeID = new SemanticType(p.getProperty("type.class.integer", "thinklab-core:Integer")); floatTypeID = new SemanticType(p.getProperty("type.class.float", "thinklab-core:FloatingPoint")); longTypeID = new SemanticType(p.getProperty("type.class.long", "thinklab-core:LongInteger")); doubleTypeID = new SemanticType(p.getProperty("type.class.double", "thinklab-core:LongFloatingPoint")); numberTypeID = new SemanticType(p.getProperty("type.class.number", "thinklab-core:Number")); booleanTypeID = new SemanticType(p.getProperty("type.class.boolean", "thinklab-core:Boolean")); literalTypeID = new SemanticType(p.getProperty("type.class.literal", "thinklab-core:LiteralValued")); textTypeID = new SemanticType(p.getProperty("type.class.text", "thinklab-core:Text")); operatorTypeID = new SemanticType(p.getProperty("type.class.operator", "thinklab-core:Operation")); rootTypeID = new SemanticType(p.getProperty("type.class.thing", "owl:Thing")); ordinalRankingTypeID = new SemanticType( p.getProperty("type.class.ordinal-ranking", "thinklab-core:OrdinalRanking")); booleanRankingTypeID = new SemanticType( p.getProperty("type.class.boolean-ranking", "thinklab-core:BooleanRanking")); ordinalRangeMappingTypeID = new SemanticType( p.getProperty( "type.class.ordered-range-mapping", "thinklab-core:OrderedRangeMapping")); reifiedLiteralPropertyID = new SemanticType( p.getProperty( "type.property.reified-literal", "thinklab-core:ExtendedLiteralProperty")); classificationPropertyID = new SemanticType( p.getProperty( "type.property.classification", "thinklab-core:ClassificationProperty")); additionalRestrictionsPropertyID = new SemanticType( p.getProperty("type.property.restrictions", "thinklab-core:AdditionalRestrictions")); abstractPropertyID = new SemanticType(p.getProperty("type.property.abstract", "thinklab-core:AbstractClass")); importedPropertyID = new SemanticType(p.getProperty("type.property.imported", "thinklab-core:importedFrom")); /* * define XSD mappings for simple types. * * TODO we should also have additional IValue types with validation for negative and * positive numbers, URL, ID etc, just like in XSD. */ xsdMappings.put(XSDVocabulary.STRING.toString(), textTypeID.toString()); xsdMappings.put(XSDVocabulary.FLOAT.toString(), floatTypeID.toString()); xsdMappings.put(XSDVocabulary.DOUBLE.toString(), doubleTypeID.toString()); xsdMappings.put(XSDVocabulary.LONG.toString(), longTypeID.toString()); xsdMappings.put(XSDVocabulary.INT.toString(), integerTypeID.toString()); xsdMappings.put(XSDVocabulary.INTEGER.toString(), integerTypeID.toString()); xsdMappings.put(XSDVocabulary.SHORT.toString(), integerTypeID.toString()); xsdMappings.put(XSDVocabulary.STRING.toString(), textTypeID.toString()); xsdMappings.put(XSDVocabulary.BOOLEAN.toString(), booleanTypeID.toString()); } catch (ThinklabRuntimeException e1) { throw new ThinklabValidationException("configuration error: " + e1.getMessage()); } /* retrieve actual concepts from semantic types */ try { integerType = requireConcept(integerTypeID); floatType = requireConcept(floatTypeID); textType = requireConcept(textTypeID); longType = requireConcept(longTypeID); doubleType = requireConcept(doubleTypeID); numberType = requireConcept(numberTypeID); booleanType = requireConcept(booleanTypeID); literalType = requireConcept(literalTypeID); booleanRankingType = requireConcept(booleanRankingTypeID); ordinalRankingType = requireConcept(ordinalRankingTypeID); ordinalRangeMappingType = requireConcept(ordinalRangeMappingTypeID); operatorType = requireConcept(operatorTypeID); classificationProperty = requireProperty(classificationPropertyID); reifiedLiteralProperty = requireProperty(reifiedLiteralPropertyID); additionalRestrictionsProperty = requireProperty(additionalRestrictionsPropertyID); abstractProperty = requireProperty(abstractPropertyID); importedProperty = requireProperty(importedPropertyID); } catch (ThinklabResourceNotFoundException e) { throw new ThinklabValidationException( "core type specifications are incomplete: " + e.getMessage()); } typesInitialized = true; }