Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Autowire Spring Atlas Components based on Spring properties instead of Spring profiles #10376

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e708ed9
determine atlas enabled based on property than profile
ole-ve Feb 21, 2025
873e7dc
remove atlas profile from intellij run configs
ole-ve Feb 21, 2025
f46a008
remove atlas profile from docs
ole-ve Feb 21, 2025
2a10c4b
Revert "remove atlas profile from intellij run configs"
ole-ve Feb 21, 2025
8586e62
fix "remove atlas profile from intellij run configs"
ole-ve Feb 21, 2025
a7f396f
add activeModuleFeatures to client tests
ole-ve Feb 21, 2025
fac798d
add JavaDoc to ModuleFeatureInfoContributor
ole-ve Feb 21, 2025
774788d
Revert "remove atlas profile from docs"
ole-ve Feb 21, 2025
4b13ace
fix "remove atlas profile from docs"
ole-ve Feb 21, 2025
c98efa6
explicitly type empty activeModuleFeatures string array
ole-ve Feb 21, 2025
07bbc22
use AtlasNotPresentException over ApiConditionNotPresentException
ole-ve Feb 21, 2025
646556a
enable atlas in test application-artemis.yml
ole-ve Feb 21, 2025
1d16f47
remove atlas config from AbstractSpringIntegrationIndependentTest
ole-ve Feb 21, 2025
27625b2
refactor AbstractModuleAccessArchitectureTest to allow passing ignore…
ole-ve Feb 21, 2025
c744b3c
ignore module-external dependencies to AtlasNotPresentException in At…
ole-ve Feb 21, 2025
27aae0d
fix conditions of shouldOnlyAccessApiDomainDtoAndAllowedException
ole-ve Feb 21, 2025
352cf9f
change arch test to additionally allow @Conditional instead of @Profi…
ole-ve Feb 21, 2025
5e04e5e
throw RuntimeException instead of calling System-exit on undefined pr…
ole-ve Feb 21, 2025
3b9f85c
fix non-core conditions in AuthorizationTestService
ole-ve Feb 21, 2025
b8a051e
improve naming of test case verifying module-external access
ole-ve Feb 21, 2025
624d973
add some JavaDoc
ole-ve Feb 21, 2025
2054841
remove superseded check on classes outside of package already covered…
ole-ve Feb 22, 2025
8aa5fba
Merge branch 'develop' into chore/atlas-enabled-condition
ole-ve Feb 22, 2025
7be82a5
Merge remote-tracking branch 'origin/develop' into chore/atlas-enable…
ole-ve Feb 22, 2025
0399ebb
fix renaming of missing api exception
ole-ve Feb 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server___Client_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/admin/setup/aeolus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Enable the ``aeolus`` Spring profile

::

--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,atlas,local,aeolus
--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,local,aeolus

Configure the Aeolus Endpoint
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/setup/apollon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Enable the ``apollon`` Spring profile:

::

--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,atlas,local,apollon
--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,local,apollon

Configure API Endpoints:
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/setup/athena.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Enable the ``athena`` Spring profile:

::

--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,atlas,local,athena
--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,local,athena

Configure API Endpoints:
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/setup/distributed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ For ICL, the run configuration for core nodes need to include the additional pro

::

--spring.profiles.active=prod,core,atlas,ldap-only,localvc,localci,athena,scheduling,iris,lti
--spring.profiles.active=prod,core,ldap-only,localvc,localci,athena,scheduling,iris,lti

Core nodes do not require further adjustments to the ``application-prod.yml``, as long as you have added the necessary variables as described in the :ref:`Integrated Code Lifecycle Setup <Integrated Code Lifecycle Setup>`.

Expand Down
2 changes: 1 addition & 1 deletion docs/admin/setup/iris.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Enable the ``iris`` Spring profile:

::

--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,atlas,local,iris
--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,local,iris

Configure Pyris API Endpoints:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/setup/production-setup-tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ permissions in the ``/opt/artemis/`` directory that contains the ``Artemis.war``
--add-opens java.management/sun.management=ALL-UNNAMED \
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED \
-jar Artemis.war \
--spring.profiles.active=prod,localci,localvc,artemis,scheduling,buildagent,core,atlas,local,openapi
--spring.profiles.active=prod,localci,localvc,artemis,scheduling,buildagent,core,local,openapi
SuccessExitStatus=143
StandardOutput=/opt/artemis/artemis.log # remove to use default journald logging/cleanup mechanisms
StandardError=inherit
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/setup/aeolus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ e.g.:

::

--spring.profiles.active=dev,localci,localvc,aeolus,artemis,scheduling,atlas,local
--spring.profiles.active=dev,localci,localvc,aeolus,artemis,scheduling,local


More information on how Aeolus works can be found on `GitHub <https://github.com/ls1intum/Aeolus>`_ or in the `Aeolus documentation <https://ls1intum.github.io/Aeolus/>`_.
2 changes: 1 addition & 1 deletion docs/dev/setup/integrated-code-lifecycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ e.g.:

::

--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,atlas,local
--spring.profiles.active=dev,localci,localvc,artemis,scheduling,buildagent,core,local

All of these profiles are enabled by default when using the ``Artemis (Server, LocalVC & LocalCI)`` run configuration in IntelliJ.
Please read :ref:`Server Setup` for more details.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/setup/jenkins-gitlab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ In addition, you have to start Artemis with the profiles ``gitlab`` and

::

--spring.profiles.active=dev,jenkins,gitlab,artemis,atlas,scheduling
--spring.profiles.active=dev,jenkins,gitlab,artemis,scheduling

Please read :ref:`Server Setup` for more details.

Expand Down
2 changes: 1 addition & 1 deletion docs/dev/setup/jenkins-localvc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ In addition, you have to start Artemis with the profiles ``localvc`` and

::

--spring.profiles.active=dev,jenkins,localvc,artemis,atlas,scheduling
--spring.profiles.active=dev,jenkins,localvc,artemis,scheduling

Please read :ref:`Server Setup` for more details.

Expand Down
6 changes: 3 additions & 3 deletions docs/dev/setup/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ The Artemis server should startup by running the main class

::

--spring.profiles.active=dev,jenkins,gitlab,artemis,atlas,scheduling
--spring.profiles.active=dev,jenkins,gitlab,artemis,scheduling

If you use IntelliJ (Community or Ultimate) you can set the active
profiles by

* Choosing ``Run | Edit Configurations...``
* Going to the ``Configuration Tab``
* Expanding the ``Environment`` section to reveal ``VM Options`` and setting them to
``-Dspring.profiles.active=dev,jenkins,gitlab,artemis,atlas,scheduling``
``-Dspring.profiles.active=dev,jenkins,gitlab,artemis,scheduling``

Set Spring profiles with IntelliJ Ultimate
""""""""""""""""""""""""""""""""""""""""""
Expand All @@ -245,4 +245,4 @@ sure to pass the active profiles to the ``gradlew`` command like this:

.. code:: bash

./gradlew bootRun --args='--spring.profiles.active=dev,jenkins,gitlab,artemis,atlas,scheduling'
./gradlew bootRun --args='--spring.profiles.active=dev,jenkins,gitlab,artemis,scheduling'
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyService;
import de.tum.cit.aet.artemis.lecture.domain.Lecture;

@Conditional(AtlasEnabled.class)
@Controller
@Profile(PROFILE_ATLAS)
public class CompetencyApi extends AbstractAtlasApi {

private final CompetencyService competencyService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.domain.LearningObject;
import de.tum.cit.aet.artemis.atlas.domain.competency.Competency;
import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency;
Expand All @@ -19,7 +18,7 @@
import de.tum.cit.aet.artemis.exercise.domain.participation.Participant;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class CompetencyProgressApi extends AbstractAtlasApi {

private final CompetencyProgressService competencyProgressService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import java.util.List;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink;
import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyLectureUnitLink;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class CompetencyRelationApi extends AbstractAtlasApi {

private final CompetencyRelationRepository competencyRelationRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency;
import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class CourseCompetencyApi extends AbstractAtlasApi {

private final CourseCompetencyRepository courseCompetencyRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.service.profile.CourseLearnerProfileService;
import de.tum.cit.aet.artemis.atlas.service.profile.LearnerProfileService;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.User;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class LearnerProfileApi extends AbstractAtlasApi {

private final LearnerProfileService learnerProfileService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO;
import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class LearningMetricsApi extends AbstractAtlasApi {

private final LearningMetricsService metricsService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import jakarta.validation.constraints.NotNull;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.User;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class LearningPathApi extends AbstractAtlasApi {

private final LearningPathService learningPathService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite;
import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository;
import de.tum.cit.aet.artemis.core.domain.Course;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class PrerequisitesApi extends AbstractAtlasApi {

private final PrerequisiteRepository prerequisiteRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package de.tum.cit.aet.artemis.atlas.api;

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATLAS;

import java.util.Set;

import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Controller;

import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled;
import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent;
import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository;

@Controller
@Profile(PROFILE_ATLAS)
@Conditional(AtlasEnabled.class)
public class ScienceEventApi extends AbstractAtlasApi {

private final ScienceEventRepository scienceEventRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.tum.cit.aet.artemis.atlas.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import de.tum.cit.aet.artemis.core.config.ArtemisConfigHelper;

/**
* Condition to check if the Atlas module is enabled.
* Based on this condition, Spring components concerning atlas functionality can be enabled or disabled.
*/
public class AtlasEnabled implements Condition {

private final ArtemisConfigHelper artemisConfigHelper;

public AtlasEnabled() {
this.artemisConfigHelper = new ArtemisConfigHelper();
}

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
return artemisConfigHelper.isAtlasEnabled(context.getEnvironment());
}
}
Loading
Loading