public override void SetDisplayFolder(string folder, Culture culture)
 {
     Hierarchy.SetDisplayFolder(folder, culture);
 }
        public void SetContainer(IEnumerable <IFolderObject> objects, IFolder newContainer, Culture culture)
        {
            if (objects == null)
            {
                throw new ArgumentNullException("objects");
            }
            if (newContainer == null)
            {
                throw new ArgumentNullException("newContainer");
            }
            if (objects.Count() == 0)
            {
                return;
            }
            if (objects.Any(o => o.Table != newContainer.ParentTable))
            {
                throw new ArgumentException("Cannot move objects between tables. To move a measure from one table to another, use method \"MoveObjects\".");
            }

            Handler.BeginUpdate("folder structure change");

            foreach (var obj in objects)
            {
                obj.SetDisplayFolder((newContainer as Folder)?.Path ?? "", culture);
            }

            Handler.EndUpdate();
        }
 public override string GetDisplayFolder(Culture culture)
 {
     return(Hierarchy.GetDisplayFolder(culture));
 }
 private ObjectTranslation GetTrans(Culture culture)
 {
     return(culture.ObjectTranslations[_tabularObject.MetadataObject, _translatedProperty]);
 }
Exemple #5
0
        public static bool ImportTranslations(string culturesJson, Model Model, bool overwriteExisting, bool haltOnError)
        {
            var json     = JObject.Parse(culturesJson);
            var cultures = json["cultures"] as JArray;

            foreach (var cult in cultures)
            {
                var     cultureName = cult.Value <string>("name");
                Culture culture;
                if (Model.Cultures.Contains(cultureName))
                {
                    culture = Model.Cultures[cultureName];
                }
                else
                {
                    culture = new Culture(cultureName);
                    Model.Cultures.Add(culture);
                }

                if (overwriteExisting)
                {
                    // When the user chooses to overwrite existing translations, we simply
                    // delete all translations for the particular culture, to make sure
                    // that only the translations in the Json appear in the model after import.
                    culture.Delete();
                    culture = new Culture(cultureName);
                }

                var trans = cult["translations"];
                var model = trans["model"];

                foreach (var t in model.A("tables"))
                {
                    var tn = t.Value <string>("name");
                    if (Model.Tables.Contains(tn))
                    {
                        ApplyTrans(cultureName, Model.Tables[tn], t, overwriteExisting);
                    }
                    else if (haltOnError)
                    {
                        return(false);
                    }
                    else
                    {
                        continue;
                    }

                    var table = Model.Tables[tn];

                    foreach (var c in t.A("columns"))
                    {
                        var cn = c.Value <string>("name");
                        if (table.Columns.Contains(cn))
                        {
                            ApplyTrans(cultureName, table.Columns[cn], c, overwriteExisting);
                        }
                        else if (haltOnError)
                        {
                            return(false);
                        }
                    }

                    foreach (var m in t.A("measures"))
                    {
                        var mn = m.Value <string>("name");
                        if (table.Measures.Contains(mn))
                        {
                            ApplyTrans(cultureName, table.Measures[mn], m, overwriteExisting);
                        }
                        else if (haltOnError)
                        {
                            return(false);
                        }
                    }

                    foreach (var h in t.A("hierarchies"))
                    {
                        var hn = h.Value <string>("name");
                        if (table.Hierarchies.Contains(hn))
                        {
                            ApplyTrans(cultureName, table.Hierarchies[hn], h, overwriteExisting);
                        }
                        else if (haltOnError)
                        {
                            return(false);
                        }
                        else
                        {
                            continue;
                        }

                        var hierarchy = table.Hierarchies[hn];

                        foreach (var l in h.A("levels"))
                        {
                            var ln = l.Value <string>("name");
                            if (hierarchy.Levels.Contains(ln))
                            {
                                ApplyTrans(cultureName, hierarchy.Levels[ln], l, overwriteExisting);
                            }
                            else if (haltOnError)
                            {
                                return(false);
                            }
                        }
                    }
                }


                foreach (var p in model.A("perspectives"))
                {
                    var pn = p.Value <string>("name");
                    if (Model.Perspectives.Contains(pn))
                    {
                        ApplyTrans(cultureName, Model.Perspectives[pn], p, overwriteExisting);
                    }
                    else if (haltOnError)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
 public bool Contains(Culture culture)
 {
     return(GetTrans(culture) != null);
 }
Exemple #7
0
 public override void SetDisplayFolder(string folder, Culture culture)
 {
     Measure.SetDisplayFolder(folder, culture);
 }
Exemple #8
0
 public override string GetDisplayFolder(Culture culture)
 {
     return(Measure.GetDisplayFolder(culture));
 }
 public static void SetDisplayFolder(this IFolderObject folderObject, string newFolderName, Culture culture)
 {
     if (folderObject is Folder)
     {
         var folder = folderObject as Folder;
         folder.DisplayFolder = newFolderName;
     }
     else
     {
         if (culture == null)
         {
             folderObject.DisplayFolder = newFolderName;
         }
         else
         {
             folderObject.TranslatedDisplayFolders[culture] = newFolderName;
         }
     }
 }
        public static IEnumerable <Folder> GetFolderStack(this IFolderObject folderObject, Culture culture)
        {
            var folder = folderObject.GetFolder(culture);

            while (folder != null && folder.Name != "")
            {
                yield return(folder);

                folder = folder.GetFolder(culture);
            }
        }