private static TextContent getOrCreateInformationObjectsTextContent(Process process, IInformationObject sourceObject)
 {
     var processItems = process.ProcessItems;
     var matchingProcessItem = processItems.FirstOrDefault(processItem => processItem.Inputs.Any(sourceObject.IsObjectsSemanticItem));
     TextContent result = null;
     if (matchingProcessItem != null)
     {
         var matchingOutput = matchingProcessItem.Outputs.FirstOrDefault(semanticItem => semanticItem.ItemFullType == typeof (TextContent).FullName);
         if (matchingOutput != null)
         {
             var textContentLocation = matchingOutput.ItemValue;
             result = TextContent.RetrieveTextContent(textContentLocation, Owner);
         }
         if (result == null)
         {
             processItems.Remove(matchingProcessItem);
             matchingProcessItem = null;
         }
     }
     if(matchingProcessItem == null)
     {
         matchingProcessItem = new ProcessItem();
         matchingProcessItem.Inputs.Add(new SemanticInformationItem(sourceObject));
         TextContent textContent = new TextContent();
         textContent.SetLocationAsOwnerContent(Owner, textContent.ID);
         textContent.GeneratedByProcessID = process.ID;
         matchingProcessItem.Outputs.Add(new SemanticInformationItem(textContent));
         processItems.Add(matchingProcessItem);
         result = textContent;
     }
     return result;
 }
 public static void ExecuteMethod_ExecuteProcess(Process process)
 {
     bool isInitialRun = process.ProcessItems.Count == 0;
     if (isInitialRun)
         performInitialMigration(process);
     else
         performUpdatingMigration(process);
 }
 public static void ExecuteMethod_AddProcessObjectToContainerAndStoreBoth(ProcessContainer ownerProcessContainer, Process process)
 {
     if(ownerProcessContainer.ProcessIDs == null)
         ownerProcessContainer.ProcessIDs = new List<string>();
     ownerProcessContainer.ProcessIDs.Add(process.ID);
     ownerProcessContainer.StoreInformation();
     process.StoreInformation();
 }
 public static void ExecuteMethod_SetContentsAsProcessOutput(Process process, string[] callPickCategorizedContentConnectionOutput)
 {
     /*
      *                 var contentLocation = processItem.Outputs.First(item => item.ItemFullType == "ContentLocation").ItemValue;
         var contentMD5 = processItem.Outputs.First(item => item.ItemFullType == "ContentMD5").ItemValue;
     */
     process.ProcessItems.Clear();
     foreach (string contentLocation in callPickCategorizedContentConnectionOutput)
     {
         bool isMediaContentType = InformationObjectSupport.IsContentGivenType(contentLocation, typeof (MediaContent).FullName);
         if (isMediaContentType)
         {
             string extension = Path.GetExtension(contentLocation);
             string fullLocationWithoutExtension = contentLocation.Substring(0, contentLocation.Length - extension.Length);
             var mediaContentBlobs = InformationContext.CurrentOwner.GetOwnerBlobListing(fullLocationWithoutExtension, true);
             foreach (CloudBlockBlob mediaContentBlob in mediaContentBlobs)
             {
                 SemanticInformationItem semanticItemForLocation = new SemanticInformationItem
                 {
                     ItemFullType = "ContentLocation",
                     ItemValue = mediaContentBlob.Name
                 };
                 SemanticInformationItem semanticItemForMD5 = new SemanticInformationItem
                 {
                     ItemFullType = "ContentMD5",
                     ItemValue = mediaContentBlob.Properties.ContentMD5
                 };
                 ProcessItem processItem = new ProcessItem();
                 processItem.Outputs.Add(semanticItemForLocation);
                 processItem.Outputs.Add(semanticItemForMD5);
                 process.ProcessItems.Add(processItem);
             }
         }
         else
         {
             var blob = StorageSupport.GetOwnerBlobReference(InformationContext.CurrentOwner, contentLocation);
             blob.FetchAttributes();
             SemanticInformationItem semanticItemForLocation = new SemanticInformationItem
                 {
                     ItemFullType = "ContentLocation",
                     ItemValue = contentLocation
                 };
             SemanticInformationItem semanticItemForMD5 = new SemanticInformationItem
                 {
                     ItemFullType = "ContentMD5",
                     ItemValue = blob.Properties.ContentMD5
                 };
             ProcessItem processItem = new ProcessItem();
             processItem.Outputs.Add(semanticItemForLocation);
             processItem.Outputs.Add(semanticItemForMD5);
             process.ProcessItems.Add(processItem);
         }
     }
 }
 public static Process GetTarget_Process(string processDescription, string executingOperationName, SemanticInformationItem[] initialArguments)
 {
     Process process = new Process
         {
             ProcessDescription = processDescription,
             ExecutingOperation = new SemanticInformationItem(executingOperationName, null),
         };
     process.InitialArguments.AddRange(initialArguments);
     process.SetLocationAsOwnerContent(InformationContext.CurrentOwner, process.ID);
     return process;
 }
 public static ContentItemLocationWithMD5[] GetTarget_ContentListingResult(Process packageContentListingProcess)
 {
     List<ContentItemLocationWithMD5> contentList = new List<ContentItemLocationWithMD5>();
     foreach (var processItem in packageContentListingProcess.ProcessItems)
     {
         var contentLocation = processItem.Outputs.First(item => item.ItemFullType == "ContentLocation").ItemValue;
         var contentMD5 = processItem.Outputs.First(item => item.ItemFullType == "ContentMD5").ItemValue;
         contentList.Add(new ContentItemLocationWithMD5
             {
                 ContentLocation = contentLocation,
                 ContentMD5 = contentMD5
             });
     }
     return contentList.ToArray();
 }
 public static void ExecuteMethod_ExecuteAndStoreProcessWithLock(string processLockLocation, Process process)
 {
     string lockEtag;
     bool obtainLock = StorageSupport.AcquireLogicalLockByCreatingBlob(processLockLocation, out lockEtag);
     if (obtainLock == false)
         return;
     try
     {
         string operationTypeName = process.ExecutingOperation.ItemFullType;
         OperationSupport.ExecuteOperation(operationTypeName, new Tuple<string, object>("Process", process));
         process.StoreInformation();
     }
     finally
     {
         StorageSupport.ReleaseLogicalLockByDeletingBlob(processLockLocation, lockEtag);
     }
 }
partial         static void CreateCustomDemo(ref Process customDemoObject);
        public static Process CreateDemoDefault()
        {
            Process customDemo = null;
                    Process.CreateCustomDemo(ref customDemo);
                    if(customDemo != null)
                        return customDemo;
                    var result = new Process();
                    result.ProcessID = @"Process.ProcessID";

                    result.ProcessName = @"Process.ProcessName";

                    result.CategoryCollection = CategoryCollection.CreateDemoDefault();

                    return result;
        }
 public static Process CreateDefault()
 {
     var result = new Process();
             result.CategoryCollection = CategoryCollection.CreateDefault();
             return result;
 }
 public static Connection GetTarget_Connection(Process process)
 {
     string connectionID = process.InitialArguments.First(ia => ia.ItemFullType == "ConnectionID").ItemValue;
     return Connection.RetrieveFromOwnerContent(InformationContext.CurrentOwner, connectionID);
 }
 public static void ExecuteMethod_CallMigrationSupport(Process process, string sourceContentRoot, string targetContentRoot, Dictionary<string, string> categoryMap)
 {
     MigrationSupport.MigrateAaltoGlobalImpactContent(process, sourceContentRoot, targetContentRoot, categoryMap);
 }
 private static void performUpdatingMigration(Process process)
 {
     performInitialMigration(process);
 }
Esempio n. 14
0
 private static Dictionary<string, ProcessItem> getMigrationProcessItemDict(Process process)
 {
     var result = process.ProcessItems
                         .Where(pi => pi.Inputs.FirstOrDefault(inp => inp.ItemFullType == "SourceLocation") != null)
                         .ToDictionary(pi => pi.Inputs.FirstOrDefault(inp => inp.ItemFullType == "SourceLocation").ItemValue, pi => pi);
     return result;
 }
 public static string GetTarget_ConnectionID(Process process)
 {
     string connectionID = process.InitialArguments.First(arg => arg.ItemFullType == "ConnectionID").ItemValue;
     return connectionID;
 }
Esempio n. 16
0
 public static CreateProcessReturnValue Get_ReturnValue(Process process)
 {
     return new CreateProcessReturnValue {CreatedProcess = process};
 }
 public static string GetTarget_ProcessLockLocation(Process process)
 {
     return process.RelativeLocation + ".lock";
 }
 private void CopyContentFrom(Process sourceObject)
 {
     ProcessID = sourceObject.ProcessID;
             ProcessName = sourceObject.ProcessName;
             CategoryCollection = sourceObject.CategoryCollection;
 }
Esempio n. 19
0
        public static void MigrateAaltoGlobalImpactContent(Process process, string sourceContentRoot, string targetContentRoot, Dictionary<string, string> categoryMap)
        {
            if (targetContentRoot != string.Empty && targetContentRoot.EndsWith("/") == false)
                targetContentRoot += "/";
            var owner = InformationContext.CurrentOwner;
            var argDict = process.InitialArguments.ToDictionary(item => item.ItemFullType, item => item.ItemValue);
            string mediaContentFullName = typeof(MediaContent).FullName;
            string processID = process.ID;
            var sourceBlobs = owner.GetOwnerBlobListing(sourceContentRoot, true).Cast<CloudBlockBlob>().ToArray();
            Dictionary<string, ProcessItem> sourceProcessItems = getMigrationProcessItemDict(process);
            List<ProcessItem> processItemsToAdd;
            List<ProcessItem> processItemsToUpdate;
            List<ProcessItem> processItemsToDelete;
            determineHowToProcessBlobs(sourceBlobs, sourceProcessItems, out processItemsToAdd, out processItemsToUpdate, out processItemsToDelete);

            processItemsToDelete.ForEach(itemToDelete =>
                {
                    deleteProcessItem(itemToDelete);
                    process.ProcessItems.Remove(itemToDelete);
                });
            string targetCategoryCollectionLocation = string.Format("{0}AaltoGlobalImpact.OIP/CategoryCollection/MasterCollection",
                                                                    targetContentRoot);
            var targetCategoryCollection = CategoryCollection.RetrieveCategoryCollection(targetCategoryCollectionLocation, owner);
            process.ProcessItems.AddRange(processItemsToAdd);
            var processItemsToProcess = processItemsToAdd.Union(processItemsToUpdate);
            foreach (var processItem in processItemsToProcess)
            {
                string sourceLocation = processItem.GetInputValue("SourceLocation");
                string informationObjectType = processItem.GetInputValue("InformationObjectType");
                string contentMD5 = null;
                string eTag = null;
                List<CloudBlob> storedBlobs = new List<CloudBlob>();
                string targetLocation = null;
                if (informationObjectType != null && informationObjectType != mediaContentFullName)
                {
                    var iObject = StorageSupport.RetrieveInformation(sourceLocation, informationObjectType, null, owner);
                    CloudBlob storedBlob = null;
                    if (iObject is TextContent)
                    {
                        storedBlob = processTextContent((TextContent)iObject, targetContentRoot, categoryMap,
                            targetCategoryCollection, processID);
                    } else if (iObject is LinkToContent)
                    {
                        storedBlob = processLinkToContent((LinkToContent) iObject, targetContentRoot, categoryMap,
                                                          targetCategoryCollection, processID);
                    } else if (iObject is EmbeddedContent)
                    {
                        storedBlob = processEmbeddedContent((EmbeddedContent)iObject, targetContentRoot, categoryMap,
                                                          targetCategoryCollection, processID);
                    }
                    else if (iObject is BinaryFile)
                    {
                        storedBlob = processBinaryContent((BinaryFile)iObject, targetContentRoot, categoryMap,
                                                          targetCategoryCollection, processID);
                    }
                    else if (iObject is Image)
                    {
                        storedBlob = processImageContent((Image)iObject, targetContentRoot, categoryMap,
                                                          targetCategoryCollection, processID);
                    }
                    if (storedBlob != null)
                    {
                        processItem.SetOutputValue("InformationObjectType", informationObjectType);
                        targetLocation = StorageSupport.RemoveOwnerPrefixIfExists(storedBlob.Name);
                        contentMD5 = storedBlob.Properties.ContentMD5;
                        eTag = storedBlob.Properties.ETag;
                        processItem.SetOutputValue("ContentMD5", contentMD5);
                        processItem.SetOutputValue("ETag", eTag);
                        processItem.SetOutputValue("TargetLocation", targetLocation);
                    }
                }
                else if(informationObjectType == mediaContentFullName)
                {
                    string fileNamePart = Path.GetFileName(sourceLocation);
                    string targetBlobPath = StorageSupport.GetOwnerContentLocation(owner,
                                                                                          string.Format("{0}AaltoGlobalImpact.OIP/MediaContent/{1}", targetContentRoot, fileNamePart));
                    var targetBlob = StorageSupport.GetOwnerBlobReference(InformationContext.CurrentOwner, targetBlobPath);
                    var sourceBlob = StorageSupport.GetOwnerBlobReference(InformationContext.CurrentOwner, sourceLocation);
                    targetBlob.CopyFromBlob(sourceBlob);
                    targetLocation = StorageSupport.RemoveOwnerPrefixIfExists(targetBlob.Name);
                    contentMD5 = targetBlob.Properties.ContentMD5;
                    eTag = targetBlob.Properties.ETag;
                    processItem.SetOutputValue("ContentMD5", contentMD5);
                    processItem.SetOutputValue("ETag", eTag);
                    processItem.SetOutputValue("TargetLocation", targetLocation);

                }
            }
        }
 public static void ExecuteMethod_SetConnectionProcesses(Connection connection, Process processToListPackageContents, Process processToProcessReceivedData, Process processToUpdateThisSideCategories)
 {
     connection.ProcessIDToListPackageContents = processToListPackageContents.ID;
     connection.ProcessIDToProcessReceived = processToProcessReceivedData.ID;
     connection.ProcessIDToUpdateThisSideCategories = processToUpdateThisSideCategories.ID;
 }
 private static void performInitialMigration(Process process)
 {
     var argDict = process.InitialArguments.ToDictionary(item => item.ItemFullType, item => item.ItemValue);
     string inputRoot = argDict["InputRoot"];
     string blogFullName = typeof (Blog).FullName;
     var blogs = StorageSupport.CurrActiveContainer
                               .GetInformationObjects(Owner, inputRoot, fullName =>
                                                                        InformationObjectSupport.IsContentGivenType(fullName, blogFullName))
                               .Cast<Blog>();
     string activityFullName = typeof (Activity).FullName;
     var activities = StorageSupport.CurrActiveContainer
                                    .GetInformationObjects(Owner, inputRoot, fullName =>
                                                                             InformationObjectSupport.IsContentGivenType(fullName, activityFullName))
                                    .Cast<Activity>();
     var targetCategoryCollection =
         CategoryCollection.RetrieveFromOwnerContent(Owner, "MasterCollection");
     var targetAddressAndLocationCollection =
         AddressAndLocationCollection.RetrieveFromOwnerContent(Owner, "MasterCollection");
     foreach (var blog in blogs)
     {
         TextContent textContent = getOrCreateInformationObjectsTextContent(process, blog);
         MediaContent blogMediaContent = getBlogMediaContent(blog);
         setTextContentImage(textContent, blogMediaContent);
         textContent.Title = blog.Title;
         textContent.Published = blog.Published;
         textContent.Author = blog.Author;
         textContent.SubTitle = blog.SubTitle;
         textContent.Excerpt = blog.Excerpt;
         textContent.Body = blog.Body;
         textContent.RawHtmlContent = blog.Body;
         textContent.Categories = getCategoriesByTitleFilteringToOne(targetCategoryCollection.CollectionContent,
                                                       blog.CategoryCollection.GetIDSelectedArray());
         textContent.Locations = getLocationsByWhitespaceTrimmedLocationName(targetAddressAndLocationCollection.CollectionContent,
                                                                      blog.LocationCollection.GetIDSelectedArray());
         textContent.StoreInformation();
     }
     foreach (var activity in activities)
     {
         TextContent textContent = getOrCreateInformationObjectsTextContent(process, activity);
         MediaContent activityMediaContent = getActivityMediaContent(activity);
         setTextContentImage(textContent, activityMediaContent);
         textContent.Title = activity.ActivityName;
         textContent.Published = activity.StartingTime;
         textContent.Author = activity.ContactPerson;
         textContent.Excerpt = activity.Excerpt;
         textContent.Body = activity.Description;
         textContent.RawHtmlContent = activity.Description;
         textContent.Categories = getCategoriesByTitleFilteringToOne(targetCategoryCollection.CollectionContent,
                                                       activity.CategoryCollection.GetIDSelectedArray());
         textContent.Locations = getLocationsByWhitespaceTrimmedLocationName(targetAddressAndLocationCollection.CollectionContent,
                                                                      activity.LocationCollection.GetIDSelectedArray());
         textContent.StoreInformation();
     }
 }