Skip to content

Commit

Permalink
EPMRPP-90223 upsa external, project_type, created_at fields (#1025)
Browse files Browse the repository at this point in the history
* EPMRPP-90223 remove project_type, rename creation_date columns

* EPMRPP-90223 rename organization_type

* EPMRPP-90223 update script reference
  • Loading branch information
grabsefx authored Aug 5, 2024
1 parent fc6e7ed commit d012326
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 436 deletions.
12 changes: 6 additions & 6 deletions project-properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ project.ext {
(migrationsUrl + '/migrations/76_user_bid_extension.up.sql') : 'V076__user_bid_extension.sql',
(migrationsUrl + '/migrations/77_email_server_documentation_link.up.sql') : 'V077__email_server_documentation_link.sql',
(migrationsUrl + '/migrations/78_drop_redundant_index.up.sql') : 'V078__drop_redundant_index.sql',
(migrationsUrl + '/migrations/83_add_slugify_function.up.sql') : 'V083__add_slugify_function.sql',
(migrationsUrl + '/migrations/84_organization_tables.up.sql') : 'V084__organization_tables.sql',
(migrationsUrl + '/migrations/86_notication_update.up.sql') : 'V086__notication_update.sql',
(migrationsUrl + '/migrations/88_add_retention_policy_launch.up.sql') : 'V088__add_retention_policy_launch.sql',
(migrationsUrl + '/migrations/89_add_group_enum_value.up.sql') : 'V089__add_group_enum_value.sql',
(migrationsUrl + '/migrations/90_analytics_data_table.up.sql') : 'V090__analytics_data_table.sql',
(migrationsUrl + '/migrations/84_notification_update.up.sql') : 'V084__notification_update.sql',
(migrationsUrl + '/migrations/86_add_retention_policy_launch.up.sql') : 'V086__add_retention_policy_launch.sql',
(migrationsUrl + '/migrations/87_add_group_enum_value.up.sql') : 'V087__add_group_enum_value.sql',
(migrationsUrl + '/migrations/88_analytics_data_table.up.sql') : 'V088__analytics_data_table.sql',
(migrationsUrl + '/migrations/198_add_slugify_function.up.sql') : 'V198__add_slugify_function.sql',
(migrationsUrl + '/migrations/199_organization_tables.up.sql') : 'V199__organization_tables.sql',
(migrationsUrl + '/migrations/200_migrate_org_roles.up.sql') : 'V200__migrate_org_roles.sql',
(migrationsUrl + '/migrations/201_drop_table_onboarding.up.sql') : 'V201__drop_table_onboarding.sql',
(migrationsUrl + '/migrations/202_update_project_table.up.sql') : 'V202__update_project_table.up.sql',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_NAME;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_ORGANIZATION;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_ORGANIZATION_ID;
import static com.epam.ta.reportportal.commons.querygen.constant.ProjectCriteriaConstant.CRITERIA_PROJECT_TYPE;
import static com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_CLUSTER_ID;
import static com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_DURATION;
import static com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_HAS_CHILDREN;
Expand Down Expand Up @@ -201,8 +200,6 @@ public enum FilterTarget {
new CriteriaHolderBuilder().newBuilder(CRITERIA_SLUG, PROJECT.SLUG, String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_ORGANIZATION_ID,
PROJECT.ORGANIZATION_ID, Long.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_TYPE, PROJECT.PROJECT_TYPE,
String.class).get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_ATTRIBUTE_NAME,
ATTRIBUTE.NAME,
String.class,
Expand Down Expand Up @@ -241,8 +238,7 @@ protected Collection<? extends SelectField> selectFields() {
PROJECT.SLUG,
PROJECT.ORGANIZATION,
PROJECT.ORGANIZATION_ID,
PROJECT.PROJECT_TYPE,
PROJECT.CREATION_DATE,
PROJECT.CREATED_AT,
PROJECT.METADATA,
PROJECT_ATTRIBUTE.VALUE,
ATTRIBUTE.NAME,
Expand Down Expand Up @@ -287,14 +283,11 @@ protected Field<Long> idField() {
.get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_KEY, PROJECT.KEY, String.class)
.get(),
new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_TYPE, PROJECT.PROJECT_TYPE,
String.class).get(),

new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_ORGANIZATION,
PROJECT.ORGANIZATION, String.class).get(),

new CriteriaHolderBuilder().newBuilder(CRITERIA_PROJECT_CREATION_DATE,
PROJECT.CREATION_DATE, Timestamp.class).get(),
PROJECT.CREATED_AT, Timestamp.class).get(),

new CriteriaHolderBuilder().newBuilder(CRITERIA_ORG_ID,
PROJECT.ORGANIZATION_ID, Long.class).get(),
Expand All @@ -319,7 +312,7 @@ protected Field<Long> idField() {
public QuerySupplier getQuery() {
SelectQuery<? extends Record> query = DSL.select(selectFields()).getQuery();
addFrom(query);
query.addGroupBy(PROJECT.ID, PROJECT.CREATION_DATE, PROJECT.KEY, PROJECT.PROJECT_TYPE);
query.addGroupBy(PROJECT.ID, PROJECT.CREATED_AT, PROJECT.KEY);
QuerySupplier querySupplier = new QuerySupplier(query);
joinTables(querySupplier);
return querySupplier;
Expand All @@ -332,11 +325,10 @@ protected Collection<? extends SelectField> selectFields() {
.as(LAUNCHES_QUANTITY),
DSL.max(LAUNCH.START_TIME).as(LAST_RUN),
PROJECT.ID,
PROJECT.CREATION_DATE,
PROJECT.CREATED_AT,
PROJECT.KEY,
PROJECT.SLUG,
PROJECT.NAME,
PROJECT.PROJECT_TYPE,
PROJECT.ORGANIZATION,
PROJECT.ORGANIZATION_ID
);
Expand Down Expand Up @@ -415,7 +407,6 @@ protected Collection<? extends SelectField> selectFields() {
PROJECT.NAME,
PROJECT.KEY,
PROJECT.SLUG,
PROJECT.PROJECT_TYPE,
PROJECT_USER.PROJECT_ID,
PROJECT_USER.PROJECT_ROLE,
PROJECT_USER.USER_ID,
Expand Down Expand Up @@ -1523,7 +1514,7 @@ protected Field<Long> idField() {
public QuerySupplier getQuery() {
SelectQuery<? extends Record> query = DSL.select(selectFields()).getQuery();
addFrom(query);
query.addGroupBy(PROJECT.ID, PROJECT.CREATION_DATE, PROJECT.KEY, PROJECT.PROJECT_TYPE);
query.addGroupBy(PROJECT.ID, PROJECT.CREATED_AT, PROJECT.KEY);
QuerySupplier querySupplier = new QuerySupplier(query);
joinTables(querySupplier);
return querySupplier;
Expand All @@ -1536,12 +1527,11 @@ protected Collection<? extends SelectField> selectFields() {
)).as(LAUNCHES_QUANTITY),
DSL.max(LAUNCH.START_TIME).as(LAST_RUN),
PROJECT.ID,
PROJECT.CREATION_DATE,
PROJECT.CREATED_AT,
PROJECT.UPDATED_AT,
PROJECT.KEY,
PROJECT.SLUG,
PROJECT.NAME,
PROJECT.PROJECT_TYPE,
PROJECT.ORGANIZATION_ID
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

import com.epam.ta.reportportal.commons.querygen.Queryable;
import com.epam.ta.reportportal.entity.attribute.Attribute;
import com.epam.ta.reportportal.entity.enums.ProjectType;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.project.ProjectAttribute;
import com.epam.ta.reportportal.entity.project.ProjectInfo;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -83,14 +81,4 @@ public interface ProjectRepositoryCustom extends FilterableRepository<Project> {
*/
Page<Project> findAllIdsAndProjectAttributes(Pageable pageable);

/**
* Delete {@code limit} project with specified {@code projectType} and last launch run before
* {@code bound}
*
* @param projectType
* @param bound
* @param limit
* @return number of deleted projects
*/
int deleteByTypeAndLastLaunchRunBefore(ProjectType projectType, Instant bound, int limit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

package com.epam.ta.reportportal.dao;

import static com.epam.ta.reportportal.commons.EntityUtils.INSTANT_TO_TIMESTAMP;
import static com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName;
import static com.epam.ta.reportportal.dao.util.QueryUtils.collectJoinFields;
import static com.epam.ta.reportportal.dao.util.RecordMappers.PROJECT_MAPPER;
import static com.epam.ta.reportportal.dao.util.ResultFetchers.PROJECT_FETCHER;
import static com.epam.ta.reportportal.jooq.Tables.ATTRIBUTE;
import static com.epam.ta.reportportal.jooq.Tables.LAUNCH;
import static com.epam.ta.reportportal.jooq.Tables.PROJECT;
import static com.epam.ta.reportportal.jooq.Tables.PROJECT_ATTRIBUTE;
import static com.epam.ta.reportportal.jooq.Tables.PROJECT_USER;
Expand All @@ -32,11 +30,8 @@
import com.epam.ta.reportportal.commons.querygen.FilterTarget;
import com.epam.ta.reportportal.commons.querygen.QueryBuilder;
import com.epam.ta.reportportal.commons.querygen.Queryable;
import com.epam.ta.reportportal.entity.enums.ProjectType;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.project.ProjectInfo;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.jooq.DSLContext;
Expand Down Expand Up @@ -136,20 +131,5 @@ public Page<Project> findAllIdsAndProjectAttributes(Pageable pageable) {
);
}

@Override
public int deleteByTypeAndLastLaunchRunBefore(ProjectType projectType, Instant bound,
int limit) {
Timestamp timestamp = INSTANT_TO_TIMESTAMP.apply(bound);
return dsl.deleteFrom(PROJECT)
.where(PROJECT.ID.in(dsl.select(PROJECT.ID)
.from(PROJECT)
.join(LAUNCH)
.onKey()
.where(PROJECT.PROJECT_TYPE.eq(projectType.name()))
.groupBy(PROJECT.ID)
.having(DSL.max(LAUNCH.START_TIME).le(timestamp))
.limit(limit)))
.execute();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId;
import com.epam.ta.reportportal.entity.enums.IntegrationAuthFlowEnum;
import com.epam.ta.reportportal.entity.enums.IntegrationGroupEnum;
import com.epam.ta.reportportal.entity.enums.ProjectType;
import com.epam.ta.reportportal.entity.enums.StatusEnum;
import com.epam.ta.reportportal.entity.enums.TestItemTypeEnum;
import com.epam.ta.reportportal.entity.filter.UserFilter;
Expand Down Expand Up @@ -181,8 +180,8 @@ public class RecordMappers {
* Maps record into {@link Project} object
*/
public static final RecordMapper<? super Record, Project> PROJECT_MAPPER = r -> {
Project project = r.into(PROJECT.ID, PROJECT.NAME, PROJECT.ORGANIZATION, PROJECT.CREATION_DATE,
PROJECT.PROJECT_TYPE, PROJECT.ORGANIZATION_ID)
Project project = r.into(PROJECT.ID, PROJECT.NAME, PROJECT.ORGANIZATION, PROJECT.CREATED_AT,
PROJECT.ORGANIZATION_ID)
.into(Project.class);
ofNullable(r.field(PROJECT.KEY))
.ifPresent(f -> project.setKey(r.get(PROJECT.KEY)));
Expand Down Expand Up @@ -430,7 +429,6 @@ public class RecordMappers {
project.setName(r.get(PROJECT.NAME));
project.setKey(r.get(PROJECT.KEY));
project.setSlug(r.get(PROJECT.SLUG));
project.setProjectType(ProjectType.valueOf(r.get(PROJECT.PROJECT_TYPE)));
project.setOrganizationId(r.get(ORGANIZATION.ID));

User user = new User();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private ResultFetchers() {

projectProfile.setId(row.get(PROJECT.ID));
projectProfile.setOrganizationId(row.get(PROJECT.ORGANIZATION_ID));
projectProfile.setCreatedAt(row.get(PROJECT.CREATION_DATE, Instant.class));
projectProfile.setCreatedAt(row.get(PROJECT.CREATED_AT, Instant.class));
projectProfile.setUpdatedAt(row.get(PROJECT.UPDATED_AT, Instant.class));
projectProfile.setKey(row.get(PROJECT.KEY));
projectProfile.setSlug(row.get(PROJECT.SLUG));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public enum OrganizationType {

PERSONAL,
INTERNAL,
UPSA;
EXTERNAL;

public static Optional<OrganizationType> findByName(String name) {
return Arrays.stream(OrganizationType.values())
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.epam.ta.reportportal.entity.project;

import com.epam.ta.reportportal.entity.Metadata;
import com.epam.ta.reportportal.entity.enums.ProjectType;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.entity.pattern.PatternTemplate;
import com.epam.ta.reportportal.entity.project.email.SenderCase;
Expand Down Expand Up @@ -67,9 +66,6 @@ public class Project implements Serializable {
@Column(name = "name")
private String name;

@Column(name = "project_type")
private ProjectType projectType;

@OneToMany(mappedBy = "project", cascade = {CascadeType.PERSIST}, fetch = FetchType.LAZY)
@OrderBy("creationDate desc")
private Set<Integration> integrations = Sets.newHashSet();
Expand All @@ -86,7 +82,7 @@ public class Project implements Serializable {
CascadeType.PERSIST}, fetch = FetchType.EAGER, orphanRemoval = true)
private Set<SenderCase> senderCases = Sets.newHashSet();

@Column(name = "creation_date")
@Column(name = "created_at")
private Instant creationDate;

@Column(name = "updated_at")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.epam.reportportal.rules.commons.validation.Suppliers;
import com.epam.ta.reportportal.entity.attribute.Attribute;
import com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum;
import com.epam.ta.reportportal.entity.enums.ProjectType;
import com.epam.ta.reportportal.entity.enums.TestItemIssueGroup;
import com.epam.ta.reportportal.entity.item.issue.IssueType;
import com.epam.ta.reportportal.entity.project.email.SenderCase;
Expand Down Expand Up @@ -213,14 +212,6 @@ public static Map<String, String> getConfigParametersByPrefix(
.orElseGet(Collections::emptyMap);
}

public static boolean isPersonalForUser(ProjectType projectType, String projectName,
String username) {
return projectType == ProjectType.PERSONAL && Pattern.compile(
LINE_START_SYMBOL + username + PERSONAL_PROJECT_POSTFIX_REGEX)
.matcher(projectName)
.matches();
}

public static Optional<ProjectAttribute> extractAttribute(Project project,
ProjectAttributeEnum attribute) {
return project.getProjectAttributes()
Expand All @@ -242,4 +233,4 @@ private static Predicate<String> processRecipientsEmails(final Iterable<String>
public static String getOwner() {
return OWNER;
}
}
}
Loading

0 comments on commit d012326

Please sign in to comment.