void suiKnowBase::initialize() { registerAllKeynodes(); // createMinimalBase(); // first of all we need to find identification* and main_ nodes resolveMainIdentificationKeynodes(); // resolve other keynodes ScHelperInterface *helper = suiRoot::getInstance()->scHelper(); for (KeynodesMap::iterator it = mKeynodesMap.begin(); it != mKeynodesMap.end(); ++it) { ScUri uri = helper->findElementByMainIdentifier(it.key()); if (!uri.isEmpty()) helper->appendKeynode(uri, it.value()); } }
void suiKnowBase::resolveMainIdentificationKeynodes() { // get sc-links with identification* and main_ strings ScMemoryInterface *memory = suiRoot::getInstance()->scMemory(); ScHelperInterface *helper = suiRoot::getInstance()->scHelper(); QString idtf_alias = "identification*"; QString main_alias = "main_"; ScUriList idtf_candidates; if (!memory->find_str_content(idtf_alias, idtf_candidates)) SuiExcept(SuiExceptionItemNotFound, QString("Can't find sc-link with content: %1").arg(idtf_alias), "void suiKnowBase::resolveMainIdentificationKeynodes()"); ScUriList main_candidates; if (!memory->find_str_content(main_alias, main_candidates)) SuiExcept(SuiExceptionFileNotFound, QString("Can't find sc-link with content: %1").arg(main_alias), "void suiKnowBase::resolveMainIdentificationKeynodes()"); // all founded objects can be a candidates, so try them all for (ScUriList::iterator idtf_it = idtf_candidates.begin(); idtf_it != idtf_candidates.end(); ++idtf_it) for (ScUriList::iterator main_it = main_candidates.begin(); main_it != main_candidates.end(); ++main_it) { // iterate all possible identification sets for node identification* ScSafeIterator it_idtf_set(memory, ScTemplate() << ScElementType(ScNode | ScConst | ScTuple) << ScElementType(ScArcMain) << *idtf_it << ScElementType(ScArcMain) << ScElementType(ScNode | ScConst | ScRole)); while (!it_idtf_set.is_over()) { // now check if founded attribute (value with index 4) also // exist in any construction when we trying to find // identification set for main_ node ScSafeIterator it_main_set(memory, ScTemplate() << ScElementType(ScNode | ScConst) << ScElementType(ScArcMain) << *main_it << ScElementType(ScArcMain) << it_idtf_set.value(4)); while (!it_main_set.is_over()) { // trying to find idetification* node ScSafeIterator it1(memory, ScTemplate() << it_idtf_set.value(0) << ScElementType(ScArcCommon | ScConst) << ScElementType(ScNode | ScConst)); memory->_printEl(it_idtf_set.value(0)); while (!it1.is_over()) { // check if it have output arc into common arc from identifiers set // to identification* node if (helper->checkExist(ScTemplate() << it1.value(2) << ScElementType(ScArcMain) << it1.value(1))) { // now we just have founded candidate to identification* (it1.value(2)) node // to ensure we just need to check if it links to common arc // from identification set for main_ node if (helper->checkExist(ScTemplate() << it_main_set.value(0) << ScElementType(ScArcCommon | ScConst) << it_idtf_set.value(4) << ScElementType(ScArcMain) << it1.value(2))) { helper->appendKeynode(it_idtf_set.value(4), "/etc/main_"); helper->appendKeynode(it1.value(2), "/etc/identification*"); return; } } it1.next(); } it_main_set.next(); } it_idtf_set.next(); } } }