Free cookie consent management tool by TermsFeed Policy Generator

Changeset 542


Ignore:
Timestamp:
09/04/08 18:41:04 (16 years ago)
Author:
gkronber
Message:

improved operators to write items to the DB and added two operators to extract items from the DB and add them as variables. ticket #261 (Items are stored multiple times in the result entries in the CEDMA DB)

Location:
trunk/sources/HeuristicLab.CEDMA.Operators
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Operators/HeuristicLab.CEDMA.Operators.csproj

    r538 r542  
    5454  </ItemGroup>
    5555  <ItemGroup>
     56    <Compile Include="VariableExtractor.cs" />
     57    <Compile Include="SubScopesExtractor.cs" />
    5658    <Compile Include="OntologyExtractor.cs" />
    5759    <Compile Include="ResultsExtractor.cs" />
  • trunk/sources/HeuristicLab.CEDMA.Operators/InjectedVariableExtractor.cs

    r538 r542  
    4141      AddVariableInfo(new VariableInfo("AgentId", "Id of the agent to extract injected variables from.", typeof(IntData), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("CedmaServerUri", "Uri of the CEDMA server", typeof(StringData), VariableKind.In));
    43       AddVariableInfo(new VariableInfo("VariableName", "Name of the injected variable that should be extracted", typeof(StringData), VariableKind.In));
     43      AddVariableInfo(new VariableInfo("VariableNames", "The names of injected variables that should be extracted", typeof(ItemList<StringData>), VariableKind.In));
    4444    }
    4545
     
    4747      string serverUrl = GetVariableValue<StringData>("CedmaServerUri", scope, true).Data;
    4848      long agentId = GetVariableValue<IntData>("AgentId", scope, true).Data;
    49       string variableName = GetVariableValue<StringData>("VariableName", scope, true).Data;
     49      ItemList<StringData> variableNames = GetVariableValue<ItemList<StringData>>("VariableNames", scope, true);
    5050
    5151      NetTcpBinding binding = new NetTcpBinding();
     
    5656      using(ChannelFactory<IDatabase> factory = new ChannelFactory<IDatabase>(binding)) {
    5757        IDatabase database = factory.CreateChannel(new EndpointAddress(serverUrl));
    58         IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(database.GetAgentRawData(agentId));       
     58        IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(database.GetAgentRawData(agentId));
    5959        OperatorLinkPatcher.LinkDatabase(opGraph, database);
    60         IVariable var = FindInjectedVariable(database, variableName, opGraph);
    61         if(var != null) {
     60        List<IVariable> vars = FindInjectedVariable(database, variableNames, opGraph);
     61        foreach(IVariable var in vars) {
    6262          scope.AddVariable(var);
    6363        }
     
    6666    }
    6767
    68     private IVariable FindInjectedVariable(IDatabase database, string variableName, IOperatorGraph opGraph) {
     68    private List<IVariable> FindInjectedVariable(IDatabase database, ItemList<StringData> variableNames, IOperatorGraph opGraph) {
     69      List<IVariable> vars = new List<IVariable>();
    6970      foreach(IOperator op in opGraph.Operators) {
    70         IVariable var = FindInjectedVariable(database, variableName, op);
    71         if(var != null) return var;
     71        vars.AddRange(FindInjectedVariable(database, variableNames, op));
    7272      }
    73       return null;
     73      return vars;
    7474    }
    7575
    76     private IVariable FindInjectedVariable(IDatabase database, string variableName, IOperator op) {
    77       IVariable var = op.GetVariable(variableName);
    78       if(var != null) return var;
    79       else if(op is CombinedOperator) {
    80         var = FindInjectedVariable(database, variableName, ((CombinedOperator)op).OperatorGraph);
     76    private List<IVariable> FindInjectedVariable(IDatabase database, ItemList<StringData> variableNames, IOperator op) {
     77      List<IVariable> vars = new List<IVariable>();
     78      List<string> missingVariables = new List<string>();
     79      foreach(StringData variableName in variableNames) missingVariables.Add(variableName.Data);
     80      foreach(string variableName in missingVariables) {
     81        IVariable var = op.GetVariable(variableName);
     82        if(var != null) {
     83          vars.Add(var);
     84          variableNames.Remove(new StringData(variableName));
     85        }
     86      }
     87      if(op is CombinedOperator) {
     88        vars.AddRange(FindInjectedVariable(database, variableNames, ((CombinedOperator)op).OperatorGraph));
    8189      } else if(op is OperatorLink) {
    8290        OperatorLink link = op as OperatorLink;
     
    8694        link.Operator = target;
    8795
    88         var = FindInjectedVariable(database, variableName, link.Operator);
     96        vars.AddRange(FindInjectedVariable(database, variableNames, link.Operator));
    8997      }
    90       return var;
     98      return vars;
    9199    }
    92100  }
  • trunk/sources/HeuristicLab.CEDMA.Operators/MakeStatement.cs

    r538 r542  
    3939    public MakeStatement()
    4040      : base() {
    41       AddVariableInfo(new VariableInfo("AgentId", "Id of the agent to extract injected variables from.", typeof(IntData), VariableKind.In));
    4241      AddVariableInfo(new VariableInfo("CedmaServerUri", "Uri of the CEDMA server", typeof(StringData), VariableKind.In));
    4342      AddVariableInfo(new VariableInfo("Subject", "", typeof(IItem), VariableKind.In));
     
    4847    public override IOperation Apply(IScope scope) {
    4948      string serverUrl = GetVariableValue<StringData>("CedmaServerUri", scope, true).Data;
    50       long agentId = GetVariableValue<IntData>("AgentId", scope, true).Data;
    5149      IItem subject = GetVariableValue<IItem>("Subject", scope, true);
    5250      IItem predicate = GetVariableValue<IItem>("Predicate", scope, true);
Note: See TracChangeset for help on using the changeset viewer.