예제 #1
0
 public UndoAnnotationAction(IAnnotationObject obj, string annotationName, string newValue, string oldValue)
 {
     Obj           = obj;
     this.name     = annotationName;
     this.newValue = newValue;
     this.oldValue = oldValue;
 }
예제 #2
0
        public void IgnoreRule(BestPracticeRule rule, bool ignore = true, IAnnotationObject obj = null)
        {
            if (obj == null)
            {
                obj = _model;
            }

            var ignoreRules = new AnalyzerIgnoreRules(obj ?? _model);

            if (ignore)
            {
                if (!ignoreRules.RuleIDs.Contains(rule.ID))
                {
                    ignoreRules.RuleIDs.Add(rule.ID);
                }
            }
            else
            {
                if (ignoreRules.RuleIDs.Contains(rule.ID))
                {
                    ignoreRules.RuleIDs.Remove(rule.ID);
                }
            }

            ignoreRules.Save(obj);
        }
예제 #3
0
        public AnalyzerIgnoreRules(IAnnotationObject obj)
        {
            RuleIDs = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            var json = obj.GetAnnotation("BestPracticeAnalyzer_IgnoreRules") ?? obj.GetAnnotation("BestPractizeAnalyzer_IgnoreRules"); // Stupid typo in earlier version

            if (!string.IsNullOrEmpty(json))
            {
                JsonConvert.PopulateObject(json, this);
            }
        }
예제 #4
0
        public void Save(IAnnotationObject obj)
        {
            var model = obj.Model;

            if (model == null)
            {
                return;
            }
            model.Handler.PowerBIGovernance.SuspendGovernance();
            obj.RemoveAnnotation("BestPractizeAnalyzer_IgnoreRules"); // Stupid typo in earlier version
            obj.SetAnnotation(Analyzer.BPAAnnotationIgnore, JsonConvert.SerializeObject(this));
            model.Handler.PowerBIGovernance.ResumeGovernance();
            model.Handler.UndoManager.FlagChange();
        }
예제 #5
0
        public static bool CheckFlag(this IAnnotationObject obj, string annotationName)
        {
            if (!obj.HasAnnotation(annotationName))
            {
                return(false);
            }

            var value = obj.GetAnnotation(annotationName);

            if (value == "0" || value.EqualsI("false") || value.EqualsI("no"))
            {
                return(false);
            }

            return(true);
        }
        public static void ClearTabularEditorAnnotations(this IAnnotationObject obj, bool includeChildren = false)
        {
            obj.RemoveAnnotation("TabularEditor_TranslatedNames", false);
            obj.RemoveAnnotation("TabularEditor_TranslatedDescriptions", false);
            obj.RemoveAnnotation("TabularEditor_TranslatedDisplayFolders", false);
            obj.RemoveAnnotation("TabularEditor_InPerspective", false);
            obj.RemoveAnnotation("TabularEditor_RLS", false);
            obj.RemoveAnnotation("TabularEditor_OLS", false);

            if (includeChildren && obj is ITabularObjectContainer)
            {
                foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <IAnnotationObject>())
                {
                    child.ClearTabularEditorAnnotations(true);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Removes all annotations from the model, that are used by Tabular Editor to serialize metadata in a way different from the TOM. For example,
        /// to store object translations as annotations on the object instead of elsewhere in the TOM tree. All these annotations can be recreated from
        /// the TOM.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="includeChildren"></param>
        public static void ClearTabularEditorAnnotations(this IAnnotationObject obj, bool includeChildren = false)
        {
            obj.RemoveAnnotation(ANN_NAMES, false);
            obj.RemoveAnnotation(ANN_DESCRIPTIONS, false);
            obj.RemoveAnnotation(ANN_DISPLAYFOLDERS, false);
            obj.RemoveAnnotation(ANN_INPERSPECTIVE, false);
            obj.RemoveAnnotation(ANN_RLS, false);
            obj.RemoveAnnotation(ANN_OLS, false);

            obj.RemoveAnnotation(ANN_RELATIONSHIPS, false);

            if (includeChildren && obj is ITabularObjectContainer)
            {
                foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <IAnnotationObject>())
                {
                    child.ClearTabularEditorAnnotations(true);
                }
            }
        }
예제 #8
0
 public void Save(IAnnotationObject obj)
 {
     obj.RemoveAnnotation("BestPractizeAnalyzer_IgnoreRules"); // Stupid typo in earlier version
     obj.SetAnnotation("BestPracticeAnalyzer_IgnoreRules", JsonConvert.SerializeObject(this), false);
 }
예제 #9
0
 public void Save(IAnnotationObject obj)
 {
     obj.RemoveAnnotation("BestPractizeAnalyzer_IgnoreRules"); // Stupid typo in earlier version
     obj.SetAnnotation(Analyzer.BPAAnnotationIgnore, JsonConvert.SerializeObject(this));
     UI.UIController.Current.Handler.UndoManager.FlagChange();
 }
예제 #10
0
 internal AnnotationCollection(IAnnotationObject parent)
 {
     Parent = parent;
 }