public string ConvertV2ToBetaSearch(string RDFResults, string queryid, string version, bool individual) { System.Text.StringBuilder returnxml = new System.Text.StringBuilder(); XmlDocument RDF = new XmlDocument(); Utility.Namespace namespacemgr = new Connects.Profiles.Utility.Namespace(); XmlNamespaceManager namespaces; string uri = string.Empty; string affiliationuri = string.Empty; string xpathbufferDepartment = string.Empty; string topnode = string.Empty; RDF.LoadXml(RDFResults); namespaces = namespacemgr.LoadNamespaces(RDF); int count = 0; XmlNode pub; List<CustomPub> custompubs; XmlNodeList persons; Int64 currentnode = 0; PersonData persondata; if (individual) { persons = RDF.SelectNodes("//rdf:RDF", namespaces); } else { persons = RDF.SelectNodes("//prns:hasConnection[@rdf:nodeID!='']", namespaces); } foreach (XmlNode person in persons) { if (individual) { uri = RDF.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", namespaces).Value; returnxml.Append("<Person QueryRelevance=\"1\" Visible=\"true\">"); } else { uri = RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/rdf:object/@rdf:resource", namespaces).Value; returnxml.Append("<Person QueryRelevance=\"" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/prns:connectionWeight", namespaces).InnerText + "\" Visible=\"true\">"); } currentnode = Convert.ToInt64(uri.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<PersonID>" + this.GetPersonID(currentnode).ToString() + "</PersonID>"); persondata = this.GetPersonData(this.GetPersonID(currentnode)); //NAME returnxml.Append("<Name>"); returnxml.Append("<FullName>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:fullName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</FullName>"); returnxml.Append("<FirstName>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/foaf:firstName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/foaf:firstName", namespaces).InnerText); returnxml.Append("</FirstName>"); returnxml.Append("<LastName>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/foaf:lastName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/foaf:lastName", namespaces).InnerText); returnxml.Append("</LastName>"); returnxml.Append("</Name>"); //END NAME // <InternalIDList> // <InternalID Name="EcommonsUsername">GMW3</InternalID> // </InternalIDList> ////ADDRESS returnxml.Append("<Address>"); returnxml.Append("<Address1>"); returnxml.Append(persondata.AddressLine1); returnxml.Append("</Address1>"); returnxml.Append("<Address2>"); returnxml.Append(persondata.AddressLine2); returnxml.Append("</Address2>"); returnxml.Append("<Address3>"); returnxml.Append(persondata.AddressLine3); returnxml.Append("</Address3>"); returnxml.Append("<Address4>"); returnxml.Append(persondata.AddressLine4); returnxml.Append("</Address4>"); returnxml.Append("<Telephone>"); returnxml.Append(persondata.Phone); returnxml.Append("</Telephone>"); returnxml.Append("<Fax>"); returnxml.Append(persondata.Fax); returnxml.Append("</Fax>"); returnxml.Append("<Latitude>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:latitude", namespaces) != null) returnxml.Append(Convert.ToDecimal(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:latitude", namespaces).InnerText)); returnxml.Append("</Latitude>"); returnxml.Append("<Longitude>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:longitude", namespaces) != null) returnxml.Append(Convert.ToDecimal(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:longitude", namespaces).InnerText)); returnxml.Append("</Longitude>"); returnxml.Append("</Address>"); //END ADDRESS // NARRATIVE (UCSF) returnxml.Append("<Narrative>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/vivo:overview", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/vivo:overview", namespaces).InnerText); returnxml.Append("</Narrative>"); // END NARRATIVE // PHOTOURL (UCSF) returnxml.Append("<PhotoUrl>"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:mainImage/@rdf:resource", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:mainImage/@rdf:resource", namespaces).InnerText); returnxml.Append("</PhotoUrl>"); // END PHOTOURL returnxml.Append("<AffiliationList Visible=\"true\">"); if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:personInPrimaryPosition/@rdf:resource", namespaces) != null) affiliationuri = RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:personInPrimaryPosition/@rdf:resource", namespaces).Value; foreach (XmlNode affiliation in RDF.SelectNodes("rdf:RDF/rdf:Description[@rdf:about='" + affiliationuri + "']", namespaces)) { if (affiliationuri != string.Empty) { returnxml.Append("<Affiliation Primary=\"" + affiliation.SelectSingleNode("prns:isPrimaryPosition", namespaces).InnerText + "\">"); returnxml.Append("<JobTitle>"); returnxml.Append(affiliation.SelectSingleNode("vivo:hrJobTitle", namespaces).InnerText); returnxml.Append("</JobTitle>"); returnxml.Append("<InstitutionAbbreviation>"); returnxml.Append("</InstitutionAbbreviation>"); returnxml.Append("<InstitutionName>"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + affiliation.SelectSingleNode("vivo:positionInOrganization/@rdf:resource", namespaces).Value + "']", namespaces).InnerText); returnxml.Append("</InstitutionName>"); returnxml.Append("<DepartmentName>"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + affiliation.SelectSingleNode("prns:positionInDepartment/@rdf:resource", namespaces).Value + "']", namespaces).InnerText); returnxml.Append("</DepartmentName>"); } if (affiliation.SelectSingleNode("prns:hasFacultyRank", namespaces) != null) { returnxml.Append("<FacultyType>"); returnxml.Append(RDF.SelectSingleNode("rdf:Description[@rdf:about='" + affiliation.SelectSingleNode("prns:hasFacultyRank", namespaces).InnerText + "']/rdfs:label", namespaces).InnerText); returnxml.Append("</FacultyType>"); } returnxml.Append("</Affiliation>"); } returnxml.Append("</AffiliationList>"); returnxml.Append("<ProfileURL Visible=\"true\">" + uri + "</ProfileURL>"); returnxml.Append("<BasicStatistics Visible=\"true\">"); returnxml.Append("<PublicationCount>"); returnxml.Append(this.GetPubCount(Convert.ToInt64(uri.Split('/')[uri.Split('/').Length - 1]))); returnxml.Append("</PublicationCount>"); returnxml.Append("<MatchingPublicationCount>0</MatchingPublicationCount>"); //No equlivant to new system if (!individual) returnxml.Append("<MatchScore>" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/prns:connectionWeight", namespaces).InnerText + "</MatchScore>"); returnxml.Append("</BasicStatistics>"); if (individual) { if (version != "2") returnxml.Append("<Publications>"); returnxml.Append("<PublicationList>"); custompubs = this.GetCustomPubs(currentnode); foreach (XmlNode publication in RDF.SelectNodes("//vivo:authorInAuthorship", namespaces)) { try { pub = RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + publication.SelectSingleNode("@rdf:resource", namespaces).Value + "']/vivo:linkedInformationResource/@rdf:resource", namespaces).Value + "']", namespaces); if (pub.SelectSingleNode("bibo:pmid", namespaces) != null) returnxml.Append("<Publication CustomCategory='' Type='PubMed' Visible='true'>"); else returnxml.Append("<Publication CustomCategory='' Type='Custom' Visible='true'>"); returnxml.Append("<PublicationID>"); returnxml.Append(publication.SelectSingleNode("@rdf:resource", namespaces).Value); returnxml.Append("</PublicationID>"); if (pub.SelectSingleNode("prns:informationResourceReference", namespaces) != null) { returnxml.Append("<PublicationReference>"); //returnxml.Append(pub.SelectSingleNode("rdfs:label", namespaces).InnerText); returnxml.Append(pub.SelectSingleNode("prns:informationResourceReference", namespaces).InnerText.Replace("&", "&").Replace(">", ">").Replace("<", "<").Replace("%", "%")); returnxml.Append("</PublicationReference>"); } returnxml.Append("<PublicationMatchDetailList>"); returnxml.Append("</PublicationMatchDetailList>"); returnxml.Append("<PublicationSourceList>"); if (pub.SelectSingleNode("bibo:pmid", namespaces) != null) { returnxml.Append("<PublicationSource ID='" + pub.SelectSingleNode("bibo:pmid", namespaces).InnerText + "' URL='" + "http://www.ncbi.nlm.nih.gov/pubmed/" + pub.SelectSingleNode("bibo:pmid", namespaces).InnerText + "' Primary='true' Name='PubMed'/>"); } returnxml.Append("</PublicationSourceList>"); returnxml.Append("</Publication>"); } catch (Exception ex) { DebugLogging.Log(ex.Message); DebugLogging.Log(ex.StackTrace); } } returnxml.Append("</PublicationList>"); if (version != "2") returnxml.Append("</Publications>"); } if (individual) { returnxml.Append("<PassiveNetworks>"); returnxml.Append("<SimilarPersonList TotalSimilarPeopleCount=\"" + RDF.SelectNodes("rdf:RDF/rdf:Description/prns:similarTo", namespaces).Count + "\">"); foreach (XmlNode similarto in RDF.SelectNodes("rdf:RDF/rdf:Description/prns:similarTo", namespaces)) { if (similarto.SelectSingleNode("@rdf:resource", namespaces).Value != uri) { currentnode = Convert.ToInt64(similarto.SelectSingleNode("@rdf:resource", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<SimilarPerson PersonID=\"" + this.GetPersonID(currentnode) + "\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + similarto.SelectSingleNode("@rdf:resource", namespaces).Value + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</SimilarPerson>"); } } returnxml.Append("</SimilarPersonList>"); returnxml.Append("<CoAuthorList TotalCoAuthorCount=\"" + RDF.SelectNodes("rdf:RDF/rdf:Description/vivo:authorInAuthorship", namespaces).Count + "\">"); foreach (XmlNode coauthorpub in RDF.SelectNodes("rdf:RDF/rdf:Description[@rdf:about= /rdf:RDF[1]/rdf:Description[1]/prns:coAuthorOf/@rdf:resource][position() < 5]", namespaces)) { if (coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value != uri) { currentnode = Convert.ToInt64(coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<CoAuthor PersonID=\"" + this.GetPersonID(currentnode) + "\" Institution=\"" + (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value + "']/prns:personInPrimaryPosition/@rdf:resource", namespaces).Value + "']/rdfs:label", namespaces)).InnerText + "\">"); returnxml.Append(coauthorpub.SelectSingleNode("rdfs:label", namespaces).InnerText); returnxml.Append("</CoAuthor>"); } } returnxml.Append("</CoAuthorList>"); returnxml.Append("<NeighborList>"); foreach (XmlNode neighbor in RDF.SelectNodes("rdf:RDF/rdf:Description/prns:physicalNeighborOf", namespaces)) { if (neighbor.SelectSingleNode("@rdf:resource", namespaces).Value != uri) { currentnode = Convert.ToInt64(neighbor.SelectSingleNode("@rdf:resource", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<Neighbor PersonID=\"" + this.GetPersonID(currentnode) + "\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + neighbor.SelectSingleNode("@rdf:resource", namespaces).Value + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</Neighbor>"); } } returnxml.Append("</NeighborList>"); List<String> concepts = new List<String>(); foreach (XmlNode keyword in RDF.SelectNodes("rdf:RDF/rdf:Description/rdf:type", namespaces)) { // see if this is a keyword XmlNode resource = keyword.SelectSingleNode("@rdf:resource", namespaces); if (resource.Value == "http://www.w3.org/2004/02/skos/core#Concept") { concepts.Add(keyword.ParentNode.SelectSingleNode("rdfs:label", namespaces).InnerText); } } returnxml.Append("<KeywordList TotalKeywordCount=\"" + concepts.Count + "\">"); foreach (String concept in concepts) { returnxml.Append("<Keyword>"); returnxml.Append(concept); returnxml.Append("</Keyword>"); } returnxml.Append("</KeywordList>"); returnxml.Append("</PassiveNetworks>"); } returnxml.Append("</Person>"); count++; } string complete = "false"; if (RDF.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces) != null && count.ToString() == RDF.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText) complete = "true"; topnode = "<?xml version=\"1.0\"?><PersonList Complete=\"" + complete + "\" ThisCount=\"" + count.ToString() + "\" TotalCount=\"" + (RDF.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces) == null ? "0" : RDF.SelectSingleNode("rdf:RDF/rdf:Description/prns:numberOfConnections", namespaces).InnerText) + "\" QueryID=\"" + queryid + "\" xmlns=\"http://connects.profiles.schema/profiles/personlist\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"; returnxml.Append("</PersonList>"); return (topnode + returnxml.ToString()).Replace("&", "&"); }
public string ConvertV2ToBetaSearch(string RDFResults, string queryid, string version, bool individual) { System.Text.StringBuilder returnxml = new System.Text.StringBuilder(); XmlDocument RDF = new XmlDocument(); Utility.Namespace namespacemgr = new Connects.Profiles.Utility.Namespace(); XmlNamespaceManager namespaces; string uri = string.Empty; string affiliationuri = string.Empty; string xpathbufferDepartment = string.Empty; string topnode = string.Empty; RDF.LoadXml(RDFResults); namespaces = namespacemgr.LoadNamespaces(RDF); int count = 0; XmlNode pub = null; List<CustomPub> custompubs; XmlNodeList persons; Int64 currentnode = 0; PersonData persondata; bool bynodeid = false; if (RDF.SelectNodes("//prns:hasConnection[@rdf:nodeID!='']", namespaces) != null && RDF.SelectSingleNode("rdf:RDF/rdf:Description[1]/@rdf:about", namespaces) == null) bynodeid = true; if (individual && !bynodeid) { persons = RDF.SelectNodes("//rdf:RDF", namespaces); } else { persons = RDF.SelectNodes("//prns:hasConnection[@rdf:nodeID!='']", namespaces); } foreach (XmlNode person in persons) { if (individual && !bynodeid) { if (RDF.SelectSingleNode("rdf:RDF/rdf:Description[1]/@rdf:about", namespaces) != null) { uri = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[1]/@rdf:about", namespaces).Value; returnxml.Append("<Person QueryRelevance=\"1\" Visible=\"true\">"); } } else { if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/rdf:object/@rdf:resource", namespaces) != null) { uri = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/rdf:object/@rdf:resource", namespaces).Value; returnxml.Append("<Person QueryRelevance=\"" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/prns:connectionWeight", namespaces).InnerText + "\" Visible=\"true\">"); } else { returnxml.Append("<Person QueryRelevance=\"" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/prns:connectionWeight", namespaces).InnerText + "\" Visible=\"true\">"); } } if (uri != string.Empty) { currentnode = Convert.ToInt64(uri.Split('/')[uri.Split('/').Length - 1]); if (version == "2") { returnxml.Append("<PersonID>" + this.GetPersonID(currentnode).ToString() + "</PersonID>"); } else { returnxml.Append("<PersonID>" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/catalyst:eCommonsLogin", namespaces).InnerText + "</PersonID>"); } persondata = this.GetPersonData(this.GetPersonID(currentnode)); //NAME returnxml.Append("<Name>"); returnxml.Append("<FullName>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:fullName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</FullName>"); returnxml.Append("<FirstName>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/foaf:firstName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/foaf:firstName", namespaces).InnerText); returnxml.Append("</FirstName>"); returnxml.Append("<LastName>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/foaf:lastName", namespaces) != null) returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/foaf:lastName", namespaces).InnerText); returnxml.Append("</LastName>"); returnxml.Append("</Name>"); //END NAME /* returnxml.Append("<InternalIDList>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/catalyst:eCommonsLogin", namespaces) != null) { returnxml.Append("<InternalID Name=\"EcommonsUsername\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/catalyst:eCommonsLogin", namespaces).InnerText); returnxml.Append("</InternalID>"); } if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/catalyst:harvardId", namespaces) != null) { returnxml.Append("<InternalID Name=\"HarvardID\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/catalyst:harvardId", namespaces).InnerText); returnxml.Append("</InternalID>"); } returnxml.Append("</InternalIDList>"); */ if (version == "2") { ////ADDRESS returnxml.Append("<Address>"); returnxml.Append("<Address1>"); returnxml.Append(persondata.AddressLine1); returnxml.Append("</Address1>"); returnxml.Append("<Address2>"); returnxml.Append(persondata.AddressLine2); returnxml.Append("</Address2>"); returnxml.Append("<Address3>"); returnxml.Append(persondata.AddressLine3); returnxml.Append("</Address3>"); returnxml.Append("<Address4>"); returnxml.Append(persondata.AddressLine4); returnxml.Append("</Address4>"); returnxml.Append("<Telephone>"); returnxml.Append(persondata.Phone); returnxml.Append("</Telephone>"); returnxml.Append("<Fax>"); returnxml.Append(persondata.Fax); returnxml.Append("</Fax>"); returnxml.Append("<Latitude>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:latitude", namespaces) != null) returnxml.Append(Convert.ToDecimal(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:latitude", namespaces).InnerText)); returnxml.Append("</Latitude>"); returnxml.Append("<Longitude>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:longitude", namespaces) != null) returnxml.Append(Convert.ToDecimal(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:longitude", namespaces).InnerText)); returnxml.Append("</Longitude>"); returnxml.Append("</Address>"); //END ADDRESS } returnxml.Append("<AffiliationList Visible=\"true\">"); string organization = string.Empty; string department = string.Empty; string primary = string.Empty; if (RDF.SelectNodes("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/vivo:personInPosition/@rdf:resource", namespaces) != null) { try { affiliationuri = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:personInPrimaryPosition/@rdf:resource", namespaces).Value; } catch (Exception ex) { } XmlNodeList afflist = null; if (individual) { afflist = RDF.SelectNodes("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/vivo:personInPosition/@rdf:resource", namespaces); } else { afflist = RDF.SelectNodes("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliationuri + "']", namespaces); } foreach (XmlNode affiliation in afflist) { if (affiliationuri != string.Empty) { if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliation.Value + "']/prns:isPrimaryPosition", namespaces) != null && individual) { primary = "true"; } else if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliationuri + "']/prns:isPrimaryPosition", namespaces) != null && !individual) { primary = "true"; } else { primary = "false"; } returnxml.Append("<Affiliation Primary=\"" + primary + "\">"); returnxml.Append("<JobTitle>"); if (individual) returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliation.Value + "']/vivo:hrJobTitle", namespaces).InnerText); else returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliationuri + "']/vivo:hrJobTitle", namespaces).InnerText); returnxml.Append("</JobTitle>"); returnxml.Append("<InstitutionAbbreviation>"); try { if (individual) organization = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliation.Value + "']/vivo:positionInOrganization/@rdf:resource", namespaces).InnerText; else organization = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliationuri + "']/vivo:positionInOrganization/@rdf:resource", namespaces).InnerText; returnxml.Append(GetInstitutionAbbreviation(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + organization + "']/rdfs:label", namespaces).InnerText)); } catch (Exception e) { } returnxml.Append("</InstitutionAbbreviation>"); returnxml.Append("<InstitutionName>"); try { returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + organization + "']/rdfs:label", namespaces).InnerText); } catch (Exception e) { } returnxml.Append("</InstitutionName>"); returnxml.Append("<DepartmentName>"); try { if (individual) department = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliation.Value + "']/prns:positionInDepartment/@rdf:resource", namespaces).InnerText; else department = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + affiliationuri + "']/prns:positionInDepartment/@rdf:resource", namespaces).InnerText; returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + department + "']/rdfs:label", namespaces).InnerText); } catch (Exception e) { } returnxml.Append("</DepartmentName>"); } if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about=/rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:hasFacultyRank/@rdf:resource]/rdfs:label", namespaces) != null) { returnxml.Append("<FacultyType>"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about=/rdf:RDF/rdf:Description[@rdf:about='" + uri + "']/prns:hasFacultyRank/@rdf:resource]/rdfs:label", namespaces).InnerText); returnxml.Append("</FacultyType>"); } returnxml.Append("</Affiliation>"); } } returnxml.Append("</AffiliationList>"); returnxml.Append("<ProfileURL Visible=\"true\">" + uri + "</ProfileURL>"); if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/vivo:email", namespaces) != null) { returnxml.Append("<EmailImageUrl Visible=\"true\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/vivo:email", namespaces).InnerText); returnxml.Append("</EmailImageUrl>"); } else { returnxml.Append("<EmailImageUrl/>"); } if (RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:mainImage/@rdf:resource", namespaces) != null) { returnxml.Append("<PhotoUrl Visible=\"true\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + uri + "']/prns:mainImage/@rdf:resource", namespaces).InnerText); returnxml.Append("</PhotoUrl>"); } else { returnxml.Append("<PhotoUrl/>"); } returnxml.Append("<BasicStatistics Visible=\"true\">"); returnxml.Append("<PublicationCount>"); returnxml.Append(this.GetPubCount(Convert.ToInt64(uri.Split('/')[uri.Split('/').Length - 1]))); returnxml.Append("</PublicationCount>"); returnxml.Append("<MatchingPublicationCount>0</MatchingPublicationCount>"); //No equlivant to new system try { returnxml.Append("<MatchScore>" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/prns:connectionWeight", namespaces).InnerText + "</MatchScore>"); } catch (Exception ex) { } returnxml.Append("</BasicStatistics>"); if (individual) { if (version != "2") returnxml.Append("<Publications>"); returnxml.Append("<PublicationList>"); custompubs = this.GetCustomPubs(currentnode); foreach (XmlNode publication in RDF.SelectNodes("//vivo:authorInAuthorship", namespaces)) { try { pub = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + publication.SelectSingleNode("@rdf:resource", namespaces).Value + "']/vivo:linkedInformationResource/@rdf:resource", namespaces).Value + "']", namespaces); } catch (Exception ex) { pub = null; } if (pub != null) { if (pub.SelectSingleNode("bibo:pmid", namespaces) != null) returnxml.Append("<Publication CustomCategory='' Type='PubMed' Visible='true'>"); else returnxml.Append("<Publication CustomCategory='' Type='Custom' Visible='true'>"); returnxml.Append("<PublicationID>"); returnxml.Append(publication.SelectSingleNode("@rdf:resource", namespaces).Value); returnxml.Append("</PublicationID>"); returnxml.Append("<PublicationReference>"); returnxml.Append(((pub.SelectSingleNode("prns:informationResourceReference", namespaces).InnerText).Replace("<", "<").Replace(">", ">"))); returnxml.Append("</PublicationReference>"); returnxml.Append("<PublicationMatchDetailList>"); returnxml.Append("</PublicationMatchDetailList>"); if (version == "2") { returnxml.Append("<PublicationSourceList>"); if (pub.SelectSingleNode("bibo:pmid", namespaces) != null) { returnxml.Append("<PublicationSource ID='" + pub.SelectSingleNode("bibo:pmid", namespaces).InnerText + "' URL='" + "http://www.ncbi.nlm.nih.gov/pubmed/" + pub.SelectSingleNode("bibo:pmid", namespaces).InnerText + "' Primary='true' Name='PubMed'/>"); } returnxml.Append("</PublicationSourceList>"); } else { returnxml.Append("<PublicationURL>"); try { returnxml.Append("http://www.ncbi.nlm.nih.gov/pubmed/" + pub.SelectSingleNode("bibo:pmid", namespaces).InnerText); } catch (Exception ex) { } returnxml.Append("</PublicationURL>"); returnxml.Append("<PubMedID>"); try { returnxml.Append(pub.SelectSingleNode("bibo:pmid", namespaces).InnerText); } catch (Exception ex) { } returnxml.Append("</PubMedID>"); returnxml.Append("<PublicationSourceList/>"); } returnxml.Append("</Publication>"); pub = null; } } returnxml.Append("</PublicationList>"); if (version != "2") returnxml.Append("</Publications>"); } if (individual) { returnxml.Append("<PassiveNetworks>"); returnxml.Append("<SimilarPersonList TotalSimilarPeopleCount=\"" + RDF.SelectNodes("rdf:RDF[1]/rdf:Description/prns:similarTo", namespaces).Count + "\">"); foreach (XmlNode similarto in RDF.SelectNodes("rdf:RDF[1]/rdf:Description/prns:similarTo", namespaces)) { if (similarto.SelectSingleNode("@rdf:resource", namespaces).Value != uri) { currentnode = Convert.ToInt64(similarto.SelectSingleNode("@rdf:resource", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<SimilarPerson PersonID=\"" + this.GetPersonID(currentnode) + "\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + similarto.SelectSingleNode("@rdf:resource", namespaces).Value + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</SimilarPerson>"); } } returnxml.Append("</SimilarPersonList>"); returnxml.Append("<CoAuthorList TotalCoAuthorCount=\"" + RDF.SelectNodes("rdf:RDF/rdf:Description[1]/vivo:authorInAuthorship", namespaces).Count + "\">"); foreach (XmlNode coauthorpub in RDF.SelectNodes("rdf:RDF/rdf:Description[@rdf:about= /rdf:RDF[1]/rdf:Description[1]/prns:coAuthorOf/@rdf:resource][position() < 5]", namespaces)) { if (coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value != uri) { currentnode = Convert.ToInt64(coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<CoAuthor PersonID=\"" + this.GetPersonID(currentnode) + "\" Institution=\"" + (RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + RDF.SelectSingleNode("rdf:RDF/rdf:Description[@rdf:about='" + coauthorpub.SelectSingleNode("@rdf:about", namespaces).Value + "']/prns:personInPrimaryPosition/@rdf:resource", namespaces).Value + "']/rdfs:label", namespaces)).InnerText + "\">"); returnxml.Append(coauthorpub.SelectSingleNode("rdfs:label", namespaces).InnerText); returnxml.Append("</CoAuthor>"); } } returnxml.Append("</CoAuthorList>"); returnxml.Append("<NeighborList>"); foreach (XmlNode neighbor in RDF.SelectNodes("rdf:RDF/rdf:Description[1]/prns:physicalNeighborOf", namespaces)) { if (neighbor.SelectSingleNode("@rdf:resource", namespaces).Value != uri) { currentnode = Convert.ToInt64(neighbor.SelectSingleNode("@rdf:resource", namespaces).Value.Split('/')[uri.Split('/').Length - 1]); returnxml.Append("<Neighbor PersonID=\"" + this.GetPersonID(currentnode) + "\">"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + neighbor.SelectSingleNode("@rdf:resource", namespaces).Value + "']/prns:fullName", namespaces).InnerText); returnxml.Append("</Neighbor>"); } } returnxml.Append("</NeighborList>"); returnxml.Append("<KeywordList TotalKeywordCount=\"" + RDF.SelectNodes("rdf:RDF/rdf:Description[1]/vivo:hasResearchArea", namespaces).Count + "\">"); foreach (XmlNode keyword in RDF.SelectNodes("rdf:RDF/rdf:Description[1]/vivo:hasResearchArea", namespaces)) { returnxml.Append("<Keyword>"); returnxml.Append(RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:about='" + keyword.SelectSingleNode("@rdf:resource", namespaces).Value + "']/rdfs:label", namespaces).InnerText); returnxml.Append("</Keyword>"); } returnxml.Append("</KeywordList>"); returnxml.Append("</PassiveNetworks>"); } returnxml.Append("</Person>"); count++; } else { if (person.SelectSingleNode("@rdf:nodeID", namespaces) != null) returnxml.Append("<PersonID>" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description[@rdf:nodeID='" + person.SelectSingleNode("@rdf:nodeID", namespaces).Value + "']/rdf:object/@rdf:nodeID", namespaces).Value + "']/prns:personId", namespaces).InnerText + "</PersonID></Person>"); } } string complete = "false"; string totalcount = string.Empty; if (!individual) { if (count.ToString() == RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description/prns:numberOfConnections", namespaces).InnerText) complete = "true"; totalcount = RDF.SelectSingleNode("rdf:RDF[1]/rdf:Description/prns:numberOfConnections", namespaces).InnerText; } else { count = 1; totalcount = count.ToString(); complete = "true"; } topnode = "<?xml version=\"1.0\"?><PersonList Complete=\"" + complete + "\" ThisCount=\"" + count.ToString() + "\" TotalCount=\"" + totalcount + "\" QueryID=\"" + queryid + "\" xmlns=\"http://connects.profiles.schema/profiles/personlist\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"; returnxml.Append("</PersonList>"); string returnstring = (topnode + returnxml.ToString()).Replace("&", "&"); return returnstring; }
public Connects.Profiles.Service.DataContracts.PersonList ProfileSearch(Connects.Profiles.Service.DataContracts.Profiles qd, bool isSecure) { Connects.Profiles.Service.DataContracts.PersonList pl = null; try { DataIO ps = new DataIO(); XmlDocument searchrequest = new XmlDocument(); Utility.Namespace namespacemgr = new Connects.Profiles.Utility.Namespace(); XmlNamespaceManager namespaces; string responseXML; Connects.Profiles.Service.DataContracts.Profiles p = new Connects.Profiles.Service.DataContracts.Profiles(); string req = Connects.Profiles.Utility.XmlUtilities.SerializeToString(qd); Type type = typeof(Connects.Profiles.Service.DataContracts.PersonList); searchrequest.LoadXml(this.ConvertToRDFRequest(req)); namespaces = namespacemgr.LoadNamespaces(searchrequest); if (qd.QueryDefinition.PersonID!=null) { responseXML = ps.Search(qd.QueryDefinition.PersonID).OuterXml; } else { responseXML = ps.Search(searchrequest,isSecure).OuterXml; } string queryid = string.Empty; string version = string.Empty; bool individual = false; queryid = qd.QueryDefinition.QueryID; version = qd.Version.ToString(); if (qd.QueryDefinition.PersonID != null) individual = true; responseXML = ps.ConvertV2ToBetaSearch(responseXML, queryid, version, individual); pl = Connects.Profiles.Utility.XmlUtilities.DeserializeObject(responseXML, type) as Connects.Profiles.Service.DataContracts.PersonList; } catch (Exception ex) { DebugLogging.Log("ERROR==> " + ex.Message + " STACK:" + ex.StackTrace + " SOURCE:" + ex.Source); } return pl; }