Merge pull request #216 from vran-dev/issue-215
feature: support fast filter diff results
This commit is contained in:
commit
e9a07b1098
api/src/main/resources/static
core/src/main/java/com/databasir/core/domain/document
databasir-frontend
|
@ -17,4 +17,4 @@
|
|||
#fcc28c
|
||||
#ffa
|
||||
#fff
|
||||
*/.hljs{background:#333;color:#fff}.hljs-doctag,.hljs-meta-keyword,.hljs-name,.hljs-strong{font-weight:700}.hljs-code,.hljs-emphasis{font-style:italic}.hljs-section,.hljs-tag{color:#62c8f3}.hljs-selector-class,.hljs-selector-id,.hljs-template-variable,.hljs-variable{color:#ade5fc}.hljs-meta-string,.hljs-string{color:#a2fca2}.hljs-attr,.hljs-quote,.hljs-selector-attr{color:#7bd694}.hljs-tag .hljs-attr{color:inherit}.hljs-attribute,.hljs-title,.hljs-type{color:#ffa}.hljs-number,.hljs-symbol{color:#d36363}.hljs-bullet,.hljs-template-tag{color:#b8d8a2}.hljs-built_in,.hljs-keyword,.hljs-literal,.hljs-selector-tag{color:#fcc28c}.hljs-code,.hljs-comment,.hljs-formula{color:#888}.hljs-link,.hljs-regexp,.hljs-selector-pseudo{color:#c6b4f0}.hljs-meta{color:#fc9b9b}.hljs-deletion{background:#fc9b9b;color:#333}.hljs-addition{background:#a2fca2;color:#333}.hljs-subst{color:#fff}.hljs a{color:inherit}.hljs a:focus,.hljs a:hover{color:inherit;text-decoration:underline}.hljs mark{background:#555;color:inherit}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:inline-block;align-items:left;justify-content:space-between;font-size:14px;padding:8px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:hidden;scrollbar-width:thin}.search-input{border-width:0 0 0 0;border-style:solid;width:90%!important;min-height:33px;margin-right:10px}.search-input>div{box-shadow:none}.search-input::-moz-placeholder{color:hsla(0,0%,71%,.808)}.search-input:-ms-input-placeholder{color:hsla(0,0%,71%,.808)}.search-input::placeholder{color:hsla(0,0%,71%,.808)}.search-input:focus>div{outline:none;border-width:0 0 1px 0;transition:.5s ease-in;box-shadow:0 0 0 1px var(--el-input-border-color,var(--el-border-color)) inset}.card-header{display:flex;justify-content:space-between;align-items:center}
|
||||
*/.hljs{background:#333;color:#fff}.hljs-doctag,.hljs-meta-keyword,.hljs-name,.hljs-strong{font-weight:700}.hljs-code,.hljs-emphasis{font-style:italic}.hljs-section,.hljs-tag{color:#62c8f3}.hljs-selector-class,.hljs-selector-id,.hljs-template-variable,.hljs-variable{color:#ade5fc}.hljs-meta-string,.hljs-string{color:#a2fca2}.hljs-attr,.hljs-quote,.hljs-selector-attr{color:#7bd694}.hljs-tag .hljs-attr{color:inherit}.hljs-attribute,.hljs-title,.hljs-type{color:#ffa}.hljs-number,.hljs-symbol{color:#d36363}.hljs-bullet,.hljs-template-tag{color:#b8d8a2}.hljs-built_in,.hljs-keyword,.hljs-literal,.hljs-selector-tag{color:#fcc28c}.hljs-code,.hljs-comment,.hljs-formula{color:#888}.hljs-link,.hljs-regexp,.hljs-selector-pseudo{color:#c6b4f0}.hljs-meta{color:#fc9b9b}.hljs-deletion{background:#fc9b9b;color:#333}.hljs-addition{background:#a2fca2;color:#333}.hljs-subst{color:#fff}.hljs a{color:inherit}.hljs a:focus,.hljs a:hover{color:inherit;text-decoration:underline}.hljs mark{background:#555;color:inherit}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:inline-block;align-items:left;justify-content:space-between;font-size:14px;padding:8px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:hidden;scrollbar-width:thin}.search-input{border-width:0 0 0 0;border-style:solid;min-height:33px;margin-right:10px}.search-input>div{box-shadow:none}.search-input::-moz-placeholder{color:hsla(0,0%,71%,.808)}.search-input:-ms-input-placeholder{color:hsla(0,0%,71%,.808)}.search-input::placeholder{color:hsla(0,0%,71%,.808)}.search-input:focus>div{outline:none;border-width:0 0 1px 0;transition:.5s ease-in;box-shadow:0 0 0 1px var(--el-input-border-color,var(--el-border-color)) inset}.card-header{display:flex;justify-content:space-between;align-items:center}
|
|
@ -17,4 +17,4 @@
|
|||
#fcc28c
|
||||
#ffa
|
||||
#fff
|
||||
*/.hljs{background:#333;color:#fff}.hljs-doctag,.hljs-meta-keyword,.hljs-name,.hljs-strong{font-weight:700}.hljs-code,.hljs-emphasis{font-style:italic}.hljs-section,.hljs-tag{color:#62c8f3}.hljs-selector-class,.hljs-selector-id,.hljs-template-variable,.hljs-variable{color:#ade5fc}.hljs-meta-string,.hljs-string{color:#a2fca2}.hljs-attr,.hljs-quote,.hljs-selector-attr{color:#7bd694}.hljs-tag .hljs-attr{color:inherit}.hljs-attribute,.hljs-title,.hljs-type{color:#ffa}.hljs-number,.hljs-symbol{color:#d36363}.hljs-bullet,.hljs-template-tag{color:#b8d8a2}.hljs-built_in,.hljs-keyword,.hljs-literal,.hljs-selector-tag{color:#fcc28c}.hljs-code,.hljs-comment,.hljs-formula{color:#888}.hljs-link,.hljs-regexp,.hljs-selector-pseudo{color:#c6b4f0}.hljs-meta{color:#fc9b9b}.hljs-deletion{background:#fc9b9b;color:#333}.hljs-addition{background:#a2fca2;color:#333}.hljs-subst{color:#fff}.hljs a{color:inherit}.hljs a:focus,.hljs a:hover{color:inherit;text-decoration:underline}.hljs mark{background:#555;color:inherit}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:inline-block;align-items:left;justify-content:space-between;font-size:14px;padding:8px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:hidden;scrollbar-width:thin}.search-input{border-width:0 0 0 0;border-style:solid;width:90%!important;min-height:33px;margin-right:10px}.search-input>div{box-shadow:none}.search-input::-moz-placeholder{color:hsla(0,0%,71%,.808)}.search-input:-ms-input-placeholder{color:hsla(0,0%,71%,.808)}.search-input::placeholder{color:hsla(0,0%,71%,.808)}.search-input:focus>div{outline:none;border-width:0 0 1px 0;transition:.5s ease-in;box-shadow:0 0 0 1px var(--el-input-border-color,var(--el-border-color)) inset}.card-header{display:flex;justify-content:space-between;align-items:center}
|
||||
*/.hljs{background:#333;color:#fff}.hljs-doctag,.hljs-meta-keyword,.hljs-name,.hljs-strong{font-weight:700}.hljs-code,.hljs-emphasis{font-style:italic}.hljs-section,.hljs-tag{color:#62c8f3}.hljs-selector-class,.hljs-selector-id,.hljs-template-variable,.hljs-variable{color:#ade5fc}.hljs-meta-string,.hljs-string{color:#a2fca2}.hljs-attr,.hljs-quote,.hljs-selector-attr{color:#7bd694}.hljs-tag .hljs-attr{color:inherit}.hljs-attribute,.hljs-title,.hljs-type{color:#ffa}.hljs-number,.hljs-symbol{color:#d36363}.hljs-bullet,.hljs-template-tag{color:#b8d8a2}.hljs-built_in,.hljs-keyword,.hljs-literal,.hljs-selector-tag{color:#fcc28c}.hljs-code,.hljs-comment,.hljs-formula{color:#888}.hljs-link,.hljs-regexp,.hljs-selector-pseudo{color:#c6b4f0}.hljs-meta{color:#fc9b9b}.hljs-deletion{background:#fc9b9b;color:#333}.hljs-addition{background:#a2fca2;color:#333}.hljs-subst{color:#fff}.hljs a{color:inherit}.hljs a:focus,.hljs a:hover{color:inherit;text-decoration:underline}.hljs mark{background:#555;color:inherit}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:inline-block;align-items:left;justify-content:space-between;font-size:14px;padding:8px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:hidden;scrollbar-width:thin}.search-input{border-width:0 0 0 0;border-style:solid;min-height:33px;margin-right:10px}.search-input>div{box-shadow:none}.search-input::-moz-placeholder{color:hsla(0,0%,71%,.808)}.search-input:-ms-input-placeholder{color:hsla(0,0%,71%,.808)}.search-input::placeholder{color:hsla(0,0%,71%,.808)}.search-input:focus>div{outline:none;border-width:0 0 1px 0;transition:.5s ease-in;box-shadow:0 0 0 1px var(--el-input-border-color,var(--el-border-color)) inset}.card-header{display:flex;justify-content:space-between;align-items:center}
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir</title><script defer="defer" type="module" src="/js/chunk-vendors.661f96f0.js"></script><script defer="defer" type="module" src="/js/app.7bd4174c.js"></script><link href="/css/chunk-vendors.113af7af.css" rel="stylesheet"><link href="/css/app.ee11d130.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.fc4c9525.js" nomodule></script><script defer="defer" src="/js/app-legacy.9cbae090.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir</title><script defer="defer" type="module" src="/js/chunk-vendors.661f96f0.js"></script><script defer="defer" type="module" src="/js/app.b62e398c.js"></script><link href="/css/chunk-vendors.113af7af.css" rel="stylesheet"><link href="/css/app.ee11d130.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.fc4c9525.js" nomodule></script><script defer="defer" src="/js/app-legacy.08e14aa6.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,108 @@
|
|||
package com.databasir.core.domain.document.diff;
|
||||
|
||||
import com.databasir.core.diff.data.DiffType;
|
||||
import com.databasir.core.domain.document.comparator.DiffResult;
|
||||
import com.databasir.core.domain.document.comparator.TableDiffResult;
|
||||
import com.databasir.core.domain.document.data.DiffAble;
|
||||
import com.databasir.core.domain.document.data.TableDocumentResponse;
|
||||
import com.databasir.core.domain.document.data.TableDocumentResponse.ForeignKeyDocumentResponse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public class DiffTypeFills {
|
||||
|
||||
public static TableDocumentResponse fillRemoved(TableDocumentResponse data) {
|
||||
data.setDiffType(DiffType.REMOVED);
|
||||
data.getColumns().forEach(col -> col.setDiffType(DiffType.REMOVED));
|
||||
data.getForeignKeys().forEach(col -> col.setDiffType(DiffType.REMOVED));
|
||||
data.getIndexes().forEach(col -> col.setDiffType(DiffType.REMOVED));
|
||||
data.getTriggers().forEach(col -> col.setDiffType(DiffType.REMOVED));
|
||||
return data;
|
||||
}
|
||||
|
||||
public static TableDocumentResponse fillAdded(TableDocumentResponse data, TableDiffResult diff) {
|
||||
data.setDiffType(DiffType.ADDED);
|
||||
var cols =
|
||||
diff(diff.getColumnDiffResults(), emptyList(), data.getColumns(), i -> i.getName());
|
||||
data.setColumns(cols);
|
||||
var indexes =
|
||||
diff(diff.getIndexDiffResults(), emptyList(), data.getIndexes(), i -> i.getName());
|
||||
data.setIndexes(indexes);
|
||||
var foreignKeys = foreignKeyDiff(diff.getForeignKeyDiffResults(),
|
||||
emptyList(), data.getForeignKeys());
|
||||
data.setForeignKeys(foreignKeys);
|
||||
var triggers =
|
||||
diff(diff.getTriggerDiffResults(), emptyList(), data.getTriggers(), t -> t.getName());
|
||||
data.setTriggers(triggers);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static TableDocumentResponse fillModified(TableDocumentResponse current,
|
||||
TableDocumentResponse original,
|
||||
TableDiffResult diff) {
|
||||
current.setDiffType(DiffType.MODIFIED);
|
||||
current.setOriginal(original);
|
||||
var cols =
|
||||
diff(diff.getColumnDiffResults(), original.getColumns(), current.getColumns(),
|
||||
col -> col.getName());
|
||||
current.setColumns(cols);
|
||||
var indexes =
|
||||
diff(diff.getIndexDiffResults(), original.getIndexes(), current.getIndexes(), i -> i.getName());
|
||||
current.setIndexes(indexes);
|
||||
var foreignKeys = foreignKeyDiff(diff.getForeignKeyDiffResults(),
|
||||
original.getForeignKeys(), current.getForeignKeys());
|
||||
current.setForeignKeys(foreignKeys);
|
||||
var triggers =
|
||||
diff(diff.getTriggerDiffResults(), original.getTriggers(), current.getTriggers(),
|
||||
t -> t.getName());
|
||||
current.setTriggers(triggers);
|
||||
return current;
|
||||
}
|
||||
|
||||
public static <T extends DiffAble> List<T> diff(Collection<DiffResult> diffs,
|
||||
Collection<T> original,
|
||||
Collection<T> current,
|
||||
Function<T, String> idMapping) {
|
||||
var currentMapByName = current.stream()
|
||||
.collect(Collectors.toMap(idMapping, Function.identity(), (a, b) -> a));
|
||||
var originalMapByName = original.stream()
|
||||
.collect(Collectors.toMap(idMapping, Function.identity(), (a, b) -> a));
|
||||
return diffs.stream().map(diff -> {
|
||||
if (diff.getDiffType() == DiffType.ADDED) {
|
||||
var t = currentMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.ADDED);
|
||||
return t;
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.REMOVED) {
|
||||
var t = originalMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.REMOVED);
|
||||
return t;
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.MODIFIED) {
|
||||
var c = currentMapByName.get(diff.getId());
|
||||
var o = originalMapByName.get(diff.getId());
|
||||
c.setDiffType(DiffType.MODIFIED);
|
||||
c.setOriginal(o);
|
||||
return c;
|
||||
}
|
||||
var t = currentMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.NONE);
|
||||
return t;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<ForeignKeyDocumentResponse> foreignKeyDiff(Collection<DiffResult> diffs,
|
||||
Collection<ForeignKeyDocumentResponse> original,
|
||||
Collection<ForeignKeyDocumentResponse> current) {
|
||||
Function<ForeignKeyDocumentResponse, String> idMapping = fk -> {
|
||||
return fk.getFkTableName() + "." + fk.getFkColumnName() + "." + fk.getKeySeq();
|
||||
};
|
||||
return diff(diffs, original, current, idMapping);
|
||||
}
|
||||
}
|
|
@ -7,12 +7,11 @@ import com.databasir.core.diff.Diffs;
|
|||
import com.databasir.core.diff.data.DiffType;
|
||||
import com.databasir.core.diff.data.RootDiff;
|
||||
import com.databasir.core.domain.DomainErrors;
|
||||
import com.databasir.core.domain.document.comparator.DiffResult;
|
||||
import com.databasir.core.domain.document.comparator.DocumentDiffs;
|
||||
import com.databasir.core.domain.document.comparator.TableDiffResult;
|
||||
import com.databasir.core.domain.document.converter.*;
|
||||
import com.databasir.core.domain.document.data.*;
|
||||
import com.databasir.core.domain.document.data.TableDocumentResponse.ForeignKeyDocumentResponse;
|
||||
import com.databasir.core.domain.document.diff.DiffTypeFills;
|
||||
import com.databasir.core.domain.document.diff.DiffTypePredictor;
|
||||
import com.databasir.core.domain.document.event.DocumentUpdated;
|
||||
import com.databasir.core.domain.document.generator.DocumentFileGenerator;
|
||||
|
@ -28,13 +27,13 @@ import com.databasir.dao.tables.pojos.*;
|
|||
import com.databasir.dao.value.DocumentDiscussionCountPojo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.jooq.tools.StringUtils;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.sql.Connection;
|
||||
|
@ -238,7 +237,7 @@ public class DocumentService {
|
|||
descriptionMapByTableName
|
||||
);
|
||||
|
||||
// if original version is not null mean version diff enabled
|
||||
// if original version is not null means version diff enabled
|
||||
if (originalVersion != null) {
|
||||
var originalDocument =
|
||||
databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, originalVersion)
|
||||
|
@ -444,6 +443,8 @@ public class DocumentService {
|
|||
return emptyList();
|
||||
}
|
||||
var current = this.getTableDetails(projectId, databaseDocumentId, request.getTableIds());
|
||||
List<Integer> currentTableIds = current.stream().map(t -> t.getId()).collect(Collectors.toList());
|
||||
var missedIds = CollectionUtils.disjunction(currentTableIds, request.getTableIds());
|
||||
if (request.getOriginalVersion() != null) {
|
||||
DatabaseDocumentPojo doc =
|
||||
databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, request.getOriginalVersion())
|
||||
|
@ -451,7 +452,8 @@ public class DocumentService {
|
|||
List<String> tableNames = current.stream().map(t -> t.getName()).distinct().collect(Collectors.toList());
|
||||
List<Integer> originalTableIds =
|
||||
tableDocumentDao.selectTableIdsByDatabaseDocumentIdAndTableNameIn(doc.getId(), tableNames);
|
||||
var original = this.getTableDetails(projectId, doc.getId(), originalTableIds);
|
||||
var allOriginalTableIds = CollectionUtils.union(missedIds, originalTableIds);
|
||||
var original = this.getTableDetails(projectId, doc.getId(), allOriginalTableIds);
|
||||
Map<String, TableDocumentResponse> currentMapByName = current.stream()
|
||||
.collect(Collectors.toMap(TableDocumentResponse::getName, Function.identity(), (a, b) -> a));
|
||||
Map<String, TableDocumentResponse> originalMapByName = original.stream()
|
||||
|
@ -463,46 +465,16 @@ public class DocumentService {
|
|||
.map(diff -> {
|
||||
if (diff.getDiffType() == DiffType.ADDED) {
|
||||
TableDocumentResponse c = currentMapByName.get(diff.getId());
|
||||
c.setDiffType(DiffType.ADDED);
|
||||
var cols =
|
||||
diff(diff.getColumnDiffResults(), emptyList(), c.getColumns(), i -> i.getName());
|
||||
c.setColumns(cols);
|
||||
var indexes =
|
||||
diff(diff.getIndexDiffResults(), emptyList(), c.getIndexes(), i -> i.getName());
|
||||
c.setIndexes(indexes);
|
||||
var foreignKeys = foreignKeyDiff(diff.getForeignKeyDiffResults(),
|
||||
emptyList(), c.getForeignKeys());
|
||||
c.setForeignKeys(foreignKeys);
|
||||
var triggers =
|
||||
diff(diff.getTriggerDiffResults(), emptyList(), c.getTriggers(), t -> t.getName());
|
||||
c.setTriggers(triggers);
|
||||
return c;
|
||||
return DiffTypeFills.fillAdded(c, diff);
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.REMOVED) {
|
||||
TableDocumentResponse t = originalMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.REMOVED);
|
||||
return t;
|
||||
return DiffTypeFills.fillRemoved(t);
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.MODIFIED) {
|
||||
TableDocumentResponse c = currentMapByName.get(diff.getId());
|
||||
TableDocumentResponse o = originalMapByName.get(diff.getId());
|
||||
c.setDiffType(DiffType.MODIFIED);
|
||||
c.setOriginal(o);
|
||||
var cols =
|
||||
diff(diff.getColumnDiffResults(), o.getColumns(), c.getColumns(),
|
||||
col -> col.getName());
|
||||
c.setColumns(cols);
|
||||
var indexes =
|
||||
diff(diff.getIndexDiffResults(), o.getIndexes(), c.getIndexes(), i -> i.getName());
|
||||
c.setIndexes(indexes);
|
||||
var foreignKeys = foreignKeyDiff(diff.getForeignKeyDiffResults(),
|
||||
o.getForeignKeys(), c.getForeignKeys());
|
||||
c.setForeignKeys(foreignKeys);
|
||||
var triggers =
|
||||
diff(diff.getTriggerDiffResults(), o.getTriggers(), c.getTriggers(),
|
||||
t -> t.getName());
|
||||
c.setTriggers(triggers);
|
||||
return c;
|
||||
return DiffTypeFills.fillModified(c, o, diff);
|
||||
}
|
||||
TableDocumentResponse t = currentMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.NONE);
|
||||
|
@ -567,46 +539,4 @@ public class DocumentService {
|
|||
return tableResponseConverter.from(tables, columnMapByTableId);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends DiffAble> List<T> diff(Collection<DiffResult> diffs,
|
||||
Collection<T> original,
|
||||
Collection<T> current,
|
||||
Function<T, String> idMapping) {
|
||||
var currentMapByName = current.stream()
|
||||
.collect(Collectors.toMap(idMapping, Function.identity(), (a, b) -> a));
|
||||
var originalMapByName = original.stream()
|
||||
.collect(Collectors.toMap(idMapping, Function.identity(), (a, b) -> a));
|
||||
return diffs.stream().map(diff -> {
|
||||
if (diff.getDiffType() == DiffType.ADDED) {
|
||||
var t = currentMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.ADDED);
|
||||
return t;
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.REMOVED) {
|
||||
var t = originalMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.REMOVED);
|
||||
return t;
|
||||
}
|
||||
if (diff.getDiffType() == DiffType.MODIFIED) {
|
||||
var c = currentMapByName.get(diff.getId());
|
||||
var o = originalMapByName.get(diff.getId());
|
||||
c.setDiffType(DiffType.MODIFIED);
|
||||
c.setOriginal(o);
|
||||
return c;
|
||||
}
|
||||
var t = currentMapByName.get(diff.getId());
|
||||
t.setDiffType(DiffType.NONE);
|
||||
return t;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<ForeignKeyDocumentResponse> foreignKeyDiff(Collection<DiffResult> diffs,
|
||||
Collection<ForeignKeyDocumentResponse> original,
|
||||
Collection<ForeignKeyDocumentResponse> current) {
|
||||
Function<ForeignKeyDocumentResponse, String> idMapping = fk -> {
|
||||
return fk.getFkTableName() + "." + fk.getFkColumnName() + "." + fk.getKeySeq();
|
||||
};
|
||||
return diff(diffs, original, current, idMapping);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 05b6e6761238bcda003a787cb66c51a002c810c7
|
||||
Subproject commit f67d6b70df557fe7f156c23c5b81922bd2fab404
|
Loading…
Reference in New Issue