BuildOrganizationalItem() public method

public BuildOrganizationalItem ( Tridion.ContentManager.CommunicationManagement tcmStructureGroup ) : Tridion.Extensions.DynamicDelivery.ContentModel.OrganizationalItem
tcmStructureGroup Tridion.ContentManager.CommunicationManagement
return Tridion.Extensions.DynamicDelivery.ContentModel.OrganizationalItem
        public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager, int linkLevels, bool resolveWidthAndHeight)
        {
            Dynamic.Page p = new Dynamic.Page();
            p.Title = tcmPage.Title;
            p.Id = tcmPage.Id.ToString();
            p.Filename = tcmPage.FileName;
            p.PageTemplate = manager.BuildPageTemplate(tcmPage.PageTemplate);
            p.Schema = manager.BuildSchema(tcmPage.MetadataSchema);
            p.Metadata = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
            if (linkLevels > 0) {
                try {
                    if (tcmPage.Metadata != null) {
                        var tcmMetadataFields = new Tridion.ContentManager.ContentManagement.Fields.ItemFields(tcmPage.Metadata, tcmPage.MetadataSchema);
                        p.Metadata = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
                    }
                } catch (ItemDoesNotExistException) {
                    // fail silently if there is no metadata schema
                }
            }

            p.ComponentPresentations = new List<Dynamic.ComponentPresentation>();
            foreach (TCM.ComponentPresentation cp in tcmPage.ComponentPresentations) {
                Dynamic.ComponentPresentation dynCp = manager.BuildComponentPresentation(cp, engine, linkLevels - 1, resolveWidthAndHeight);
                p.ComponentPresentations.Add(dynCp);
            }
            p.StructureGroup = manager.BuildOrganizationalItem((TCM.StructureGroup)tcmPage.OrganizationalItem);
            p.Publication = manager.BuildPublication(tcmPage.ContextRepository);
            p.Categories = manager.BuildCategories(tcmPage);

            return p;
        }
        public static Dynamic.Page BuildPage(TCM.Page tcmPage, Engine engine, BuildManager manager, int linkLevels, bool resolveWidthAndHeight)
        {
            Dynamic.Page p = new Dynamic.Page();
            p.Title        = tcmPage.Title;
            p.Id           = tcmPage.Id.ToString();
            p.Filename     = tcmPage.FileName;
            p.PageTemplate = manager.BuildPageTemplate(tcmPage.PageTemplate);
            p.Schema       = manager.BuildSchema(tcmPage.MetadataSchema);
            p.Metadata     = new Dynamic.SerializableDictionary <string, Dynamic.Field>();
            if (linkLevels > 0)
            {
                try {
                    if (tcmPage.Metadata != null)
                    {
                        var tcmMetadataFields = new Tridion.ContentManager.ContentManagement.Fields.ItemFields(tcmPage.Metadata, tcmPage.MetadataSchema);
                        p.Metadata = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
                    }
                } catch (ItemDoesNotExistException) {
                    // fail silently if there is no metadata schema
                }
            }

            p.ComponentPresentations = new List <Dynamic.ComponentPresentation>();
            foreach (TCM.ComponentPresentation cp in tcmPage.ComponentPresentations)
            {
                Dynamic.ComponentPresentation dynCp = manager.BuildComponentPresentation(cp, engine, linkLevels - 1, resolveWidthAndHeight);
                p.ComponentPresentations.Add(dynCp);
            }
            p.StructureGroup = manager.BuildOrganizationalItem((TCM.StructureGroup)tcmPage.OrganizationalItem);
            p.Publication    = manager.BuildPublication(tcmPage.ContextRepository);
            p.Categories     = manager.BuildCategories(tcmPage);

            return(p);
        }
        public static Dynamic.Schema BuildSchema(TCM.Schema tcmSchema, BuildManager manager)
        {
            if (tcmSchema == null) {
                return null;
            }
            Dynamic.Schema s = new Dynamic.Schema();
            s.Title = tcmSchema.Title;
            s.Id = tcmSchema.Id.ToString();
            s.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmSchema.OrganizationalItem);
            s.Publication = manager.BuildPublication(tcmSchema.ContextRepository);

            return s;
        }
        public static Dynamic.Schema BuildSchema(TCM.Schema tcmSchema, BuildManager manager)
        {
            if (tcmSchema == null)
            {
                return(null);
            }
            Dynamic.Schema s = new Dynamic.Schema();
            s.Title       = tcmSchema.Title;
            s.Id          = tcmSchema.Id.ToString();
            s.Folder      = manager.BuildOrganizationalItem((TCM.Folder)tcmSchema.OrganizationalItem);
            s.Publication = manager.BuildPublication(tcmSchema.ContextRepository);

            return(s);
        }
 public static Dynamic.ComponentTemplate BuildComponentTemplate(TComm.ComponentTemplate tcmComponentTemplate, BuildManager manager)
 {
     Dynamic.ComponentTemplate ct = new Dynamic.ComponentTemplate();
     ct.Title = tcmComponentTemplate.Title;
     ct.Id = tcmComponentTemplate.Id.ToString();
     ct.OutputFormat = tcmComponentTemplate.OutputFormat;
      if (tcmComponentTemplate.Metadata != null && tcmComponentTemplate.MetadataSchema != null)
      {
     ct.MetadataFields = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
     TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponentTemplate.Metadata, tcmComponentTemplate.MetadataSchema);
     ct.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from component templates, never resolve binary widht/height
      }
      else
      {
     ct.MetadataFields = null;
      }
      ct.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmComponentTemplate.OrganizationalItem);
      ct.Publication = manager.BuildPublication(tcmComponentTemplate.ContextRepository);
     return ct;
 }
Example #6
0
 public static Dynamic.ComponentTemplate BuildComponentTemplate(TComm.ComponentTemplate tcmComponentTemplate, BuildManager manager)
 {
     Dynamic.ComponentTemplate ct = new Dynamic.ComponentTemplate();
     ct.Title        = tcmComponentTemplate.Title;
     ct.Id           = tcmComponentTemplate.Id.ToString();
     ct.OutputFormat = tcmComponentTemplate.OutputFormat;
     if (tcmComponentTemplate.Metadata != null && tcmComponentTemplate.MetadataSchema != null)
     {
         ct.MetadataFields = new Dynamic.SerializableDictionary <string, Dynamic.Field>();
         TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponentTemplate.Metadata, tcmComponentTemplate.MetadataSchema);
         ct.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from component templates, never resolve binary widht/height
     }
     else
     {
         ct.MetadataFields = null;
     }
     ct.Folder      = manager.BuildOrganizationalItem((TCM.Folder)tcmComponentTemplate.OrganizationalItem);
     ct.Publication = manager.BuildPublication(tcmComponentTemplate.ContextRepository);
     return(ct);
 }
        public static Dynamic.PageTemplate BuildPageTemplate(TComm.PageTemplate tcmPageTemplate, BuildManager manager)
        {
            Dynamic.PageTemplate pt = new Dynamic.PageTemplate();
            pt.Title = tcmPageTemplate.Title;
            pt.Id = tcmPageTemplate.Id.ToString();
            pt.FileExtension = tcmPageTemplate.FileExtension;

             if (tcmPageTemplate.Metadata != null && tcmPageTemplate.MetadataSchema != null)
             {
            pt.MetadataFields = new Dynamic.SerializableDictionary<string, Dynamic.Field>();
            TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmPageTemplate.Metadata, tcmPageTemplate.MetadataSchema);
            pt.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from page templates, never resolve binary widht/height
             }
             else
             {
            pt.MetadataFields = null;
             }
             pt.Publication = manager.BuildPublication(tcmPageTemplate.ContextRepository);
             pt.Folder = manager.BuildOrganizationalItem((TCM.Folder)tcmPageTemplate.OrganizationalItem);
             return pt;
        }
        public static Dynamic.PageTemplate BuildPageTemplate(TComm.PageTemplate tcmPageTemplate, BuildManager manager)
        {
            Dynamic.PageTemplate pt = new Dynamic.PageTemplate();
            pt.Title         = tcmPageTemplate.Title;
            pt.Id            = tcmPageTemplate.Id.ToString();
            pt.FileExtension = tcmPageTemplate.FileExtension;

            if (tcmPageTemplate.Metadata != null && tcmPageTemplate.MetadataSchema != null)
            {
                pt.MetadataFields = new Dynamic.SerializableDictionary <string, Dynamic.Field>();
                TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmPageTemplate.Metadata, tcmPageTemplate.MetadataSchema);
                pt.MetadataFields = manager.BuildFields(tcmMetadataFields, 0, false); // never follow links to comopnents from page templates, never resolve binary widht/height
            }
            else
            {
                pt.MetadataFields = null;
            }
            pt.Publication = manager.BuildPublication(tcmPageTemplate.ContextRepository);
            pt.Folder      = manager.BuildOrganizationalItem((TCM.Folder)tcmPageTemplate.OrganizationalItem);
            return(pt);
        }
Example #9
0
        public static Dynamic.Component BuildComponent(TCM.Component tcmComponent, int linkLevels, bool resolveWidthAndHeight, BuildManager manager)
        {
            GeneralUtils.TimedLog("start BuildComponent");
            Dynamic.Component c = new Dynamic.Component();
            c.Title = tcmComponent.Title;
            c.Id    = tcmComponent.Id.ToString();
            GeneralUtils.TimedLog("component title = " + c.Title);

            GeneralUtils.TimedLog("start building schema");
            c.Schema = manager.BuildSchema(tcmComponent.Schema);
            GeneralUtils.TimedLog("finished building schema");
            c.ComponentType = (ComponentType)Enum.Parse(typeof(ComponentType), tcmComponent.ComponentType.ToString());

            if (tcmComponent.ComponentType.Equals(TCM.ComponentType.Multimedia))
            {
                GeneralUtils.TimedLog("start building multimedia");
                Multimedia multimedia = new Multimedia();
                multimedia.MimeType = tcmComponent.BinaryContent.MultimediaType.MimeType;
                multimedia.Size     = tcmComponent.BinaryContent.FileSize;
                multimedia.FileName = tcmComponent.BinaryContent.Filename;
                // remove leading dot from extension because microsoft returns this as ".gif"
                multimedia.FileExtension = System.IO.Path.GetExtension(multimedia.FileName).Substring(1);

                if (resolveWidthAndHeight)
                {
                    MemoryStream memstream = new MemoryStream();
                    tcmComponent.BinaryContent.WriteToStream(memstream);
                    Image image = Image.FromStream(memstream);
                    memstream.Close();

                    multimedia.Width  = image.Size.Width;
                    multimedia.Height = image.Size.Height;
                }
                else
                {
                    multimedia.Width  = 0;
                    multimedia.Height = 0;
                }
                c.Multimedia = multimedia;
                GeneralUtils.TimedLog("finished building multimedia");
            }
            else
            {
                c.Multimedia = null;
            }
            c.Fields         = new Dynamic.SerializableDictionary <string, Field>();
            c.MetadataFields = new Dynamic.SerializableDictionary <string, Field>();
            if (linkLevels > 0)
            {
                if (tcmComponent.Content != null)
                {
                    GeneralUtils.TimedLog("start retrieving tcm fields");
                    TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmComponent.Content, tcmComponent.Schema);
                    GeneralUtils.TimedLog("finished retrieving tcm fields");
                    GeneralUtils.TimedLog("start building fields");
                    c.Fields = manager.BuildFields(tcmFields, linkLevels, resolveWidthAndHeight);
                    GeneralUtils.TimedLog("finished building fields");
                }
                if (tcmComponent.Metadata != null)
                {
                    GeneralUtils.TimedLog("start retrieving tcm metadata fields");
                    TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponent.Metadata, tcmComponent.MetadataSchema);
                    GeneralUtils.TimedLog("finished retrieving tcm metadata fields");
                    GeneralUtils.TimedLog("start building metadata fields");
                    c.MetadataFields = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
                    GeneralUtils.TimedLog("finished building metadata fields");
                }
            }



            GeneralUtils.TimedLog("start retrieving tcm publication");
            TCM.Repository pub = tcmComponent.ContextRepository;
            GeneralUtils.TimedLog("finished retrieving tcm publication");
            GeneralUtils.TimedLog("start building publication");
            c.Publication = manager.BuildPublication(pub);
            GeneralUtils.TimedLog("finished building publication");

            GeneralUtils.TimedLog("start retrieving tcm folder");
            TCM.Folder folder = (TCM.Folder)tcmComponent.OrganizationalItem;
            GeneralUtils.TimedLog("finished retrieving tcm folder");
            GeneralUtils.TimedLog("start building folder");
            c.Folder = manager.BuildOrganizationalItem(folder);
            GeneralUtils.TimedLog("finished building folder");
            GeneralUtils.TimedLog("start building categories");
            c.Categories = manager.BuildCategories(tcmComponent);
            GeneralUtils.TimedLog("finished building categories");

            GeneralUtils.TimedLog("finished BuildComponent " + c.Title);

            return(c);
        }
        public static Dynamic.Component BuildComponent(TCM.Component tcmComponent, int linkLevels, bool resolveWidthAndHeight, BuildManager manager)
        {
            GeneralUtils.TimedLog("start BuildComponent");
            Dynamic.Component c = new Dynamic.Component();
            c.Title = tcmComponent.Title;
            c.Id = tcmComponent.Id.ToString();
             GeneralUtils.TimedLog("component title = " + c.Title);

             GeneralUtils.TimedLog("start building schema");
             c.Schema = manager.BuildSchema(tcmComponent.Schema);
             GeneralUtils.TimedLog("finished building schema");
             c.ComponentType = (ComponentType)Enum.Parse(typeof(ComponentType), tcmComponent.ComponentType.ToString());

             if (tcmComponent.ComponentType.Equals(TCM.ComponentType.Multimedia))
             {
            GeneralUtils.TimedLog("start building multimedia");
            Multimedia multimedia = new Multimedia();
            multimedia.MimeType = tcmComponent.BinaryContent.MultimediaType.MimeType;
            multimedia.Size = tcmComponent.BinaryContent.FileSize;
            multimedia.FileName = tcmComponent.BinaryContent.Filename;
            // remove leading dot from extension because microsoft returns this as ".gif"
            multimedia.FileExtension = System.IO.Path.GetExtension(multimedia.FileName).Substring(1);

            if (resolveWidthAndHeight)
            {
               MemoryStream memstream = new MemoryStream();
               tcmComponent.BinaryContent.WriteToStream(memstream);
               Image image = Image.FromStream(memstream);
               memstream.Close();

               multimedia.Width = image.Size.Width;
               multimedia.Height = image.Size.Height;
            }
            else
            {
               multimedia.Width = 0;
               multimedia.Height = 0;
            }
            c.Multimedia = multimedia;
            GeneralUtils.TimedLog("finished building multimedia");
             }
             else
             {
            c.Multimedia = null;
             }
             c.Fields = new Dynamic.SerializableDictionary<string,Field>();
            c.MetadataFields = new Dynamic.SerializableDictionary<string, Field>();
            if (linkLevels > 0) {
            if (tcmComponent.Content != null)
            {
               GeneralUtils.TimedLog("start retrieving tcm fields");
               TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmComponent.Content, tcmComponent.Schema);
               GeneralUtils.TimedLog("finished retrieving tcm fields");
               GeneralUtils.TimedLog("start building fields");
               c.Fields = manager.BuildFields(tcmFields, linkLevels, resolveWidthAndHeight);
               GeneralUtils.TimedLog("finished building fields");
            }
                if (tcmComponent.Metadata != null) {
               GeneralUtils.TimedLog("start retrieving tcm metadata fields");
               TCM.Fields.ItemFields tcmMetadataFields = new TCM.Fields.ItemFields(tcmComponent.Metadata, tcmComponent.MetadataSchema);
               GeneralUtils.TimedLog("finished retrieving tcm metadata fields");
               GeneralUtils.TimedLog("start building metadata fields");
               c.MetadataFields = manager.BuildFields(tcmMetadataFields, linkLevels, resolveWidthAndHeight);
               GeneralUtils.TimedLog("finished building metadata fields");
            }
            }

             GeneralUtils.TimedLog("start retrieving tcm publication");
             TCM.Repository pub = tcmComponent.ContextRepository;
             GeneralUtils.TimedLog("finished retrieving tcm publication");
             GeneralUtils.TimedLog("start building publication");
             c.Publication = manager.BuildPublication(pub);
             GeneralUtils.TimedLog("finished building publication");

             GeneralUtils.TimedLog("start retrieving tcm folder");
             TCM.Folder folder = (TCM.Folder) tcmComponent.OrganizationalItem;
             GeneralUtils.TimedLog("finished retrieving tcm folder");
             GeneralUtils.TimedLog("start building folder");
             c.Folder = manager.BuildOrganizationalItem(folder);
             GeneralUtils.TimedLog("finished building folder");
             GeneralUtils.TimedLog("start building categories");
             c.Categories = manager.BuildCategories(tcmComponent);
             GeneralUtils.TimedLog("finished building categories");

             GeneralUtils.TimedLog("finished BuildComponent " + c.Title);

             return c;
        }