Remove entityManager from TaskService

This commit is contained in:
Sebastian Böckelmann 2023-11-11 10:30:50 +01:00
parent aa9f37d2e5
commit 94b469238d
2 changed files with 38 additions and 30 deletions

View File

@ -4,10 +4,8 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Resolve Merge-Conflict">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Consider increased number of tasks">
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/core/tasks/TaskServiceTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/core/tasks/TaskServiceTest.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -87,6 +85,21 @@
</key>
</component>
<component name="RunManager" selected="JUnit.TaskServiceTest.deleteTask">
<configuration name="TaskRepositoryTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="core.tasks.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="core.tasks" />
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskRepositoryTest" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TaskServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" />
<extension name="coverage">
@ -134,22 +147,6 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TaskServiceTest.editTask" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="core.tasks.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="core.tasks" />
<option name="MAIN_CLASS_NAME" value="core.tasks.TaskServiceTest" />
<option name="METHOD_NAME" value="editTask" />
<option name="TEST_OBJECT" value="method" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="TaskgroupServiceTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="demo" />
<extension name="coverage">
@ -176,9 +173,9 @@
<list>
<item itemvalue="JUnit.TaskServiceTest.deleteTask" />
<item itemvalue="JUnit.TaskServiceTest" />
<item itemvalue="JUnit.TaskServiceTest.createTask" />
<item itemvalue="JUnit.TaskServiceTest.editTask" />
<item itemvalue="JUnit.TaskRepositoryTest" />
<item itemvalue="JUnit.TaskgroupServiceTest" />
<item itemvalue="JUnit.TaskServiceTest.createTask" />
</list>
</recent_temporary>
</component>
@ -458,15 +455,29 @@
<option name="project" value="LOCAL" />
<updated>1699693472182</updated>
</task>
<option name="localTasksCounter" value="31" />
<task id="LOCAL-00031" summary="Deleting Task test">
<option name="closed" value="true" />
<created>1699694400508</created>
<option name="number" value="00031" />
<option name="presentableId" value="LOCAL-00031" />
<option name="project" value="LOCAL" />
<updated>1699694400508</updated>
</task>
<task id="LOCAL-00032" summary="Consider increased number of tasks">
<option name="closed" value="true" />
<created>1699694552466</created>
<option name="number" value="00032" />
<option name="presentableId" value="LOCAL-00032" />
<option name="project" value="LOCAL" />
<updated>1699694552466</updated>
</task>
<option name="localTasksCounter" value="33" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Delete Schedules" />
<MESSAGE value="Deliver Schedule Path Info when fetching Schedules" />
<MESSAGE value="Removed unused TaskgroupShortInfo.java" />
<MESSAGE value="Fix Foreign Key Constraint Fail when deleting Taskgroups" />
<MESSAGE value="Stop and Finish TaskSchedules" />
@ -490,7 +501,9 @@
<MESSAGE value="Use @Sql instead of persit()" />
<MESSAGE value="Make the Test Transactional" />
<MESSAGE value="Resolve Merge-Conflict" />
<option name="LAST_COMMIT_MESSAGE" value="Resolve Merge-Conflict" />
<MESSAGE value="Deleting Task test" />
<MESSAGE value="Consider increased number of tasks" />
<option name="LAST_COMMIT_MESSAGE" value="Consider increased number of tasks" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

View File

@ -24,8 +24,6 @@ public class TaskService {
private final TaskRepository taskRepository;
private final TaskScheduleService taskScheduleService;
private final TaskgroupRepository taskgroupRepository;
@PersistenceContext
private EntityManager entityManager;
public TaskService(@Autowired TaskRepository taskRepository,
@ -101,9 +99,6 @@ public class TaskService {
public void deleteTask(Task task) {
taskScheduleService.deleteScheduleByTask(task);
taskRepository.deleteByTaskID(task.getTaskID());
entityManager.flush();
entityManager.detach(task);
}
public void clearTasks(Taskgroup taskgroup) {