示例#1
0
        public static ViewTemplate CreateViewTemplate(MissingInfoConfiguration config, ViewTemplate baseTemplate)
        {
            var template = CreateViewTemplateFromListOfFields(baseTemplate, config.FieldsToShowCommaSeparated, config.FieldsToShowReadOnly);

            //see WS-1120 ([email protected]) Add option to limit "add meanings" task to the ones that have a semantic domain
            //for now, let's just turn off all ghosts in these fill-in tasks
            template.DoWantGhosts = false;

            MarkReadOnlyFields(template, config.FieldsToShowReadOnly);

            //hack until we overhaul how Tasks are setup:
            var isBaseFormFillingTask = config.FieldsToShowCommaSeparated.Contains(LexEntry.WellKnownProperties.BaseForm);

            if (isBaseFormFillingTask)
            {
                Field flagField = new Field();
                flagField.DisplayName = StringCatalog.Get("~&This word has no Base Form",
                                                          "The user will click this to say that this word has no baseform.  E.g. Kindness has Kind as a baseform, but Kind has no other word as a baseform.");
                flagField.DataTypeName = "Flag";
                flagField.ClassName    = "LexEntry";
                flagField.FieldName    = "flag-skip-" + config.MissingInfoFieldName;
                flagField.Enabled      = true;
                template.Add(flagField);
            }
            return(template);
        }
示例#2
0
		public MissingInfoTask(MissingInfoConfiguration config,
							   LexEntryRepository lexEntryRepository,
							   ViewTemplate viewTemplate)
			: base( config, lexEntryRepository)
		{
			if (config.MissingInfoField == null)
			{
				throw new ArgumentNullException("MissingInfoField");
			}
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}

			_missingInfoField = viewTemplate[config.MissingInfoField];

			_viewTemplate = CreateViewTemplateFromListOfFields(viewTemplate, config.FieldsToShow);
			MarkReadOnlyFields(config.FieldsToShowReadOnly);

			//hack until we overhaul how Tasks are setup:
			_isBaseFormFillingTask = config.FieldsToShow.Contains(LexEntry.WellKnownProperties.BaseForm);
			if (_isBaseFormFillingTask)
			{
				Field flagField = new Field();
				flagField.DisplayName = StringCatalog.Get("~This word has no Base Form",
														  "The user will click this to say that this word has no baseform.  E.g. Kindess has Kind as a baseform, but Kind has no other word as a baseform.");
				flagField.DataTypeName = "Flag";
				flagField.ClassName = "LexEntry";
				flagField.FieldName = "flag_skip_" + config.MissingInfoField;
				flagField.Enabled = true;
				_viewTemplate.Add(flagField);
			}
			_writingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem;
			// use the master view Template instead of the one for this task. (most likely the one for this
			// task doesn't have the EntryLexicalForm field specified but the Master (Default) one will
			Field fieldDefn =
				WeSayWordsProject.Project.DefaultViewTemplate.GetField(
					Field.FieldNames.EntryLexicalForm.ToString());
			if (fieldDefn != null)
			{
				if (fieldDefn.WritingSystemIds.Count > 0)
				{
					_writingSystem = BasilProject.Project.WritingSystems[fieldDefn.WritingSystemIds[0]];
				}
				else
				{
					throw new ConfigurationException("There are no writing systems enabled for the Field '{0}'",
													 fieldDefn.FieldName);
				}
			}
		}
示例#3
0
        public MissingInfoTask(MissingInfoConfiguration config,
                               LexEntryRepository lexEntryRepository,
                               ViewTemplate defaultViewTemplate,
                               TaskMemoryRepository taskMemoryRepository)
            : base(config, lexEntryRepository, taskMemoryRepository)
        {
            Guard.AgainstNull(config.MissingInfoFieldName, "MissingInfoFieldName");
            Guard.AgainstNull(defaultViewTemplate, "viewTemplate");
            Debug.Assert(config.WritingSystemsWeWantToFillInArray == null ||
                         config.WritingSystemsWeWantToFillInArray.Length == 0 ||
                         !string.IsNullOrEmpty(config.WritingSystemsWeWantToFillInArray[0]));

            _config     = config;
            _taskMemory = taskMemoryRepository.FindOrCreateSettingsByTaskId(config.TaskName);


            _missingInfoField = defaultViewTemplate[config.MissingInfoFieldName];

            _viewTemplate = config.CreateViewTemplate(defaultViewTemplate);
        }