private void AddWorkflowAux(Workflow workflow, DuplicateMode mode) { if (!workflowStoreAux.ContainsKey(workflow.Id)) { // Add dependencies AddDependencies(workflow, workflow.ScheduledComponents); foreach (Workflow component in workflow.ScheduledComponents.Where(c => c is Workflow wf && wf.IsAuxiliary)) { AddWorkflowAux(component, Replace); } AircadiaProject.workflowStoreAux[workflow.Id] = workflow; OnHandler(WorkflowAuxChanged, workflow); } else if (mode == Replace || (mode == UserDecides && ShowConfirmationMessageBox(workflow))) // Workflow not there or user approves substitution { HashSet <string> affected = GetAffected(workflow); if (affected.Count > 0) { // Relink component RelinkComponent(workflow, affected); } workflowStoreAux[workflow.Id] = workflow; OnHandler(WorkflowAuxChanged, workflow, Updated); } }
private void AddWorkflow(Workflow workflow, DuplicateMode mode) { if (!workflowStore.ContainsKey(workflow.Id)) // Model not there { // Add dependencies AddDependencies(workflow, workflow.ScheduledComponents); foreach (Workflow component in workflow.ScheduledComponents.Where(c => c is Workflow wf && wf.IsAuxiliary)) { AddWorkflowAux(component, Replace); } AircadiaProject.workflowStore[workflow.Id] = workflow; OnHandler(WorkflowChanged, workflow); } else if (mode == Replace || (mode == UserDecides && ShowConfirmationMessageBox(workflow))) { Workflow oldWorkflow = AircadiaProject.workflowStore[workflow.Id]; HashSet <string> affected = GetAffected(workflow); if (affected.Count > 0) { // If there are major changes confirmation is required if (ThereAreMajorChanges(oldWorkflow, workflow)) { if (ShowConfirmationModMessageBox(workflow, affected)) { // Remove dependencies Remove(oldWorkflow, false); // Add new component Add(workflow, Replace); return; } else { // Do not do anything return; } } else { // Relink component RelinkComponent(workflow, affected); } } foreach (Workflow component in oldWorkflow.ScheduledComponents.Where(c => c is Workflow wf && wf.IsAuxiliary)) { RemoveWorkflowAux(component); } foreach (Workflow component in workflow.ScheduledComponents.Where(c => c is Workflow wf && wf.IsAuxiliary)) { AddWorkflowAux(component, Replace); } AircadiaProject.workflowStore[workflow.Id] = workflow; OnHandler(WorkflowAuxChanged, workflow, Updated); } }
private void AddStudy(Study study, DuplicateMode mode) { if (!studyStore.ContainsKey(study.Id)) // Model not there { // Add dependencies AddDependencies(study, study.StudiedComponent); AircadiaProject.studyStore[study.Id] = study; OnHandler(StudyChanged, study, Added); } else if (mode == Replace || (mode == UserDecides && ShowConfirmationMessageBox(study))) { Study oldStudy = AircadiaProject.studyStore[study.Id]; HashSet <string> affected = GetAffected(study); if (affected.Count > 0) { // If there are major changes confirmation is required if (ThereAreMajorChanges(oldStudy, study)) { if (ShowConfirmationModMessageBox(study, affected)) { // Remove dependencies Remove(oldStudy, false); // Add new component Add(study, Replace); return; } else { // Do not do anything return; } } else { // Relink component RelinkStudy(study, affected); } } studyStore[study.Id] = study; OnHandler(StudyChanged, study, Updated); } }
private void AddModel(Model model, DuplicateMode mode) { if (!modelStore.ContainsKey(model.Id)) { // Add dependencies AddDependencies(model, model.GetAllData()); AircadiaProject.modelStore[model.Id] = model; OnHandler(ModelChanged, model); } else if (mode == Replace || (mode == UserDecides && ShowConfirmationMessageBox(model))) { Model oldModel = AircadiaProject.modelStore[model.Id]; HashSet <string> affected = GetAffected(model); if (affected.Count > 0) { // If there are major changes confirmation is required if (ThereAreMajorChanges(oldModel, model)) { if (ShowConfirmationModMessageBox(model, affected)) { // Remove dependencies Remove(oldModel, false); // Add new component Add(model, Replace); return; } else { // Do not do anything return; } } else { // Relink component RelinkComponent(model, affected); } } AircadiaProject.modelStore[model.Id] = model; OnHandler(ModelChanged, model, Updated); } }
private void AddData(Data data, DuplicateMode mode) { if (!AircadiaProject.dataStore.ContainsKey(data.Id)) // Model not there { // Add dependencies AddDependencies(data); AircadiaProject.dataStore[data.Id] = data; OnHandler(DataChanged, data); } else if (mode == Replace || (mode == UserDecides && ShowConfirmationMessageBox(data))) { Data oldData = AircadiaProject.dataStore[data.Id]; HashSet <string> affected = GetAffected(data); if (affected.Count > 0) { // If there are major changes confirmation is required if (ThereAreMajorChanges(oldData, data)) { if (ShowConfirmationModMessageBox(data, affected)) { // Remove dependencies Remove(oldData, false); // Add new component Add(data, Replace); return; } else { // Do not do anything return; } } else { // Relink component RelinkData(data, affected); } } AircadiaProject.dataStore[data.Id] = data; OnHandler(DataChanged, data, Updated); } }
public void Add(AircadiaComponent component, DuplicateMode mode = UserDecides) { if (component is Data data) { if (data.IsAuxiliary) { AddDataAux(data, mode); } else { AddData(data, mode); } } else if (component is Model model) { if (model.IsAuxiliary) { AddModelAux(model, mode); } else { AddModel(model, mode); } } else if (component is Workflow workflow) { if (workflow.IsAuxiliary) { AddWorkflowAux(workflow, mode); } else { AddWorkflow(workflow, mode); } } else if (component is Study study) { AddStudy(study, mode); } }
/// <summary> /// Parses out the Arguments received from the "CLI" /// </summary> /// <param name="args">Array of arguments received from the "CLI"</param> private static void ParseArguments(string[] args) { // Is it Collections or Collections-Mask ? if (args.Where(t => t.Equals(Args.COLLECTIONS_COPY)).FirstOrDefault() != null) { _duplicateMode = DuplicateMode.DuplicateCollections; } else if (args.Where(t => t.Equals(Args.COLLECTIONS_MASK)).FirstOrDefault() != null) { _duplicateMode = DuplicateMode.DuplicateCollectionsWithMask; } else // If no parameter was set (neither "collections" or "collections-mask", aborts) { Console.WriteLine("No 'copy-parameter' received. Expected either : -collections or -collections-mask"); System.Environment.Exit(-102); } // Checking for index-copy parameter _copyIndexes = (args.Where(t => t.Equals(Args.COPY_INDEXES)).FirstOrDefault() != null); // Checking for "DUPLICATION_SUFFIX" parameter if (args.Where(t => t.Equals(Args.DUPLICATION_SUFFIX)).FirstOrDefault() != null) { // Reaching the index of the "Suffix" parameter received int suffixIndex = GetArgumentIndex(args, Args.DUPLICATION_SUFFIX) + 1; // Reading actual "Suffix" received _duplicationSuffix = args[suffixIndex]; } else // If no "Suffix" received, uses the default one { _duplicationSuffix = "_COPY"; } // Parsing the rest of the args based on the ones received switch (_duplicateMode) { // Parsing collection names after the argument case DuplicateMode.DuplicateCollections: // Reading arguments for the collection names int startIndex = GetArgumentIndex(args, Args.COLLECTIONS_COPY) + 1; for (int index = startIndex; index < args.Length; index++) { // Checking whether this argument starts with '-' meaning that it is a parameter, and should not be added to the list of collections if (args[index].StartsWith("-")) { break; } // Adds it to the list of collection names _collections.Value.Add(args[index]); } break; case DuplicateMode.DuplicateCollectionsWithMask: startIndex = GetArgumentIndex(args, Args.COLLECTIONS_MASK); _collections.Value.Add(args[startIndex + 1]); break; } }