Changeset 549 for trunk/sources/HeuristicLab.CEDMA.Operators
- Timestamp:
- 09/11/08 14:33:04 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Operators/SelectProperties.cs
r547 r549 45 45 AddVariableInfo(new VariableInfo("CedmaServerUri", "Uri of the CEDMA server", typeof(StringData), VariableKind.In)); 46 46 AddVariableInfo(new VariableInfo("SubjectGuid", "", typeof(StringData), VariableKind.In)); 47 AddVariableInfo(new VariableInfo("Predicate", "", typeof(StringData), VariableKind.In)); 48 AddVariableInfo(new VariableInfo("Property", "", typeof(IItem), VariableKind.New)); 47 49 } 48 50 … … 50 52 string serverUrl = GetVariableValue<StringData>("CedmaServerUri", scope, true).Data; 51 53 StringData subjectGuid = GetVariableValue<StringData>("SubjectGuid", scope, true); 54 StringData predicate = GetVariableValue<StringData>("Predicate", scope, true); 52 55 53 56 NetTcpBinding binding = new NetTcpBinding(); … … 60 63 Statement template = new Statement( 61 64 new Entity(cedmaNamespace+subjectGuid.Data), 62 new Entity( null),65 new Entity(cedmaNamespace+predicate.Data), 63 66 new Entity(null)); 64 67 IList<Statement> result = store.Select(template); 65 68 66 foreach(Statement s in result) { 69 if(result.Count == 1) { 70 Statement s = result[0]; 71 Variable var = new Variable(); 72 var.Name = scope.TranslateName("Property"); 73 scope.AddVariable(var); 67 74 if(s.Property is Literal) { 68 scope.AddVariable(new Variable(s.Predicate.Uri.Replace(cedmaNamespace,""), TranslateLiteral((Literal)s.Property)));75 var.Value = TranslateLiteral((Literal)s.Property); 69 76 } else if(s.Property is SerializedLiteral) { 70 scope.AddVariable(new Variable(s.Predicate.Uri.Replace(cedmaNamespace, ""), TranslateLiteral((SerializedLiteral)s.Property)));77 var.Value = TranslateLiteral((SerializedLiteral)s.Property); 71 78 } else { 72 scope.AddVariable(new Variable(s.Predicate.Uri, new StringData(((Entity)s.Property).Uri.Replace(cedmaNamespace, "")))); 79 var.Value = new StringData(((Entity)s.Property).Uri.Replace(cedmaNamespace, "")); 80 } 81 } else { 82 ItemList<IItem> resultValues = new ItemList<IItem>(); 83 scope.AddVariable(new Variable(scope.TranslateName("Property"), resultValues)); 84 foreach(Statement s in result) { 85 if(s.Property is Literal) { 86 resultValues.Add(TranslateLiteral((Literal)s.Property)); 87 } else if(s.Property is SerializedLiteral) { 88 resultValues.Add(TranslateLiteral((SerializedLiteral)s.Property)); 89 } else { 90 resultValues.Add(new StringData(((Entity)s.Property).Uri.Replace(cedmaNamespace, ""))); 91 } 73 92 } 74 93 }
Note: See TracChangeset
for help on using the changeset viewer.