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); } } }
partial static void CreateCustomDemo(ref ProcessItem customDemoObject);
private static void determineHowToProcessBlobs(CloudBlockBlob[] sourceBlobs, Dictionary<string, ProcessItem> sourceProcessItems, out List<ProcessItem> processItemsToAdd, out List<ProcessItem> processItemsToUpdate, out List<ProcessItem> processItemsToDelete) { string[] validInformationObjectTypes = new string[] { "AaltoGlobalImpact.OIP.TextContent", "AaltoGlobalImpact.OIP.MediaContent", "AaltoGlobalImpact.OIP.Image", "AaltoGlobalImpact.OIP.EmbeddedContent", "AaltoGlobalImpact.OIP.LinkToContent", "AaltoGlobalImpact.OIP.Image" }; processItemsToAdd = new List<ProcessItem>(); processItemsToUpdate = new List<ProcessItem>(); processItemsToDelete = new List<ProcessItem>(); HashSet<string> processedBlobs = new HashSet<string>(); foreach (var sourceBlob in sourceBlobs) { string candidateType = sourceBlob.GetBlobInformationObjectType(); bool continueProcessing = validInformationObjectTypes.Contains(candidateType); if (!continueProcessing) continue; string ownerStrippedName = StorageSupport.RemoveOwnerPrefixIfExists(sourceBlob.Name); processedBlobs.Add(ownerStrippedName); ProcessItem currProcessItem = null; sourceProcessItems.TryGetValue(ownerStrippedName, out currProcessItem); bool isAddingNewItem = false; if (currProcessItem == null) { currProcessItem = new ProcessItem(); currProcessItem.Inputs.Add(new SemanticInformationItem("SourceLocation", ownerStrippedName)); currProcessItem.Inputs.Add(new SemanticInformationItem("InformationObjectType", candidateType)); currProcessItem.Inputs.Add(new SemanticInformationItem("SourceMD5", "")); processItemsToAdd.Add(currProcessItem); sourceProcessItems.Add(ownerStrippedName, currProcessItem); isAddingNewItem = true; } bool sourceChangedSinceProcessing = currProcessItem.GetInputValue("SourceMD5") != sourceBlob.Properties.ContentMD5; if (!sourceChangedSinceProcessing) continue; if(!isAddingNewItem) processItemsToUpdate.Add(currProcessItem); currProcessItem.SetInputValue("SourceMD5", sourceBlob.Properties.ContentMD5); if (candidateType == "AaltoGlobalImpact.OIP.TextContent") { } else if (candidateType == "AaltoGlobalImpact.OIP.MediaContent") { } } var keysToDelete = sourceProcessItems.Keys.Where(key => processedBlobs.Contains(key) == false); processItemsToDelete.AddRange(keysToDelete.Select(key => sourceProcessItems[key])); }
private static void deleteProcessItem(ProcessItem itemToDelete) { try { string informationObjectType = itemToDelete.GetOutputValue("InformationObjectType"); string targetLocation = itemToDelete.GetOutputValue("TargetLocation"); if (string.IsNullOrEmpty(targetLocation)) throw new InvalidDataException("Target location must not be null"); if (informationObjectType != null) { var iObject = StorageSupport.RetrieveInformation(targetLocation, informationObjectType, null, InformationContext.CurrentOwner); iObject.DeleteInformationObject(); } else { StorageSupport.DeleteBlobsFromOwnerTarget(InformationContext.CurrentOwner, targetLocation); } } catch { } }
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; }