protected override void InitValue(TargetDocument obj)
 {
     if (obj.ContainsPath(new Path(_from)))
     {
         this.Value = obj[new Path(_from)];
     }
 }
        public override Boolean Execute(TargetDocument obj)
        {
            obj.RemoveProperty(Path);

            obj.CreateOrUpdateProperty(Path,Value, true);

            return true;
        }
예제 #3
0
        private void ApplySubStructureReplacements(TargetDocument targetDocument)
        {
            var substructure = GetSupportedSubStructureTargets().ToArray();

            foreach (var saetning in substructure)
            {
                var targetStructure = GetTargetStructureForSubstructureChange(targetDocument, saetning);
            }
        }
예제 #4
0
        private static object[] GetWebBasedSample(string legalRessource)
        {
            var qs         = new RdfBasedLegalDocumentLoader().Load(legalRessource);
            var docType    = qs.GetDocType();
            var components = legalRessource.Split('/');
            var number     = int.Parse(components.Last());
            var year       = int.Parse(components[components.Length - 2]);
            var target     = new TargetDocument(new Uri($"{legalRessource}/xml"), docType, year, number);

            return(new object[] { target, qs.GetChangeDocuments(), XDocument.Load($"{qs.GetLaterConsolidationUri()}/xml") });
        }
        public override Boolean Execute(TargetDocument obj)
        {
            if (obj.ContainsPath(Path))
            {
                Object valueToTest = obj[Path];

                return valueToTest.Equals(ExpectedResult);
            }

            return false;
        }
        public override Boolean Execute(TargetDocument obj)
        {
            if (obj.ContainsPath(new Path(_from)))
            {
                //remove the property
                obj.RemoveProperty(new Path(_from));
                //add the new one
                obj.CreateOrUpdateProperty(Path, Value, true);
            }

            return true;
        }
 public override Boolean Execute(TargetDocument obj)
 {
     if (Value != null)
     {
         obj.CreateOrUpdateProperty(Path, obj[Path].ToString() + Value.ToString(), true);
         return true;
     }
     else
     {
         obj.CreateOrUpdateProperty(Path, obj[Path].ToString() + obj[ValueOf].ToString(), true);
         return true;
     }
 }
예제 #8
0
        public void Patch(TargetDocument targetDocument, ChangeDocument[] changes)
        {
            var chronologicalOrder = changes
                                     .OrderBy(change => change.Year)
                                     .ThenBy(change => change.Number)
                                     .Select(change => new { change, RelevantChanges = FindRelevantChanges(targetDocument, change) })
                                     .ToArray();

            foreach (var change in chronologicalOrder)
            {
                ApplyChange(change.RelevantChanges, targetDocument);
            }
        }
        protected override void ProcessRecord()
        {
            var targetdoc = new TargetDocument(this.Document);

            if (this.Filename != null)
            {
                this.Client.Document.SaveDocumentAs(targetdoc, this.Filename);
            }
            else
            {
                this.Client.Document.SaveDocument(targetdoc);
            }
        }
예제 #10
0
        private void ApplyStructureReplacments(TargetDocument targetDocument)
        {
            var elementsToReplace = FindStructureElementsInTargetDocument(targetDocument, AendringDefinition.StructureTargets);

            if (!elementsToReplace?.Any() ?? false)
            {
                return;
            }
            var replacement = GetAendringAktionStructures();

            elementsToReplace.Skip(1).Remove();
            elementsToReplace.First().ReplaceWith(replacement);
        }
 public override Boolean Execute(TargetDocument obj)
 {
     //according to RFC 6902 if the path does not exists than the operation fails
     if (obj.ContainsPath(Path))
     {
         obj.RemoveProperty(Path);
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #12
0
        public Boolean Apply(TargetDocument obj)
        {
            InitValue(obj);

            if (Converter != null)
            {
                Value = Converter.Convert(Value);
            }

            Boolean result = Execute(obj);

            return result;
        }
예제 #13
0
        //Herved bekendtgøres økologiloven, jf. lovbekendtgørelse nr. 196 af 12. marts 2009, med de ændringer, der følger af § 7 i lov nr. 341 af 27. april 2011.
        //Herved bekendtgøres økologiloven, lov nr. 463 af 17. juni 2008, med de ændringer, der følger af § 70 i lov nr. 1336 af 19. december 2008.
        public void Patch(TargetDocument targetDocument, ChangeDocument[] changes)
        {
            var name                       = "økologiloven";
            var docDescription             = "lov nr. 463 af 17. juni 2008";
            var aendringsParagrafReference = "§ 70";
            var changeDocDescription       = "lov nr. 1336 af 19. december 2008";
            var template                   = $"Herved bekendtgøres {name}, {docDescription}, med de ændringer, der følger af {aendringsParagrafReference} i {changeDocDescription}.";

            var dokumentIndhold = targetDocument.Source.Descendants("DokumentIndhold").FirstOrDefault();

            dokumentIndhold.Descendants("Indledning").Remove();
            AddNewIndledning(template, dokumentIndhold);
            //Herved bekendtgøres økologiloven, lov nr. 463 af 17. juni 2008, med de ændringer, der følger af § 70 i lov nr. 1336 af 19. december 2008.</Char>
        }
예제 #14
0
        public void Patch(TargetDocument targetDocument, ChangeDocument[] changeDocuments)
        {
            var firstCharTitelNode = targetDocument.Source.XPathSelectElement("//TitelGruppe/Titel/Linea/Char");
            var currentTitle       = firstCharTitelNode.Value;

            if (currentTitle.StartsWith("Bekendtgørelse"))
            {
                CreateLovbekendtgørelseTitle(currentTitle, firstCharTitelNode);
            }
            else
            {
                ConvertLovToLovbekendtgoerelse(currentTitle, firstCharTitelNode);
            }
        }
        private void HandleStructureElementInserts(TargetDocument targetDocument)
        {
            var elementToInsert = GetAendringAktionStructures();

            var structureTargets = AendringDefinition.StructureTargets.Where(element => element.SubElementTarget == null);

            foreach (var xElement in FindStructureElementsInTargetDocument(targetDocument, structureTargets))
            {
                //We only insert after same type... sometimes, forexample for Paragrafgrupper the location is a paragraf, but the change is a paragrafgruppe
                //it is not allowed to insert paragrafgrupper inside paragrafgrupper, so that is why we select first ancestor with same name as change being inserted
                var siblingToInsertAfter = SelectSameTypeSelfOrImmediateAncestor(xElement, elementToInsert);

                siblingToInsertAfter.AddAfterSelf(elementToInsert.NormalizeWhiteSpace());
            }
        }
        private void HandleSubElementInserts(TargetDocument targetDocument)
        {
            var saetninger           = GetSupportedSubStructureTargets();
            var aendringAktionChange = GetAendringAktionStructures().ToArray();

            foreach (var saetning in saetninger)
            {
                var structureElementsFound = GetTargetStructureForSubstructureChange(targetDocument, saetning);
                if (structureElementsFound.Length == 0)
                {
                    throw new ApplyAendringerException($"No target structure found for {saetning}, can't apply subelement changes.");
                }

                DoSubStructureInsertAfter(structureElementsFound, saetning, aendringAktionChange);
            }
        }
예제 #17
0
 public List <IVisio.Master> FindMastersInDocumentByName(TargetDocument target_doc, string name)
 {
     if (VisioScripting.Helpers.WildcardHelper.NullOrStar(name))
     {
         // return all masters
         var masters = target_doc.Document.Masters.ToList();
         return(masters);
     }
     else
     {
         // return masters matching the name
         var masters2 = target_doc.Document.Masters.ToEnumerable();
         var masters3 = VisioScripting.Helpers.WildcardHelper.FilterObjectsByNames(masters2, new[] { name }, p => p.Name, true, VisioScripting.Helpers.WildcardHelper.FilterAction.Include).ToList();
         return(masters3);
     }
 }
        public void Scripting_Draw_DirectedGraph4()
        {
            // Load the graph
            string xml = this.get_datafile_content(@"datafiles\directed_graph_4.xml");

            // Draw the graph
            var client = this.GetScriptingClient();

            this.draw_directed_graph(client, xml);

            // Cleanup
            string output_filename = TestGlobals.TestHelper.GetOutputFilename(nameof(Scripting_Draw_DirectedGraph4), ".vsd");
            var    targetdoc       = new TargetDocument();

            client.Document.SaveDocumentAs(targetdoc, output_filename);
            client.Document.CloseDocument(targetdoc, true);
        }
예제 #19
0
        public List <IVisio.Page> FindPagesInDocument(TargetDocument targetdoc, string name)
        {
            targetdoc = targetdoc.ResolveToDocument(this._client);

            if (VisioScripting.Helpers.WildcardHelper.NullOrStar(name))
            {
                // return all pages
                var all_pages = targetdoc.Document.Pages.ToList();
                return(all_pages);
            }
            else
            {
                // return the named page
                var all_pages   = targetdoc.Document.Pages.ToEnumerable();
                var named_pages = VisioScripting.Helpers.WildcardHelper.FilterObjectsByNames(all_pages, new[] { name },
                                                                                             p => p.Name, true, VisioScripting.Helpers.WildcardHelper.FilterAction.Include).ToList();
                return(named_pages);
            }
        }
예제 #20
0
        public IVisio.Master GetMaster(TargetDocument targetdoc, string name)
        {
            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            var masters = targetdoc.Document.Masters;

            IVisio.Master masterobj = this._try_get_master(masters, name);

            if (masterobj == null)
            {
                string msg = string.Format("No such master \"{0}\" in \"{1}\"", name, targetdoc.Document.Name);
                throw new VisioOperationException(msg);
            }

            return(masterobj);
        }
예제 #21
0
        public IVisio.Master GetMasterWithNameInDocument(TargetDocument target_doc, string master)
        {
            if (master == null)
            {
                throw new System.ArgumentNullException(nameof(master));
            }

            var masters = target_doc.Document.Masters;

            IVisio.Master masterobj = this.TryGetMaster(masters, master);

            if (masterobj == null)
            {
                string msg = string.Format("No such master \"{0}\" in \"{1}\"", master, target_doc.Document.Name);
                throw new VisioOperationException(msg);
            }

            return(masterobj);
        }
예제 #22
0
        /// <summary>
        /// Generate
        /// </summary>
        /// <param name="compilationUnit"></param>
        /// <param name="columns"></param>
        public void Generate(CompilationUnit compilationUnit, ColumnsLayout columns = ColumnsLayout.FreeTextFormat)
        {
            this.Layout = columns;
            Compiler.Preprocessor.ProcessedTokensDocument processedTokensDocument = compilationUnit.ProcessedTokensDocumentSnapshot;

            // Create a token iterator on top of pre-processed tokens lines
            Compiler.Scanner.ITokensLinesIterator tokensIterator = Compiler.Preprocessor.ProcessedTokensDocument.GetProcessedTokensIterator(
                compilationUnit.TextSourceInfo, processedTokensDocument.Lines, compilationUnit.CompilerOptions);

            //var date1 = DateTime.Now;
            TypeCobol.Compiler.Scanner.Token curToken = null;
            while ((curToken = (curToken == null ? tokensIterator.NextToken() : curToken)) != null)
            {
                var token = curToken;
                curToken = null;
                if (token.TokenType == Compiler.Scanner.TokenType.EndOfFile)
                {
                    break;
                }
                else if (token is TypeCobol.Compiler.Preprocessor.ImportedToken)
                {
                    InsertImportedTokensAction(token, tokensIterator);
                    curToken = tokensIterator.CurrentToken;
                }
                else if (token is TypeCobol.Compiler.Preprocessor.ReplacedPartialCobolWord)
                {
                    ReplaceAction(token as TypeCobol.Compiler.Preprocessor.ReplacedPartialCobolWord);
                }
            }
            //Now Run Actions
            PerformActions();
            TargetDocument.Write(Destination);

            //var date2 = DateTime.Now;
            //var date_diff = date2 - date1;
            //System.Console.Out.WriteLine(date_diff);
        }
예제 #23
0
        public void TestOekologiLoven(TargetDocument targetDocument, ChangeDocument[] changeDocuments, XDocument expectedXdoc)
        {
            var sut = new PatchEngineFactory().Create();

            //Act
            var patchResult = sut.ApplyPatches(changeDocuments, targetDocument);



            string diffResult;
            var    compareResult = _xmlCompare.CompareXml(expectedXdoc, patchResult, out diffResult);

            if (!compareResult)
            {
                _logger.WriteLine(diffResult);
            }

            if (!compareResult && _launchViewer)
            {
                _xdocDiffViewer.Launch(expectedXdoc, patchResult);
            }

            Assert.True(compareResult);
        }
예제 #24
0
 public void Patch(TargetDocument targetDocument, ChangeDocument[] changeDocuments)
 {
     targetDocument.Source.Root.Attribute("SchemaLocation").Value = _lbkSchemaLocation;
 }
예제 #25
0
 public void Apply(TargetDocument targetDocument)
 {
 }
예제 #26
0
 protected virtual void InitValue(TargetDocument obj) { }
예제 #27
0
 public abstract Boolean Execute(TargetDocument obj);
예제 #28
0
 public void Apply(TargetDocument targetDocument)
 {
     ApplyStructureReplacments(targetDocument);
     ApplySubStructureReplacements(targetDocument);
 }
        public void Apply(TargetDocument targetDocument)
        {
            HandleStructureElementInserts(targetDocument);

            HandleSubElementInserts(targetDocument);
        }
 public void SaveDocumentAs(TargetDocument targetdoc, string filename)
 {
     targetdoc = targetdoc.Resolve(this._client);
     targetdoc.Document.SaveAs(filename);
 }
 public void SaveDocument(TargetDocument targetdoc)
 {
     targetdoc = targetdoc.Resolve(this._client);
     targetdoc.Document.Save();
 }
 protected IEnumerable <XElement> FindStructureElementsInTargetDocument(TargetDocument targetDocument, Element targetsToLookFor)
 {
     return(FindStructureElementsInTargetDocument(targetDocument, new[] { targetsToLookFor }));
 }
예제 #33
0
        public void Apply(TargetDocument targetDocument)
        {
            var targetElements = FindStructureElementsInTargetDocument(targetDocument, AendringDefinition.StructureTargets).ToArray();

            targetElements.Remove();
        }
예제 #34
0
 private void ApplyChange(Tuple <XElement, AendringDefinition>[] relevantChanges, TargetDocument targetDocument)
 {
     foreach (var change in relevantChanges)
     {
         _aendringAendringAktionHandlerFactory
         .Create(change.Item2, change.Item1)
         .Apply(targetDocument);
     }
 }