internal void WriteEntityAdditionalDescription(Dictionary <Guid, OntologyEntity> entityDictionary, Guid resourceId) { if (entityDictionary != null) { foreach (Guid id in entityDictionary.Keys) { if ((entityDictionary[id].HasAnyPropertyWithData()) || (entityDictionary[id].Entities != null && entityDictionary[id].Entities.Count > 0) && entityDictionary[id].HasRDFTypeAndRDFLabelDefined()) { File.WriteLine($"<rdf:Description rdf:about=\"{GraphsUrl}items/{entityDictionary[id].Items}_{resourceId}_{id}\">"); if (string.IsNullOrWhiteSpace(entityDictionary[id].RdfsLabel) || string.IsNullOrWhiteSpace(entityDictionary[id].RdfType)) { throw new GnossAPIException("rdfType and rdfLabel are required, they can't be null or empty"); } else { Write("rdf:type", entityDictionary[id].RdfType); Write("rdfs:label", entityDictionary[id].RdfsLabel); if (entityDictionary[id].Properties != null) { foreach (OntologyProperty prop in entityDictionary[id].Properties) { if (prop.GetType().Equals(DataTypes.OntologyPropertyImage)) { if (prop.Value.ToString().Contains(Constants.IMAGES_PATH_ROOT)) { prop.Value = prop.Value.ToString().Substring(prop.Value.ToString().LastIndexOf("/") + "/".Length); } prop.Value = GnossHelper.GetImagePath(resourceId, prop.Value.ToString()); } Write(prop.Name, prop.Value, prop.Language); } if (entityDictionary[id].Entities == null || entityDictionary[id].Entities.Count == 0) { File.WriteLine("</rdf:Description>"); } } if (entityDictionary[id].Entities != null && entityDictionary[id].Entities.Count > 0) { Dictionary <Guid, OntologyEntity> dicSubEnt = EntityListToEntityDictionary(entityDictionary[id].Entities); WriteEntityFirstDescription(dicSubEnt, resourceId, true); WriteEntityAdditionalDescription(dicSubEnt, resourceId); } } } } } }
internal override void WritePropertyList(List <OntologyProperty> propertyList, Guid resourceId) { if (propertyList != null) { foreach (OntologyProperty prop in propertyList) { if (!string.IsNullOrWhiteSpace(prop.Name) && prop.Value != null) { if (prop.GetType().Equals(DataTypes.OntologyPropertyImage)) { if (prop.Value.ToString().Contains(Constants.IMAGES_PATH_ROOT)) { prop.Value = prop.Value.ToString().Substring(prop.Value.ToString().LastIndexOf("/") + "/".Length); } prop.Value = GnossHelper.GetImagePath(resourceId, prop.Value.ToString()); } Write(prop.Name, prop.Value, prop.Language); } } } }