diff --git a/src/Database.Tests/Properties/AssemblyInfo.cs b/src/Database.Tests/Properties/AssemblyInfo.cs index a7af04bd8ddca37e5265a853dff5d3be59f2a4d7..6a5fce73ffaf7323bd9dc13a183be1c47ef56240 100644 --- a/src/Database.Tests/Properties/AssemblyInfo.cs +++ b/src/Database.Tests/Properties/AssemblyInfo.cs @@ -9,8 +9,8 @@ using System.Reflection; [assembly: AssemblyDescription("Database.Tests is a part of the CoScInE group.")] [assembly: AssemblyCompany("IT Center, RWTH Aachen University")] [assembly: AssemblyProduct("Database.Tests")] -[assembly: AssemblyVersion("1.17.1")] -[assembly: AssemblyFileVersion("1.17.1")] -[assembly: AssemblyInformationalVersion("1.17.1-topic-672-toggle0015")] +[assembly: AssemblyVersion("1.18.1")] +[assembly: AssemblyFileVersion("1.18.1")] +[assembly: AssemblyInformationalVersion("1.18.1-topic-712-organi0004")] [assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")] diff --git a/src/Database/Database.csproj b/src/Database/Database.csproj index 132f2f45b5205df8c9542544e9a03df11a9846bd..de0a93ac7b1fee626b00976e24597b3a8f7fd6db 100644 --- a/src/Database/Database.csproj +++ b/src/Database/Database.csproj @@ -84,9 +84,9 @@ <Compile Include="ReturnObjects\DisciplineObject.cs" /> <Compile Include="ReturnObjects\FeatureObject.cs" /> <Compile Include="ReturnObjects\GitlabResourceTypeObject.cs" /> - <Compile Include="ReturnObjects\InstituteObject.cs" /> <Compile Include="ReturnObjects\IReturnObject.cs" /> <Compile Include="ReturnObjects\LicenseObject.cs" /> + <Compile Include="ReturnObjects\OrganizationObject.cs" /> <Compile Include="ReturnObjects\ProjectObject.cs" /> <Compile Include="ReturnObjects\ProjectRoleObject.cs" /> <Compile Include="ReturnObjects\RDSResourceTypeObject.cs" /> @@ -119,7 +119,6 @@ <Compile Include="Models\DatabaseModel.cs" /> <Compile Include="Models\DisciplineModel.cs" /> <Compile Include="Models\GitlabResourceTypeModel.cs" /> - <Compile Include="Models\InstituteModel.cs" /> <Compile Include="Models\LicenseModel.cs" /> <Compile Include="Models\MetadataModel.cs" /> <Compile Include="Models\ProjectDisciplineModel.cs" /> diff --git a/src/Database/Models/InstituteModel.cs b/src/Database/Models/InstituteModel.cs deleted file mode 100644 index 3216522c6a1c968591937a7ea1f6c0f3090e236e..0000000000000000000000000000000000000000 --- a/src/Database/Models/InstituteModel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Coscine.Database.DataModel; -using LinqToDB; -using System; -using System.Linq.Expressions; - -namespace Coscine.Database.Models -{ - public class InstituteModel : DatabaseModel<Institute> - { - public override Expression<Func<Institute, Guid>> GetIdFromObject() - { - return (institute) => institute.Id; - } - - public override ITable<Institute> GetITableFromDatabase(CoscineDB db) - { - return db.Institutes; - } - - public override void SetObjectId(Institute databaseObject, Guid id) - { - databaseObject.Id = id; - } - } -} diff --git a/src/Database/Models/ProjectModel.cs b/src/Database/Models/ProjectModel.cs index d8f63a5c71875e02733a9d5675edbc8257214952..1e7efeaea33ecfe85a21cce1189f8d361c294178 100644 --- a/src/Database/Models/ProjectModel.cs +++ b/src/Database/Models/ProjectModel.cs @@ -128,7 +128,7 @@ namespace Coscine.Database.Models public Project StoreFromObject(ProjectObject projectObject, User user) { - if (projectObject.Disciplines.Count() == 0 || projectObject.Institutes.Count() == 0) + if (projectObject.Disciplines.Count() == 0 || projectObject.Organizations.Count() == 0) { throw new ArgumentException("Discipline and Institute are necessary!"); } @@ -151,7 +151,7 @@ namespace Coscine.Database.Models try { SetDisciplines(project, projectObject.Disciplines); - SetInstitutes(project, projectObject.Institutes); + SetOrganizations(project, projectObject.Organizations); } catch (Exception e) { @@ -179,19 +179,19 @@ namespace Coscine.Database.Models } } - private void SetInstitutes(Project project, IEnumerable<InstituteObject> institutes) + private void SetOrganizations(Project project, IEnumerable<OrganizationObject> organizations) { ProjectInstituteModel projectInstituteModel = new ProjectInstituteModel(); foreach (var oldInstitute in projectInstituteModel.GetAllWhere((projectInstitute) => projectInstitute.ProjectId == project.Id)) { projectInstituteModel.Delete(oldInstitute); } - foreach (var institute in institutes) + foreach (var organization in organizations) { projectInstituteModel.Insert(new ProjectInstitute() { ProjectId = project.Id, - InstituteId = institute.Id + OrganizationUrl = organization.Url, }); } } @@ -268,7 +268,7 @@ namespace Coscine.Database.Models public int UpdateByObject(Project project, ProjectObject projectObject) { - if (projectObject.Disciplines.Count() == 0 || projectObject.Institutes.Count() == 0) + if (projectObject.Disciplines.Count() == 0 || projectObject.Organizations.Count() == 0) { throw new ArgumentException("Discipline and Institute are necessary!"); } @@ -284,7 +284,7 @@ namespace Coscine.Database.Models project.GrantId = projectObject.GrantId; SetDisciplines(project, projectObject.Disciplines); - SetInstitutes(project, projectObject.Institutes); + SetOrganizations(project, projectObject.Organizations); project.VisibilityId = projectObject.Visibility.Id; return Update(project); @@ -308,17 +308,19 @@ namespace Coscine.Database.Models { disciplines = project.ProjectDisciplineProjectIdIds.Select((discipline) => new DisciplineObject(discipline.Discipline.Id, discipline.Discipline.Url, discipline.Discipline.DisplayNameDe, discipline.Discipline.DisplayNameEn)); } - IEnumerable<InstituteObject> institutes = new List<InstituteObject>(); + + IEnumerable<OrganizationObject> organizations = new List<OrganizationObject>(); if (project.ProjectInstituteProjectIdIds == null) { - InstituteModel instituteModel = new InstituteModel(); - institutes = instituteModel.GetAllWhere((institute) => (from relation in institute.ProjectInstituteInstituteIdIds where relation.ProjectId == project.Id select relation).Any()) - .Select((institute) => new InstituteObject(institute.Id, institute.IKZ, institute.DisplayName)); + ProjectInstituteModel projectInstituteModel = new ProjectInstituteModel(); + organizations = projectInstituteModel.GetAllWhere((projectInstitute) => (projectInstitute.ProjectId == project.Id)) + .Select((projectInstitute) => new OrganizationObject(projectInstitute.OrganizationUrl, projectInstitute.OrganizationUrl)); } else { - institutes = project.ProjectInstituteProjectIdIds.Select((institute) => new InstituteObject(institute.Institute.Id, institute.Institute.IKZ, institute.Institute.DisplayName)); + organizations = project.ProjectInstituteProjectIdIds.Select((institute) => new OrganizationObject(institute.OrganizationUrl, institute.OrganizationUrl)); } + if (project.Visibility == null && project.VisibilityId.HasValue) { VisibilityModel visibilityModel = new VisibilityModel(); @@ -328,7 +330,7 @@ namespace Coscine.Database.Models return new ProjectObject(project.Id, project.Description, project.DisplayName, project.StartDate, project.EndDate, project.Keywords, project.ProjectName, project.PrincipleInvestigators, project.GrantId, disciplines, - institutes, + organizations, project.Visibility == null ? null : new VisibilityObject(project.Visibility.Id, project.Visibility.DisplayName), parentId); } diff --git a/src/Database/Models/ResourceModel.cs b/src/Database/Models/ResourceModel.cs index 819351a59c7703348221b03f2dccae4b34b724bb..a454c3d6c8372ded109e6b6a187b249555a9b886 100644 --- a/src/Database/Models/ResourceModel.cs +++ b/src/Database/Models/ResourceModel.cs @@ -301,7 +301,7 @@ namespace Coscine.Database.Models { S3ResourceTypeModel s3ResourceTypeModel = new S3ResourceTypeModel(); var s3ResourceType = s3ResourceTypeModel.GetById(resource.ResourceTypeOptionId.Value); - resourceTypeOptionObject = new S3ResourceTypeObject(s3ResourceType.Id, s3ResourceType.BucketName, null, null); + resourceTypeOptionObject = new S3ResourceTypeObject(s3ResourceType.Id, s3ResourceType.BucketName, null, null, s3ResourceType.ResourceUrl); } else if(resource.Type.DisplayName == "gitlab" && resource.ResourceTypeOptionId != null) { diff --git a/src/Database/Properties/AssemblyInfo.cs b/src/Database/Properties/AssemblyInfo.cs index 428a76f49dcb39ee9e0a796e0a80f4005d4bb7e4..c9774aed82b7d178b7d0b4a7915b231c5fbb3003 100644 --- a/src/Database/Properties/AssemblyInfo.cs +++ b/src/Database/Properties/AssemblyInfo.cs @@ -9,8 +9,8 @@ using System.Reflection; [assembly: AssemblyDescription("Database is a part of the CoScInE group.")] [assembly: AssemblyCompany("IT Center, RWTH Aachen University")] [assembly: AssemblyProduct("Database")] -[assembly: AssemblyVersion("1.17.1")] -[assembly: AssemblyFileVersion("1.17.1")] -[assembly: AssemblyInformationalVersion("1.17.1-topic-672-toggle0015")] +[assembly: AssemblyVersion("1.18.1")] +[assembly: AssemblyFileVersion("1.18.1")] +[assembly: AssemblyInformationalVersion("1.18.1-topic-712-organi0004")] [assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")] diff --git a/src/Database/ReturnObjects/InstituteObject.cs b/src/Database/ReturnObjects/InstituteObject.cs deleted file mode 100644 index 4ca6e875260ce94bf2e1e7bd27975a32b8c09e97..0000000000000000000000000000000000000000 --- a/src/Database/ReturnObjects/InstituteObject.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Coscine.Database.ReturnObjects -{ - public class InstituteObject : IReturnObject - { - public Guid Id { get; set; } - - public string Ikz { get; set; } - public string DisplayName { get; set; } - - public InstituteObject(Guid id, string ikz, string displayName) - { - Id = id; - Ikz = ikz; - DisplayName = displayName; - } - } -} diff --git a/src/Database/ReturnObjects/OrganizationObject.cs b/src/Database/ReturnObjects/OrganizationObject.cs new file mode 100644 index 0000000000000000000000000000000000000000..1fb6d6f1d3ff7c9d5801b48e2cc662caba080bfe --- /dev/null +++ b/src/Database/ReturnObjects/OrganizationObject.cs @@ -0,0 +1,17 @@ +using System; + +namespace Coscine.Database.ReturnObjects +{ + [Serializable] + public class OrganizationObject : IReturnObject + { + public string Url { get; set; } + public string DisplayName { get; set; } + + public OrganizationObject(string url, string displayName) + { + Url = url; + DisplayName = displayName; + } + } +} diff --git a/src/Database/ReturnObjects/ProjectObject.cs b/src/Database/ReturnObjects/ProjectObject.cs index 469f53e11beed932fcecf3fde2eaf54dfa99a76e..ce10c1b14290d2b622c27c08f86c22966c86e039 100644 --- a/src/Database/ReturnObjects/ProjectObject.cs +++ b/src/Database/ReturnObjects/ProjectObject.cs @@ -20,12 +20,12 @@ namespace Coscine.Database.ReturnObjects public string GrantId { get; set; } public IEnumerable<DisciplineObject> Disciplines { get; set; } - public IEnumerable<InstituteObject> Institutes { get; set; } + public IEnumerable<OrganizationObject> Organizations { get; set; } public VisibilityObject Visibility { get; set; } public Guid ParentId { get; set; } - public ProjectObject(Guid id, string description, string displayName, DateTime startDate, DateTime endDate, string keywords, string projectName, string principleInvestigators, string grantId, IEnumerable<DisciplineObject> discipline, IEnumerable<InstituteObject> institute, VisibilityObject visibility, Guid parentId = new Guid()) + public ProjectObject(Guid id, string description, string displayName, DateTime startDate, DateTime endDate, string keywords, string projectName, string principleInvestigators, string grantId, IEnumerable<DisciplineObject> discipline, IEnumerable<OrganizationObject> organization, VisibilityObject visibility, Guid parentId = new Guid()) { Id = id; Description = description; @@ -40,7 +40,7 @@ namespace Coscine.Database.ReturnObjects GrantId = grantId; Disciplines = discipline; - Institutes = institute; + Organizations = organization; Visibility = visibility; } } diff --git a/src/Database/ReturnObjects/S3ResourceTypeObject.cs b/src/Database/ReturnObjects/S3ResourceTypeObject.cs index 97f9ea54ef03d7a8730f4cc0468138c80dba9e0c..0eacb19bd0aa8c819b4795541cd94ad7bf5c4bdf 100644 --- a/src/Database/ReturnObjects/S3ResourceTypeObject.cs +++ b/src/Database/ReturnObjects/S3ResourceTypeObject.cs @@ -9,14 +9,15 @@ namespace Coscine.Database.ReturnObjects public string BucketName { get; set; } public string AccessKey { get; set; } public string SecretKey { get; set; } + public string ResourceUrl { get; set; } - public S3ResourceTypeObject(Guid id, string bucketName, string accessKey, string secretKey) + public S3ResourceTypeObject(Guid id, string bucketName, string accessKey, string secretKey, string resourceUrl) { Id = id; BucketName = bucketName; - AccessKey = accessKey; SecretKey = secretKey; + ResourceUrl = resourceUrl; } } }