Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/08 21:35:35 (16 years ago)
Author:
gkronber
Message:

worked on #211.

  • Implemented downloading of linked operators from the database in AgentList (to allow view/edit of the whole operator graph)
  • Implemented downloading and patching of linked operators in RunScheduler to prepare the operator-graph for execution (OperatorLink operator can't be executed)

(there is some code duplication because the patching is very similar in AgentList DatabaseOperatorLibrary and RunScheduler. This needs some more work)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Server/RunScheduler.cs

    r419 r420  
    7676        IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(entry.RawData);
    7777
    78         foreach(IOperator op in opGraph.Operators) {
    79           PatchLinks(op);
    80         }
     78        PatchLinks(opGraph, new Dictionary<long, IOperator>());
    8179
    8280        AtomicOperation operation = new AtomicOperation(opGraph.InitialOperator, scope);
     
    9997    }
    10098
    101     private void PatchLinks(IOperator op) {
    102       if(op is OperatorLink) {
    103         OperatorLink link = op as OperatorLink;
    104         OperatorEntry targetEntry = database.GetOperator(link.Id);
    105         IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
    106         ReplaceOperatorInGraph(link, target);
    107       } else if(op is CombinedOperator) {
    108         CombinedOperator combinedOp = op as CombinedOperator;
    109         foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) {
    110           PatchLinks(internalOp);
     99    private void PatchLinks(IOperatorGraph opGraph, Dictionary<long, IOperator> patchedOperators) {
     100      Dictionary<IOperator, IOperator> patchDictionary = new Dictionary<IOperator, IOperator>();
     101      foreach(IOperator op in opGraph.Operators) {
     102        IOperator patched = PatchLinks(op, patchedOperators);
     103        patchDictionary.Add(op, patched);
     104      }
     105      foreach(KeyValuePair<IOperator, IOperator> p in patchDictionary) {
     106        IOperator original = p.Key;
     107        IOperator patch = p.Value;
     108        if(original != patch) {
     109          foreach(IOperator subOperator in original.SubOperators) {
     110            patch.AddSubOperator(subOperator);
     111          }
     112          if(opGraph.InitialOperator == original)
     113            opGraph.InitialOperator = patch;
     114          opGraph.RemoveOperator(original.Guid);
     115          opGraph.AddOperator(patch);
    111116        }
    112117      }
    113118    }
    114119
    115     private void ReplaceOperatorInGraph(OperatorLink link, IOperator target) {
    116       throw new NotImplementedException();
     120    private IOperator PatchLinks(IOperator op, Dictionary<long, IOperator> patchedOperators) {
     121      if(op is OperatorLink) {
     122        OperatorLink link = op as OperatorLink;
     123        if(patchedOperators.ContainsKey(link.Id)) {
     124          return patchedOperators[link.Id];
     125        } else {
     126          OperatorEntry targetEntry = database.GetOperator(link.Id);
     127          IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData);
     128          patchedOperators.Add(link.Id, target);
     129          PatchLinks(target, patchedOperators);
     130          return target;
     131        }
     132      } else if(op is CombinedOperator) {
     133        PatchLinks(((CombinedOperator)op).OperatorGraph, patchedOperators);
     134        return op;
     135      }
     136      return op;
    117137    }
    118138
Note: See TracChangeset for help on using the changeset viewer.