public IDictionary <string, LabelsRoot> BuildEntityLabels() { var resultSet = ExecuteQueryFromResource("EntityLabels.rq"); var rootsByLanguage = new Dictionary <string, LabelsRoot>(); foreach (var language in localizationLanguages) { rootsByLanguage.Add(language, new LabelsRoot { Labels = new Dictionary <string, EntityLabel>() }); } foreach (var group in resultSet.Select(row => (Entity: SerializeUriNode(row["entity"]), Text: ((ILiteralNode)row["label"]).Value, Language: ((ILiteralNode)row["label"]).Language)) .GroupBy(r => r.Entity)) { var entity = group.Key; var labels = group.ToDictionary(r => r.Language, r => r.Text); foreach (var(language, root) in rootsByLanguage) { var label = LanguageUtility.GetTextWithFallback(language, labels); if (!string.IsNullOrEmpty(label)) { root.Labels.Add(entity, new EntityLabel { Label = label }); } } } resultSet = ExecuteQueryFromResource("EntityDescriptions.rq"); foreach (var group in resultSet.Select(row => (Entity: SerializeUriNode(row["entity"]), Text: ((ILiteralNode)row["desc"]).Value, Language: ((ILiteralNode)row["desc"]).Language)) .GroupBy(r => r.Entity)) { var entity = group.Key; var labels = group.ToDictionary(r => r.Language, r => r.Text); foreach (var(language, root) in rootsByLanguage) { var desc = LanguageUtility.GetTextWithFallback(language, labels); if (!string.IsNullOrEmpty(desc)) { if (!root.Labels.TryGetValue(entity, out var label)) { label = new EntityLabel(); root.Labels.Add(entity, label); } label.Description = desc; } } } return(rootsByLanguage); }
public override bool Equals(object obj) { if (ReferenceEquals(obj, this)) { return(true); } if (!(obj is IPersistEntity entity)) { return(false); } return(EntityLabel.Equals(entity.EntityLabel) && Model.Equals(entity.Model)); }
async Task <EntityLabel> EntityLabelCreated(EntityLabel entityLabel) { if (entityLabel == null) { throw new ArgumentNullException(nameof(entityLabel)); } if (entityLabel.EntityId <= 0) { return(entityLabel); } if (entityLabel.LabelId <= 0) { return(entityLabel); } // Get label var label = await _labelStore.GetByIdAsync(entityLabel.LabelId); // No label found no further work needed if (label == null) { return(entityLabel); } // Get total count for entities labeled with this label var entityLabels = await _entityLabelStore.QueryAsync() .Take(1) .Select <EntityLabelQueryParams>(q => { q.LabelId.Equals(label.Id); q.HidePrivate.True(); q.HideHidden.True(); q.HideSpam.True(); q.HideDeleted.True(); }) .ToList(); // Update label label.TotalEntities = entityLabels?.Total ?? 0; label.LastEntityDate = DateTimeOffset.UtcNow; // Persist label updates await _labelManager.UpdateAsync(label); return(entityLabel); }
public override bool Equals(object obj) { if (ReferenceEquals(obj, this)) { return(true); } var entity = obj as IPersistEntity; if (entity == null) { return(false); } return(EntityLabel.Equals(entity.EntityLabel) && Model.Equals(entity.Model)); }
private string GetItemName(KeyValuePair <EntityWrapper, AlertDrawStyle> kv) { string text; Entity itemEntity = kv.Key.GetComponent <WorldItem>().ItemEntity; EntityLabel labelForEntity = GameController.EntityListWrapper.GetLabelForEntity(itemEntity); if (labelForEntity == null) { if (!itemEntity.IsValid) { return(null); } text = kv.Value.Text; } else { text = labelForEntity.Text; } return(text); }
private string GetItemName(KeyValuePair <ExileBot.Entity, AlertDrawStyle> kv) { string text; EntityLabel labelFromEntity = this.poe.GetLabelFromEntity(kv.Key); if (labelFromEntity == null) { Entity itemEntity = kv.Key.GetComponent <WorldItem>().ItemEntity; if (!itemEntity.IsValid) { return(null); } text = kv.Value.Text; } else { text = labelFromEntity.Text; } return(text); }
// Start void Start() { cam = Camera.main; entity = GetComponent<Entity>(); nameLabel = entity.nameLabel; }
private static void UpdateTranslations <TEntity>( DatabaseContext context, List <Language> listLanguages, TEntity entity) where TEntity : EntityTranslation { var entityLabelDefinition = context.EntityLabelDefinition .FirstOrDefault(x => x.Id == entity.EntityLabelDefinition_Id); var translations = context.EntityLabel .Where(x => x.EntityLabelDefinition_Id == entityLabelDefinition.Id) .ToList(); if (!string.IsNullOrWhiteSpace(entity.Translation.NL)) { var language = listLanguages.First(x => x.Id == 1); EntityLabel label; if (translations.Any(x => x.Language_Id == language.Id)) { label = translations.First(x => x.Language_Id == language.Id); label.Label = entity.Translation.NL; label.TrackingState = TrackingState.Modified; context.EntityLabel.Update(label); } else { label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.NL, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } } if (!string.IsNullOrWhiteSpace(entity.Translation.EN)) { var language = listLanguages.First(x => x.Id == 2); EntityLabel label; if (translations.Any(x => x.Language_Id == language.Id)) { label = translations.First(x => x.Language_Id == language.Id); label.Label = entity.Translation.EN; label.TrackingState = TrackingState.Modified; context.EntityLabel.Update(label); } else { label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.EN, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } } if (!string.IsNullOrWhiteSpace(entity.Translation.DE)) { var language = listLanguages.First(x => x.Id == 3); EntityLabel label; if (translations.Any(x => x.Language_Id == language.Id)) { label = translations.First(x => x.Language_Id == language.Id); label.Label = entity.Translation.DE; label.TrackingState = TrackingState.Modified; context.EntityLabel.Update(label); } else { label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.DE, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } } if (!string.IsNullOrWhiteSpace(entity.Translation.FR)) { var language = listLanguages.First(x => x.Id == 4); EntityLabel label; if (translations.Any(x => x.Language_Id == language.Id)) { label = translations.First(x => x.Language_Id == language.Id); label.Label = entity.Translation.FR; label.TrackingState = TrackingState.Modified; context.EntityLabel.Update(label); } else { label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.FR, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } } }
private static void AddNewEntityTranslation <TEntity>( DatabaseContext context, List <Language> listLanguages, TEntity entity, TEntity databaseEntity) where TEntity : EntityTranslation { var entityLabelDefinition = new EntityLabelDefinition { Key = $"{typeof(TEntity).Name.ToLower()}.{StringExtension.GenerateRandomString()}", TrackingState = TrackingState.Added }; context.EntityLabelDefinition.Add(entityLabelDefinition); if (databaseEntity.IsNullOrDefault()) { entity.EntityLabelDefinition = entityLabelDefinition; entity.EntityLabelDefinition_Id = entityLabelDefinition.Id; } else { databaseEntity.EntityLabelDefinition = entityLabelDefinition; databaseEntity.EntityLabelDefinition_Id = entityLabelDefinition.Id; } if (!string.IsNullOrWhiteSpace(entity.Translation.NL)) { var language = listLanguages.First(x => x.Id == 1); var label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.NL, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } if (!string.IsNullOrWhiteSpace(entity.Translation.EN)) { var language = listLanguages.First(x => x.Id == 2); var label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.EN, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } if (!string.IsNullOrWhiteSpace(entity.Translation.DE)) { var language = listLanguages.First(x => x.Id == 3); var label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.DE, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } if (!string.IsNullOrWhiteSpace(entity.Translation.FR)) { var language = listLanguages.First(x => x.Id == 4); var label = new EntityLabel { EntityLabelDefinition_Id = entityLabelDefinition.Id, EntityLabelDefinition = entityLabelDefinition, Language = language, Language_Id = language.Id, Label = entity.Translation.FR, TrackingState = TrackingState.Added }; context.EntityLabel.Add(label); } }
public override int GetHashCode() { //good enough as most entities will be in collections of only one model, equals distinguishes for model return(EntityLabel.GetHashCode()); }
public LayerStylerPerEntity() { UseIfcSubStyles = true; LayerGrouper = new EntityLabel(); }