Beispiel #1
0
/*it extracts servers address from the message if the server is new server it assignes new server address for the server*/
void getSrvId(char *msg,char *strSrvId,int type){
	char *srvId;
	if(type==IPV4 && savedIpv4<MAX_SRV_CONN){
	  srvId=parseTocken(msg,2,DELIMITER,strlen(msg));
		if(srvId){
			if(strcmp(srvId,NEWSERVER)==0)
				assignId(srvId);
							
			strcpy(strSrvId,srvId);
			free(srvId);
		}
	}			
	else if(type==IPV6 && savedIpv6<MAX_SRV_CONN){
	
		srvId=parseTocken(msg,2,DELIMITER,strlen(msg));
		if(srvId){
			if(strcmp(srvId,NEWSERVER)==0)
				assignId(srvId);
							
			strcpy(strSrvId,srvId);
			free(srvId);
		}
	}
	else
		strcpy(strSrvId,NEWSERVER);	
}
bool DataSourceInterface::executeInsertInternal(Query& query, void* entity) {
	DataSourceEntityMapping dsemp = mapping->getDataSourceEntityMapping(query.getClassName());
	ClassInfo clas = reflector->getClassInfo(query.getClassName(), appName);

	if(dsemp.isIdGenerate() && dsemp.getIdgendbEntityType()!="identity") {
		assignId(dsemp, clas, entity);
	}

	bool flag = executeInsert(query, entity);

	if(flag && dsemp.isIdGenerate() && dsemp.getIdgendbEntityType()=="identity") {
		assignId(dsemp, clas, entity);
	}

	return flag;
}
Beispiel #3
0
		void Ellipse::appendAsXml(SvgElement& parent, Drawing& drawing) {
			SvgElement element = parent.createElement("ellipse");
			assignId(element);
			Point mapped = drawing.map(m_centre);
			element.setAttribute("cx", NumberUtil::formatFloat(mapped.getX()));
			element.setAttribute("cy", NumberUtil::formatFloat(mapped.getY()));
			element.setAttribute("rx", NumberUtil::formatFloat(m_radius));
			element.setAttribute("ry", NumberUtil::formatFloat(m_radius * m_eccentricity));

			if (m_inclination != 0) {
				element.setAttribute("transform", "rotate(" + NumberUtil::formatFloat((float) (m_inclination * 180.0 / M_PI)) + ")");
			}
			setStrokeAndFill(element, drawing);
			parent.appendChild(element);
		}
Beispiel #4
0
// add GeneId as RelationshipXref to Protein or ProteinReference with unipax_id id
bool UniPAX::mysql::MySQLManager::addGeneId(UnipaxId id, std::string external_protein_id,
		std::map<std::string, boost::shared_ptr<UniPAX::RelationshipXref> > & rxref_map,
		KernelCollector& manager, UniProtReader& reader)
{

    if (DBManager::isType(id, UniPAX::ClassType::idProtein)) //UniPAX::Protein
	{
		boost::shared_ptr<UniPAX::Protein> protein = boost::dynamic_pointer_cast<UniPAX::Protein>(super::getObjectByID(id));

		std::string::size_type found = external_protein_id.find("-");
		if (found != std::string::npos)
		{
			std::cout << "shorten id '" << external_protein_id << "' to '" << external_protein_id.substr(0,found) << "'" << std::endl;
			external_protein_id = external_protein_id.substr(0, found);
		}

		std::vector<std::string> ids;
		// change standardName of Protein
		ids = reader.getMappedId(external_protein_id,"UniProtKB-ID");
		if (!ids.empty())
		{
			protein->setStandardName(ids[0]);
		}

		ids.clear();
		ids = reader.getMappedId(external_protein_id,"GeneID");

		// if no corresponding GeneId found ... continue
		if (ids.empty())
		{
			std::cout << "no corresponding GeneId found for '" << external_protein_id << "'" << std::endl;
			return false;
		}

		std::string search_string = std::string("EntrezGene")+"||"+ids[0];

		boost::shared_ptr<UniPAX::RelationshipXref> rxref;
		UnipaxId rxid = getRelationshipXrefId("EntrezGene", ids[0]);

		UnipaxId help = db_ids["RelationshipTypeVocabulary"];
		help++;


		if (rxid == 0)
		{
			if (rxref_map.find(search_string) == rxref_map.end())
			{
				rxref = boost::shared_ptr<UniPAX::RelationshipXref>(new UniPAX::RelationshipXref());
				rxref->setDb("EntrezGene");
				rxref->setId(ids[0]);
				assignId(rxref, false);
				boost::shared_ptr<UniPAX::RelationshipTypeVocabulary> rtv = boost::shared_ptr<UniPAX::RelationshipTypeVocabulary>(new UniPAX::RelationshipTypeVocabulary);
				rtv->setTerm("Coding gene");
				rxref->addRelationshipType(rtv);
				rtv->setUnipaxId(help);

				rxref_map[search_string] = rxref;
			}
			else
			{
				rxref = rxref_map.find(search_string)->second;
			}
		}
		else
		{
			rxref = boost::dynamic_pointer_cast<UniPAX::RelationshipXref>(super::getObjectByID(rxid));
		}
		protein->addXref(rxref);

		manager.collect(protein);

	}
    else if (DBManager::isType(id, UniPAX::ClassType::idProteinReference)) //UniPAX::ProteinReference
	{

		boost::shared_ptr<UniPAX::ProteinReference> proteinref = boost::dynamic_pointer_cast<UniPAX::ProteinReference>(super::getObjectByID(id));

		size_t found = external_protein_id.find("-");
		if (found != std::string::npos)
		{
			std::cout << "shorten id '" << external_protein_id << "' to '" << external_protein_id.substr(0,found) << "'" << std::endl;
			external_protein_id = external_protein_id.substr(0,found);
		}

		std::vector<std::string> ids;

		// change standardName of ProteinReference
		ids = reader.getMappedId(external_protein_id,"UniProtKB-ID");
		if (!ids.empty())
		{
			proteinref->setStandardName(ids[0]);
		}

		ids.clear();
		ids = reader.getMappedId(external_protein_id,"GeneID");

		// if no corresponding GeneId found ... continue
		if (ids.empty())
		{
			std::cout << "no corresponding GeneId found for '" << external_protein_id << "'" << std::endl;
			return false;
		}

		std::string search_string = std::string("EntrezGene")+"||"+ids[0];

		boost::shared_ptr<UniPAX::RelationshipXref> rxref;
		UnipaxId rxid = getRelationshipXrefId("EntrezGene", ids[0]);

		UnipaxId help = db_ids["RelationshipTypeVocabulary"];
		help++;


		if (rxid == 0)
		{
			if (rxref_map.find(search_string) == rxref_map.end())
			{
				rxref = boost::shared_ptr<UniPAX::RelationshipXref>(new UniPAX::RelationshipXref());
				rxref->setDb("EntrezGene");
				rxref->setId(ids[0]);
				assignId(rxref, false);
				boost::shared_ptr<UniPAX::RelationshipTypeVocabulary> rtv = boost::shared_ptr<UniPAX::RelationshipTypeVocabulary>(new UniPAX::RelationshipTypeVocabulary);
				rtv->setTerm("Coding gene");
				rxref->addRelationshipType(rtv);
				rtv->setUnipaxId(help);

				rxref_map[search_string] = rxref;
			}
			else
			{
				rxref = rxref_map.find(search_string)->second;
			}
		}
		else
		{
			rxref = boost::dynamic_pointer_cast<UniPAX::RelationshipXref>(super::getObjectByID(rxid));
		}
		proteinref->addXref(rxref);

		manager.collect(proteinref);
	}

	return true;
}
Beispiel #5
0
bool UniPAX::mysql::MySQLManager::assignId(boost::shared_ptr<UniPAX::UPBase> object)
{
	return assignId(object, true);
}