/// <summary> /// Retrieves the table alias for the specified path/process. If the collection does not contain an alias for the specified path/process, a new alias is generated. /// </summary> /// <param name="path">The field path.</param> /// <param name="process">The process.</param> /// <returns>The table alias.</returns> public string GetTableAlias(string path, IProcessMetadata process) { if (process == null) throw new ArgumentNullException("process"); return GetTableAlias(path, process.Name); }
public bool Match(IProcessMetadata metadata) { return CChain<bool> .If(() => this.Name == metadata.Name, true, false) .ThenIf(() => this.Description == metadata.Description, true) .ThenIf(() => this.Version == metadata.Version, true) .ThenIf(() => this.Author == metadata.Author, true) .Result; }
/// <summary> /// Initializes a new instance of the <see cref="GenericFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> /// <exception cref="ArgumentException"> /// The <paramref name="editProperty"/> property doesn't have a <see cref="FieldTypeAttribute"/> attribute. /// </exception> public GenericFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var fieldTypeAttribute = editProperty.GetCustomAttribute<FieldTypeAttribute>(false); if (fieldTypeAttribute == null) throw new ArgumentException("FieldType attribute not found."); _columnType = fieldTypeAttribute.ColumnType; }
/// <summary> /// Initializes a new instance of the <see cref="DateTimeFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public DateTimeFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var attribute = editProperty.GetCustomAttribute<DateTimeFormatAttribute>(false); DateTimeFormat format; if (attribute != null && Enum.TryParse(attribute.Value, out format)) { _dateTimeFormat = format; } }
/// <summary> /// Initializes a new instance of the <see cref="DisplayListFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public DisplayListFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var displayListAttribute = editProperty.GetCustomAttribute<DisplayListFieldAttribute>(false); if (displayListAttribute == null) throw new ArgumentException("DisplayListField attribute not found."); _referencedProcess = GetProcess(displayListAttribute.ReferenceTableName); _isSingleItemView = displayListAttribute.IsSingleItemView; }
/// <summary> /// Initializes a new instance of the <see cref="BooleanFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public BooleanFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var isSwitchToggleAttribute = editProperty.GetCustomAttribute<IsSwitchToggleAttribute>(false); _isSwitchToggle = isSwitchToggleAttribute != null && true.Equals(isSwitchToggleAttribute.Value); _undefinedLabelAttribute = editProperty.GetCustomAttribute<UndefinedLabelAttribute>(false); _falseLabelAttribute = editProperty.GetCustomAttribute<FalseLabelAttribute>(false); _trueLabelAttribute = editProperty.GetCustomAttribute<TrueLabelAttribute>(false); _mainLabelAttribute = editProperty.GetCustomAttribute<MainLabelAttribute>(false); }
/// <summary> /// Initializes a new instance of the <see cref="ChecklistFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public ChecklistFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var checklistAttribute = editProperty.GetCustomAttribute<ChecklistFieldAttribute>(false); if (checklistAttribute == null) throw new ArgumentException("ChecklistFieldAttribute not found."); _questionProcess = GetProcess(checklistAttribute.QuestionProcessName); _answerProcess = GetProcess(checklistAttribute.AnswerProcessName); }
/// <summary> /// Initializes a new instance of the <see cref="MultiCrossReferenceFieldMetadata"/> class. /// </summary> /// <param name="declaringType"> /// The declaring type. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> /// <exception cref="ArgumentException"> /// The <paramref name="editProperty"/> property doesn't have a <see cref="CrossRefFieldAttribute"/> attribute. /// </exception> public MultiCrossReferenceFieldMetadata(IProcessMetadata declaringType, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringType, editProperty, infoProperty) { var crAttribute = editProperty.GetCustomAttribute<CrossRefFieldAttribute>(false); if (crAttribute == null) throw new ArgumentException("CrossRefField attribute not found."); if (!string.IsNullOrEmpty(crAttribute.LinkFieldSystemName)) { _linkField = GetFieldFromReferencedProcess<SingleCrossReferenceFieldMetadata>(crAttribute.LinkFieldSystemName); } }
/// <summary> /// Initializes a new instance of the <see cref="ApprovalActionDataContext"/> class. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="actionGuid"> /// The action GUID. /// </param> /// <param name="approvalFieldName"> /// The approval field name. /// </param> /// <exception cref="ArgumentNullException"> /// The <paramref name="process"/> parameter is null. /// </exception> public ApprovalActionDataContext(IProcessMetadata process, Guid actionGuid, string approvalFieldName) { if (process == null) throw new ArgumentNullException("process"); _process = process; _actionGuid = actionGuid; _approvalFieldName = approvalFieldName; _allActionsQuery = new Lazy<QueryDefinition>(GenerateAllActionsQuery, LazyThreadSafetyMode.PublicationOnly); _invalidActionsQuery = new Lazy<QueryDefinition>(GenerateInvalidActionsQuery, LazyThreadSafetyMode.PublicationOnly); }
public void TestInit() { _processRepository = Mock.Create<IProcessMetadataRepository>(Behavior.Loose); _dtm = Mock.Create<IDynamicTypeManager>(Behavior.Loose); _filterManager = Mock.Create<IFilterManager>(Behavior.Loose); _filterMetadataFactory = Mock.Create<IFilterMetadataFactory>(Behavior.Loose); _layoutManager = Mock.Create<ILayoutManager>(Behavior.Loose); _layoutMetadataFactory = Mock.Create<ILayoutMetadataFactory>(Behavior.Loose); _processMetadata = CreateProcess(ProcessName); Mock.Arrange(() => _processMetadata.SupportsStates).Returns(true); Mock.Arrange(() => _processRepository.GetProcessMetadata(ProcessName)).Returns(_processMetadata); }
/// <summary> /// Initializes a new instance of the <see cref="TreeViewFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public TreeViewFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var treeViewAttribute = editProperty.GetCustomAttribute<TreeViewFieldAttribute>(false); if (treeViewAttribute == null) throw new ArgumentException("TreeViewField attribute not found."); _referencedProcess = GetProcess(treeViewAttribute.ReferenceTableName); _displayField = new Lazy<DisplayFieldMetadata>(() => InitializeDisplayField(treeViewAttribute), LazyThreadSafetyMode.PublicationOnly); _detailedViewDisplayFields = new Lazy<ReadOnlyCollection<DisplayFieldMetadata>>( () => InitializeDetailedViewDisplayFields(treeViewAttribute), LazyThreadSafetyMode.PublicationOnly); }
/// <summary> /// Creates a new instance of field metadata for the specified property. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> /// <returns> /// The <see cref="FieldMetadata"/>. /// </returns> public static IFieldMetadata CreateFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) { var fieldTypeAttribute = editProperty.GetCustomAttribute<FieldTypeAttribute>(false); switch (fieldTypeAttribute.ColumnType) { case ColumnTypes.String: return new TextFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Label: return new LabelFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Reference: return new SingleCrossReferenceFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.MultiReference: return new MultiCrossReferenceFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.DateTime: return new DateTimeFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.ReverseReference: return new SingleReverseCrossReferenceFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.ReverseMultiReference: return new MultiReverseCrossReferenceFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Checklist: return new ChecklistFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Boolean: return new BooleanFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Image: return new ImageFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.DisplayList: return new DisplayListFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.TreeView: return new TreeViewFieldMetadata(declaringProcess, editProperty, infoProperty); case ColumnTypes.Double: case ColumnTypes.Integer: case ColumnTypes.Numeric: return new NumericFieldMetadata(declaringProcess, editProperty, infoProperty); default: return new GenericFieldMetadata(declaringProcess, editProperty, infoProperty); } }
public void TestInit() { _dynamicTypeManager = Mock.Create<IDynamicTypeManager>(Behavior.Loose); _filterManager = Mock.Create<IFilterManager>(Behavior.Loose); _layoutManager = Mock.Create<ILayoutManager>(Behavior.Loose); _searchUtils = Mock.Create<ISearchUtils>(Behavior.Loose); _processMetadataRepository = Mock.Create<IProcessMetadataRepository>(Behavior.Loose); _filterDescriptorFactory = Mock.Create<IFilterDescriptorFactory>(Behavior.Loose); _metricsManager = Mock.Create<IMetricsManager>(Behavior.Loose); _kpiManager = Mock.Create<IKPIManager>(Behavior.Loose); _filterRepository = Mock.Create<IFilterRepository>(Behavior.Loose); _processMetadata = Mock.Create<IProcessMetadata>(Behavior.Loose); Mock.Arrange(() => _processMetadata.Name).Returns(ProcessName); Mock.Arrange(() => _processMetadataRepository.GetProcessMetadata(ProcessName)).Returns(_processMetadata); }
/// <summary> /// Initializes a new instance of the <see cref="ApproverRetriever"/> class. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="roleId"> /// The role id. /// </param> /// <param name="memberFieldPath"> /// The member field path. /// </param> /// <param name="businessUnitFieldPath"> /// The business unit field path. /// </param> public ApproverRetriever(IProcessMetadata process, int? roleId, string memberFieldPath, string businessUnitFieldPath, string fieldName, int level, bool useProcess, bool isOverride) { if (process == null) throw new ArgumentNullException("process"); _process = process; _roleId = roleId != 0 ? roleId : null; _memberFieldPath = memberFieldPath; _businessUnitFieldPath = businessUnitFieldPath; _fieldName = fieldName; _level = level; _useProcess = useProcess; _isOverride = isOverride; _queryDefinition = new Lazy<QueryDefinition>(GenerateQuery, LazyThreadSafetyMode.PublicationOnly); }
/// <summary> /// Initializes a new instance of the <see cref="NumericFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public NumericFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var fieldTypeAttribute = editProperty.GetCustomAttribute<FieldTypeAttribute>(false); if (fieldTypeAttribute == null) throw new ArgumentException("FieldType attribute not found."); _columnType = fieldTypeAttribute.ColumnType; var numericAttribute = editProperty.GetCustomAttribute<NumericAttribute>(false); if (numericAttribute != null) { _numericType = numericAttribute.NumericType; _decimalDigits = numericAttribute.NumberOfDigits; } }
/// <summary> /// Initializes a new instance of the <see cref="TextFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public TextFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var textFieldAttribute = editProperty.GetCustomAttribute<TextFieldAttribute>(false); if (textFieldAttribute != null) { _numberOfRows = textFieldAttribute.NumberOfRows; _numberOfCharacters = textFieldAttribute.NumberOfCharacters; if (!string.IsNullOrEmpty(textFieldAttribute.MaskType)) { _maskType = (MaskType)Enum.Parse(typeof(MaskType), textFieldAttribute.MaskType); } _mask = textFieldAttribute.Mask; } _isRichText = Attribute.IsDefined(editProperty, typeof(RichTextAttribute), false); _isLocalizable = Attribute.IsDefined(editProperty, typeof(AllowLocalizedDataAttribute), false); _isLocalizedCopy = Attribute.IsDefined(editProperty, typeof(LocalizedFieldAttribute), false); }
/// <summary> /// Determines if the collection contains an alias for the specified path/process. /// </summary> /// <param name="path">The field path.</param> /// <param name="process">The process.</param> /// <returns><c>true</c> if the collection contains an alias for the specified path/process; otherwise, <c>false</c>.</returns> public bool Contains(string path, IProcessMetadata process) { if (process == null) throw new ArgumentNullException("process"); return Contains(path, process.Name); }
/// <summary> /// Formats the given values assuming that they are in the same order as the column definitions. /// </summary> /// <param name="metadata">The current metadata for the process.</param> /// <param name="values">The values to format.</param> /// <returns>The formatted values.</returns> internal string[] FormatValues(IProcessMetadata metadata, object[] values) { return(FormatValuesBase(metadata, values)); }
/// <summary> /// Creates process metadata. /// </summary> /// <param name="process"> /// The process. /// </param> /// <returns> /// The <see cref="ProcessMetadata"/>. /// </returns> public ProcessMetadata CreateProcessMetadata(IProcessMetadata process) { if (process == null) throw new ArgumentNullException("process"); return new ProcessMetadata { Name = process.Name, DisplayName = process.DisplayName, CanCreate = DynamicTypeManager.CanCreate(process.Name) }; }
/// <summary> /// Creates an approver retriever. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="roleId"> /// The role id. /// </param> /// <param name="membersFieldPath"> /// The members field path. /// </param> /// <param name="businessUnitsFieldPath"> /// The business units field path. /// </param> /// <returns> /// The <see cref="IPersonRetriever"/>. /// </returns> public override IPersonRetriever CreateApproverRetriever(IProcessMetadata process, int? roleId, string membersFieldPath, string businessUnitsFieldPath, string fieldName, int level, bool useProcess, bool isOverride) { return new ApproverRetriever(process, roleId, membersFieldPath, businessUnitsFieldPath, fieldName, level, useProcess, isOverride); }
/// <summary> /// Parses the given values assuming that they are in the same order as the column definitions. /// </summary> /// <param name="metadata">The current metadata for the process.</param> /// <param name="values">The values to parse.</param> /// <returns>The parsed objects.</returns> internal object[] ParseValues(IProcessMetadata metadata, string[] values) { return(ParseValuesBase(metadata, values)); }
/// <summary> /// Initializes a new instance of the <see cref="SingleCrossReferenceFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> /// <exception cref="ArgumentException"> /// The <paramref name="editProperty"/> property doesn't have a <see cref="CrossRefFieldAttribute"/> attribute. /// </exception> public SingleCrossReferenceFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { }
private FilterParameterMetadata CreateParameterMetadata(IProcessMetadata process, FilterValue filterValue, bool includeParameterValues) { if (process.SupportsStates && IsCurrentStateFilter(filterValue)) { return CreateCurrentStateParameter(filterValue, process, includeParameterValues); } var field = FilteringUtils.FindProcessField(process, filterValue.SystemName); return field != null ? CreateParameter(filterValue, field, includeParameterValues) : CreateParameter(filterValue); }
private static FieldMetadata CreateFieldMetadata(IProcessMetadata process, IFieldMetadata field) { return new FieldMetadata { Name = field.Name, DisplayName = field.DisplayName, ColumnType = field.ColumnType, IsHidden = field.IsHiddenInProcess(process), IsHiddenOnDetails = field.IsHiddenOnDetails(process), IsHiddenOnSearch = field.IsHiddenOnSearch(process), IsFilterable = field.IsFilterable, IsGroupable = field.IsGroupable, IsSortable = field.IsSortable }; }
/// <summary> /// Creates an approver retriever. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="roleId"> /// The role id. /// </param> /// <param name="membersFieldPath"> /// The members field path. /// </param> /// <param name="businessUnitsFieldPath"> /// The business units field path. /// </param> /// <returns> /// The <see cref="IPersonRetriever"/>. /// </returns> public abstract IPersonRetriever CreateApproverRetriever(IProcessMetadata process, int? roleId, string membersFieldPath, string businessUnitsFieldPath, string fieldName, int level, bool useProcess, bool isOverride);
/// <summary> /// Gets the collection of values that can be used to filter the specified process by current state GUID. /// </summary> /// <param name="process"> /// The process metadata. /// </param> /// <returns> /// The collection of values. /// </returns> public IEnumerable<FilterMemberValue> GetCurrentStateGuidValues(IProcessMetadata process) { return process.States.Select(s => new FilterMemberValue(s.Name, s.Guid)).OrderBy(x => x.Value).ToList(); }
/// <summary> /// Gets the process field that corresponds to the specified filter parameter. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="parameterName"> /// The parameter name. /// </param> /// <returns> /// The <see cref="IFieldMetadata"/>. /// </returns> public IFieldMetadata FindProcessField(IProcessMetadata process, string parameterName) { IFieldMetadata field; if (process.SupportsStates && IsCurrentState(parameterName)) { return process.TryGetField(Constants.CurrentStateColumnName, out field) ? field : null; } if (process.TryGetField(parameterName, out field)) { return field; } if (parameterName.EndsWith("Id", StringComparison.Ordinal)) { parameterName = parameterName.Remove(parameterName.Length - 2); } return process.TryGetField(parameterName, out field) ? field : null; }
private static IEnumerable<string> GetBaseProcessJoins( string path, IProcessMetadata sourceProcess, IProcessMetadata targetProcess, TableAliasCollection aliasCollection) { var joinList = new List<string>(); while (sourceProcess != targetProcess) { if (sourceProcess.BaseProcess == null) throw new InvalidOperationException("invalid reference"); joinList.Add( string.Format( CultureInfo.InvariantCulture, @"INNER JOIN [dbo].[{0}] {1} ON {1}.[Id] = {2}.[ParentId] AND {1}.[IsRemoved] = 0", sourceProcess.BaseProcess.Name, aliasCollection.GetTableAlias(path, sourceProcess.BaseProcess), aliasCollection.GetTableAlias(path, sourceProcess))); sourceProcess = sourceProcess.BaseProcess; } return joinList; }
public string GetTableAlias(string path, IProcessMetadata process) { var fullName = path + process.Name; return GetTableAlias(fullName); }
/// <summary> /// Creates an approver retriever. /// </summary> /// <param name="process"> /// The process. /// </param> /// <param name="roleId"> /// The role id. /// </param> /// <param name="membersFieldPath"> /// The members field path. /// </param> /// <param name="businessUnitsFieldPath"> /// The business units field path. /// </param> /// <returns> /// The <see cref="IPersonRetriever"/>. /// </returns> public override IPersonRetriever CreateApproverRetriever(IProcessMetadata process, int? roleId, string membersFieldPath, string businessUnitsFieldPath, string fieldName, int level, bool useProcess, bool isOverride) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="LabelFieldMetadata"/> class. /// </summary> /// <param name="declaringProcess"> /// The declaring process. /// </param> /// <param name="editProperty"> /// The editable root property info. /// </param> /// <param name="infoProperty"> /// The info class property info. /// </param> public LabelFieldMetadata(IProcessMetadata declaringProcess, PropertyInfo editProperty, PropertyInfo infoProperty) : base(declaringProcess, editProperty, infoProperty) { var labelFieldAttribute = editProperty.GetCustomAttribute<LabelFieldAttribute>(false); _isHeaderHidden = labelFieldAttribute != null && labelFieldAttribute.IsHeaderHidden; }
public void LogTechnicalDebug(string message, IProcessMetadata metadata = null) => _technicalLogger.Debug(GetMessageWithMetaData(metadata, message));
private FilterParameterMetadata CreateCurrentStateParameter(FilterValue filterValue, IProcessMetadata process, bool includeValues) { var parameter = new FilterParameterMetadata { Name = filterValue.SystemName, DisplayName = filterValue.DisplayName, DefaultValue = filterValue.DefaultValue, DataType = FilterDataType.State }; if (includeValues) { parameter.Values.AddRange( filterValue.SystemName == Constants.CurrentStateGuidColumnName ? FilteringUtils.GetCurrentStateGuidValues(process) : FilteringUtils.GetCurrentStateIdValues(process)); parameter.ValuesSpecified = true; } return parameter; }