Changeset 542
- Timestamp:
- 09/04/08 18:41:04 (16 years ago)
- 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 54 54 </ItemGroup> 55 55 <ItemGroup> 56 <Compile Include="VariableExtractor.cs" /> 57 <Compile Include="SubScopesExtractor.cs" /> 56 58 <Compile Include="OntologyExtractor.cs" /> 57 59 <Compile Include="ResultsExtractor.cs" /> -
trunk/sources/HeuristicLab.CEDMA.Operators/InjectedVariableExtractor.cs
r538 r542 41 41 AddVariableInfo(new VariableInfo("AgentId", "Id of the agent to extract injected variables from.", typeof(IntData), VariableKind.In)); 42 42 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)); 44 44 } 45 45 … … 47 47 string serverUrl = GetVariableValue<StringData>("CedmaServerUri", scope, true).Data; 48 48 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); 50 50 51 51 NetTcpBinding binding = new NetTcpBinding(); … … 56 56 using(ChannelFactory<IDatabase> factory = new ChannelFactory<IDatabase>(binding)) { 57 57 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)); 59 59 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) { 62 62 scope.AddVariable(var); 63 63 } … … 66 66 } 67 67 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>(); 69 70 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)); 72 72 } 73 return null;73 return vars; 74 74 } 75 75 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)); 81 89 } else if(op is OperatorLink) { 82 90 OperatorLink link = op as OperatorLink; … … 86 94 link.Operator = target; 87 95 88 var = FindInjectedVariable(database, variableName, link.Operator);96 vars.AddRange(FindInjectedVariable(database, variableNames, link.Operator)); 89 97 } 90 return var ;98 return vars; 91 99 } 92 100 } -
trunk/sources/HeuristicLab.CEDMA.Operators/MakeStatement.cs
r538 r542 39 39 public MakeStatement() 40 40 : base() { 41 AddVariableInfo(new VariableInfo("AgentId", "Id of the agent to extract injected variables from.", typeof(IntData), VariableKind.In));42 41 AddVariableInfo(new VariableInfo("CedmaServerUri", "Uri of the CEDMA server", typeof(StringData), VariableKind.In)); 43 42 AddVariableInfo(new VariableInfo("Subject", "", typeof(IItem), VariableKind.In)); … … 48 47 public override IOperation Apply(IScope scope) { 49 48 string serverUrl = GetVariableValue<StringData>("CedmaServerUri", scope, true).Data; 50 long agentId = GetVariableValue<IntData>("AgentId", scope, true).Data;51 49 IItem subject = GetVariableValue<IItem>("Subject", scope, true); 52 50 IItem predicate = GetVariableValue<IItem>("Predicate", scope, true);
Note: See TracChangeset
for help on using the changeset viewer.