private static Tuple<string, List<Category>, List<MediaContent>> getTextContentTuple(TextContent textContent)
 {
     List<MediaContent> mediaContents = new List<MediaContent>();
     if(textContent.ImageData != null)
         mediaContents.Add(textContent.ImageData);
     return new Tuple<string, List<Category>, List<MediaContent>>(textContent.RelativeLocation,
         textContent.Categories != null ? textContent.Categories.CollectionContent : new List<Category>(),
         mediaContents);
 }
 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;
 }
Пример #3
0
 private static CloudBlob processTextContent(TextContent textContent, string targetContentRootLocation, Dictionary<string, string> categoryMap, CategoryCollection targetCategoryCollection, string processID)
 {
     var owner = InformationContext.CurrentOwner;
     var sourceCategories = textContent.Categories;
     var targetItemCategories = GetTargetItemCategories(sourceCategories, targetCategoryCollection, categoryMap);
     textContent.Categories = targetItemCategories;
     textContent.RelativeLocation = StorageSupport.GetOwnerContentLocation(owner,
                                                                           string.Format("{0}AaltoGlobalImpact.OIP/TextContent/{1}", targetContentRootLocation, textContent.ID));
     textContent.GeneratedByProcessID = processID;
     if (textContent.ImageData != null)
     {
         textContent.ImageData.FixCurrentOwnerLocation();
     }
     if(textContent.Locations != null)
         textContent.Locations.CollectionContent.ForEach(location => location.FixCurrentOwnerLocation());
     var storedBlob = textContent.StoreInformationMasterFirst(owner, true, overwriteIfExists: true);
     return storedBlob;
 }
 private static void setTextContentImage(TextContent textContent, MediaContent legacyContent)
 {
     var owner = VirtualOwner.FigureOwner(textContent);
     var existingImageData = textContent.ImageData;
     if (existingImageData != null && legacyContent != null)
     {
         // If actual content is equal, return without doing anything
         if(existingImageData.GetMD5FromStorage() == legacyContent.GetMD5FromStorage())
             return;
         var legacyData = legacyContent.GetContentData();
         if (legacyData == null)
         {
             existingImageData.ClearCurrentContent(owner);
             textContent.ImageData = null;
             return;
         }
         string fileNameWithExtension = "data" + legacyContent.FileExt;
         existingImageData.SetMediaContent(fileNameWithExtension,
             legacyContent.GetContentData());
     }
     if (existingImageData != null && legacyContent == null)
     {
         existingImageData.ClearCurrentContent(owner);
         textContent.ImageData = null;
         return;
     }
     if (existingImageData == null && legacyContent != null)
     {
         var legacyData = legacyContent.GetContentData();
         if (legacyData == null)
             return;
         string fileNameWithExtension = "data" + legacyContent.FileExt;
         var newImageData = new MediaContent();
         newImageData.SetLocationAsOwnerContent(owner, newImageData.ID);
         newImageData.SetMediaContent(fileNameWithExtension,
             legacyContent.GetContentData());
         textContent.ImageData = newImageData;
     }
 }