Ejemplo n.º 1
0
 internal override void ConfigureGenerator(OperationGenerator attrb)
 {
     if (indexes != null)
     {
         attrb.TaskRangeIndex = indexes;
     }
     attrb.RangeIsAll = isAll;
 }
Ejemplo n.º 2
0
 internal override void ConfigureGenerator(OperationGenerator attrb)
 {
     if (attrb.TaskName == null)
     {
         attrb.TaskName = literal;
         Logger.Info("Found task name", "ConfigureGenerator::TokenLiteral");
     }
     else
     {
         attrb.TaskName += " " + literal;
         Logger.Warning("Task name already defined but more literals present. Appending to task name.", "ConfigureGenerator::TokenLiteral");
     }
 }
Ejemplo n.º 3
0
 internal override void ConfigureGenerator(OperationGenerator attrb)
 {
     if (contextType == ContextType.CURRENT ||
         contextType == ContextType.NEXT ||
         contextType == ContextType.FOLLOWING
         )
     {
         attrb.CurrentSpecifier = contextType;
     }
     else
     {
         attrb.CurrentMode = contextType;
     }
 }
Ejemplo n.º 4
0
 private void InvokeStep(Step s)
 {
     try
     {
         string            type         = s.ControlType;
         List <UIProperty> props        = s.UIProperties;
         string            method       = s.Method;
         string            input        = s.Input;
         string            outparameter = "";
         if (s.HasGlobalDataAsInput)
         {
             input = input.Substring(1, input.Length - 2);
             input = this.global.GetData(input);
         }
         else if (s.HasOutputVariableAsInput)
         {
             string parameterName      = input.Substring(1, input.Length - 2);
             bool   hasParameterOutput = parameters.ContainsKey(parameterName);
             if (hasParameterOutput)
             {
                 input = parameters[parameterName];
             }
             else
             {
                 log.Report(LogType.Error, "The input variable hasn't be assigned or output by previous steps.");
                 return;
             }
         }
         log.Report(LogType.BeginStep, " {0} ({1}) -> {2} .\r\n", s.ControlType, s.ControlName, s.Method);
         if (!s.HasOutput)
         {
             OperationGenerator.Generate(type, props, method, input);
         }
         else
         {
             OperationGenerator.Generate(type, props, method, input, out outparameter);
             parameters.Add(s.Output, outparameter);
         }
     }
     catch (Exception ex)
     {
         log.Report(LogType.Error, ex.Message);
     }
     finally
     {
         log.Report(LogType.EndStep, "\nStep: {0} ({1}) -> {2} .\n", s.ControlType, s.ControlName, s.Method);
     }
 }
Ejemplo n.º 5
0
 internal override void ConfigureGenerator(OperationGenerator attrb)
 {
     bool multipleTaskDurations = false;
     if (index != 0)
     {
         if (attrb.TimeRangeIndex == 0)
         {
             attrb.TimeRangeIndex = index;
         }
         else
         {
             multipleTaskDurations = true;
             Logger.Warning("Attempted to update timeRangeIndex again", "ConfigureGenerator::TokenTimeRange");
         }
     }
     if (timeRangeType != TimeRangeType.DEFAULT)
     {
         if (attrb.TimeRangeType == TimeRangeType.DEFAULT)
         {
             attrb.TimeRangeType = timeRangeType;
         }
         else
         {
             multipleTaskDurations = true;
             Logger.Warning("Attempted to update timeRangeType again", "ConfigureGenerator::TokenTimeRange");
         }
     }
     if (timeRange != TimeRangeKeywordsType.NONE)
     {
         if (attrb.TimeRangeFirst == TimeRangeKeywordsType.NONE)
         {
             attrb.TimeRangeFirst = timeRange;
         }
         else if (attrb.TimeRangeSecond == TimeRangeKeywordsType.NONE
             || attrb.TimeRangeSecond <= timeRange)
         {
             attrb.TimeRangeSecond = timeRange;
         }
     }
     if (multipleTaskDurations)
     {
         Logger.Warning("Multiple task durations were detected.", "ConfigureGenerator::TokenTimeRange");
         AlertBox.Show("Multiple task durations specified. Only the first is accepted.");
     }
 }
        public void GenerateWithTerraformVars(OpenApiDocument document)
        {
            logger.LogDebug("In GenerateWithTerraformVars");
            var version   = document.Info.Version;
            var revisions = new List <string>();

            if (RevisionMappingFile != null)
            {
                var revisionsMappingParsed = GetRevisions(JObject.Parse(File.ReadAllText(RevisionMappingFile)));
                revisions.AddRange(revisionsMappingParsed);
            }
            else
            {
                revisions.Add("1");
            }

            var apiFilePath = Path.Combine(OutputDir, $"api.{version}.tf");

            if (!Directory.Exists(Path.Combine(OutputDir)))
            {
                Console.WriteLine($"Creating directory {Path.Combine(OutputDir)}");
                Directory.CreateDirectory(Path.Combine(OutputDir));
            }
            var generatedApiOutput = ApiGenerator.GenerateTerraformOutput(document, revisions, PoliciesPath);

            System.IO.File.WriteAllText(apiFilePath, ApiVariablesApplier.ApplyVariables(generatedApiOutput, TerraformVarSubFile));

            if (RevisionMappingFile != null)
            {
                var operationFilePath        = Path.Combine(OutputDir, $"operations.{version}.tf");
                var backendServiceUrl        = JObject.Parse(File.ReadAllText(TerraformVarSubFile)).SelectToken("api_backend_url").Value <string>();
                var generatedOperationOutput = OperationGenerator.GenerateTerraformOutput(document, RevisionMappingFile, backendServiceUrl, PoliciesPath);

                System.IO.File.WriteAllText(operationFilePath, OperationVariablesApplier.ApplyVariables(generatedOperationOutput, TerraformVarSubFile));
            }
            else
            {
                var operationFilePath        = Path.Combine(OutputDir, $"operations.{version}.tf");
                var backendServiceUrl        = JObject.Parse(File.ReadAllText(TerraformVarSubFile)).SelectToken("api_backend_url").Value <string>();
                var generatedOperationOutput = OperationGenerator.GenerateTerraformOutput(document, backendServiceUrl, PoliciesPath);

                System.IO.File.WriteAllText(operationFilePath, OperationVariablesApplier.ApplyVariables(generatedOperationOutput, TerraformVarSubFile));
            }
        }
Ejemplo n.º 7
0
 private void ForEachOperation(DataAccessModel daLayer, OperationGenerator opGen, TextWriter tw)
 {
     foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       foreach (OperationModel model3 in model2.Operations)
       {
     if ((daLayer == null) || (model3.DataLayer == daLayer))
     {
       if (model3 is TableOperation)
       {
         if (((TableOperation) (model3)).m_Table.m_generate)
         {
           opGen(model3, tw);
         }
       }
       else
       {
         opGen(model3, tw);
       }
     }
       }
     }
       }
 }
Ejemplo n.º 8
0
 internal override void ConfigureGenerator(OperationGenerator attrb)
 {
     attrb.SortType = sortType;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// The base method which should be overriden by derived classes.
 /// It allows the token to configure an OperationGenerator to create
 /// an appropriate Operation.
 /// </summary>
 /// <param name="attrb">The OperationGenerator to configure.</param>
 internal abstract void ConfigureGenerator(OperationGenerator attrb);
Ejemplo n.º 10
0
 public void AddOperationGenerator(OperationGenerator g)
 {
     this.generators [g.Type()] = g;
 }