Exemplo n.º 1
0
        /// <summary>
        /// Process the field properties and add it in WITD
        /// </summary>
        /// <param name="witField">Handle to Field instance to process the properties</param>
        /// <param name="cqFieldType">ClearQuest field type</param>
        /// <param name="isUserField">Is it a user field</param>
        private void ProcessFieldProperties(FieldDefinition witField, int cqFieldType, bool isUserField)
        {
            Logger.EnteredMethod(LogSource.CQ, witField);
            switch (CQWrapper.GetEntityFieldRequiredness(cqEntity, witField.OldFieldName))
            {
            case CQConstants.MANDATORY:
            {
                PlainRule pRule = new PlainRule();
                witField.REQUIRED = pRule;
                break;
            }

            case CQConstants.READONLY:
            {
                // PlainRule pRule = new PlainRule();
                // witField.READONLY = pRule;
                string roMsg = UtilityMethods.Format(CQResource.CQ_FLD_READONLY_CHANGED, witField.OldFieldName);
                Logger.Write(LogSource.CQ, TraceLevel.Warning, roMsg);
                ConverterMain.MigrationReport.WriteIssue(String.Empty,
                                                         roMsg, CQWrapper.GetEntityDefName(this.cqEntity), null, IssueGroup.Witd.ToString(), ReportIssueType.Warning);
                break;
            }

            case CQConstants.OPTIONAL:
                // no handling for these behaviors
                break;

            case CQConstants.USEHOOK:
                // no handling for these behaviors
                string hookMsg = UtilityMethods.Format(CQResource.CQ_FLD_SKIP_HOOK, witField.OldFieldName);
                ConverterMain.MigrationReport.WriteIssue(String.Empty,
                                                         hookMsg, CQWrapper.GetEntityDefName(this.cqEntity), null, IssueGroup.Witd.ToString(), ReportIssueType.Warning);
                Logger.Write(LogSource.CQ, TraceLevel.Warning, hookMsg);
                break;
            }

            if (!isUserField)
            {
                int      choiceType = CQWrapper.GetFieldChoiceType(cqEntity, witField.OldFieldName);
                object[] choices    = (object[])CQWrapper.GetFieldChoiceList(cqEntity, witField.OldFieldName);
                ListRule choiceList = null;
                if (choices != null && choices.Length > 0)
                {
                    choiceList = new ListRule();
                    foreach (object ob in choices)
                    {
                        ListItem lItem = new ListItem();
                        lItem.value = (string)ob;
                        choiceList.WITDItems.Add(lItem);
                    }

                    // decide whether its ALLOWED or SUGGESTED list
                    if (choiceType == CQConstants.CLOSED_CHOICE &&
                        cqFieldType != CQConstants.FIELD_MULTILINE_STRING)
                    {
                        witField.ALLOWEDVALUES = choiceList;
                    }
                    else
                    {
                        // since currituck does not allow multi value list, for all such fields
                        // set the List Type to Suggested Values (instead of Allowed Values)
                        witField.SUGGESTEDVALUES = choiceList;
                    }

                    // if there is a field containing any of Suggested/Allowed/Prohibited
                    // values, the fieldtype has to be either string or integer..
                    // as per the CQ-Currituck field mappings, we map Multiline String
                    // to Plain Text..
                    // So if it is niether String nor Integer, Move it to String type..
                    if (witField.type != FieldType.String && witField.type != FieldType.Integer)
                    {
                        Logger.Write(LogSource.CQ, TraceLevel.Warning,
                                     "Converting Field {0} of type {1} to String type",
                                     witField.OldFieldName, witField.type);
                        witField.type = FieldType.String;
                    }
                }
            }

            Logger.ExitingMethod(LogSource.CQ);
        } // end of ProcessFieldProperties