@Override public void execute(ComputationStep.Context context) { try (DbSession dbSession = dbClient.openSession(false)) { Component project = treeRootHolder.getRoot(); dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid()); dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, project.getUuid()); dbSession.commit(); } }
private void updateDb(ComponentDto component) { ComponentUpdateDto updateComponent = ComponentUpdateDto.copyFrom(component); updateComponent.setBChanged(true); dbClient.componentDao().update(dbSession, updateComponent); dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, component.getRootUuid()); dbSession.commit(); }
dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid()); db.commit();
dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid());
@Test public void update_copy_component_uuid_of_sub_view() { OrganizationDto organizationDto = dbTester.organizations().insert(); ComponentDto view = newViewDto(organizationDto); ComponentDto subView = newSubViewDto(view).setCopyComponentUuid("OLD_COPY"); persistComponents(view, subView); treeRootHolder.setRoot( createViewBuilder(PORTFOLIO) .addChildren( createSubView1Builder("NEW_COPY").build()) .build()); underTest.execute(new TestComputationStepContext()); // commit functional transaction -> copies B-fields to A-fields dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid()); dbTester.commit(); ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY); assertThat(subViewReloaded.getCopyResourceUuid()).isEqualTo("NEW_COPY"); }
@Test public void update_module_to_directory_change_scope() { ComponentDto project = prepareProject(); ComponentDto module = ComponentTesting.newModuleDto(project).setUuid("CDEF").setDbKey("MODULE_KEY").setPath("module"); dbClient.componentDao().insert(db.getSession(), module); db.getSession().commit(); assertThat(dbClient.componentDao().selectByUuid(db.getSession(), "CDEF").get().scope()).isEqualTo("PRJ"); treeRootHolder.setRoot( asTreeRoot(project) .addChildren( builder(DIRECTORY, 2).setUuid("CDEF").setKey(PROJECT_KEY + ":module") .setName("module") .addChildren( builder(FILE, 3).setUuid("HIJK").setKey(PROJECT_KEY + ":module/FooTest.java") .setName("module/FooTest.java") .setShortName("FooTest.java") .setFileAttributes(new FileAttributes(false, null, 1)) .build()) .build()) .build()); underTest.execute(new TestComputationStepContext()); // commit the functional transaction dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid()); db.commit(); assertThat(dbClient.componentDao().selectByUuid(db.getSession(), "CDEF").get().scope()).isEqualTo("DIR"); }
@Test public void update_view_name_and_longName() { ComponentDto viewDto = newViewDto(dbTester.organizations().insert()).setLongName("another long name").setCreatedAt(now); persistComponents(viewDto); treeRootHolder.setRoot(createViewBuilder(PORTFOLIO).build()); underTest.execute(new TestComputationStepContext()); // commit functional transaction -> copies B-fields to A-fields dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), viewDto.uuid()); dbTester.commit(); assertRowsCountInTableProjects(1); ComponentDto newViewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(newViewDto); }
dbClient.componentDao().applyBChangesForRootComponentUuid(db.getSession(), project.uuid()); db.commit();
@Test public void update_copy_component_uuid_of_project_view() { OrganizationDto organizationDto = dbTester.organizations().insert(); ComponentDto view = newViewDto(organizationDto); ComponentDto project1 = newPrivateProjectDto(organizationDto, "P1"); ComponentDto project2 = newPrivateProjectDto(organizationDto, "P2"); persistComponents(view, project1, project2); // Project view in DB is associated to project1 ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view) .setDbKey(PROJECT_VIEW_1_KEY) .setCreatedAt(now); persistComponents(projectView); treeRootHolder.setRoot( createViewBuilder(PORTFOLIO) // Project view in the View is linked to the first project2 .addChildren(createProjectView1Builder(project2, null).build()) .build()); underTest.execute(new TestComputationStepContext()); // commit functional transaction -> copies B-fields to A-fields dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid()); dbTester.commit(); ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); // Project view should now be linked to project2 assertDtoIsProjectView1(pv1Dto, view, view, project2); }
@Test public void update_project_view() { OrganizationDto organizationDto = dbTester.organizations().insert(); ComponentDto view = newViewDto(organizationDto); ComponentDto project = ComponentTesting.newPrivateProjectDto(organizationDto); persistComponents(view, project); ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view) .setOrganizationUuid(ORGANIZATION_UUID) .setDbKey(PROJECT_VIEW_1_KEY) .setName("Old name") .setCreatedAt(now); persistComponents(projectView); treeRootHolder.setRoot( createViewBuilder(PORTFOLIO) .addChildren(createProjectView1Builder(project, null).build()) .build()); underTest.execute(new TestComputationStepContext()); // commit functional transaction -> copies B-fields to A-fields dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid()); dbTester.commit(); assertRowsCountInTableProjects(3); ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); assertDtoIsProjectView1(pv1Dto, view, view, project); }
@Override public void execute() { try (DbSession dbSession = dbClient.openSession(false)) { Component project = treeRootHolder.getRoot(); dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid()); dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, project.getUuid()); dbSession.commit(); } }