...
 
Commits (3)
......@@ -46,7 +46,8 @@ namespace Coscine.Api.Project.Tests
DisciplineModel disciplineModel = new DisciplineModel();
Discipline = new Discipline()
{
DisplayName = "TestDiscipline",
DisplayNameDe = "TestDiscipline",
DisplayNameEn = "TestDiscipline",
Url = "http://rwth-aachen.de"
};
disciplineModel.Insert(Discipline);
......
......@@ -56,8 +56,8 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Action, Version=1.5.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.5.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.6.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.6.0\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.2.2.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.2.2\lib\net461\Coscine.ApiCommons.dll</HintPath>
......@@ -65,8 +65,8 @@
<Reference Include="Coscine.Configuration, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.4.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.Database, Version=1.8.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.8.0\lib\net461\Coscine.Database.dll</HintPath>
<Reference Include="Coscine.Database, Version=1.9.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.9.0\lib\net461\Coscine.Database.dll</HintPath>
</Reference>
<Reference Include="Coscine.ProxyApi, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ProxyApi.1.2.0\lib\net461\Coscine.ProxyApi.dll</HintPath>
......
......@@ -105,7 +105,7 @@ namespace Coscine.Api.Project.Tests
public void TestControllerStore()
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
......@@ -140,7 +140,7 @@ namespace Coscine.Api.Project.Tests
public void TestControllerDelete()
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
......@@ -174,7 +174,7 @@ namespace Coscine.Api.Project.Tests
public void TestControllerDeleteWithSubProjects()
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
......@@ -189,7 +189,7 @@ namespace Coscine.Api.Project.Tests
stream.Close();
newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
createdProjectObject.Id);
......@@ -217,7 +217,7 @@ namespace Coscine.Api.Project.Tests
public void TestControllerStoreWithSubProject()
{
ProjectObject newProjectObject = new ProjectObject(Guid.NewGuid(), "NewProject", "NewDisplayName", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName));
......@@ -229,7 +229,7 @@ namespace Coscine.Api.Project.Tests
ProjectObject createdProjectObject = (ProjectObject)okObjectResult.Value;
ProjectObject newSubProjectObject = new ProjectObject(Guid.NewGuid(), "NewSubProject", "NewDisplayNameSub", DateTime.Now, DateTime.Now.AddYears(1), "test2;test3", "abc", "investigator", "grandId",
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new List<InstituteObject>() { new InstituteObject(Institute.Id, Institute.IKZ, Institute.DisplayName) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
createdProjectObject.Id);
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project.Tests")]
[assembly: AssemblyVersion("1.6.2.0")]
[assembly: AssemblyFileVersion("1.6.2.0")]
[assembly: AssemblyInformationalVersion("1.6.2.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyInformationalVersion("1.7.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -94,7 +94,7 @@ namespace Coscine.Api.Project.Tests
"keys",
"usageR",
new ResourceTypeObject(Resources[0].Type.Id, Resources[0].Type.DisplayName),
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayName) },
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
new LicenseObject(License.Id, License.DisplayName),
JObject.FromObject(new RDSResourceTypeObject(Guid.NewGuid(), "PITLABTTEST", "accesskey", "secretkey"))
......
......@@ -88,7 +88,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.Database" publicKeyToken="767d77427707b70a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
......
......@@ -4,10 +4,10 @@
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
<package id="Consul" version="0.7.2.6" targetFramework="net472" />
<package id="Coscine.Action" version="1.5.0" targetFramework="net472" />
<package id="Coscine.Action" version="1.6.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.2.2" targetFramework="net472" />
<package id="Coscine.Configuration" version="1.4.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.8.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.9.0" targetFramework="net472" />
<package id="Coscine.ProxyApi" version="1.2.0" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.4.0" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
......
......@@ -91,7 +91,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.Database" publicKeyToken="767d77427707b70a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
......
......@@ -26,7 +26,7 @@ namespace Coscine.Api.Project.Controllers
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
return _disciplineModel.GetAll().Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayName));
return _disciplineModel.GetAll().OrderBy(discipline => discipline.DisplayNameDe.Substring(discipline.DisplayNameDe.Length - 3)).Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
}));
}
}
......
......@@ -11,24 +11,22 @@ using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using Coscine.Configuration;
namespace Coscine.Api.Project.Controllers
{
public class ProjectController : Controller
{
private readonly Authenticator _authenticator;
private readonly List<IProjectAction> _projectActions;
private readonly ProjectModel _projectModel;
private readonly IConfiguration _configuration;
private readonly Emitter _emitter;
public ProjectController()
{
_authenticator = new Authenticator(this, Program.Configuration);
_projectActions = new List<IProjectAction>()
{
new PIDAction(),
new SharePointSiteAction()
};
_configuration = Program.Configuration;
_projectModel = new ProjectModel();
_emitter = new Emitter(this._configuration);
}
[Route("[controller]")]
......@@ -164,16 +162,9 @@ namespace Coscine.Api.Project.Controllers
projectInstituteModel.Delete(projectInstitute);
}
FireEvents((projectAction, projectEventArgs) =>
_emitter.EmitProjectDelete(new ProjectEventArgs(_configuration)
{
try
{
projectAction.OnProjectDelete(project, projectEventArgs);
}
catch (Exception)
{
// Filter exception, because sometimes the PID or SharePoint site might not be generated in e.g. tests
}
Project = project
});
_projectModel.Delete(project);
......@@ -195,19 +186,14 @@ namespace Coscine.Api.Project.Controllers
subProjectModel.LinkSubProject(projectObject.ParentId, project.Id);
}
FireEvents((projectAction, projectEventArgs) => projectAction.OnProjectCreate(project, projectEventArgs));
_emitter.EmitProjectCreate(new ProjectEventArgs(_configuration)
{
Project = project,
ProjectOwner = user
});
return _projectModel.CreateReturnObjectFromDatabaseObject(project);
}));
}
private void FireEvents(Action<IProjectAction, ProjectEventArgs> eventAction)
{
ProjectEventArgs projectEventArgs = new ProjectEventArgs(Program.Configuration, new object[0]);
foreach (var projectAction in _projectActions)
{
eventAction(projectAction, projectEventArgs);
}
}
}
}
using Coscine.Api.Project.Models;
using Coscine.Action;
using Coscine.Action.EventArgs;
using Coscine.Action.Implementations.User;
using Coscine.Api.Project.Models;
using Coscine.Api.Project.ReturnObjects;
using Coscine.ApiCommons;
using Coscine.ApiCommons.Exceptions;
......@@ -17,11 +20,15 @@ namespace Coscine.Api.Project.Controllers
{
private readonly Authenticator _authenticator;
private readonly ProjectRoleModel _projectRoleModel;
private readonly Emitter _emitter;
private readonly Coscine.Configuration.IConfiguration _configuration;
public ProjectRoleController()
{
_emitter = new Emitter(Program.Configuration);
_authenticator = new Authenticator(this, Program.Configuration);
_projectRoleModel = new ProjectRoleModel();
_configuration = Program.Configuration;
}
[Route("[controller]/{projectId}")]
......@@ -89,8 +96,19 @@ namespace Coscine.Api.Project.Controllers
{
ProjectRoleObject projectRoleObject = ObjectFactory<ProjectRoleObject>.DeserializeFromStream(Request.Body);
ProjectModel projectModel = new ProjectModel();
if (projectModel.OwnsProject(user, projectModel.GetById(projectRoleObject.ProjectId)))
var project = projectModel.GetById(projectRoleObject.ProjectId);
RoleModel roleModel = new RoleModel();
var role = roleModel.GetById(projectRoleObject.Role.Id);
UserModel userModel = new UserModel();
var userToAdd = userModel.GetById(projectRoleObject.User.Id);
if (projectModel.OwnsProject(user, project))
{
_emitter.EmitUserAdd(new UserEventArgs(this._configuration)
{
Project = project,
Role = role,
User = userToAdd
});
return _projectRoleModel.SetFromObject(projectRoleObject);
}
else
......@@ -110,6 +128,16 @@ namespace Coscine.Api.Project.Controllers
{
_projectRoleModel.CheckIfLastOwnerWillBeRemoved(roleId, projectId);
var project = projectModel.GetById(projectId);
UserModel userModel = new UserModel();
var userToRemove = userModel.GetById(userId);
_emitter.EmitUserRemove(new UserEventArgs(this._configuration)
{
Project = project,
User = userToRemove
});
return _projectRoleModel.Delete(_projectRoleModel.GetWhere((projectRole) =>
projectRole.ProjectId == projectId
&& projectRole.UserId == userId
......
......@@ -172,11 +172,11 @@ namespace Coscine.Api.Project.Models
{
DisciplineModel disciplineModel = new DisciplineModel();
disciplines = disciplineModel.GetAllWhere((discipline) => (from relation in discipline.ProjectDisciplineDisciplineIdIds where relation.ProjectId == project.Id select relation).Any())
.Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayName));
.Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
}
else
{
disciplines = project.ProjectDisciplineProjectIdIds.Select((discipline) => new DisciplineObject(discipline.Discipline.Id, discipline.Discipline.Url, discipline.Discipline.DisplayName));
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>();
if (project.ProjectInstituteProjectIdIds == null)
......
......@@ -234,7 +234,7 @@ namespace Coscine.Api.Project.Models
(from relation in discipline.ResourceDisciplineDisciplineIdIds
where relation.ResourceId == resource.Id
select relation).Any())
.Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayName));
.Select((discipline) => new DisciplineObject(discipline.Id, discipline.Url, discipline.DisplayNameDe, discipline.DisplayNameEn));
if (resource.Visibility == null && resource.VisibilityId != null)
{
......
......@@ -45,8 +45,8 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Action, Version=1.5.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.5.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.6.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.6.0\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.2.2.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.2.2\lib\net461\Coscine.ApiCommons.dll</HintPath>
......@@ -54,8 +54,8 @@
<Reference Include="Coscine.Configuration, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.4.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.Database, Version=1.8.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.8.0\lib\net461\Coscine.Database.dll</HintPath>
<Reference Include="Coscine.Database, Version=1.9.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.9.0\lib\net461\Coscine.Database.dll</HintPath>
</Reference>
<Reference Include="Coscine.ProxyApi, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ProxyApi.1.2.0\lib\net461\Coscine.ProxyApi.dll</HintPath>
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project")]
[assembly: AssemblyVersion("1.6.2.0")]
[assembly: AssemblyFileVersion("1.6.2.0")]
[assembly: AssemblyInformationalVersion("1.6.2.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyInformationalVersion("1.7.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -13,13 +13,16 @@ namespace Coscine.Api.Project.ReturnObjects
public Guid Id { get; set; }
public string Url { get; set; }
public string DisplayName { get; set; }
public string DisplayNameDe { get; set; }
public DisciplineObject(Guid id, string url, string displayName)
public string DisplayNameEn { get; set; }
public DisciplineObject(Guid id, string url, string displayNameDe, string displayNameEn)
{
Id = id;
Url = url;
DisplayName = displayName;
DisplayNameDe = displayNameDe;
DisplayNameEn = displayNameEn;
}
}
}
......@@ -3,10 +3,10 @@
<package id="AutoMapper" version="8.0.0" targetFramework="net472" />
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Consul" version="0.7.2.6" targetFramework="net472" />
<package id="Coscine.Action" version="1.5.0" targetFramework="net472" />
<package id="Coscine.Action" version="1.6.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.2.2" targetFramework="net472" />
<package id="Coscine.Configuration" version="1.4.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.8.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.9.0" targetFramework="net472" />
<package id="Coscine.ProxyApi" version="1.2.0" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.4.0" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
......