public ObjectTreeElement(IEditorProvider provider, IObjectEditor editor) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } if (editor == null) { throw new ArgumentNullException(nameof(editor)); } Editor = editor; Children = new AsyncValue <IReadOnlyList <ObjectTreeElement> > (QueryChildrenAsync(provider)); string typeName = $"[{Editor.TargetType.Name}]"; Task <string> nameTask; INameableObject nameable = Editor as INameableObject; if (nameable != null) { nameTask = nameable.GetNameAsync().ContinueWith(t => (!String.IsNullOrWhiteSpace(t.Result)) ? $"{typeName} \"{t.Result}\"" : typeName, TaskScheduler.Default); } else { nameTask = Task.FromResult(typeName); } Name = new AsyncValue <string> (nameTask, typeName); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM ITSELF, CREATES STUB OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="NameableCore"/> class. /// </summary> /// <param name="agencyScheme"> /// The itemMutableObject. /// </param> protected internal NameableCore(INameableObject agencyScheme) : base(agencyScheme) { this.name = new List<ITextTypeWrapper>(); this.description = new List<ITextTypeWrapper>(); this.name = agencyScheme.Names; this.ValidateNameableAttributes(); }
/// <summary> /// Insert a record with the values from <paramref name="maintainable" /> to <c>LOCALISED_STRING</c> for an artifact with the specified /// <paramref name="artefactPrimaryKey" /> /// </summary> /// <param name="artefactPrimaryKey">The artifact primary key.</param> /// <param name="maintainable">The maintainable.</param> /// <param name="database">The database.</param> public void InsertForArtefact(long artefactPrimaryKey, INameableObject maintainable, Database database) { using (var dbCommand = _insertLocalisedString.CreateCommand(database)) { _insertLocalisedString.CreateArtIdParameter(dbCommand).Value = artefactPrimaryKey; _insertLocalisedString.CreateItemIdParameter(dbCommand); InsertCommon(maintainable, dbCommand); } }
/// <summary> /// Insert a record with the values from <paramref name="nameableObject" /> to <c>LOCALISED_STRING</c> for an item with the specified /// <paramref name="itemPrimaryKey" /> /// </summary> /// <param name="itemPrimaryKey">The item primary key.</param> /// <param name="nameableObject">The nameable Object.</param> /// <param name="database">The database.</param> public void InsertForItem(long itemPrimaryKey, INameableObject nameableObject, Database database) { using (var dbCommand = _insertLocalisedString.CreateCommand(database)) { _insertLocalisedString.CreateItemIdParameter(dbCommand).Value = itemPrimaryKey; _insertLocalisedString.CreateArtIdParameter(dbCommand); InsertCommon(nameableObject, dbCommand); } }
/// <summary> /// Run common artefact import command. /// </summary> /// <param name="artefact"> /// The artefact. /// </param> /// <param name="command"> /// The command. /// </param> /// <param name="artefactStoredProcedure"> /// The artefact stored procedure. /// </param> /// <returns> /// The <see cref="ArtefactImportStatus"/>. /// </returns> protected long RunNameableArtefactCommand(INameableObject artefact, DbCommand command, ArtefactProcedurebase artefactStoredProcedure) { var artID = this.RunIdentifiableArterfactCommand(artefact, command, artefactStoredProcedure); DbTransactionState state = new DbTransactionState(command.Transaction, this._database); _localisedStringInsertEngine.InsertForArtefact(artID, artefact, state.Database); return(artID); }
private void SetupNode(JsTreeNode node, INameableObject artefact, string defaultString, string format, string TwoLetterISOLanguageName) { string result = TextTypeHelper.GetText(artefact.Names, TwoLetterISOLanguageName); string title = string.Format(format, result.Length == 0 ? TextTypeHelper.GetText(artefact.Descriptions, TwoLetterISOLanguageName) : result); if (string.IsNullOrEmpty(title)) { title = defaultString; } node.text = title; }
/// <summary> /// Get localised name for the specified artefact /// </summary> /// <param name="identifiable"> /// The artefact /// </param> /// <returns> /// The localized name if it exists or the id /// </returns> public static string GetLocalizedName(INameableObject identifiable) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentUICulture; string lang = cultureInfo.TwoLetterISOLanguageName; string ret = TextTypeHelper.GetText(identifiable.Names, lang); if (string.IsNullOrEmpty(ret)) { ret = identifiable.Id; } return(ret); }
/// <summary> /// Assemble SDMX nameable artefact. /// </summary> /// <param name="assembleInto"> /// The assemble into. /// </param> /// <param name="assembleFrom"> /// The assemble from. /// </param> public void AssembleNameable(NameableType assembleInto, INameableObject assembleFrom) { this.AssembleIdentifiable(assembleInto, assembleFrom); IList<ITextTypeWrapper> names = assembleFrom.Names; if (ObjectUtil.ValidCollection(names)) { this.GetTextType(names, assembleInto.Name); } IList<ITextTypeWrapper> descriptions = assembleFrom.Descriptions; if (ObjectUtil.ValidCollection(descriptions)) { this.GetTextType(descriptions, assembleInto.Description); } }
public NameableMutableObjectBaseCore(INameableObject identifiable) : base(identifiable) { this._descriptions = new List<ITextTypeWrapperMutableObject>(); this.names = new List<ITextTypeWrapperMutableObject>(); if (identifiable.Description != null) { foreach (ITextTypeWrapper currentTextType in identifiable .Descriptions) { _descriptions.Add(new TextTypeWrapperMutableCore(currentTextType)); } } if (identifiable.Name != null) { foreach (ITextTypeWrapper currentTextType0 in identifiable.Names) { names.Add(new TextTypeWrapperMutableCore(currentTextType0)); } } }
public string GetNameableDescription(INameableObject nameableObject) { string DefaultDescription = "", LocalizedName = ""; if (nameableObject.Names == null) return ""; foreach (ITextTypeWrapper description in nameableObject.Descriptions) { if (description.Locale == Language) LocalizedName = description.Value; if (description.Locale == _defaultLanguage) DefaultDescription = description.Value; } //return (LocalizedName != "" ? LocalizedName : DefaultDescription); return (LocalizedName != "" ? LocalizedName : string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="NameableMutableCore"/> class. /// </summary> /// <param name="objTarget"> /// The obj target. /// </param> protected NameableMutableCore(INameableObject objTarget) : base(objTarget) { if (objTarget.Name != null) { foreach (ITextTypeWrapper currentTextType in objTarget.Names) { this._names.Add(new TextTypeWrapperMutableCore(currentTextType)); } } if (objTarget.Description != null) { foreach (ITextTypeWrapper currentTextType0 in objTarget.Descriptions) { this._descriptions.Add(new TextTypeWrapperMutableCore(currentTextType0)); } } }
public string GetNameableName(INameableObject nameableObject) { string DefaultName = "", LocalizedName = ""; if (nameableObject.Names == null) return ""; foreach (ITextTypeWrapper name in nameableObject.Names) { if (name.Locale == Language) LocalizedName = name.Value; if (name.Locale == _defaultLanguage) DefaultName = name.Value; } //return (LocalizedName != "" ? LocalizedName : DefaultName); return (LocalizedName != "" ? LocalizedName : string.Empty); }
/// <summary> /// Insert a record with the values from <paramref name="nameableObject"/> to <c>LOCALISED_STRING</c> /// </summary> /// <param name="nameableObject"> /// The nameable object. /// </param> /// <param name="dbCommand"> /// The DB command. /// </param> private static void InsertCommon(INameableObject nameableObject, DbCommand dbCommand) { _insertLocalisedString.CreateOutputParameter(dbCommand); var typeParameter = _insertLocalisedString.CreateTypeParameter(dbCommand); var languageParameter = _insertLocalisedString.CreateLanguageParameter(dbCommand); var textParameter = _insertLocalisedString.CreateTextParameter(dbCommand); typeParameter.Value = LocalisedStringType.Name; foreach (var name in nameableObject.Names) { InsertCommon(name, dbCommand, languageParameter, textParameter); } typeParameter.Value = LocalisedStringType.Desc; foreach (var description in nameableObject.Descriptions) { InsertCommon(description, dbCommand, languageParameter, textParameter); } }
/// <summary> /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c> /// </summary> /// <param name="node"> /// The <see cref="JsTreeNode"/> /// </param> /// <param name="artefact"> /// The <c>IdentifiableArtefactBean</c> /// </param> /// <param name="defaultString"> /// The text to use in case there is no name or description /// </param> /// <param name="format"> /// The format that will be used with <see cref="System.String.Format(string,object)"/> and artefact name or description /// </param> protected static void SetupNode( JsTreeNode node, INameableObject artefact, string defaultString, string format) { string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; /*string result = TextTypeHelper.GetText(artefact.Names, lang); * string title = string.Format(CultureInfo.CurrentCulture, format, result.Length == 0 ? TextTypeHelper.GetText(artefact.Descriptions, lang) : result); * */ string result; string title = ""; if (string.IsNullOrEmpty(title)) { title = defaultString; } ////Data data = new Data { title = title }; ////node.data.Add(data); node.data = title; }
private void SetupNode(JsTreeNode node, INameableObject artefact, string TwoLetterISOLanguageName) { string entitle = artefact.Id; SetupNode(node, artefact, entitle, "{0}", TwoLetterISOLanguageName); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ProcessStepCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="process"> /// The process. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public ProcessStepCore(INameableObject parent, ProcessStepType process) : base(process, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProcessStep), parent) { this.input = new List<IInputOutputObject>(); this.output = new List<IInputOutputObject>(); this.transitions = new List<ITransition>(); this.processSteps = new List<IProcessStepObject>(); if (process.Input != null) { foreach (InputOutputType currentIo in process.Input) { this.input.Add(new InputOutputCore(this, currentIo)); } } if (process.Output != null) { foreach (InputOutputType currentIo0 in process.Output) { this.output.Add(new InputOutputCore(this, currentIo0)); } } if (process.Computation != null) { this.computation = new ComputationCore(this, process.Computation); } if (process.ProcessStep != null) { foreach (ProcessStepType processStep in process.ProcessStep) { this.processSteps.Add(new ProcessStepCore(this, processStep)); } } if (process.Transition != null) { foreach (TransitionType trans in process.Transition) { ITransition transitionCore = new TransitionCore(trans, this); this.transitions.Add(transitionCore); } } try { this.Validate(); } catch (SdmxSemmanticException e) { throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this); } }
/// <summary> /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c> /// </summary> /// <param name="node"> /// The <see cref="JsTreeNode"/> /// </param> /// <param name="artefact"> /// The <c>IdentifiableArtefactBean</c> /// </param> /// <param name="defaultString"> /// The text to use in case there is no name or description /// </param> /// <param name="format"> /// The format that will be used with <see cref="System.String.Format(string,object)"/> and artefact name or description /// </param> protected static void SetupNode( JsTreeNode node, INameableObject artefact, string defaultString, string format) { string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; /*string result = TextTypeHelper.GetText(artefact.Names, lang); string title = string.Format(CultureInfo.CurrentCulture, format, result.Length == 0 ? TextTypeHelper.GetText(artefact.Descriptions, lang) : result); * */ string result; string title=""; if (string.IsNullOrEmpty(title)) { title = defaultString; } ////Data data = new Data { title = title }; ////node.data.Add(data); node.data = title; }
/// <summary> /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c> /// </summary> /// <param name="node"> /// The <see cref="JsTreeNode"/> /// </param> /// <param name="artefact"> /// The <c>IdentifiableArtefactBean</c> /// </param> protected static void SetupNode(JsTreeNode node, INameableObject artefact) { string entitle = artefact.Id; SetupNode(node, artefact, entitle, DefaultFormat1); }
private async Task UpdateMembersAsync(IObjectEditor[] removedEditors = null, IObjectEditor[] newEditors = null) { if (this.objEditors.Count == 0) { ClearMembers(); return; } IObjectEditor editor = this.objEditors[0]; Task <string> nameQuery = null; INameableObject firstNameable = editor as INameableObject; if (this.objEditors.Count == 1) { nameQuery = firstNameable?.GetNameAsync(); } IObjectEventEditor events = editor as IObjectEventEditor; var newEventSet = new HashSet <IEventInfo> (events?.Events ?? Enumerable.Empty <IEventInfo> ()); bool knownProperties = (editor?.KnownProperties?.Count ?? 0) > 0; string newTypeName = editor?.TargetType.Name; var newPropertySet = new HashSet <IPropertyInfo> (editor?.Properties ?? Enumerable.Empty <IPropertyInfo>()); for (int i = 1; i < this.objEditors.Count; i++) { editor = this.objEditors[i]; if (editor == null) { continue; } newPropertySet.IntersectWith(editor.Properties); if (editor is IObjectEventEditor) { events = (IObjectEventEditor)editor; newEventSet.IntersectWith(events.Events); } if (firstNameable == null) { firstNameable = editor as INameableObject; } if (newTypeName != editor.TargetType.Name) { newTypeName = String.Format(PropertyEditing.Properties.Resources.MultipleTypesSelected, this.objEditors.Count); } if (!knownProperties) { knownProperties = (editor.KnownProperties?.Count ?? 0) > 0; } } TypeName = newTypeName; if (knownProperties && this.knownEditors == null) { this.knownEditors = new BidirectionalDictionary <KnownProperty, EditorViewModel> (); } await UpdatePropertiesAsync(newPropertySet, removedEditors, newEditors); EventsEnabled = events != null; UpdateEvents(newEventSet, removedEditors, newEditors); string name = (this.objEditors.Count > 1) ? String.Format(PropertyEditing.Properties.Resources.MultipleObjectsSelected, this.objEditors.Count) : PropertyEditing.Properties.Resources.NoName; if (this.objEditors.Count == 1) { string tname = nameQuery?.Result; if (tname != null) { name = tname; } } SetNameable(firstNameable); SetCurrentObjectName(name, this.objEditors.Count > 1); }
/// <summary> /// Perform a deep equal comparison against <paramref name="nameableObject"/> /// </summary> /// <param name="nameableObject"> /// The maintainable object to compare against /// </param> /// <param name="includeFinalProperties"> /// Set to true to compare final properties. /// These are <see cref="name"/>, <see cref="description"/>. Otherwise those are ignored. /// </param> /// <returns> /// True if the <paramref name="nameableObject"/> deep equals this instance; otherwise false /// </returns> protected internal bool DeepEqualsNameable(INameableObject nameableObject, bool includeFinalProperties) { if (nameableObject == null) { return false; } if (includeFinalProperties) { if (!this.Equivalent(this.name, nameableObject.Names, includeFinalProperties)) { return false; } if (!this.Equivalent(this.description, nameableObject.Descriptions, includeFinalProperties)) { return false; } } return this.DeepEqualsInternal(nameableObject, includeFinalProperties); }
private void SetNameable(INameableObject nameable) { this.nameable = nameable; OnPropertyChanged(nameof(IsObjectNameable)); }
private void SetupNode(JsTreeNode node, INameableObject artefact) { string entitle = artefact.Id; SetupNode(node, artefact, entitle, "{0}"); }
private void UpdateMembers(IObjectEditor[] removedEditors = null, IObjectEditor[] newEditors = null) { if (this.objEditors.Count == 0) { ClearMembers(); return; } Task <string> nameQuery = null; INameableObject firstNameable = this.objEditors[0] as INameableObject; if (this.objEditors.Count == 1) { nameQuery = firstNameable?.GetNameAsync(); } IObjectEventEditor events = this.objEditors[0] as IObjectEventEditor; var newEventSet = new HashSet <IEventInfo> (events?.Events ?? Enumerable.Empty <IEventInfo> ()); string newTypeName = this.objEditors[0]?.TypeName; var newPropertySet = new HashSet <IPropertyInfo> (this.objEditors[0]?.Properties ?? Enumerable.Empty <IPropertyInfo>()); for (int i = 1; i < this.objEditors.Count; i++) { IObjectEditor editor = this.objEditors[i]; newPropertySet.IntersectWith(editor.Properties); if (editor is IObjectEventEditor) { events = (IObjectEventEditor)editor; newEventSet.IntersectWith(events.Events); } if (firstNameable == null) { firstNameable = editor as INameableObject; } if (newTypeName != editor.TypeName) { newTypeName = String.Format(PropertyEditing.Properties.Resources.MultipleTypesSelected, this.objEditors.Count); } } TypeName = newTypeName; UpdateProperties(newPropertySet, removedEditors, newEditors); EventsEnabled = events != null; UpdateEvents(newEventSet, removedEditors, newEditors); string name = (this.objEditors.Count > 1) ? String.Format(PropertyEditing.Properties.Resources.MultipleObjectsSelected, this.objEditors.Count) : PropertyEditing.Properties.Resources.NoName; if (this.objEditors.Count == 1) { string tname = nameQuery?.Result; if (tname != null) { name = tname; } } SetNameable(firstNameable); SetCurrentObjectName(name, this.objEditors.Count > 1); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ProcessStepCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="process"> /// The process. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public ProcessStepCore( INameableObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ProcessStepType process) : base( process, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProcessStep), process.id, default(Uri), process.Name, process.Description, process.Annotations, parent) { this.input = new List<IInputOutputObject>(); this.output = new List<IInputOutputObject>(); this.transitions = new List<ITransition>(); this.processSteps = new List<IProcessStepObject>(); if (process.Input != null) { LOG.Warn("Input items not supported for SDMX V2.0. These items will be discarded"); } if (process.Output != null) { LOG.Warn("Input items not supported for SDMX V2.0. These items will be discarded"); } if (process.Computation != null) { this.computation = new ComputationCore(this, process); } if (process.ProcessStep != null) { foreach ( Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ProcessStepType processStep in process.ProcessStep) { this.processSteps.Add(new ProcessStepCore(this, processStep)); } } if (process.Transition != null) { foreach (Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.TransitionType trans in process.Transition) { ITransition transitionCore = new TransitionCore(trans, this); this.transitions.Add(transitionCore); } } try { this.Validate(); } catch (SdmxSemmanticException e) { throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this); } }