/// <summary> /// The function gets all info about profile according to its type and the content of XML file it uses /// </summary> /// <param name="subjectURI">The URI of the subject resource as String</param> /// <param name="profile">Type of profile(full, mini, micro)</param> /// <param name="resultLimit">Max number of results got from queries</param> /// <returns>Object of one of the classes (FullProfile, MiniProfile, MicroProfile)</returns> public Profile ConstructProfile(String subjectURI, choiceProfile profile, int resultLimit = 10) { if (util.isInternalURI(subjectURI)) { subjectURI = util.encodeURI(subjectURI); } subjectURI = useRedirection(subjectURI); if (util.isInternalURI(subjectURI)) { subjectURI = util.encodeURI(subjectURI); } if (profile == choiceProfile.micro) { MicroProfile micro = new MicroProfile(); String abst = getAbstract(subjectURI); micro.IsShortAbstract = false; if (abst != null && abst.Length > 280) { String temp = abst.Substring(279); micro.Abstract = abst.Substring(0, 280 + temp.IndexOf(" ")) + "..."; micro.IsShortAbstract = true; } else { micro.Abstract = abst; } micro.Label = util.getLabel(subjectURI); micro.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.small); micro.URI = subjectURI; return(micro); } else if (profile == choiceProfile.mini) { MiniProfile mini = new MiniProfile(); String abst = getAbstract(subjectURI); mini.IsShortAbstract = false; if (abst != null && abst.Length > 560) { String temp = abst.Substring(559); mini.Abstract = abst.Substring(0, 560 + temp.IndexOf(" ")) + " ..."; mini.IsShortAbstract = true; } else { mini.Abstract = abst; } mini.Label = util.getLabel(subjectURI); mini.URI = subjectURI; mini.Details = setProfileDetails("mini", subjectURI, resultLimit); mini.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.small); return(mini); } else if (profile == choiceProfile.full) { FullProfile full = new FullProfile(); full.Abstract = getAbstract(subjectURI); full.Label = util.getLabel(subjectURI); full.URI = subjectURI; List <String> relations = RelationGenerator.getRelatedEntities(subjectURI); List <Entity> related = new List <Entity>(); for (int i = 0; i < relations.Count; i++) { String rel = relations[i]; if (util.isInternalURI(rel)) { rel = util.encodeURI(rel); } rel = useRedirection(rel); Entity en = new Entity(); en.URI = rel; en.Label = util.getLabel(rel); en.Picture = imageGrapper.get_fb_link(rel, imageGrapper.E.small); related.Add(en); } full.Related = related; full.Details = setProfileDetails("full", subjectURI, resultLimit); full.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.large); full.Location = getLocation(subjectURI); return(full); } return(null); }
/// <summary> /// The function gets all info about profile according to its type and the content of XML file it uses /// </summary> /// <param name="subjectURI">The URI of the subject resource as String</param> /// <param name="profile">Type of profile(full, mini, micro)</param> /// <param name="resultLimit">Max number of results got from queries</param> /// <returns>Object of one of the classes (FullProfile, MiniProfile, MicroProfile)</returns> public Profile ConstructProfile(String subjectURI, choiceProfile profile, int resultLimit = 10) { if (util.isInternalURI(subjectURI)) subjectURI = util.encodeURI(subjectURI); subjectURI = useRedirection(subjectURI); if (util.isInternalURI(subjectURI)) subjectURI = util.encodeURI(subjectURI); if (profile == choiceProfile.micro) { MicroProfile micro = new MicroProfile(); String abst = getAbstract(subjectURI); micro.IsShortAbstract = false; if ( abst != null && abst.Length > 280) { String temp = abst.Substring(279); micro.Abstract = abst.Substring(0, 280 + temp.IndexOf(" ")) + "..."; micro.IsShortAbstract = true; } else micro.Abstract = abst; micro.Label = util.getLabel(subjectURI); micro.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.small); micro.URI = subjectURI; return micro; } else if (profile == choiceProfile.mini) { MiniProfile mini = new MiniProfile(); String abst = getAbstract(subjectURI); mini.IsShortAbstract = false; if (abst != null && abst.Length > 560) { String temp = abst.Substring(559); mini.Abstract = abst.Substring(0, 560 + temp.IndexOf(" ")) + " ..."; mini.IsShortAbstract = true; } else mini.Abstract = abst; mini.Label = util.getLabel(subjectURI); mini.URI = subjectURI; mini.Details = setProfileDetails("mini", subjectURI, resultLimit); mini.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.small); return mini; } else if (profile == choiceProfile.full) { FullProfile full = new FullProfile(); full.Abstract = getAbstract(subjectURI); full.Label = util.getLabel(subjectURI); full.URI = subjectURI; List<String> relations = RelationGenerator.getRelatedEntities(subjectURI); List<Entity> related = new List<Entity>(); for (int i = 0; i < relations.Count; i++) { String rel = relations[i]; if (util.isInternalURI(rel)) rel = util.encodeURI(rel); rel = useRedirection(rel); Entity en = new Entity(); en.URI = rel; en.Label = util.getLabel(rel); en.Picture = imageGrapper.get_fb_link(rel, imageGrapper.E.small); related.Add(en); } full.Related = related; full.Details = setProfileDetails("full", subjectURI, resultLimit); full.Picture = imageGrapper.get_fb_link(subjectURI, imageGrapper.E.large); full.Location = getLocation(subjectURI); return full; } return null; }