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

EPMRPP-73239 || Stale materialized view repository impl #807

Merged
merged 3 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions project-properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ project.ext {
(migrationsUrl + '/migrations/52_analyzer_search_attribute.up.sql') : 'V052__analyzer_search_attribute.sql',
(migrationsUrl + '/migrations/54_analyzer_unique_error_attribute.up.sql') : 'V054__analyzer_unique_error_attribute.sql',
(migrationsUrl + '/migrations/58_alter_ticket.up.sql') : 'V058__alter_ticket.sql',
(migrationsUrl + '/migrations/59_stale_materialized_view.up.sql') : 'V059__stale_materialized_view.sql',

]
excludeTests = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.epam.ta.reportportal.dao;

import com.epam.ta.reportportal.entity.materialized.StaleMaterializedView;

import java.util.Optional;

/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
public interface StaleMaterializedViewRepository {

Optional<StaleMaterializedView> findById(Long id);

StaleMaterializedView insert(StaleMaterializedView view);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.epam.ta.reportportal.dao;

import com.epam.ta.reportportal.entity.materialized.StaleMaterializedView;
import org.jooq.DSLContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Optional;

import static com.epam.ta.reportportal.jooq.tables.JStaleMaterializedView.STALE_MATERIALIZED_VIEW;

/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
@Repository
public class StaleMaterializedViewRepositoryImpl implements StaleMaterializedViewRepository {

private final DSLContext dsl;

@Autowired
public StaleMaterializedViewRepositoryImpl(DSLContext dsl) {
this.dsl = dsl;
}

@Override
public Optional<StaleMaterializedView> findById(Long id) {
return dsl.select()
.from(STALE_MATERIALIZED_VIEW)
.where(STALE_MATERIALIZED_VIEW.ID.eq(id))
.fetchOptionalInto(StaleMaterializedView.class);
}

@Override
public StaleMaterializedView insert(StaleMaterializedView view) {
Long id = dsl.insertInto(STALE_MATERIALIZED_VIEW)
miracle8484 marked this conversation as resolved.
Show resolved Hide resolved
.columns(STALE_MATERIALIZED_VIEW.NAME, STALE_MATERIALIZED_VIEW.CREATION_DATE)
.values(view.getName(), Timestamp.valueOf(view.getCreationDate()))
.returningResult(STALE_MATERIALIZED_VIEW.ID)
.fetchOne()
.into(Long.class);
view.setId(id);
return view;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.epam.ta.reportportal.entity.materialized;

import java.time.LocalDateTime;

/**
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
*/
public class StaleMaterializedView {

private Long id;
private String name;
private LocalDateTime creationDate;

public StaleMaterializedView() {
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public LocalDateTime getCreationDate() {
return creationDate;
}

public void setCreationDate(LocalDateTime creationDate) {
this.creationDate = creationDate;
}
}
67 changes: 9 additions & 58 deletions src/main/java/com/epam/ta/reportportal/jooq/Indexes.java

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

79 changes: 12 additions & 67 deletions src/main/java/com/epam/ta/reportportal/jooq/JPublic.java

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

Loading