Skip to content

Commit

Permalink
Merge pull request #3083 from ingef/release
Browse files Browse the repository at this point in the history
Merge Release
  • Loading branch information
awildturtok authored Jun 12, 2023
2 parents 0ecae3b + ab19e25 commit 56e2bbf
Show file tree
Hide file tree
Showing 80 changed files with 1,885 additions and 1,693 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/test_build_backend_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Test building backend image

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- develop
- master
paths:
- 'backend/**'
- 'executable/**'
- 'Dockerfile'
- 'pom.xml'
- 'lombok.config'
- 'scripts/**'
- '.github/workflows/test_build_backend_image.yml'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-backend

jobs:
test-build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0

- name: Build docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
40 changes: 40 additions & 0 deletions .github/workflows/test_build_frontend_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Test building frontend image

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- develop
- master
paths:
- 'frontend/*'
- 'scripts/*'
- '.github/workflows/test_build_frontend_image.yml'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-frontend

jobs:
test-build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0

- name: Build docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./frontend
push: false
19 changes: 0 additions & 19 deletions .restyled.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bakdata.conquery.apiv1;

import java.net.URI;
import java.util.List;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
Expand Down Expand Up @@ -91,12 +90,12 @@ public boolean isSearchDisabled() {
return false;
}

public List<TrieSearch<FrontendValue>> getSearches(IndexConfig config, NamespaceStorage storage) {
public TrieSearch<FrontendValue> createTrieSearch(IndexConfig config, NamespaceStorage storage) {

final URI resolvedURI = FileUtil.getResolvedUri(config.getBaseUrl(), getFilePath());
log.trace("Resolved filter template reference url for search '{}': {}", this.getId(), resolvedURI);

FrontendValueIndex search = indexService.getIndex(new FrontendValueIndexKey(
final FrontendValueIndex search = indexService.getIndex(new FrontendValueIndexKey(
resolvedURI,
columnValue,
value,
Expand All @@ -105,7 +104,7 @@ public List<TrieSearch<FrontendValue>> getSearches(IndexConfig config, Namespace
config.getSearchSplitChars()
));

return List.of(search);
return search;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public class MetaDataPatch implements Taggable, Labelable, ShareInformation {
* @param <INST> Type of the instance that is patched
*/
public <T extends MetaDataPatch, ID extends Id<?>, INST extends Taggable & Shareable & Labelable & Identifiable<? extends ID> & Owned & Authorized> void applyTo(INST instance, MetaStorage storage, Subject subject) {
buildChain(
QueryUtils.getNoOpEntryPoint(),
storage,
subject,
instance
)
.accept(this);
buildChain(QueryUtils.getNoOpEntryPoint(), storage, subject, instance).accept(this);
}

protected <T extends MetaDataPatch, ID extends Id<?>, INST extends Taggable & Shareable & Labelable & Identifiable<? extends ID> & Owned & Authorized> Consumer<T> buildChain(Consumer<T> patchConsumerChain, MetaStorage storage, Subject subject, INST instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import com.bakdata.conquery.models.query.QueryResolveContext;
import com.bakdata.conquery.models.query.Visitable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand All @@ -37,31 +37,44 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.google.common.base.Strings;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.Nullable;

@Getter
@Setter
@CPSType(id = "EXTERNAL_FORM", base = QueryDescription.class, subTyped = true)
@JsonDeserialize(using = Deserializer.class)
@RequiredArgsConstructor
@Slf4j
@ToString
public class ExternalForm extends Form implements SubTyped {


@JsonValue
@ToString.Exclude
private final ObjectNode node;

private final String subType;

public JsonNode getExternalApiPayload() {
return ((ObjectNode) node.deepCopy()
.without("values"))
.set("type", new TextNode(subType));

}

@Nullable
@Override
public String getFormType() {
return CPSTypeIdResolver.createSubTyped(this.getClass().getAnnotation(CPSType.class).id(), getSubType());
@JsonIgnore
public JsonNode getValues() {
return node.get("values");
}

@Override
Expand All @@ -72,41 +85,52 @@ public String getLocalizedTypeLabel() {
}

// Form had no specific title set. Try localized lookup in FormConfig
Locale preferredLocale = I18n.LOCALE.get();
FormType frontendConfig = FormScanner.FRONTEND_FORM_CONFIGS.get(this.getFormType());
final Locale preferredLocale = I18n.LOCALE.get();
final FormType frontendConfig = FormScanner.FRONTEND_FORM_CONFIGS.get(getFormType());

if (frontendConfig == null) {
return getSubType();
}

JsonNode titleObj = frontendConfig.getRawConfig().path("title");
final JsonNode titleObj = frontendConfig.getRawConfig().path("title");
if (!titleObj.isObject()) {
log.trace("Expected \"title\" member to be of type Object in {}", frontendConfig);
return getSubType();
}

List<Locale> localesFound = new ArrayList<>();
final List<Locale> localesFound = new ArrayList<>();
titleObj.fieldNames().forEachRemaining((lang) -> localesFound.add(new Locale(lang)));

if (localesFound.isEmpty()) {
log.trace("Could not extract a locale from the provided FrontendConfig: {}", frontendConfig);
return getSubType();
}

Locale chosenLocale = Locale.lookup(Locale.LanguageRange.parse(preferredLocale.getLanguage()), localesFound);

if (chosenLocale == null) {
chosenLocale = localesFound.get(0);
log.trace("Locale lookup did not return a matching locale. Using the first title encountered: {}", chosenLocale);
}
JsonNode title = titleObj.path(chosenLocale.getLanguage());

final JsonNode title = titleObj.path(chosenLocale.getLanguage());

if (!title.isTextual()) {
log.trace("Expected a textual node for the localized title. Was: {}", title.getNodeType());
return getSubType();
}
String ret = title.asText();

final String ret = title.asText();

log.trace("Extracted localized title. Was: \"{}\"", ret);
return ret.isBlank() ? getSubType() : ret;
}

@Override
public String getFormType() {
return CPSTypeIdResolver.createSubTyped(getClass().getAnnotation(CPSType.class).id(), getSubType());
}

@Override
public ManagedExecution toManagedExecution(User user, Dataset submittedDataset, MetaStorage storage) {
return new ExternalExecution(this, user, submittedDataset, storage);
Expand Down Expand Up @@ -142,22 +166,25 @@ public static class Deserializer extends JsonDeserializer<ExternalForm> implemen
private String subTypeId;

@Override
public ExternalForm deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public ExternalForm deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

if (Strings.isNullOrEmpty(subTypeId)) {
throw new IllegalStateException("This class needs subtype information for deserialization.");
}
ObjectNode tree = p.readValueAsTree();

final ObjectNode tree = p.readValueAsTree();
return new ExternalForm(tree, subTypeId);
}

@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
// This is only called once per typeId@SubTypeId
String subTypeId = (String) ctxt.getAttribute(CPSTypeIdResolver.ATTRIBUTE_SUB_TYPE);
final String subTypeId = (String) ctxt.getAttribute(CPSTypeIdResolver.ATTRIBUTE_SUB_TYPE);

if (Strings.isNullOrEmpty(subTypeId)) {
throw new IllegalStateException("This class needs subtype information for deserialization.");
}

return new Deserializer(subTypeId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ClassToInstanceMap;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

/**
* API representation of a form query.
*/
@EqualsAndHashCode
public abstract class Form implements QueryDescription {


/**
* Raw form config (basically the raw format of this form), that is used by the backend at the moment to
* create a {@link com.bakdata.conquery.models.forms.configs.FormConfig} upon start of this form (see {@link ManagedForm#start()}).
*/
@Nullable
@Getter
@Setter
@EqualsAndHashCode.Exclude
private JsonNode values;
public abstract JsonNode getValues();

@JsonIgnore
public String getFormType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ public Query createSpecializedQuery() {
List<ExportForm.ResolutionAndAlignment> resolutionsAndAlignments =
ExportForm.getResolutionAlignmentMap(getForm().getResolvedResolutions(), getAlignmentHint());

return new AbsoluteFormQuery(
getForm().getPrerequisite(),
dateRange,
resolvedFeatures,
resolutionsAndAlignments
);
Query prerequisite = getForm().getPrerequisite();
return new AbsoluteFormQuery(prerequisite, dateRange, resolvedFeatures, resolutionsAndAlignments);
}

@Override
Expand Down
Loading

0 comments on commit 56e2bbf

Please sign in to comment.