Skip to content

Commit

Permalink
Merge pull request #3544 from ingef/release
Browse files Browse the repository at this point in the history
Merge Release
  • Loading branch information
thoniTUB authored Sep 2, 2024
2 parents 643bc6e + 765fb7a commit 77e35a5
Show file tree
Hide file tree
Showing 215 changed files with 3,559 additions and 3,300 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/reintegrate-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
- name: Configure git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git config push.autoSetupRemote true
- name: Switch to intermediate branch
run: git checkout -b $REINTEGRATE_BRANCH_NAME
- name: Push intermediate Branch
run: git push -f
- name: Create pull-request
run: >
gh pr create
Expand All @@ -28,11 +35,13 @@ jobs:
-B develop
--title "Reintegrate Main"
--head $REINTEGRATE_BRANCH_NAME
--fill
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Modify pull request
run: >
gh pr merge
--merge
--auto
--delete-branch
env:
Expand Down
2 changes: 1 addition & 1 deletion autodoc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


<properties>
<javaparser.version>3.24.4</javaparser.version>
<javaparser.version>3.26.1</javaparser.version>
</properties>

<parent>
Expand Down
11 changes: 10 additions & 1 deletion autodoc/src/main/java/com/bakdata/conquery/AutoDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.bakdata.conquery.handler.GroupHandler;
import com.bakdata.conquery.handler.SimpleWriter;
import com.bakdata.conquery.model.Group;
import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.StaticJavaParser;
import com.github.powerlibraries.io.Out;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;
Expand All @@ -17,10 +19,17 @@
public class AutoDoc {

public static void main(String[] args) throws IOException {
configureJavaParser();

new AutoDoc().start(new File(args.length == 0 ? "./docs/" : args[0]));
}

private ScanResult scan;
private static void configureJavaParser() {
ParserConfiguration parserConfiguration = StaticJavaParser.getParserConfiguration();
parserConfiguration.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_17);
}

private final ScanResult scan;

public AutoDoc() {
scan = new ClassGraph()
Expand Down
5 changes: 5 additions & 0 deletions autodoc/src/main/java/com/bakdata/conquery/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.nio.charset.Charset;
import java.time.ZonedDateTime;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import jakarta.ws.rs.DELETE;
Expand Down Expand Up @@ -41,12 +42,15 @@
import com.bakdata.conquery.models.config.CSVConfig;
import com.bakdata.conquery.models.config.ClusterConfig;
import com.bakdata.conquery.models.config.ConqueryConfig;
import com.bakdata.conquery.models.config.DatabaseConfig;
import com.bakdata.conquery.models.config.Dialect;
import com.bakdata.conquery.models.config.FrontendConfig;
import com.bakdata.conquery.models.config.LocaleConfig;
import com.bakdata.conquery.models.config.MinaConfig;
import com.bakdata.conquery.models.config.PluginConfig;
import com.bakdata.conquery.models.config.PreprocessingConfig;
import com.bakdata.conquery.models.config.QueryConfig;
import com.bakdata.conquery.models.config.SqlConnectorConfig;
import com.bakdata.conquery.models.config.StandaloneConfig;
import com.bakdata.conquery.models.config.XodusConfig;
import com.bakdata.conquery.models.config.XodusStoreFactory;
Expand Down Expand Up @@ -129,6 +133,7 @@ public class Constants {
.otherClass(MinaConfig.class)
.otherClass(FrontendConfig.CurrencyConfig.class)
.otherClass(XodusConfig.class)
.otherClasses(List.of(SqlConnectorConfig.class, DatabaseConfig.class, Dialect.class))
.hide(Charset.class)
.hide(Currency.class)
.hide(InetAddress.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import jakarta.ws.rs.core.UriBuilder;

import com.bakdata.conquery.introspection.Introspection;
Expand Down Expand Up @@ -98,7 +97,7 @@ public void handle() throws IOException {
}
if (!endpoints.isEmpty()) {
out.heading("REST endpoints");
for (Pair<String, MethodInfo> endpoint : endpoints.stream().sorted(Comparator.comparing(Pair::getLeft)).collect(Collectors.toList())) {
for (Pair<String, MethodInfo> endpoint : endpoints.stream().sorted(Comparator.comparing(Pair::getLeft)).toList()) {
handleEndpoint(endpoint.getLeft(), endpoint.getRight());
}
}
Expand All @@ -108,13 +107,13 @@ public void handle() throws IOException {
}

out.subHeading("Other Types");
for (Class<?> t : group.getOtherClasses().stream().sorted(Comparator.comparing(Class::getSimpleName)).collect(Collectors.toList())) {
for (Class<?> t : group.getOtherClasses().stream().sorted(Comparator.comparing(Class::getSimpleName)).toList()) {
handleClass(typeTitle(t), scan.getClassInfo(t.getName()));
}

if (!group.getMarkerInterfaces().isEmpty()) {
out.subHeading("Marker Interfaces");
for (Class<?> t : group.getMarkerInterfaces().stream().sorted(Comparator.comparing(Class::getSimpleName)).collect(Collectors.toList())) {
for (Class<?> t : group.getMarkerInterfaces().stream().sorted(Comparator.comparing(Class::getSimpleName)).toList()) {
handleMarkerInterface(markerTitle(t), scan.getClassInfo(t.getName()));
}
}
Expand All @@ -135,7 +134,7 @@ private void handleEndpoint(String url, MethodInfo method) throws IOException {
}
}

private void collectEndpoints(Class<?> resource) throws IOException {
private void collectEndpoints(Class<?> resource) {
final ClassInfo info = scan.getClassInfo(resource.getName());

for (MethodInfo method : info.getMethodInfo()) {
Expand Down Expand Up @@ -172,7 +171,7 @@ public void handleBase(Base base) throws IOException {
+ code(typeProperty)
+ " to one of the following values:");

for (Pair<CPSType, ClassInfo> pair : content.get(base).stream().sorted(Comparator.comparing(p -> p.getLeft().id())).collect(Collectors.toList())) {
for (Pair<CPSType, ClassInfo> pair : content.get(base).stream().sorted(Comparator.comparing(p -> p.getLeft().id())).toList()) {

handleClass(pair.getLeft(), pair.getRight());
}
Expand All @@ -198,7 +197,7 @@ private void handleClass(String name, ClassInfo c) throws IOException {
out.line("Supported Fields:");

out.tableHeader("", "Field", "Type", "Default", "Example", "Description");
for (FieldInfo field : c.getFieldInfo().stream().sorted().collect(Collectors.toList())) {
for (FieldInfo field : c.getFieldInfo().stream().sorted().toList()) {
handleField(c, field);
}
}
Expand Down Expand Up @@ -226,12 +225,7 @@ private Closeable details(String name, ClassInfo c, Introspection source) throws
);
}

return new Closeable() {
@Override
public void close() throws IOException {
out.line("</p></details>");
}
};
return () -> out.line("</p></details>");
}

private void handleMarkerInterface(String name, ClassInfo c) throws IOException {
Expand Down Expand Up @@ -487,6 +481,7 @@ private boolean isJSONSettableField(FieldInfo field) {
}
}

return false;
// is record
return field.getClassInfo().isRecord();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,55 @@
import io.github.classgraph.MethodInfo;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RequiredArgsConstructor
public class AbstractJavadocIntrospection<VALUE extends NodeWithJavadoc<?>&NodeWithRange<?>> implements Introspection {
public class AbstractJavadocIntrospection<VALUE extends NodeWithJavadoc<?> & NodeWithRange<?>> implements Introspection {

@Getter
protected final File file;
@Getter
protected final VALUE value;

@Getter(lazy = true)
private final String description = extractDescription();
@Getter(lazy = true)
private final String example = extractExample();

private String extractDescription() {
if(!value.getJavadoc().isPresent()) {
protected String extractDescription() {
if (value.getJavadoc().isEmpty()) {
return "";
}
var javadoc = value.getJavadoc().get();
return javadoc.getDescription().toText().replaceAll("\\s+", " ");
}

private String extractExample() {
if(!value.getJavadoc().isPresent()) {
if (value.getJavadoc().isEmpty()) {
return "";
}
var javadoc = value.getJavadoc().get();
return javadoc.getBlockTags()
.stream()
.filter(b->b.getTagName().equals("jsonExample"))
.findAny()
.map(JavadocBlockTag::getContent)
.map(JavadocDescription::toText)
.orElse("");
.stream()
.filter(b -> b.getTagName().equals("jsonExample"))
.findAny()
.map(JavadocBlockTag::getContent)
.map(JavadocDescription::toText)
.orElse("");
}

@Override
public String getLine() {
if(value.getJavadocComment().isPresent()) {
if (value.getJavadocComment().isPresent()) {
return "L"
+ value.getJavadocComment().get().getBegin().get().line
+ "-L"
+ value.getJavadocComment().get().getEnd().get().line;
+ value.getJavadocComment().get().getBegin().get().line
+ "-L"
+ value.getJavadocComment().get().getEnd().get().line;
}
return "L"+value.getBegin().get().line;
return "L" + value.getBegin().get().line;
}

@Override
public Introspection findMethod(MethodInfo method) {
return new SimpleIntrospection(file);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.bakdata.conquery.introspection;

import java.io.File;
import java.util.Arrays;

import com.github.javaparser.ast.body.EnumDeclaration;
import com.github.javaparser.ast.body.FieldDeclaration;
import com.github.javaparser.ast.body.TypeDeclaration;
import com.github.javaparser.ast.nodeTypes.NodeWithJavadoc;
import com.github.javaparser.ast.nodeTypes.NodeWithMembers;
import com.github.javaparser.ast.nodeTypes.NodeWithRange;
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
import com.google.common.collect.MoreCollectors;
import io.github.classgraph.ArrayTypeSignature;
import io.github.classgraph.BaseTypeSignature;
import io.github.classgraph.ClassRefTypeSignature;
import io.github.classgraph.FieldInfo;
import io.github.classgraph.MethodInfo;
import io.github.classgraph.MethodParameterInfo;
import io.github.classgraph.TypeSignature;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AbstractNodeWithMemberIntrospection<VALUE extends NodeWithJavadoc<?> & NodeWithRange<?> & NodeWithMembers<?>> extends AbstractJavadocIntrospection<VALUE> {

public AbstractNodeWithMemberIntrospection(File file, VALUE nodeWithJavadoc) {
super(file, nodeWithJavadoc);
}

@Override
public Introspection findMethod(MethodInfo method) {
var types = Arrays.stream(method.getParameterInfo())
.map(MethodParameterInfo::getTypeSignatureOrTypeDescriptor)
.map(this::toClass)
.toArray(Class[]::new);

return new AbstractJavadocIntrospection<>(
file,
value
.getMethodsByParameterTypes(types)
.stream()
.filter(md -> md.getNameAsString().equals(method.getName()))
.collect(MoreCollectors.onlyElement())
);

}

@Override
public Introspection findField(FieldInfo field) {

var f = value.getFieldByName(field.getName());
if (f.isPresent()) {
FieldDeclaration fieldDeclaration = f.get();
return new AbstractJavadocIntrospection<>(file, fieldDeclaration);
}
log.warn("Could not find field '{}'", field.getName());
return new SimpleIntrospection(file);
}

public Introspection findInnerType(String simpleName) {
for (var decl : value.getMembers()) {
if (decl instanceof NodeWithSimpleName<?> node) {
if (!node.getNameAsString().equals(simpleName)) {
continue;
}
}
else {
continue;
}
if (decl instanceof EnumDeclaration enumDeclaration) {
return new EnumIntrospection(file, enumDeclaration);
}
if (decl instanceof TypeDeclaration<?> cType) {
return new AbstractNodeWithMemberIntrospection<>(file, cType);
}
}
throw new IllegalStateException(value.getNameAsString() + " has no inner type " + simpleName);
}

private Class<?> toClass(TypeSignature sig) {
if (sig instanceof BaseTypeSignature) {
return ((BaseTypeSignature) sig).getType();
}
else if (sig instanceof ArrayTypeSignature) {
return ((ArrayTypeSignature) sig).loadClass();
}
else if (sig instanceof ClassRefTypeSignature) {
return ((ClassRefTypeSignature) sig).loadClass();
}
throw new IllegalStateException("Can't find class for signature " + sig);
}

}
Loading

0 comments on commit 77e35a5

Please sign in to comment.