Beispiel #1
0
Component xapianDocToComponent(Xapian::Document document) {
    Component component;

    // kind
    QString kindString = value (document, XapianValues::TYPE);
    component.setKind(Component::stringToKind(kindString));

    // Identifier
    QString id = value(document, XapianValues::IDENTIFIER);
    component.setId(id);

    // Component name
    QString name = value(document,XapianValues::CPTNAME);
    component.setName(name);

    // Package name
    QStringList packageNames = value(document,XapianValues::PKGNAME).split("\n",QString::SkipEmptyParts);
    component.setPackageNames(packageNames);

    // URLs
    QString concatUrlStrings = value(document, XapianValues::URLS);
    QStringList urlStrings = concatUrlStrings.split('\n',QString::SkipEmptyParts);
    if(urlStrings.size() %2 == 0) {
        QMultiHash<Component::UrlKind, QUrl> urls;
        for(int i = 0; i < urlStrings.size(); i=i+2) {
            Component::UrlKind ukind = Component::stringToUrlKind(urlStrings.at(i));
            QUrl url = QUrl::fromUserInput(urlStrings.at(i+1));
            urls.insertMulti(ukind, url);
        }
        component.setUrls(urls);
    } else {
        qWarning("Bad url strings for component: '%s' (%s)", qPrintable(id), qPrintable(concatUrlStrings));
    }

    // Provided items
    QString concatProvides = value(document, XapianValues::PROVIDED_ITEMS);
    QStringList providesList = concatProvides.split('\n',QString::SkipEmptyParts);
    QList<Provides> provideslist;
    Q_FOREACH(const QString& string, providesList) {
        QStringList providesParts = string.split(';',QString::SkipEmptyParts);
        if(providesParts.size() < 2) {
            qWarning("Bad component parts for component: '%s' (%s)", qPrintable(id), qPrintable(string));
            continue;
        }
        QString kindString = providesParts.takeFirst();
        Provides::Kind kind = Provides::stringToKind(kindString);
        Provides provides;
        provides.setKind(kind);
        QString value = providesParts.takeFirst();
        provides.setValue(value);
        QString extraData = providesParts.join(";");
        provides.setExtraData(extraData);
        provideslist << provides;
    }
Beispiel #2
0
QString CodeAtlas::FuzzyDependBuilder::collectFuzzyDepend( SymbolNode::Ptr& node )
{
	// ignore dependency under a function
	SymbolInfo nodeInfo = node->getSymInfo();
	if (nodeInfo.elementType() & SymbolInfo::Variable)
		return nodeInfo.type() + " " + nodeInfo.name();

	QString    nodeCode;
	CodeAttr::Ptr pCode = node->getAttr<CodeAttr>();
	if (pCode)
		nodeCode = pCode->getCode();
	if (nodeInfo.elementType() & SymbolInfo::Function)
		return nodeCode;

	QMultiHash<QString, ChildPack>      childList;
	int ithChild = 0;
	
	bool* isNonVar = new bool[node->childCount()];
	for (SymbolNode::ChildIterator pChild = node->childBegin();
		pChild != node->childEnd(); ++pChild, ++ithChild)
	{
		ChildPack p;
		p.m_info = pChild.key();
		p.m_code = collectFuzzyDepend(pChild.value());
		p.m_pNode = pChild.value();
		p.m_index = ithChild;
		childList.insertMulti(p.m_info.name(), p);

		isNonVar[ithChild] = (p.m_info.elementType() & SymbolInfo::Variable) == 0;
		nodeCode += "\n" + p.m_code;
	}

	FuzzyDependAttr::Ptr pAttr = node->getOrAddAttr<FuzzyDependAttr>();
	buildChildDepend(childList, pAttr->vtxEdgeMatrix(), pAttr->edgeWeightVector(), pAttr->dependPairList());

	buildSubGraphLevel(pAttr->vtxEdgeMatrix(), isNonVar, ithChild, pAttr->levelVector());
	delete[] isNonVar;
	return nodeCode;
}
DrugBaseEssentials::DrugBaseEssentials():
    Utils::Database(),
    m_dbcore_initialized(false),
    m_isDefaultDb(false)
{
    setConnectionName(Constants::DB_DRUGS_NAME);
    using namespace Constants;
    QMultiHash<int, ftype> types;
    int i = Table_MASTER;
    types.insertMulti(i, ftype(MASTER_DID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(MASTER_UID1, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_UID2, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_UID3, FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_OLDUID,FieldIsUUID));
    types.insertMulti(i, ftype(MASTER_SID, FieldIsInteger));
    i = Table_SOURCES;
    types.insertMulti(i, ftype(SOURCES_SID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SOURCES_DBUID, FieldIsUUID));
    types.insertMulti(i, ftype(SOURCES_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(SOURCES_LANG, FieldIsLanguageText));
    types.insertMulti(i, ftype(SOURCES_WEB, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_COPYRIGHT, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_LICENSE, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_DATE, FieldIsDateTime));
    types.insertMulti(i, ftype(SOURCES_DRUGS_VERSION,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_AUTHORS, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_VERSION, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_PROVIDER, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_WEBLINK, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_DRUGUID_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_ATC, FieldIsBoolean));
    types.insertMulti(i, ftype(SOURCES_INTERACTIONS, FieldIsBoolean));
    types.insertMulti(i, ftype(SOURCES_COMPL_WEBSITE,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_PACKUID_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_COMPLETION, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_AUTHOR_COMMENTS, FieldIsLongText));
    types.insertMulti(i, ftype(SOURCES_DRUGNAMECONSTRUCTOR, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_FMFCOMPAT, FieldIsShortText));
    types.insertMulti(i, ftype(SOURCES_OPENREACT_COMPAT, FieldIsShortText));
    i = Table_LABELS;
    types.insertMulti(i, ftype(LABELS_LID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(LABELS_LANG, FieldIsLanguageText));
    types.insertMulti(i, ftype(LABELS_LABEL, FieldIsShortText));
    i = Table_LABELSLINK;
    types.insertMulti(i, ftype(LABELSLINK_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(LABELSLINK_LID, FieldIsInteger));
    i= Table_BIB;
    types.insertMulti(i, ftype(BIB_BIBID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(BIB_TYPE, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_LINK, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_TEXTREF, FieldIsShortText));
    types.insertMulti(i, ftype(BIB_ABSTRACT, FieldIsLongText));
    types.insertMulti(i, ftype(BIB_EXPLAIN, FieldIsLongText));
    types.insertMulti(i, ftype(BIB_XML, FieldIsBlob));
    i = Table_BIB_LINK;
    types.insertMulti(i, ftype(BIB_LINK_MASTERID, FieldIsInteger));
    types.insertMulti(i, ftype(BIB_LINK_BIBID, FieldIsInteger));
    i = Table_DRUGS;
    types.insertMulti(i, ftype(DRUGS_ID , FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(DRUGS_DID ,FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_SID,  FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_STRENGTH,FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_VALID, FieldIsBoolean));
    types.insertMulti(i, ftype(DRUGS_MARKET, FieldIsBoolean));
    types.insertMulti(i, ftype(DRUGS_AID_MASTER_LID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUGS_LINK_SPC, FieldIsShortText));
    types.insertMulti(i, ftype(DRUGS_EXTRA_XML,FieldIsLongText));
    i = Table_MOLS;
    types.insertMulti(i, ftype(MOLS_MID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(MOLS_SID, FieldIsInteger));
    types.insertMulti(i, ftype(MOLS_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(MOLS_WWW, FieldIsShortText));
    i = Table_COMPO;
    types.insertMulti(i, ftype(COMPO_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(COMPO_DID,FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_MID,FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_STRENGTH, FieldIsShortText));
    types.insertMulti(i, ftype(COMPO_STRENGTH_NID, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_DOSE_REF, FieldIsShortText));
    types.insertMulti(i, ftype(COMPO_REF_NID, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_NATURE, FieldIsInteger));
    types.insertMulti(i, ftype(COMPO_LK_NATURE, FieldIsInteger));
    i = Table_UNITS;
    types.insertMulti(i, ftype(UNITS_NID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(UNITS_VALUE, FieldIsShortText));
    i = Table_LK_MOL_ATC;
    types.insertMulti(i, ftype(LK_MID,FieldIsInteger));
    types.insertMulti(i, ftype(LK_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(LK_ATC_SID,FieldIsInteger));
    i = Table_PACKAGING;
    types.insertMulti(i, ftype(PACK_DID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PACK_SID,  FieldIsInteger));
    types.insertMulti(i, ftype(PACK_PACK_UID,FieldIsUUID));
    types.insertMulti(i, ftype(PACK_LABEL,  FieldIsShortText));
    types.insertMulti(i, ftype(PACK_STATUS, FieldIsOneChar));
    types.insertMulti(i, ftype(PACK_MARKET, FieldIsInteger));
    types.insertMulti(i, ftype(PACK_DATE,   FieldIsDateTime));
    types.insertMulti(i, ftype(PACK_OPTION_CODE, FieldIsShortText));
    i = Table_DRUG_ROUTES;
    types.insertMulti(i, ftype(DRUG_ROUTES_DID, FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_ROUTES_RID, FieldIsInteger));
    i = Table_DRUG_FORMS;
    types.insertMulti(i, ftype(DRUG_FORMS_DID,FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_FORMS_MASTERLID,FieldIsInteger));
    i = Table_ROUTES;
    types.insertMulti(i, ftype(ROUTES_RID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ROUTES_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(ROUTES_SYSTEMIC, FieldIsShortText));
    i = Table_SEARCHENGINES;
    types.insertMulti(i, ftype(SEARCHENGINE_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SEARCHENGINE_LABEL, FieldIsShortText));
    types.insertMulti(i, ftype(SEARCHENGINE_URL,FieldIsShortText));
    i = Table_VERSION;
    types.insertMulti(i, ftype(VERSION_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(VERSION_VERSION, FieldIsShortText));
    types.insertMulti(i, ftype(VERSION_DATE, FieldIsDate));
    types.insertMulti(i, ftype(VERSION_COMMENT, FieldIsLongText));
    i = Table_ATC;
    types.insertMulti(i, ftype(ATC_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ATC_CODE, FieldIsShortText));
    types.insertMulti(i, ftype(ATC_WARNDUPLICATES, FieldIsBoolean));
    i = Table_INTERACTIONS;
    types.insertMulti(i, ftype(INTERACTIONS_IAID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(INTERACTIONS_ATC_ID1, FieldIsInteger));
    types.insertMulti(i, ftype(INTERACTIONS_ATC_ID2, FieldIsInteger));
    i = Table_IAKNOWLEDGE;
    types.insertMulti(i, ftype(IAKNOWLEDGE_IAKID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(IAKNOWLEDGE_TYPE, FieldIsShortText));
    types.insertMulti(i, ftype(IAKNOWLEDGE_RISK_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_MANAGEMENT_MASTERLID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_BIB_MASTERID, FieldIsInteger));
    types.insertMulti(i, ftype(IAKNOWLEDGE_WWW, FieldIsShortText));
    i = Table_IA_IAK;
    types.insertMulti(i, ftype(IA_IAK_IAID, FieldIsInteger));
    types.insertMulti(i, ftype(IA_IAK_IAKID, FieldIsInteger));
    i = Table_ATC_LABELS;
    types.insertMulti(i, ftype(ATC_LABELS_ATCID, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_LABELS_MASTERLID, FieldIsInteger));
    i = Table_ATC_CLASS_TREE;
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID_CLASS, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_ID_ATC, FieldIsInteger));
    types.insertMulti(i, ftype(ATC_CLASS_TREE_BIBMASTERID,FieldIsInteger));
    i = Table_PIM_SOURCES;
    types.insertMulti(i, ftype(PIM_SOURCES_SID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIM_SOURCES_UID, FieldIsUUID));
    types.insertMulti(i, ftype(PIM_SOURCES_NAME, FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_PMID, FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_COUNTRY,FieldIsShortText));
    types.insertMulti(i, ftype(PIM_SOURCES_WWW, FieldIsShortText));
    i = Table_PIM_TYPES;
    types.insertMulti(i, ftype(PIM_TYPES_TID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIM_TYPES_UID,FieldIsUUID));
    types.insertMulti(i, ftype(PIM_TYPES_MASTER_LID, FieldIsInteger));
    i = Table_PIMS;
    types.insertMulti(i, ftype(PIMS_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_SID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_TID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_LEVEL, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RISK_MASTER_LID, FieldIsInteger));
    i = Table_PIMS_RELATED_ATC;
    types.insertMulti(i, ftype(PIMS_RELATC_RMID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_RELATC_PIM_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELATC_ATC_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELATC_MAXDAYDOSE, FieldIsReal));
    types.insertMulti(i, ftype(PIMS_RELATC_MAXDAYDOSEUNIT, FieldIsInteger));
    i = Table_PIMS_RELATED_ICD;
    types.insertMulti(i, ftype(PIMS_RELICD_RMID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(PIMS_RELICD_PIM_ID, FieldIsInteger));
    types.insertMulti(i, ftype(PIMS_RELICD_ICD_SID, FieldIsInteger));
    i = Table_CURRENTVERSION;
    types.insertMulti(i, ftype(CURRENTVERSION_ID, FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(CURRENTVERSION_NUMBER, FieldIsShortText));

#if DRUGS_DATABASE_VERSION >= 0x000804
    i = Table_DRUG_SPC;
    types.insertMulti(i, ftype(DRUG_SPC_DID,FieldIsInteger));
    types.insertMulti(i, ftype(DRUG_SPC_SPCCONTENT_ID,FieldIsInteger));
    i = Table_SPC_CONTENT;
    types.insertMulti(i, ftype(SPCCONTENT_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SPCCONTENT_LABEL,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENT_URL_SOURCE,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENT_DATEOFDOWNLOAD,FieldIsDateTime));
    types.insertMulti(i, ftype(SPCCONTENT_HTMLCONTENT,FieldIsBlob));
    types.insertMulti(i, ftype(SPCCONTENT_SPCCONTENT_RESOURCES_LINK_ID,FieldIsInteger));
    i = Table_SPC_CONTENTRESOURCE_LINK;
    types.insertMulti(i, ftype(SPCCONTENT_RESOURCES_LINK_ID,FieldIsInteger));
    types.insertMulti(i, ftype(SPCCONTENT_SPCCONTENTRESOURCES_ID,FieldIsInteger));
    i = Table_SPC_CONTENTRESOURCE;
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_ID,FieldIsUniquePrimaryKey));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_TYPE,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_NAME,FieldIsShortText));
    types.insertMulti(i, ftype(SPCCONTENTRESOURCES_CONTENT,FieldIsBlob));
#endif

    for(int i=0; i < Table_MaxParam; ++i) {
        addTable(i, "t" + QString::number(i));
        const QList<ftype> &tp = types.values(i);
        for(int j=0; j < tp.count(); ++j) {
            addField(i, tp.at(j).f, "f"+QString::number(tp.count()-j), tp.at(j).t);
        }
    }
    addIndex(Table_SOURCES, SOURCES_SID);
    addIndex(Table_MASTER, MASTER_DID);
    addIndex(Table_LABELS, LABELS_LID);
    addIndex(Table_LABELSLINK, LABELSLINK_LID);
    addIndex(Table_LABELSLINK, LABELSLINK_MASTERLID);
    addIndex(Table_BIB, BIB_BIBID);
    addIndex(Table_BIB_LINK, BIB_LINK_BIBID);
    addIndex(Table_BIB_LINK, BIB_LINK_MASTERID);
    addIndex(Table_DRUGS, DRUGS_DID);
    addIndex(Table_MOLS, MOLS_MID);
    addIndex(Table_COMPO, COMPO_DID);
    addIndex(Table_COMPO, COMPO_MID);
    addIndex(Table_UNITS, UNITS_NID);
    addIndex(Table_LK_MOL_ATC, LK_MID);
    addIndex(Table_LK_MOL_ATC, LK_ATC_ID);
    addIndex(Table_LK_MOL_ATC, LK_ATC_SID);
    addIndex(Table_DRUG_ROUTES, DRUG_ROUTES_DID);
    addIndex(Table_DRUG_ROUTES, DRUG_ROUTES_RID);
    addIndex(Table_DRUG_FORMS, DRUG_FORMS_DID);
    addIndex(Table_DRUG_FORMS, DRUG_FORMS_MASTERLID);
    addIndex(Table_ROUTES, ROUTES_RID);
    addIndex(Table_ROUTES, ROUTES_MASTERLID);
    addIndex(Table_ATC, ATC_CODE);
    addIndex(Table_ATC, ATC_ID);
    addIndex(Table_INTERACTIONS, INTERACTIONS_IAID);
    addIndex(Table_INTERACTIONS, INTERACTIONS_ATC_ID1);
    addIndex(Table_INTERACTIONS, INTERACTIONS_ATC_ID2);

    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_IAKID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_RISK_MASTERLID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_MANAGEMENT_MASTERLID);
    addIndex(Table_IAKNOWLEDGE, IAKNOWLEDGE_BIB_MASTERID);
    addIndex(Table_IA_IAK, IA_IAK_IAID);
    addIndex(Table_IA_IAK, IA_IAK_IAKID);
    addIndex(Table_ATC_LABELS, ATC_LABELS_ATCID);
    addIndex(Table_ATC_LABELS, ATC_LABELS_MASTERLID);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_ID_CLASS);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_ID_ATC);
    addIndex(Table_ATC_CLASS_TREE, ATC_CLASS_TREE_BIBMASTERID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_RMID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_PIM_ID);
    addIndex(Table_PIMS_RELATED_ATC, PIMS_RELATC_ATC_ID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_RMID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_PIM_ID);
    addIndex(Table_PIMS_RELATED_ICD, PIMS_RELICD_ICD_SID);
    addIndex(Table_PIMS, PIMS_ID);
    addIndex(Table_PIM_TYPES, PIM_TYPES_TID);
    addIndex(Table_PIM_SOURCES, PIM_SOURCES_SID);

#if DRUGS_DATABASE_VERSION >= 0x000804
    addIndex(Table_DRUG_SPC, DRUG_SPC_DID);
    addIndex(Table_DRUG_SPC, DRUG_SPC_SPCCONTENT_ID);
    addIndex(Table_SPC_CONTENT, SPCCONTENT_ID);
#endif
}