Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13690


Ignore:
Timestamp:
03/11/16 15:26:56 (9 years ago)
Author:
abeham
Message:

#2588: Added service/client methods to get a single solution by id

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/RunCreationClient.cs

    r13684 r13690  
    100100    public IEnumerable<Solution> GetSolutions(long problemId) {
    101101      return CallRunCreationService(s => s.GetSolutions(problemId));
     102    }
     103
     104    public Solution GetSolution(long solutionId) {
     105      return CallRunCreationService(s => s.GetSolution(solutionId));
    102106    }
    103107
  • trunk/sources/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/RunCreationServiceClient.cs

    r13684 r13690  
    793793    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.LongValue))]
    794794    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.TimeSpanValue))]
     795    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.DoubleValue))]
     796    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.PercentValue))]
     797    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.FloatValue))]
    795798    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.IntValue))]
    796     [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.DoubleValue))]
    797     [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.FloatValue))]
    798799    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.StringValue))]
    799800    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.BinaryValue))]
    800     [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.OKB.RunCreation.PercentValue))]
    801801    public partial class Value : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
    802802    {
     
    949949    [System.Diagnostics.DebuggerStepThroughAttribute()]
    950950    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    951     [System.Runtime.Serialization.DataContractAttribute(Name="IntValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
    952         "aTransfer")]
    953     public partial class IntValue : HeuristicLab.Clients.OKB.RunCreation.Value
    954     {
    955        
    956         private int ValueField;
    957        
    958         [System.Runtime.Serialization.DataMemberAttribute()]
    959         public int Value
     951    [System.Runtime.Serialization.DataContractAttribute(Name="DoubleValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
     952        "aTransfer")]
     953    public partial class DoubleValue : HeuristicLab.Clients.OKB.RunCreation.Value
     954    {
     955       
     956        private double ValueField;
     957       
     958        [System.Runtime.Serialization.DataMemberAttribute()]
     959        public double Value
    960960        {
    961961            get
     
    976976    [System.Diagnostics.DebuggerStepThroughAttribute()]
    977977    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    978     [System.Runtime.Serialization.DataContractAttribute(Name="DoubleValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
    979         "aTransfer")]
    980     public partial class DoubleValue : HeuristicLab.Clients.OKB.RunCreation.Value
     978    [System.Runtime.Serialization.DataContractAttribute(Name="PercentValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
     979        "aTransfer")]
     980    public partial class PercentValue : HeuristicLab.Clients.OKB.RunCreation.Value
    981981    {
    982982       
     
    10301030    [System.Diagnostics.DebuggerStepThroughAttribute()]
    10311031    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    1032     [System.Runtime.Serialization.DataContractAttribute(Name="StringValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
    1033         "aTransfer")]
    1034     public partial class StringValue : HeuristicLab.Clients.OKB.RunCreation.Value
    1035     {
    1036        
    1037         private string ValueField;
    1038        
    1039         [System.Runtime.Serialization.DataMemberAttribute()]
    1040         public string Value
     1032    [System.Runtime.Serialization.DataContractAttribute(Name="IntValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
     1033        "aTransfer")]
     1034    public partial class IntValue : HeuristicLab.Clients.OKB.RunCreation.Value
     1035    {
     1036       
     1037        private int ValueField;
     1038       
     1039        [System.Runtime.Serialization.DataMemberAttribute()]
     1040        public int Value
    10411041        {
    10421042            get
     
    10461046            set
    10471047            {
    1048                 if ((object.ReferenceEquals(this.ValueField, value) != true))
     1048                if ((this.ValueField.Equals(value) != true))
    10491049                {
    10501050                    this.ValueField = value;
     
    10571057    [System.Diagnostics.DebuggerStepThroughAttribute()]
    10581058    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    1059     [System.Runtime.Serialization.DataContractAttribute(Name="BinaryValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
    1060         "aTransfer")]
    1061     public partial class BinaryValue : HeuristicLab.Clients.OKB.RunCreation.Value
    1062     {
    1063        
    1064         private byte[] ValueField;
    1065        
    1066         [System.Runtime.Serialization.DataMemberAttribute()]
    1067         public byte[] Value
     1059    [System.Runtime.Serialization.DataContractAttribute(Name="StringValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
     1060        "aTransfer")]
     1061    public partial class StringValue : HeuristicLab.Clients.OKB.RunCreation.Value
     1062    {
     1063       
     1064        private string ValueField;
     1065       
     1066        [System.Runtime.Serialization.DataMemberAttribute()]
     1067        public string Value
    10681068        {
    10691069            get
     
    10841084    [System.Diagnostics.DebuggerStepThroughAttribute()]
    10851085    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    1086     [System.Runtime.Serialization.DataContractAttribute(Name="PercentValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
    1087         "aTransfer")]
    1088     public partial class PercentValue : HeuristicLab.Clients.OKB.RunCreation.Value
    1089     {
    1090        
    1091         private double ValueField;
    1092        
    1093         [System.Runtime.Serialization.DataMemberAttribute()]
    1094         public double Value
     1086    [System.Runtime.Serialization.DataContractAttribute(Name="BinaryValue", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.OKB.RunCreation.Dat" +
     1087        "aTransfer")]
     1088    public partial class BinaryValue : HeuristicLab.Clients.OKB.RunCreation.Value
     1089    {
     1090       
     1091        private byte[] ValueField;
     1092       
     1093        [System.Runtime.Serialization.DataMemberAttribute()]
     1094        public byte[] Value
    10951095        {
    10961096            get
     
    11001100            set
    11011101            {
    1102                 if ((this.ValueField.Equals(value) != true))
     1102                if ((object.ReferenceEquals(this.ValueField, value) != true))
    11031103                {
    11041104                    this.ValueField = value;
     
    12971297        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRunCreationService/GetSolutions", ReplyAction="http://tempuri.org/IRunCreationService/GetSolutionsResponse")]
    12981298        System.Threading.Tasks.Task<System.Collections.Generic.List<HeuristicLab.Clients.OKB.RunCreation.Solution>> GetSolutionsAsync(long problemId);
     1299       
     1300        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRunCreationService/GetSolution", ReplyAction="http://tempuri.org/IRunCreationService/GetSolutionResponse")]
     1301        HeuristicLab.Clients.OKB.RunCreation.Solution GetSolution(long solutionId);
     1302       
     1303        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRunCreationService/GetSolution", ReplyAction="http://tempuri.org/IRunCreationService/GetSolutionResponse")]
     1304        System.Threading.Tasks.Task<HeuristicLab.Clients.OKB.RunCreation.Solution> GetSolutionAsync(long solutionId);
    12991305       
    13001306        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRunCreationService/GetSolutionData", ReplyAction="http://tempuri.org/IRunCreationService/GetSolutionDataResponse")]
     
    14331439        }
    14341440       
     1441        public HeuristicLab.Clients.OKB.RunCreation.Solution GetSolution(long solutionId)
     1442        {
     1443            return base.Channel.GetSolution(solutionId);
     1444        }
     1445       
     1446        public System.Threading.Tasks.Task<HeuristicLab.Clients.OKB.RunCreation.Solution> GetSolutionAsync(long solutionId)
     1447        {
     1448            return base.Channel.GetSolutionAsync(solutionId);
     1449        }
     1450       
    14351451        public byte[] GetSolutionData(long solutionId)
    14361452        {
  • trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/IRunCreationService.cs

    r13684 r13690  
    4848
    4949    [OperationContract]
     50    Solution GetSolution(long solutionId);
     51
     52    [OperationContract]
    5053    [FaultContract(typeof(MissingSolution))]
    5154    byte[] GetSolutionData(long solutionId);
  • trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs

    r13684 r13690  
    148148    }
    149149
     150    public DataTransfer.Solution GetSolution(long solutionId) {
     151      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     152
     153      using (OKBDataContext okb = new OKBDataContext()) {
     154        // TODO: In case of multi-objective problems one has to check whether it contains single- or multi-objective problems
     155        var result = Convert.ToDto(okb.SingleObjectiveSolutions.SingleOrDefault(x => x.Id == solutionId));
     156        if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) {
     157          return result;
     158        } else {
     159          var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == result.ProblemId).ToList();
     160          if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList())) {
     161            return result;
     162          } else {
     163            return null;
     164          }
     165        }
     166      }
     167    }
     168
    150169    public byte[] GetSolutionData(long solutionId) {
    151170      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
Note: See TracChangeset for help on using the changeset viewer.