/// <summary> /// /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool isContiguous(List <Domain.Attribute> selectedItems) { if (selectedItems.Count == 1) { return(true); } selectedItems.BubbleSort(); Domain.Attribute parent = null; int i = 0; int index = -1; foreach (Domain.Attribute attribute in selectedItems) { Domain.Attribute newparent = attribute.parent; int newindex = newparent != null?newparent.childrenListChangeHandler.Items.IndexOf(attribute) : -1; if (++i > 1) { if (parent != newparent) { return(false); } if (index + 1 != newindex) { return(false); } } parent = newparent; index = newindex; } return(true); }
private void OnPasteClick(object sender, RoutedEventArgs e) { Domain.Attribute parent = GetSelectedValue(); if (parent == null || parent.IsDefault) { parent = this.Root; } List <Domain.Attribute> attributes = Kernel.Util.ClipbordUtil.GetAttributes(); if (attributes != null && attributes.Count > 0) { foreach (Domain.Attribute attribute in attributes) { attribute.name = GetNewAttributeName(attribute.name); ForgetDefaultAttributes(parent); attribute.SetParent(parent); parent.AddChild(attribute); parent.related = true; AddDefaultAttributes(parent); addToSource(attribute); } attributes.Clear(); if (Changed != null) { Changed(); } } }
public List <Domain.Attribute> LoadAttributes(int sourceID) { List <Domain.Attribute> items = new List <Domain.Attribute>(); List <CollectionAttributeDTO> attributeDTOs = _collectionAttributeRepo.GetCollectionAttributes(); foreach (CollectionAttributeDTO dto in attributeDTOs) { List <CollectionAttributeOptionDTO> optionDTOs = _collectionAttributeOptionRepo.GetCollectionAttributeOptions(dto.CollectionAttributeID.Value); List <CollectionAttributeValueDTO> attributeValueDTOs = _collectionAttributeValueRepo.GetCollectionAttributeValues(dto.CollectionAttributeID.Value); Domain.Attribute attribute = new Domain.Attribute(); attribute.AttributeID = dto.CollectionAttributeID; attribute.DataType = (AttributeDataType)Enum.Parse(typeof(AttributeDataType), dto.DataType); attribute.Name = dto.Name; attribute.Options = optionDTOs.Select(x => new AttributeValue() { AttributeOptionID = x.CollectionAttributeOptionID, DefaultValue = x.Value, DisplayOrder = x.DisplayOrder, Label = x.DisplayLabel }).ToList(); attribute.Values = attributeValueDTOs.Select(x => (object)x.Value).ToList(); items.Add(attribute); } return(items); }
/// <summary> /// Remove default nodes from root /// </summary> protected virtual void ForgetDefaultItems(Persistent parent) { if (parent != null) { if (parent is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute)parent; foreach (Target value in attribute.Items.ToArray()) { if (value.IsDefault) { attribute.Items.Remove(value); } } } else if (parent is AttributeValue) { AttributeValue value = (AttributeValue)parent; foreach (Domain.AttributeValue child in value.childrenListChangeHandler.Items.ToArray()) { if (child.IsDefault) { value.childrenListChangeHandler.Items.Remove(child); } } } } }
/// <summary> /// Add default nodes /// </summary> /// <param name="parent"></param> protected virtual void AddDefaultItems(Persistent parent) { if (parent == null || parent.IsDefault) { return; } if (parent.isCompleted && parent.HasMoreElements()) { AttributeValue showModeAttributes = new Domain.AttributeValue(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = SHOW_MORE_LABEL; if (parent is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute)parent; showModeAttributes.attribut = attribute; attribute.Items.Add(showModeAttributes); } else if (parent is AttributeValue) { AttributeValue value = (AttributeValue)parent; showModeAttributes.parent = value; value.childrenListChangeHandler.Items.Add(showModeAttributes); } } }
public void AddDefaultAttributes(Domain.Attribute parent) { Domain.Attribute addNewAttribute = new Kernel.Domain.Attribute(); addNewAttribute.IsAddNewItem = true; addNewAttribute.name = "Add new attribute..."; addNewAttribute.parent = this.Root; this.Root.childrenListChangeHandler.Items.Add(addNewAttribute); if (parent.isCompleted && parent.HasMoreElements()) { Domain.Attribute showModeAttributes = new Domain.Attribute(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = "Show more attribute..."; showModeAttributes.parent = parent; parent.childrenListChangeHandler.Items.Add(showModeAttributes); } if (parent != this.Root && this.Root.isCompleted && this.Root.HasMoreElements()) { Domain.Attribute showModeAttributes = new Domain.Attribute(); showModeAttributes.IsShowMoreItem = true; showModeAttributes.name = "Show more attribute..."; showModeAttributes.parent = this.Root; this.Root.childrenListChangeHandler.Items.Add(showModeAttributes); } }
private void removeFromSource(Domain.Attribute attribute) { Source.Remove(attribute); foreach (Domain.Attribute child in attribute.childrenListChangeHandler.Items) { removeFromSource(child); } }
public void Display(Domain.Attribute attribute) { this.attribute = attribute; this.NameTextBox.Text = attribute.name; this.CanModifyValuesCheckBox.IsChecked = attribute.canUserModifyValues; this.IncrementalValuesCheckBox.IsChecked = attribute.incremental; this.dirty = false; }
private void OnOutdentClick(object sender, RoutedEventArgs e) { List <Domain.Attribute> attributes = GetSelectedValues(); if (attributes.Count == 0) { return; } attributes.BubbleSort(); foreach (Domain.Attribute attribute in attributes) { Domain.Attribute parent = attribute.parent; if (parent == null) { parent = this.Root; } Domain.Attribute grandParent = parent.parent; if (grandParent == null) { return; } ForgetDefaultAttributes(grandParent); parent.ForgetChild(attribute); parent.related = parent.childrenListChangeHandler.Items.Count > 0; grandParent.AddChild(attribute); grandParent.related = true; parent.IsExpanded = true; int row = Source.IndexOf(grandParent); if (row >= 0) { Source.Remove(grandParent); Source.Insert(row, grandParent); } else { row = Source.Count; Source.Remove(attribute); if (row - 2 >= 0) { Source.Insert(row - 2, attribute); } else { Source.Add(attribute); } } AddDefaultAttributes(grandParent); } treeList.RefreshData(); treeList.SelectedItems = attributes; if (Changed != null) { Changed(); } }
private bool IsUsedToGenerateUniverse(Domain.Attribute attribute) { if (this.Entity != null && this.Entity.model != null && this.Entity.usedToGenerateUniverse && this.Entity.model.IsUniverseGenerated() && Kernel.Application.ApplicationManager.Instance.AllocationCount > 0) { string message = "You're not allowed to add a new attribute." + "\n" + "You have to clear allocation before add attribute."; Kernel.Util.MessageDisplayer.DisplayWarning("Add attribute", message); return(true); } return(false); }
public void Display(Domain.Attribute attribute) { this.Attribute = Attribute; this.Title = attribute.name; Filter = new BrowserDataFilter(); Filter.page = 0; Filter.pageSize = BrowserDataFilter.DEFAULT_PAGE_SIZE; Filter.groupOid = attribute.oid.Value; Search(); }
public static string GetDbType(this Domain.Attribute attr) { string result = string.Empty; switch (attr.AttributeTypeName) { case AttributeTypeIds.FLOAT: result = string.Format("{0}(23,10)", AttributeTypeIds.DECIMAL); break; case AttributeTypeIds.NVARCHAR: result = string.Format("{0}({1})", AttributeTypeIds.NVARCHAR, attr.MaxLength); break; case AttributeTypeIds.NTEXT: result = AttributeTypeIds.NVARCHAR + "(MAX)"; //AttributeTypeIds.NTEXT; break; case AttributeTypeIds.VARCHAR: result = string.Format("{0}({1})", AttributeTypeIds.VARCHAR, attr.MaxLength); break; case AttributeTypeIds.CHAR: result = string.Format("{0}({1})", AttributeTypeIds.CHAR, attr.MaxLength); break; case AttributeTypeIds.NCHAR: result = string.Format("{0}({1})", AttributeTypeIds.NCHAR, attr.MaxLength); break; case AttributeTypeIds.PICKLIST: result = AttributeTypeIds.INT; break; case AttributeTypeIds.STATE: result = AttributeTypeIds.INT; break; case AttributeTypeIds.STATUS: result = AttributeTypeIds.INT; break; case AttributeTypeIds.CUSTOMER: case AttributeTypeIds.OWNER: case AttributeTypeIds.PRIMARYKEY: case AttributeTypeIds.LOOKUP: result = AttributeTypeIds.UNIQUEIDENTIFIER; break; default: result = attr.AttributeTypeName; break; } return(result); }
private void OnCellValueChanged(object sender, TreeListCellValueChangedEventArgs e) { if (e.Row != null) { String name = e.Value != null?e.Value.ToString().Trim() : ""; String oldName = e.OldValue != null?e.OldValue.ToString().Trim() : ""; Domain.Attribute attribute = (Domain.Attribute)e.Row; if (!ValidateName(attribute, name)) { attribute.name = oldName; e.Handled = true; return; } if (!name.Equals(oldName.Trim())) { if (attribute.IsDefault) { attribute.name = oldName; Domain.Attribute newAttribute = new Domain.Attribute(); newAttribute.name = name; newAttribute.parent = this.Root; ForgetDefaultAttributes(this.Root); this.Root.AddChild(newAttribute); AddDefaultAttributes(this.Root); int row = Source.Count; if (row > 0) { Source.Insert(row - 1, newAttribute); } else { Source.Add(newAttribute); } SetSelectedValue(newAttribute); } else { attribute.name = name; ForgetDefaultAttributes(attribute.parent); attribute.parent.UpdateChild(attribute); AddDefaultAttributes(attribute.parent); SetSelectedValue(attribute); } if (Changed != null) { Changed(); } } } }
public bool Update(Domain.Attribute entity) { var result = true; using (UnitOfWork.Build(_attributeRepository.DbContext)) { result = _attributeRepository.Update(entity); if (entity.OptionSetId.HasValue && entity.OptionSet != null && !entity.OptionSet.IsPublic) { var details = _optionSetDetailFinder.Query(n => n.Select(f => f.OptionSetDetailId).Where(f => f.OptionSetId == entity.OptionSetId.Value)); foreach (var item in entity.OptionSet.Items) { if (item.OptionSetDetailId.Equals(Guid.Empty)) { item.OptionSetDetailId = Guid.NewGuid(); result = _optionSetDetailCreater.Create(item); } else { result = _optionSetDetailUpdater.Update(item); } } //delete lost var ids = entity.OptionSet.Items.Select(n => n.OptionSetDetailId); var lostid = details.Select(n => n.OptionSetDetailId).Except(ids).ToList(); if (lostid.NotEmpty()) { result = _optionSetDetailDeleter.DeleteById(lostid.ToArray()); } } if (entity.PickLists.NotEmpty())//bit { foreach (var item in entity.PickLists) { if (item.StringMapId.Equals(Guid.Empty)) { result = _stringMapCreater.Create(item); } else { result = _stringMapUpdater.Update(item); } } } //localization _localizedLabelService.Update(entity.LocalizedName.IfEmpty(""), "LocalizedName", entity.AttributeId, this._appContext.BaseLanguage); _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.AttributeId, this._appContext.BaseLanguage); //set to cache var optionSetEntity = _optionSetFinder.FindById(entity.OptionSet.OptionSetId); _cacheService.SetEntity(entity); _cacheServiceOption.RemoveEntity(optionSetEntity); } return(result); }
/// <summary> /// Display children od root node /// </summary> /// <param name="root"> Attribute representing the root node </param> private void DisplayRoot(Domain.Attribute root) { Source = new ObservableCollection <Domain.Attribute>(); this.Root = root; if (this.Root != null) { ForgetDefaultAttributes(this.Root); AddDefaultAttributes(this.Root); RefreshParent(this.Root); } treeList.ItemsSource = Source; }
private void OnPropertiesClick(object sender, RoutedEventArgs e) { if (this.treeList.SelectedItem != null && this.treeList.SelectedItem is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute) this.treeList.SelectedItem; dialog = new AttributeDialog(); dialog.Owner = Application.ApplicationManager.Instance.MainWindow; dialog.Display(attribute); dialog.Changed += OnAttributeDialogChanged; dialog.Show(); } }
/// <summary> /// Load no complete object. /// </summary> /// <param name="parent"></param> protected virtual void Load(Persistent parent) { if (parent == null || parent.IsDefault) { return; } if (!parent.isCompleted && parent.oid.HasValue) { if (parent.DataFilter == null) { parent.DataFilter = new BrowserDataFilter(); parent.DataFilter.groupOid = parent.oid.Value; parent.DataFilter.page = 0; parent.DataFilter.pageSize = PAGE_SIZE; } if (parent is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute)parent; ForgetDefaultItems(attribute); attribute.DataFilter.page++; BrowserDataPage <AttributeValue> page = this.Service.getRootAttributeValuesByAttribute(attribute.DataFilter); attribute.ClearValuesInItems(); foreach (AttributeValue value in page.rows) { value.attribut = attribute; attribute.Items.Add(value); } attribute.isCompleted = true; attribute.DataFilter.page = page.currentPage; attribute.DataFilter.totalPages = page.pageCount; AddDefaultItems(attribute); } else if (parent is AttributeValue) { AttributeValue value = (AttributeValue)parent; ForgetDefaultItems(value); value.DataFilter.page++; BrowserDataPage <AttributeValue> page = this.Service.getAttributeValueChildren(value.DataFilter); value.childrenListChangeHandler.Items.Clear(); foreach (AttributeValue child in page.rows) { child.parent = value; value.childrenListChangeHandler.Items.Add(child); } value.isCompleted = true; value.DataFilter.page = page.currentPage; value.DataFilter.totalPages = page.pageCount; AddDefaultItems(value); } parent.isCompleted = true; } }
/// <summary> /// Can given items be outdent /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool canIndent(List <Domain.Attribute> selectedItems) { foreach (Domain.Attribute attribute in selectedItems) { Domain.Attribute parent = attribute != null ? attribute.parent : null; int index = parent != null?parent.childrenListChangeHandler.Items.IndexOf(attribute) : -1; if (index <= 0) { return(false); } } return(selectedItems.Count > 0); }
public bool CreateBusinessFlowAttributes(Domain.Entity entity) { var existAttributes = _attributeRepository.Query(f => f.EntityId == entity.EntityId && f.Name.In("StageId")); if (existAttributes != null && existAttributes.Count() == 1) { return(true); } var attr = new Domain.Attribute() { AttributeId = Guid.NewGuid(), EntityId = entity.EntityId, Name = "StageId", LocalizedName = _loc["entity_sys_processstage"], AttributeTypeName = AttributeTypeIds.UNIQUEIDENTIFIER, EntityName = entity.Name, IsNullable = true, IsRequired = false, LogEnabled = false, IsCustomizable = false, IsCustomField = false }; return(Create(attr)); }
public static string GetNameField(this Domain.Attribute attr, string alias = "") { if (attr == null) { return(string.Empty); } var field = alias.IsNotEmpty() ? alias : attr.Name; if (attr.TypeIsLookUp() || attr.TypeIsOwner() || attr.TypeIsCustomer() || attr.TypeIsState() || attr.TypeIsBit() || attr.TypeIsPickList() || attr.TypeIsStatus()) { field += "name"; } return(field); }
public AddEdgeViewModel(Attribute attribute) { if (attribute == null) { throw new ArgumentNullException("attribute"); } attribute.IsEditable = true; Attributes = new ChangeTrackingCollection<AttributeWrapper>(new List<AttributeWrapper> { new AttributeWrapper(attribute) }); OkButtonCommand = new DelegateCommand(OkButtonCommandExecute, OkButtonCommandCanExecute); }
private void OnAttributeDialogChanged() { if (dialog.dirty) { Domain.Attribute attribute = dialog.attribute; ForgetDefaultAttributes(attribute.parent); attribute.parent.UpdateChild(attribute); AddDefaultAttributes(attribute.parent); SetSelectedValue(attribute); if (Changed != null) { Changed(); } } }
/// <summary> /// Can given items be move down /// </summary> /// <param name="selectedItems"></param> /// <returns></returns> protected bool canMoveDown(List <Domain.Attribute> selectedItems) { foreach (Domain.Attribute attribute in selectedItems) { Domain.Attribute parent = attribute != null ? attribute.parent : null; int index = parent != null?parent.childrenListChangeHandler.Items.IndexOf(attribute) : -1; int count = parent != null ? parent.childrenListChangeHandler.Items.Count : -1; bool moveDown = count - 1 > index && !parent.childrenListChangeHandler.Items[index + 1].IsDefault; if (!moveDown) { return(false); } } return(selectedItems.Count > 0); }
protected Domain.Attribute GetCopy(Domain.Attribute attribute) { Domain.Attribute copy = new Domain.Attribute(); copy.name = "Copy Of " + attribute.name; copy.IsDefault = false; copy.position = attribute.position; copy.parent = null; foreach (Domain.Attribute child in attribute.childrenListChangeHandler.Items) { Domain.Attribute childcopy = GetCopy(child); copy.AddChild(childcopy); childcopy.parent = null; } return(copy); }
protected String GetNewAttributeName(String name) { Domain.Attribute attribute = new Domain.Attribute(); attribute.name = name; if (Root != null) { Kernel.Domain.Attribute m = (Domain.Attribute)Root.GetChildByName(attribute.name); int i = 1; while (m != null) { attribute.name = name + i++; m = (Domain.Attribute)Root.GetChildByName(attribute.name); } } return(attribute.name); }
protected Domain.Attribute GetNewAttribute() { Domain.Attribute attribute = new Domain.Attribute(); attribute.name = "Attribute"; if (Root != null) { Kernel.Domain.Attribute m = null; int i = 1; do { attribute.name = "Attribute" + i++; m = (Domain.Attribute)Root.GetChildByName(attribute.name); }while (m != null); } return(attribute); }
/// <summary> /// /// </summary> /// <param name="attribute"></param> /// <param name="name"></param> /// <returns>La attribute à copier</returns> private bool ValidateName(Kernel.Domain.Attribute value, string name) { if (string.IsNullOrWhiteSpace(name)) { Kernel.Util.MessageDisplayer.DisplayError("Empty Attribute name", "Name can't be empty! "); return(false); } Domain.Attribute found = getAttributeByName(this.Root, name); if (found == null || found.Equals(value)) { return(true); } Kernel.Util.MessageDisplayer.DisplayError("Duplicate Attribute", "There is another attribute named : '" + name + "'!"); return(false); }
private void OnMove(bool up) { List <Domain.Attribute> attributes = GetSelectedValues(); if (attributes.Count == 0) { return; } if (up) { attributes.BubbleSort(); } else { attributes.BubbleSortDesc(); } foreach (Domain.Attribute attribute in attributes) { Domain.Attribute parent = attribute.parent; if (parent == null) { parent = this.Root; } ForgetDefaultAttributes(parent); int position = attribute.position + (up ? -1 : 1); Domain.Attribute child = (Domain.Attribute)parent.GetChildByPosition(position); if (child != null) { child.SetPosition(attribute.position); parent.UpdateChild(child); attribute.SetPosition(position); parent.UpdateChild(attribute); int row = Source.IndexOf(child); Source.Remove(attribute); Source.Insert(row, attribute); } AddDefaultAttributes(parent); } treeList.SelectedItems = attributes; if (Changed != null) { Changed(); } }
/// <summary> /// Initialize chidren's parent /// </summary> /// <param name="item"></param> public virtual void RefreshParent(Persistent parent) { if (parent is Model) { Model model = (Model)parent; foreach (Entity entity in model.entityListChangeHandler.Items) { entity.model = model; RefreshParent(entity); } } else if (parent is Entity) { Entity entity = (Entity)parent; foreach (Domain.Attribute attribute in entity.attributeListChangeHandler.Items) { attribute.entity = entity; RefreshParent(attribute); } } else if (parent is Domain.Attribute) { Domain.Attribute attribute = (Domain.Attribute)parent; attribute.LoadItems(); foreach (Domain.Attribute child in attribute.childrenListChangeHandler.Items) { child.parent = attribute; RefreshParent(child); } foreach (AttributeValue value in attribute.valueListChangeHandler.Items) { value.attribut = attribute; RefreshParent(value); } } else if (parent is AttributeValue) { AttributeValue value = (AttributeValue)parent; foreach (AttributeValue child in value.childrenListChangeHandler.Items) { child.parent = value; RefreshParent(child); } } }
/// <summary> /// Perform default action /// </summary> /// <param name="action"></param> protected virtual void PerformDefaultAction(Persistent action) { if (action == null || !action.IsShowMoreItem) { return; } if (action is AttributeValue) { AttributeValue selection = (AttributeValue)action; AttributeValue parent = selection.parent; Domain.Attribute attribute = selection.attribut; BrowserDataPage <AttributeValue> page = null; if (parent != null) { ForgetDefaultItems(parent); parent.DataFilter.page++; page = this.Service.getAttributeValueChildren(parent.DataFilter); foreach (AttributeValue value in page.rows) { value.parent = parent; parent.childrenListChangeHandler.Items.Add(value); } parent.isCompleted = true; parent.DataFilter.page = page.currentPage; parent.DataFilter.totalPages = page.pageCount; AddDefaultItems(parent); } else if (attribute != null) { ForgetDefaultItems(attribute); attribute.DataFilter.page++; page = this.Service.getRootAttributeValuesByAttribute(attribute.DataFilter); foreach (AttributeValue value in page.rows) { value.attribut = attribute; attribute.Items.Add(value); } attribute.isCompleted = true; attribute.DataFilter.page = page.currentPage; attribute.DataFilter.totalPages = page.pageCount; AddDefaultItems(attribute); } } }
private void OnDeleteClick(object sender, RoutedEventArgs e) { List <Domain.Attribute> attributes = GetSelectedValues(); if (attributes.Count == 0) { return; } String message = "Do you want to delete Attribute: '" + attributes[0] + "' ?"; if (attributes.Count > 1) { message = "Do you want to delete the " + attributes.Count + " selected attributes ?"; } MessageBoxResult result = Kernel.Util.MessageDisplayer.DisplayYesNoQuestion("Delete Attribute", message); if (result == MessageBoxResult.Yes) { foreach (Domain.Attribute attribute in attributes) { if (IsUsedToGenerateUniverse(attribute)) { return; } Domain.Attribute parent = attribute.parent; ForgetDefaultAttributes(parent); if (attribute.oid.HasValue) { parent.RemoveChild(attribute); } else { parent.ForgetChild(attribute); } parent.related = parent.childrenListChangeHandler.Items.Count > 0; AddDefaultAttributes(parent); removeFromSource(attribute); } if (Changed != null) { Changed(); } } }